background preloader

Design Patterns

Facebook Twitter

SOLID (object-oriented design) In computer programming, SOLID (Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion) is a mnemonic acronym introduced by Michael Feathers for the "first five principles" named by Robert C. Martin[1][2] in the early 2000s[3] that stands for five basic principles of object-oriented programming and design. The principles when applied together intend to make it more likely that a programmer will create a system that is easy to maintain and extend over time.[3] The principles of SOLID are guidelines that can be applied while working on software to remove code smells by causing the programmer to refactor the software's source code until it is both legible and extensible.

It is part of an overall strategy of agile and adaptive programming.[3] Is Design Dead? For many that come briefly into contact with Extreme Programming, it seems that XP calls for the death of software design. Not just is much design activity ridiculed as "Big Up Front Design", but such design techniques as the UML, flexible frameworks, and even patterns are de-emphasized or downright ignored. In fact XP involves a lot of design, but does it in a different way than established software processes. XP has rejuvenated the notion of evolutionary design with practices that allow evolution to become a viable design strategy. It also provides new challenges and skills as designers need to learn how to do a simple design, how to use refactoring to keep a design clean, and how to use patterns in an evolutionary style. Extreme Programming (XP) challenges many of the common assumptions about software development.

Of these one of the most controversial is its rejection of significant effort in up-front design, in favor of a more evolutionary approach. Planned and Evolutionary Design. P of EAA. This book started after Dave Rice and I gave some talks on J2EE architecture and mulled over how the concepts we had learned in C++, Forte, CORBA, and Smalltalk had been crucial to us developing good designs in Java. With this book I wanted to set many of these patterns down to help developers whatever their platform.

These turned out to be very valuable when we started to use .NET in 2002 and Ruby in 2007. The book is a Duplex Book. The first part is a short (100 page) tutorial on enterprise application architecture. The bulk of the book is the reference to forty or so patterns. All of these patterns are ones that I've seen in the field, usually on many different programming platforms. Each pattern describes details of how it works and when to use it, together with code examples in Java, C# or both.

I've been fortunate enough to have some excellent contributors to this book, most notably Dave Rice - who wrote a good tenth of it. Inversion of Control Containers and the Dependency Injection pattern. In the Java community there's been a rush of lightweight containers that help to assemble components from different projects into a cohesive application. Underlying these containers is a common pattern to how they perform the wiring, a concept they refer under the very generic name of "Inversion of Control".

In this article I dig into how this pattern works, under the more specific name of "Dependency Injection", and contrast it with the Service Locator alternative. The choice between them is less important than the principle of separating configuration from use. One of the entertaining things about the enterprise Java world is the huge amount of activity in building alternatives to the mainstream J2EE technologies, much of it happening in open source.

Underlying these containers are a number of interesting design principles, things that go beyond both these specific containers and indeed the Java platform. Components and Services A Naive Example class MovieLister... Inversion of Control. Design Patterns. Designpattern. Learning Python Design Patterns Through Video Lectures. In my previous post about learning Python programming through video lectures I stopped at three lectures on Design Patterns. This time I continue from there. If you don't know what a Design Pattern is, think of it as a simple solution to a specific problem that occurs very frequently in software design. For example, suppose you use a bunch of unrelated pieces of code. It is a nice idea to bring the unrelated pieces of code together in a unified interface. This design pattern is called Facade. There are a bunch of patterns like this one! The three lectures are given by Alex Martelli who works as "Über Tech Lead" for Google.

Python Design Patterns, Part I Alex briefly covers the history and main principles of Design Patterns and quickly moves to discussing Structural and Behavioral DPs in Python. Interesting ideas from the lecture: Python Design Patterns, Part II In this lecture Alex discusses behavioral patterns. Python Design Patterns, A Recap. Design patterns.