The 4 Stages of Learning Design Patterns

Posted by: Steven Smith, on 13 May 2011 | View original | Bookmarked: 0 time(s)

4530185934_d44eed3c70_mDesign patterns are general, reusable solutions that occur in software design, which can usually be adapted to fit into a number of different situations and applications.  Recently, I recorded a screencast interview with Carl Franklin on Commonly Used Design Patterns for dnrTV, and one of the things we discussed was the stages of learning design patterns.  I noted that, at least for myself, Id found that I tended to go through four distinct phases during my learning process when it came to these patterns.  Ive found it valuable to enumerate these stages, because if we can recognize where we are in our learning process, it can help us to evaluate whether our decision to use a pattern is based on its true applicability to the situation, or merely is a consequence of our own knowledge (or lack thereof) of the pattern.

Ive numbered the stages starting with zero, not just to be programmer-geeky, but also because the initial stage really does represent zero knowledge.

Stage Zero Ignorance

You used what?  Never heard of it.

The first stage is basically the complete lack of knowledge.  Youre unaware of design patterns, or at least the particular pattern in question.  If someone else mentions it in conversation, youre simply lost, unless you ask for some clarification as to what they mean by the term.  Naturally at some point, every programmer must start at stage zero when it comes to design patterns, as with every other concept theyve had to learn at some point along the way.  Its worth recognizing that youre at this stage and making an effort to at least move up to Stage One with regard to design patterns in general, so youre better prepared to discuss software with your peers and able to determine whether any particular patterns have value in your specific work.

 

Stage One Awakening

Wow, I just learned about how using the XYZ pattern can greatly improve the design of my applications.  Im not really sure where to add it to my code, but now Im going to be looking for places to use it.

The easiest transition in the learning curve is of course the move from Ignorance to basic Awakening.  At Stage One, youve heard of the pattern, and maybe youve used it in a non-production manner, but youre still not sure when and where to really use it in a real application.  However, youre now able to converse with others about the pattern by name in a somewhat intelligent fashion, and youre better prepared to learn more about the pattern and recognize its use when you see it used by others (e.g. in articles, presentations, or open source projects).  For some, perhaps even many, patterns, its reasonable for you to remain at Stage One until youre confronted with a design challenge that a particular pattern is well-suited to addressing.  Hopefully when that happens, youll consider the possibility that a design pattern may apply to the problem, and then youll explore the patterns to see learn which one might best apply.  Applying the pattern to your problem will almost certainly raise your level of understanding of it.  Alternately, you can learn as much as you can about as many patterns as you can before youve encountered a real need for them.  This approach works well, too, but often quickly leads to the Stage Two level of knowledge.

 

Stage Two Overzealous

I totally get the XYZ pattern and am just loving it.  Im adding it everywhere I can shoehorn it into my code.  My designs gonna be awesome, now, for sure!

We all do this its not really related to programming or design patterns.  Once we learn something and we get comfortable with a new technique, we want to use it everywhere we can.  Carl mentions that this is commonplace in music.  Ive certainly found myself in this stage with design patterns, as well as in my martial arts studies and elsewhere.  Avoid getting stuck in a rut with any one pattern, or falling into the Golden Hammer trap.  Recognize that you may be in this stage when youre designing and refactoring your code.  Are you applying a pattern because its truly needed and improves the design, or just because you can and this particular pattern is comfortable for you?

 

Stage Three Mastery

Over time, the applications design began to exhibit certain negative characteristics such as repetition.  It was clear that applying the XYZ pattern would alleviate the issue, so I applied it via some refactoring steps and tested the application to ensure its behavior remained unchanged.

Youll know when youve really mastered a particular pattern when you can see the patterns evolving out of your code, rather than being forced upon it.  Or when you are confident enough in your design and refactoring skills to not apply the pattern up front, knowing that you can do so if and when its warranted (remembering YAGNI).  Its not necessary that you master every design pattern I dont think many developers do.  However, you should try to master those patterns that you find yourself using frequently, whether through conscious choice or merely by coincidence.  Read up on how the pattern is used from a variety of different books or videos.  Go through a kata or two with the intent of applying the pattern to the problem.  Discuss the pattern with your peers at a user group, conference, or online.  Write your own articles or blog posts about how youve found the pattern to be applicable in your work.  All of these are tools you can use to master the design patterns that you use the most, ensuring that you get the most out of their use, and avoid overusing them.

 

Resources

Common Design Patterns screencast on dnrTV (covers 6 common patterns)

Book: Design Patterns The Gang of Four reference.

Book: Head First Design Patterns The best book Ive read on learning design patterns.  Very practical and enjoyable.  My review.

Book: Design Patterns in C#

Online Training: PluralSight Pattern Library Over 20 different patterns covered in over 9 hours of training

Wikipedia: http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29 includes a nice list of patterns

Design Patterns PDF Quick Reference

Alternatives to the Singleton Design Pattern


Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD