Design Patterns – Introduction

June 26, 2009

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”.

Source: http://www.phpfreaks.com/tutorial/design-patterns—introduction/page1

Advertisements

Object-Oriented Programming for Heretics

June 24, 2009

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.

Source: http://www.tonymarston.net/php-mysql/oop-for-heretics.html


What is/is not considered to be good OO programming

June 24, 2009

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?

Source: http://www.tonymarston.net/php-mysql/good-bad-oop.html


Database Simplicity With Class

June 20, 2009

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!

Source: http://particletree.com/features/database-simplicity-with-class/


Bunch of OOP Tutorials

June 13, 2009

Lesson: Object-Oriented Programming Concepts by Java

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.

The Object Oriented Programming Web

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.

And damn, it has some of the nicest collections of algorithms, ranging from graph theory to Sorting and Searching algorithms

Object Oriented Programming in JavaScript by Mike Koss

I know it’s not a language independent tutorial but it is really, really an excellent tutorial. And besides, most of the web designers and programmers need to know JavaScript, the so-called “behavioural” language of the web. HIGHLY RECOMMENDED.

JavaScript Object-Oriented Programming

This is an article from SitePoint, so we can expect it to be really good. And it is. I am not much of a hard-core programmer but I can say that it’s a bit technical and as the name suggests, the article is language specific. But then again, everybody developing the web needs to know JavaScript by heart.

Object-Oriented Programming Concept

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).

OOPS Concepts

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).

What is Object Oriented Programming (OOP)? by Tony Marston

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.

OO PHP Part 1: OOP in Full Effect

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.


PHP OOP Quick Review:

June 9, 2009
  • 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?