Difference betwen Visitor pattern & Double Dispatch

In short they come from to different conceptualizations that, in some languages where double dispatch is not natively supported, lead to the visitor pattern as a way to concatenate two (or more) single dispatch in order to have a multi-dispatch surrogate. In long The idea of multiple dispatch is – essentially – allow a call … Read more

Actor pattern – what it exactly constitutes

That definition of an Actor actually seems a little restrictive. It certainly doesn’t handle Erlang-style actors (or I believe Scala-style actors). In my experience, an actor is something that: Sends and receives messages (each actor has a mailbox) Shares no mutable memory with other actors Is scheduled based on the whims of the runtime. An … Read more

Plugin Architecture in Web Apps (Examples or Code Snippets?)

A good plugin architecture is difficult to achieve from scratch, but offers its own rewards. It makes the software flexible and simple to maintain by localising complexity. The foremost skill it requires is the ability to write loosely coupled code. This demands a very firm grasp of polymorphism, Demeter’s Law and the related Hollywood principle. … Read more

Monostate vs. Singleton

monostate and singleton are two faces of the same medal (global state): monostate forces a behaviour (only one value along all class instances) singleton forces a structural constraint (only one instance) singleton usage is not transparent i.e.: Singleton singleton = Singleton.getInstance(); monostate usage is transparent i.e.: MonoState m1 = new MonoState(); MonoState m2 = new … Read more

Has anyone ever encountered a Monad Transformer in the wild?

The Haskell community is split on this issue. John Hughes reports that he finds it easier to teach monad transformers than to teach monads, and that his students do better with a “transformers first” approach. The GHC developers generally avoid monad transformers, preferring to roll up their own monads which integrate all the features they … Read more

What would a Log4Net Wrapper class look like?

Essentially you create an interface and then a concrete implementation of that interface that wraps the classes and methods of Log4net directly. Additional logging systems can be wrapped by creating more concrete classes which wrap other classes and methods of those systems. Finally use a factory to create instances of your wrappers based on a … Read more

Static factory methods vs Instance (normal) constructors?

In Effective Java, 2nd edition, Joshua Bloch certainly recommends the former. There are a few reasons I can remember, and doubtless some I can’t: You can give the method a meaningful name. If you’ve got two ways of constructing an instance both of which take an int, but have different meanings for that int, using … Read more