Приглашаем посетить
Романтизм (19v-euro-lit.niv.ru)

Summary

Table of Contents
Previous Next

Summary

In this chapter, you've learned that object-oriented programming is essential for PHP to survive as the web platform of tomorrow. We've talked about OOP's development and benefits after the explanation of the "software crisis" – where programs became large, complex, and unmanageable and there was a need for better software construction. We then talked about how it differs from functional programming and discussed the benefits that OO provides for us programmers and architects – increased reusability and maintainability.

After we sorted out all the groundwork, we dove into the basic building blocks of an object-oriented program – classes and objects. We learned that objects contain methods, members, and a constructor and that they become instantiated for use in our program when we use PHP's new operator. We learned that by providing useful services that clients can use and hiding the data in our objects, we can increase the reusability and maintainability of our code. This characteristic was called encapsulation because all the details of the implementation were hidden inside the class, un-exposable to any client using the class.

We then talked about adding more structure and meaning to our objects by using inheritance and polymorphism. We figured out that inheritance gives us the ability to specialize objects by adding more behavior and data to them, making our code more traceable, as well as reusable. By using polymorphism on our inherited objects, we could develop generic, elegant solutions that dealt with the details at run time with the help of the PHP interpreter. This also increased maintainability since we could add new classes to our inheritance model without modifying the logic in any of our polymorphic code.

Lastly, we finished this discussion by talking about cohesion and coupling. Cohesion is how closely the elements and functionality are related within the object, and coupling is the degree of relatedness between two or more objects. Highly cohesive modules produce smaller, more maintainable modules while loosely coupled objects provide us with greater reusability. We learned that it's good practice to create highly cohesive, yet loosely coupled modules to have highly reusable and maintainable programs.

Next, we looked at object modeling using UML. We realized that UML offers an easy, consistent way for specifying our designs for ourselves as well as communicating ideas to other programmers. Then we talked about the different kinds of containment and saw that there was a difference between physical containment and containment for reuse, called delegation.

We further looked into some more design heuristics and good practices by seeing that logic must be in the proper place. We learned that if it's scattered around our program, that it will be harder to use our objects, thus making it harder to reuse them and maintain them.

Lastly, we looked at creating object models for relational databases and an object model for a very advanced form engine. We illustrated various cases of inheritance, polymorphism, good design heuristics, delegation, and UML.


Table of Contents
Previous Next