Part I. Easing into the Fundamentals of Design Patterns

All compromise is based on give and take, but there can be no give and take on fundamentals. Any compromise on mere fundamentals is a surrender. For it is all give and no take.

Mahatma Gandhi

People talk fundamentals and superlatives and then make some changes of detail.

Oliver Wendell Holmes, Jr.

An unfortunate thing about this world is that the good habits are much easier to give up than the bad ones.

W. Somerset Maugham

Programming Habits

For years after I started programming regularly, I developed certain habits that changed from sequential to procedural programming and just cruised along on a combination of those two for years. This was due in part to the explorations of different languages. My first was Fortran II in college, then on to Basic, FORTH, PostScript, and then into assembly and machine language. I was more interested in learning about different languages than I was in good programming. Then with the Internet came Java, JavaScript, PHP, C#, and ActionScript 3.0, among others. Most of these languages were based (in part) on the kinds of structures found in C++. These were different languages, but I maintained the same old habits.

Quite by accident, I was introduced to state machines by Dr. Jonathan Kaye. Instead of thinking in terms of flow of control, he showed me how to think in terms of different states. Following state machines, I discovered the State design pattern and then Design Patterns: Elements of Reusable ...

Get Learning PHP Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.