Category archives for Design Patterns

Python design patterns #5: observer (aka: pub-sub)

The observer is probably the GOF pattern with the most impact on networking. It is a massaging pattern by itself. It’s quite simple, though. The subscribers, interested with a certain topic, subscribe with a publisher for updates regarding that topic. The publisher, triggered by our topic-aware system, then publishes the topic updates to the right subscribers. Use case Every […]

Python design patterns #4: visitor

Another favorite. Much simpler than the decorator, but sleeker no less:) Who left the door open? What if we could let someone operate over our object, whoever that someone was, whatever our object looks like and for any possible reason? Intuitively a door left open comes to mind. Its not a matter of having the […]

Python design patterns #3: the decorator

red_sports_car_decorator

Continuing with one of my favorites – the decorator. It’s a smart one, so a little more talking before coding..   Why? What do you do when you need a flexible combination of properties in an object? If you’re thinking why not sub-classing? you’re ok.. Sub classing is just right for allowing slightly different flavors […]

Python design patterns #2: adapter, bridge and proxy

Finally got the time to complete this project, since I first started it with the classic Singleton. Later I’ll post about the Borg pattern, which is the pythonic version of how singleton should have been.. ———— Adapter, Bridge and Proxy are all about can’t / won’t / prefer-not-to do something directly, but by other mean. They’re […]

From Matlab to Java To Matlab

Lately, most of my testers are either Java or Matlab. You can’t do (not in linear time 🙂 ) your Matlab magics with Java, and you can only dream on your Java OOD capabilities when working with Matlab… A nice workaround is to combine your testers; work on your main programming language of interest, and […]

Design Driven Development (DDD) vs SOA, for JAVA

To SOA or to DDD? Again, today, I had to select between the two, for a new project I’m designing. In short: SOA is inherently built on a stateless model object concept, allowing it to be super loosely coupled. Objects traveling between layers as serialized data, regenerating themselves on each de-serialization. This is loosely 🙂 […]

Singleton pattern for Python (single and multi-threaded)

Goals: Provide single point of access, to a one and only instance of a class Support lazy (on-demand) instantiation Support single and multi-threaded RT environment Challenges: Python does not support constructor hiding (i.e. marking as private) Proving I’m right – CPython does not really support multi-threading, due to its Global Interpreter Lock What’s good here? Instead of […]