Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which software design patterns do common GUI frameworks exhibit?

I have been a python programmer 7+ years now, and been designing with PyQt for 3+ years... But I am not a classically trained Comp Sci. major. More recently I have been learning Go and been actively following the Golang-nuts discussion list which is filled with extremely intelligent developers. From this discussion group, I have seen many references to software design patterns, such as Observer, Reactor, etc. Again because I am not a CS major, I never really learned all of this terminology and theory, but it made me wonder...

What design patterns do common GUI frameworks like Qt, wx, GTK exhibit?

I have a feeling like its a mixture of patterns for different components, such as the event loop vs signal/slots or binding vs Key-value observing, and so on. I would love to hear an explanation or generalization about how these software patterns map to the traditional components of these frameworks.

As a bit of a secondary element to this question: Are there GUI frameworks that try and take a completely different pattern approach to a GUI solution? Does Cocoa/objective-c use the same event loop patterns as these others?

Update
To help narrow down the focus of my question, and based on the answer by @HDDimon, I am mainly wondering about Behavior Patterns (communication):
http://en.wikipedia.org/wiki/Design_Patterns#Behavioral_patterns

like image 286
jdi Avatar asked Feb 23 '12 18:02

jdi


1 Answers

Good day. I think the best answer you will find in Martin Fowler article GUI Architectures.

from this article:

Model View Controller Probably the widest quoted pattern in UI development is Model View Controller (MVC) - it's also the most misquoted. I've lost count of the times I've seen something described as MVC which turned out to be nothing like it. Frankly a lot of the reason for this is that parts of classic MVC don't really make sense for rich clients these days. But for the moment we'll take a look at its origins.

At the heart of MVC, and the idea that was the most influential to later frameworks, is what I call Separated Presentation. The idea behind Separated Presentation is to make a clear division between domain objects that model our perception of the real world, and presentation objects that are the GUI elements we see on the screen. Domain objects should be completely self contained and work without reference to the presentation, they should also be able to support multiple presentations, possibly simultaneously. This approach was also an important part of the Unix culture, and continues today allowing many applications to be manipulated through both a graphical and command-line interface.

According to this article, the best types of patterns for division between any kinds of components is Structural Patterns.

from "Design Patterns: Elements of Reusable Object-Oriented Software" by The "Gang of Four": Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. (I really want recommend you to read this awesome book)

  • Structure Patterns:
    • Adapter
    • Bridge
    • Composite
    • Decorator
    • Facade
    • Flyweight
    • Proxy

But in any kind of frameworks you can see mix from several types of patterns: Creational patterns, Structural patterns, Behavioral patterns.

I had found a relational diagram between patterns from Design Patterns book, it may be helpful for everyday using.

UPD: Great SO answer added.

like image 103
Dmitry Zagorulkin Avatar answered Oct 17 '22 03:10

Dmitry Zagorulkin