 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Wes Shell's Blog: Encapsulation in PHP
by Chris Cornutt October 13, 2009 @ 09:05:16
Wes Shell has posted a new tutorial to his blog today looking at encapsulation in PHP development - containing parts of the script to make them easier to work with as a whole.
In order to understand the purpose of encapsulation you first need to understand the purpose of classes. [...] In order for them to be used properly as they were designed, you will need to limit how users of the class can interact with those characteristics and functionality.
He looks at the visibility modifiers (public/private/protected), interface functions and some sample code showing how to use them in a simple class to work with a Person's set of data.
voice your opinion now!
tutorial encapsulation visibility
Chance Garcia's Blog: Visibility and inheritance
by Chris Cornutt August 12, 2009 @ 09:40:20
In this recent post to his blog Chance Garcia looks at visibility and inheritance in PHP applications. Specifically, it references a question that came up on IRC about the "default" visibility for methods and the open/closed principle.
Out of the whole discussion, here is the points I got (aka understood) out of it. Please correct me in the comments if I'm off base in any way.
There's two points he makes in the remainder of the post:
- Methods should only be public when necessary.
- Private methods allow you to preserve the class' core functionality.
There's also a bit of code included to illustrate some of his points.
voice your opinion now!
visibility inheritance openclosedprinciple
DevShed: More on Private Methods with PHP 5 Member Visibility
by Chris Cornutt June 25, 2008 @ 13:58:20
DevShed finishes off their series looking a private, public and protected variables and methods in classes with this final look a private methods in PHP5 object-oriented programming.
It's time to leap forward and tackle this final article of the series, which will be focused on covering some additional aspects concerning the use of this kind of class method. In addition, I'll teach you how to utilize the "final" keyword, which is included with PHP 5, to prevent the methods of a specific class from being overridden by any subclass.
They work from a hands-on example to show how they can work with private methods (expanding a bit from last time) and how to use the "final" keyword to restrict any and all modification for a method.
voice your opinion now!
php5 tutorial oop member visibility method property final private
DevShed: Defining Public and Protected Methods with Member Visibility in PHP 5
by Chris Cornutt June 12, 2008 @ 07:51:13
DevShed continues their series looking at variable scoping in PHP5 classes with this new look at using the public and protected keywords to "restrict member visibility".
Now that you know what will be treated in this fourth chapter of the series, it's time to learn how to declare and implement public and protected methods with PHP 5 classes. Of course, as always I'm going to address this useful topic by using a hands-on approach, which means that there's a bunch of code samples ahead, waiting patiently for you.
They talk about calling methods globally first and then move into the keyword restrictions. They show the difference between a public method/variable and a protected one, including how to get at the protected members from a child class.
voice your opinion now!
tutorial php5 protected member visibility public child
DevShed: Protecting PHP 5 Class Data with Member Visibility
by Chris Cornutt May 22, 2008 @ 09:37:05
In this new tutorial posted to DevShed, they take a look at working with classes in PHP5, specifically using the keywords for "member visibility" to make your classes a bit more structured.
The previous concept can also be applied successfully when it comes to defining the visibility of properties and methods in PHP classes. [...] Using the jargon of object-oriented programming, this capacity is widely known as member visibility. This capacity allows PHP programmers to establish whether the set of methods and properties of a specific class will be public, protected, or private.
They start more generally by looking at how to set up the variables globally and then move down the line talking about restrictions (private/protected/public) and how to get to them in the scripts outside the class.
voice your opinion now!
visibility class tutorial private protected public php5
|
Community Events
Don't see your event here? Let us know!
|