Rinehart | JavaScript Object Programming | E-Book | www.sack.de
E-Book

E-Book, Englisch, 121 Seiten

Rinehart JavaScript Object Programming


1. ed
ISBN: 978-1-4842-1787-0
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

E-Book, Englisch, 121 Seiten

ISBN: 978-1-4842-1787-0
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



This brief  book explains the advantages of the object model, inheritance, both classical and prototypical, and shows how these concepts can be implemented in JavaScript. It also shows how object programming (OP) opens a new world of design possibilities that go far beyond inheritance.
This book will help the intermediate JavaScript programmer learn to use both types of inheritance. For classical inheritance, it is accompanied by a substantial online system (a windowing UI library) that shows classical inheritance at its best. The same system shows how OP 'capabilities' can eliminate much of the need for inheritance. 
For experienced JavaScript programmers, this book shows why most of the old views of JavaScript's inheritance have not done it justice. JavaScript classes inherit from JavaScript's prototypes, a fact that makes JavaScript's prototypes, when used correctly, functional equivalents to C++ classes (not to prototypes in true prototypical languages, like Self). 
JavaScript's object programming (not inheritance) is what separates it from classical OOP languages like C++ and Java. Most important, basing inheritance on JavaScript's prototypal chain is possible, but is not the best choice for prototypal inheritance or classical inheritance.

What You'll LearnWhat are objects, JavaScript objects and object programming
What is and how to use inheritance and JavaScript inheritance as well as inheritance alternatives
How to design for JavaScript
What are and how to use OO principles in JavaScript
How to use Constructors with JavaScript and more

AudienceThis book is for both intermediate and advanced JavaScript and Web development programmers. However, any programmer will understand the concepts and any JavaScript programmer should understand all of the concepts in this book.   The code there is shows examples of the concepts discussed.


Martin Rinehart, a self-confessed JavaScript lover, set aside work on his five-volume frontend-engineering textbook project for long enough to write this small book on JavaScript inheritance. He wanted to eliminate some of the massive confusion surrounding this important subject.  Martin is the author of over a dozen books on programming, and of the JSWindows system that brings a windowing UI to browser-based applications.

Rinehart JavaScript Object Programming jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Contents at a Glance;6
2;Contents;7
3;About the Author;14
4;A Note for the Implementers;15
5;Introduction;16
6;Chapter 1: Creating Objects;17
6.1; Reasons for Objects;17
6.1.1; Objects Do Methods;17
6.1.2; Event-Driven Programming;18
6.1.3; Taming Exponential Complexity;18
6.2; Class-Based vs. Prototypal;18
6.2.1; Simula;18
6.2.2; Smalltalk;18
6.2.3; C++ and Java;19
6.2.4; Self and JavaScript;19
6.3; Objects Up Close;20
6.3.1; Data Properties;20
6.3.2; Methods (Code Properties);20
6.4; Ex Nihilo Object Creation;21
6.4.1; The Object Constructor;21
6.4.2; Object Literals;22
6.4.3; More Ex Nihilo Objects;23
6.5; OOP-Style Object Creation;24
6.5.1; Constructors;24
6.5.2; Assigning Initial Property Values;24
6.5.3; Creating Instance Methods;25
6.5.4; Creating Class Statics;25
6.5.5; Getters and Setters;25
6.5.6; Default Values;26
6.6; Prototypal Object Creation;26
6.6.1; Object Prototypes;26
6.6.2; The Prototype Chain;28
6.6.3; Object Prototype Cloning;28
6.7; Summary;30
7;Chapter 2: Object Programming;31
7.1; JSWindows Sample System;31
7.2; OP Removes Restrictions;31
7.3; OP Defined;32
7.4; Programming with Properties;32
7.4.1; Dot Notation;32
7.4.2; Subscript Notation;33
7.5; Object Programming Examples;33
7.5.1; Object Sum;33
7.5.2; OP for Inheriting Prototypes;35
7.6; OP in the JSWindows Library;35
7.6.1; DOM Related;35
7.6.2; Utility;37
7.7; Summary;40
8;Chapter 3: Inheritance Theory;41
8.1; Classes;41
8.1.1; Constructors;42
8.1.2; Instance Methods;42
8.1.3; Class (Family-Wide) Properties;43
8.1.3.1;Data;43
8.1.3.2; Methods;43
8.2; Class-Based Inheritance;43
8.2.1; Property Sets;44
8.2.2; Constructing an Extending Instance;45
8.2.3; Overriding Properties;45
8.2.4; Inheritance Chains;46
8.3; Prototypal Inheritance;47
8.4; Inheritance vs. Composition;48
8.4.1; Composition in Theory;48
8.4.2; Composition in JSWindows;48
8.4.2.1;Complex Properties;49
8.4.2.2; Behaviors;50
8.5; Summary;51
9;Chapter 4: Inheritance Practice;52
9.1; Cascading init() Methods for Data;52
9.1.1; A Theoretical Example;54
9.1.1.1;The call() and apply() Methods;56
9.1.1.2;Extending an Extending Family;56
9.1.2; A Practical Example;57
9.1.2.1;Discrete Defaults;58
9.1.2.2;Implementing Capabilities;59
9.2; Prototypes for Methods;59
9.2.1;Theory;60
9.2.2; Prototypal Inheritance;60
9.2.3; Prototype Inheritance Alternatives;61
9.2.4; Prototype Alternatives;63
9.2.4.1;Library Functions;63
9.2.4.2;Prototype Lookups and Performance;63
9.2.4.3;Class (Family-Wide) Methods;64
9.3; JSWindows Inheritance;64
9.4; Summary;64
10;Chapter 5: On OOP Principles;65
10.1; Ranking OOP Principles;65
10.2; Inheritance;66
10.3; Encapsulation;66
10.3.1; Access Specifiers;66
10.3.2; Closures;67
10.4; Polymorphism;67
10.4.1; Subtype Polymorphism;67
10.4.2; Parametric Polymorphism;68
10.4.3; Ad Hoc and Other Polymorphism;69
10.4.4; JavaScript and Polymorphism;69
10.5; Classes, Abstraction, and Interfaces;70
10.5.1; Classes;70
10.5.2; Abstraction;71
10.5.3; Interfaces;71
10.6; Other OOP Principles;72
10.7; Summary;72
11;Chapter 6: More Ex Nihilo Objects;73
11.1; The Ex Nihilo Namespace Object;73
11.2; The Ex Nihilo Class;74
11.2.1; Returning Ex Nihilo Objects;75
11.2.2; The Function as an Ex Nihilo Class;75
11.3; Summary;76
12;Chapter 7: Inheritance Alternatives;78
12.1; Multiple Inheritance;78
12.2; Interfaces;80
12.3; Capabilities;81
12.4; The Window[_M[_BS]] Problem;81
12.5; Mixins;83
12.6; Calling Capability Methods;84
12.6.1; Capabilities as Constructor Properties;84
12.6.2; Capabilities as Single Properties;84
12.6.3; Capability Prototype Methods;85
12.7; Examples;85
12.7.1; Closable;86
12.7.2; Maskable;87
12.7.3; Button_sizable;89
12.7.3.1;The Button_sizable Constructor;90
12.7.3.2;The Click Functions;90
12.7.3.3; Choosable Buttons;91
12.7.3.4;The Button_sizable.Button Family;92
12.7.3.5;The Button_sizable.panel Family;93
12.7.3.6;The Click and Draw Functions;93
12.8; Summary;94
13;Chapter 8: Designing for JavaScript;96
13.1; Use Ex Nihilo Constantly;96
13.1.1; Array Literals;96
13.1.2; Styles Objects;97
13.1.3; Other Objects;97
13.2; Use Composition Liberally;97
13.2.1;Original Pos_size;98
13.2.2; Mature Pos_size;98
13.3; Use Capabilities Liberally;99
13.4; Use Inheritance Conservatively;100
13.5; Summary;101
14;Chapter 9: On Constructors;102
14.1; Constructor Magic;102
14.1.1; The new Operator;102
14.1.2; The this Parameter;103
14.1.3; The constructor.prototype;103
14.1.4; The “[[prototype]]” Property;104
14.1.5; The Prototype’s Prototype;105
14.1.6; “[[prototype]]” Implies;105
14.2; The Dynamic Prototype;106
14.3; A Bit More Magic;106
14.3.1; The Constructor Returns this;106
14.3.2; The “Magic” Summarized;107
14.4; Constructors Are Not for Inheritance;107
14.5; Summary;108
15;Chapter 10: Appendices;109
15.1; A Surveyed Pages, OOP Principles;109
15.2; B Selected Books;110
15.2.1; C++;110
15.2.2; Java;111
15.2.3; JavaScript;111
15.2.4; Python;111
15.2.5; Visual Basic;111
15.3; C Selected Websites;111
15.3.1; Wikipedia on Object-Oriented Programming, Class-Based Inheritance and Prototypal Inheritance;111
15.3.2; The Author’s Web Site on Class-Based Inheritance and JavaScript Programming;112
15.3.3; Other Web Sites on Class-Based Inheritance and Prototypal Inheritance;112
15.3.3.1;Object-Oriented Programming:;112
15.3.3.2;Prototype-Based Programming;112
15.3.3.3; Classes;113
15.3.3.4; Instances;113
15.3.3.5; Methods;113
15.3.3.6; Inheritance;113
15.3.3.7;Composition;114
15.4; D Defined Terms;114
15.5; E Support for Selected Statements;114
15.6; F Simple Closure;115
15.7; G Sealing and Freezing Objects;116
15.8; H Configuring Properties;117
15.9; I Dynamic Properties and Me;118
16;Index;119



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.