Why would one use the Publish/Subscribe pattern (in JS/jQuery)?

It’s all about loose coupling and single responsibility, which goes hand to hand with MV* (MVC/MVP/MVVM) patterns in JavaScript which are very modern in the last few years. Loose coupling is an Object-oriented principle in which each component of the system knows its responsibility and doesn’t care about the other components (or at least tries … Read more

Kyle Simpson’s OLOO Pattern vs Prototype Design Pattern

what exactly does his pattern introduce? OLOO embraces the prototype chain as-is, without needing to layer on other (IMO confusing) semantics to get the linkage. So, these two snippets have the EXACT same outcome, but get there differently. Constructor Form: function Foo() {} Foo.prototype.y = 11; function Bar() {} Bar.prototype = Object.create(Foo.prototype); Bar.prototype.z = 31; … Read more

What’s the difference between design patterns and architectural patterns? [closed]

It requires a detailed explanation but I will try to sketch the differences to best of my knowledge. Patterns are distilled commonality that you find in programs. It allows us to deconstruct a large complex structure and build using simple parts. It provides a general solution for a class of problems. A large complex software … Read more

Difference between Observer, Pub/Sub, and Data Binding

There are two major differences between Observer/Observable and Publisher/Subscriber patterns: Observer/Observable pattern is mostly implemented in a synchronous way, i.e. the observable calls the appropriate method of all its observers when some event occurs. The Publisher/Subscriber pattern is mostly implemented in an asynchronous way (using message queue). In the Observer/Observable pattern, the observers are aware … Read more

What is the difference between Strategy design pattern and State design pattern?

Honestly, the two patterns are pretty similar in practice, and the defining difference between them tends to vary depending on who you ask. Some popular choices are: States store a reference to the context object that contains them. Strategies do not. States are allowed to replace themselves (IE: to change the state of the context … Read more

DDD Approach to Access External Information

The first thing I noticed was the improper use of the bank account factory. The factory, pretty much as you have it, should be used by the repository to create the instance based on the data retrieved from the data store. As such, your call to accountRepository.FindByID will return either a FixedBankAccount or SavingsBankAccount object … Read more

Java collections covariance problem

You’re probably going to need to take a look at using wildcard types for generics. Here’s a quick link: What is PECS (Producer Extends Consumer Super)? Quick answer: change the type to List<? extends AbstractItem> Why can’t you just assign this? Imagine the code here… List<AbstractItem> foo = new ArrayList<SharpItem>(); foo.add(new BluntItem()); The static typing … Read more