Originating from architectural design (as in design of buildings), when design patterns crossed over to computer programming in the 1980’s, only a small group of people using a language called “SmallTalk” were applying them. In 1995, a group of four authors released a book called “Design Patterns: Elements of Reusable Object-Oriented Software”.
The four authors where nicked the “Gang of Four”. SmallTalk, but also C++ where the languages applying design patterns at that time. It is still the most respected book on design patterns to this date. “Gang of Four” (abbr. GoF) is also commonly used to refer to the book, rather than the authors.
Soon after, ‘Gurus’ such as Martin Fowler started publishing their own works, perhaps most notably “Patterns of Enterprise Application Architecture” (abbr. PoEAA). By then, most books where using Java in their examples. The Java community has played a big part in the evolution of Design Patterns, not in the last place thanks to efforts from Alur et al. with their “J2EE Core Patterns”.
Tony Marston gives a nice intro to OOP:
The problem with OOP is that there is no clear definition of what it is and what it is not. Since its first appearance numerous people have expanded on its original definition (whatever that was) and invented new ‘rules’ which in turn have been subject to different interpretations. For each interpretation there are also many different possible implementations. There is no single definition, or set of definitions, which is universally accepted, therefore, no matter what you do, somebody somewhere will always find a reason to complain that ‘you are wrong!’
This article is highly recommended if you want to know the basics of OOP and also the intermediate level of OO programming.
This article by Tony Marston is an important one since it deals with the best practices of OO programming. I could say the article is not language specific but since he mostly deals with PHP and MySQL, the codes are based on PHP. Describes topics such as Data Dictionary, Entities, and OOP pagination system. He also shows how to store the state of an object in one page and then “resume” that state in another PHP script by using PHP’s built-in session object. Pretty neat, huh?
Database connectivity is one of the most important columns of a dynamic web. Besides being able to handle database queries with great flexibility, a website must provide the database with strong security. One solution is to write some thousands of lines codes and repeat the process for future projects OR use a single class to handle all the database functions for all your projects. Since I have one of the most powerful assets a good programmer must have that is, laziness, I would opt for the second option.
This article from Particletree.com provides a solid background for creating really flexible database classes that you can extend in the future. Also, they provide the article for three different languages (although you can adapt the idea for almost infinite number of languages). Enjoy!
Basically it’s an introduction to Object-Oriented Programming written by Java experts. It’s a delight for programmers though since the tutorials mainly focus on the concept of the OO Programming rather than specific language syntax. Covers most of the topics in OOP including interfaces.
I guess the site can describe itself better than I can:
The Object Oriented Programming Web publishes FREE programming and computer science tutorials, lecture notes, course slides and e-books. OOPWeb.com is a great resource for all programmers and computer science students, but it’s especially popular among those who are interested in C++, Java and Object Oriented Programming.
The tutorial is relatively short and can be skimmed pretty quickly (hey! that’s a plus point for us lazy coders). Mainly deals with the different types of relations between objects, their lifestyles and soap operas (okay, cancel the last one). Has some neat and easy-to-understand examples (cars and pizzas).
This article from Exforsys Inc. is what you really want. It’s language independent and although sometimes it bends towards technical terms, it is relatively easy to understand. P.S. I first thought the site name was Exorcist (dyslexic? hmm).
I don’t know about you but I really liked Tony’s series of articles about Object-Oriented Programming. It’s really meant to be Newbie-Object-Oriented-Programming (NOOP? I thought it would be noob). The author puts some really neat examples to make sure that everyone can understand the basic concept of Object-Oriented Programming.
Object Oriented Programming with PHP by Kevin Waterson
I know some guys get upset seeing the wealth of information scattered around the web but none of them giving suitable explanations. Well, Kevin is one of them then. This guy probably packed a whole book into one complete page explaining all the important concepts of OOP and also for us lucky web developers, he has written the article using PHP! He discusses advanced topics like Autoload, Overloading, and Class Constants. MUST READ.
And boy didn’t we see the effect in full or what? This article is a whopping huge post of detailed information about the PHP OOP features. Yes sirree it is not language dependent article but WTH (notice: I didn’t use WTF…I think I just did). So get some cups of 100% caffeinated coffee and start gaining vital knowledge about OOP.
- All properties must be declared and be preceded by one of the visibility keywords: public, protected, or private. (As with every rule, there is one exception when the visibility keyword is optional.)
- Using a visibility keyword is optional when defining a method, but is recommended. If no keyword is used, the method is automatically treated as public.
- “Method” is simply OOP (Object-Oriented Programming) terminology for a function inside a class. Use the function keyword when defining a method.
- Use the new keyword to create an instance of a class (an object).
- The $this variable inside a class refers to the current object.
- Use the -> operator to access an object’s methods or properties (there is no space between – & >).
- When accessing a property with the -> operator, omit the $ sign.
- Attempting to access a protected or private property or method from an external script triggers a fatal error.
- Use getter and setter methods to access protected and private properties and methods from an external script.
Source: “PHP Object-Oriented Solutions” by David Powers. A definite reference material to keep side by side with your famous “Gang of Four” book (What? You don’t own it?)
There’s only one thing that bothers me a bit. It says PHP triggers a fatal error when trying to access any private or protected properties from an external script. Does only trying to access them from an external script trigger error? Isn’t it that anything outside the class (in the same script) trying to access protected or private property triggers a fatal error?