tailieunhanh - Developing Large Web Applications- P5

Developing Large Web Applications- P5:This book presents a number of techniques for applying established practices of good software engineering to web development—that is, development primarily using the disparate technologies of HTML, CSS, JavaScript, and server-side scripting languages. Whereas there are many books on how to use languages, how to use libraries, and how to approach software engineering, this is the first book to codify many of the techniques it presents. These techniques will make the components of your own web applications more reusable, maintainable, and reliable | Declare the methods for which you want to provide no implementation with the keyword abstract. Any class that contains an abstract method must itself be declared abstract. Example 2-7 illustrates declaring an abstract class. Example 2-7. Declaring an abstract class in PHP abstract class Account protected balance protected minimum public function construct amount lowest . abstract public function deposit amount abstract public function withdraw amount Final methods To specify that you do not want to allow a method to be overridden in a derived class declare the method with the keyword final. Example 2-8 illustrates declaring a method as a final method. Example 2-8. Declaring a final method in PHP class Account protected balance protected minimum public function construct amount lowest . final public function withdraw amount No other class can override the implementation provided here. . You can also specify that an entire class cannot be extended by placing the keyword final before the keyword class. Object-Oriented PHP 21 Object-Oriented JavaScript This section presents some of the fundamentals behind object orientation in JavaScript. JavaScript is a powerful language but many of its features including object orientation are not well understood. This is primarily because people just haven t explored them much. Douglas Crockford provides a good description of some of the misconceptions surrounding JavaScript at http and in his book JavaScript The Good Parts O Reilly . This section will provide just enough detail to help you understand the examples in this book and to recognize important differences between object orientation in PHP and JavaScript. A good book for learning more about object orientation in JavaScript is JavaScript The Definitive Guide O Reilly by David Flanagan. Objects As mentioned at the start of the chapter JavaScript is an object-based language it does not have classes. You create an object by adding