The Not So Simple "Hellow World"

Soldato
Joined
16 Dec 2005
Posts
14,443
Location
Manchester
Over the last few days I have been studying OO Design Patterns as applied to PHP. Since PHP5 supports OO programming, I aim to learn how to get the most out of it.

For those who don't know, Design Patterns are basically solutions to common problems in OO programming. These solutions are special in that they maximise re-usability, de-coupling and lots of other OO type stuff that is good! :p

While reading around, I found a crazy example of how Design Patterns can be a little overkill...

http://www.phppatterns.com/doku.php/design/hello_world_in_patterns

I would pay good money to see a lecturer start Lesson 1 of OO programming with that particular Hello World example :p

"Now for a simple example of OO programming..."

*slide shows with 160 lines of code*

class: :eek:
 
Simply knowing the Design Patterns can be a goal to aim for. I know, even as a complete DP noob, that there is a time and place for them and I would never dream of attempting the Hello World example I posted :p

I would buy the original GoF book, but I think it is a little bit beyond my current abilities. It has been a year or two since I did any serious OO programming, so I have pretty much forgotten a lot of it. Maybe in a little while when I am back on form :p
 
One thing Design Patterns certainly shone light on for me, was how having very concise behaviours encapsulated within objects is better than having objects do a mish-mash of multiple behaviours.

Definitely. It is so tempting when creating a class to add in lots of "features" that you may never actually use and you are in danger of making a "God class", or in the least a class you can't easily reuse.

Just from my few days of looking at Design Patterns I have seen how you can add functionality and behaviours to your classes without having to rewrite them or depending too much on inheritence [again, something you can get carried away with!].
 
Back
Top Bottom