Friday, June 20, 2008

Reading "Design Patterns: Elements of Reusable Object-Oriented Software"


I previously read lots of design patterns books, each and every one of these books mentions "Design Patterns: Elements of Reusable Object-Oriented Software" as a primary -if not the first- source of information that inspired the writer while writing his book.

I'll refer to the book as the GoF book as it's universally known, which means "Gang of Four", referring to the four writers of the book (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides).

Whenever I come across a sentence referring to the GoF book, I used to think "well, this book seems very inspiring, however, it was written in 1994, 14 years ago -wow- that's like the stone age for an industry in which every thing gets outdated in like 5 minutes.

I expected to find outdated information and theoretical examples that don't relate a bit to the reality of our new solutions, I'm reading in design patterns as a sort of refereshment of information before I start designing and coding a new -one of a kind- online application in ActionScript and Flex, and I don't need a group of stone age nerds to tell me how to do it".

I was wrong.

I won't start praising the book and how far it inspired me and made me rediscover aspects of Object Oriented Design. I didn't know that such aspects could be powerfully utilized and put to action, namely the concept of "polymorphism". Just take it for granted: This book is awesome.

However, to start with the book, and especially if you're new to the patterns discussed -or design patterns in general- you'll face some difficulty reading and advancing through the chapters without trouble. The writers were trying to describe different aspects of the patterns and give early examples about differences and similarities, contrasting between different patterns' structures and applicability. There are lots of cross references between the patterns throughout the book, in locations where the cross-referenced patterns were not yet explained or discussed.

I personally felt this was very frustrating, since I had to deffer understanding these discussions and comparisons till I read about these referred-to patterns later in next chapters. These discussions and comparisons were mixed up with the book's text, not in their own sections, so I had to pass though that frustrating feeling every time I stepped through these discussions.

The writers put it this way:
A word of warning and encouragement: Don't worry if you don't understand this book completely on the first reading. We didn't understand it all on the first writing! Remember that this isn't a book to read once and put on a shelf.
Well, quite honest, but let's face it, who has the time to read a 350 pages book more than once consecutively? moreover, who doesn't worry if he doesn't understand many aspects of the book on the first round. Definitely not me!!!

After finishing the second chapter, I had a couple of red smoking ears, and an inner feeling that I'm a complete idiot!. I needed some really fast and short crash course about all patterns discussed in the book before I could be able to go through another page!, I needed to know what the hell they are talking about the next time they refer to some pattern that will be discussed later, hundreds of pages away.

My dearest Wikipedia came to the rescue. I printed all Wikipedia pages discussing the design patterns mentioned in the GoF book. Reading them went so smoothly and fast, there were tons of examples in many languages (C++, Java, C#, PHP, Actionscript, etc...).

The Wikipedia pages also included many citations from the Gof book. It seemed like the book was being injected into my brain just like Nero was being taught Kung-fu in The Matrix.

After reading the Wikipedia pages, I continued my trip through the GoF book, and it felt totally different this time, feeling the change in my perception of Object Oriented Design while being re-sculptured again.

Links:

1 comment:

Taha said...

بسم الله الرحمن الرحيم

مبروك المدونه يا فندم .. ربنا ينفع بيها.. ويبارك فيها وتبقى في ميزانك ان شاء الله..

اول رد في المدونه اهو .. اي خدمه :D