O'Reilly logo

Developing Large Web Applications by Kyle Loudon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Object Orientation

Object orientation has been at the heart of many types of software for years, but web developers using JavaScript and server-side scripting languages generally haven’t been as fast to embrace it. In the early days, websites had fairly simple scripting needs, so object orientation wasn’t crucial. Today, with the complexity of software on the Web, an understanding of object orientation is fundamental to approaching the development of large web applications with the same rigor as other types of software.

Throughout this book, we’ll explore many examples that use object orientation in PHP and JavaScript, so it’s worth spending a little time to examine its importance and how both languages address it. Both PHP and JavaScript have powerful support for object orientation, but each implements it in different ways. One of the fundamental differences is that PHP is a class-based language. In class-based languages, you declare and extend classes, which you then instantiate as objects wherever needed. This is object orientation as C++ and Java developers know it. On the other hand, JavaScript is a prototype-based (or object-based) language. In prototype-based languages, there are no classes; you create objects on the fly and derive new ones using existing objects as prototypes. Whatever the language, the following tenet (first described in Chapter 1) articulates what we expect to achieve with an object-oriented implementation:

Tenet 2: The use of object orientation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required