note 99727 added to language.oop5.abstract

From: Date: Wed, 01 Sep 2010 17:31:16 +0000
Subject: note 99727 added to language.oop5.abstract
Groups: php.notes 
Request: Send a blank email to php-notes+get-172247@lists.php.net to get a copy of this message
Here is how it works, having developed on large scale projects as well as a deep understanding of programming design patterns I am very adept at developing Interfaces, Abstract Classes, and Concrete Classes to maximize standardization and re-usability of code. An interface defines the behavior through functions, it should not have variables if variables are allowed. In OOP languages an interface allows an object(class) to use ANY object that implements that interface. An Abstract class on the other hand often implements an interface (and should in most cases). The abstract class defines "universal" behaviors of all children of that class. So if a particular function is never going to change you implement it in the abstract class, AND if a particular function is almost always going to change, you mark it abstract, requiring child classes to implement it. Now you have your interface, which can be used by any object that expects that interface, and an abstract base class that implements a few of those functions and possibly adds a few of its own to the child classes, however these additional abstract functions are usually private or protected, or a part of another interface, but there are some exceptions. Now your child classes extend the abstract class that implements the interface making all these child classes capable of being used in a uniform fashion across many other objects that expect that interface and you saved yourself some time by not rewriting code because you created an abstract base class. It all forms the beautiful symphony of Object Oriented Programming. As a side note: Yes, an abstract base class can be used in place of an interface. Because PHP is not strongly typed two abstract classes that have the same function names can be used in other classes that expect these function calls, and in my opinion break OOP rules and makes things more confusing. But by using an interface it allows other programmers on your team to better understand the design of the application and upholds OOP design. ---- Server IP: 69.147.83.197 Probable Submitter: 66.124.195.3 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.abstract.php Edit -- https://master.php.net/note/edit/99727 Del: integrated -- https://master.php.net/note/delete/99727/integrated Del: useless -- https://master.php.net/note/delete/99727/useless Del: bad code -- https://master.php.net/note/delete/99727/bad+code Del: spam -- https://master.php.net/note/delete/99727/spam Del: non-english -- https://master.php.net/note/delete/99727/non-english Del: in docs -- https://master.php.net/note/delete/99727/in+docs Del: other reasons-- https://master.php.net/note/delete/99727 Reject -- https://master.php.net/note/reject/99727 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172247) next »