Friday, January 17, 2014

Learning about design patterns from the Brady Bunch

My favorite design pattern is similar to the Brady Bunch house.  When I visited Universal Studios in California several years ago we drove past several houses during the back lot tour.  It was also cool to see the clock tower from Back to The Future and the town square for Dukes of Hazard.  They were all Facades.  They had a simple front but there was nothing behind them.

I am a big proponent of KISS (Keep It SimpleStupid).  As developers, we all spend much of our life doing maintenance.  It makes sense to craft software so that it easy to understand.  Make your application easy to use for both the end user and future developers.  Maintenance costs will be reduced and it will be less frustrating to maintain.  The developer that maintains the code may be you coming back to it years later.

The Façade Design Pattern can be thought of as caller to several more complex systems.  The Façade Design Pattern is one of the easiest to understand and in my view, a critical part of enterprise architecture implementation.  One of my measurements of quality for an enterprise service or system is how easy it is to use. 

The Facade Design Pattern

A code example for Kellerman .NET FTP Library:

FTP ftp = new FTP;
ftp.Host = "";
ftp.UserName = "greg";
ftp.Password = "secret";


There is a lot of underlying complexity in the FTP protocol.  The Connect method has a lot of functionality behind it.  This complexity is hidden from the developer using the Façade pattern.  The connect command opens a TCP/IP socket, opens read and write network streams, resolves the host name through a DNS server, connects to the server, waits for the server to respond with a 220 welcome message, and then logs in using the UserName & Password. 

When we develop applications, libraries, or services; we need to take great care to make things as simple as possible.  The Façade pattern is an integral part of that strategy.  

More information:
Facade Pattern Examples in C# and Java
Facade Pattern Example

No comments:

Post a Comment