design-patterns

Translators from the data layer on

Currently working on a project, new product, using MVC. I've written a few of these, and I've found doing a repository pattern with "specialized" generic services (GetObjectService< T >, UpdateObjectService< T >, etc). This allows for those special instances of "hey, I need to get something based on this stuff" that's fairly complex an...

Pushing Questions to a client using Adobe BlazeDS/LiveCycle

Hi all, Over the past few weeks, I have been creating a sort of text-based adventure game revolving entirely around the actions of a player. The general idea is that there is a Simulation class that maintains the state of the world, and is the responsibility of the SimulationController (ie, the player) to keep actions going. Most of t...

What presentation design pattern fits HTML5 development?

There are various discussions about whether to use Flash, Silverlight or HTML5. When it comes to Silverlight, it has very different programming experience (more of a desktop model), and this makes it reasonable for Silverlight applications to use MVVP presentation pattern. But when it comes to pure HTML5-based Web application, is there ...

CQRS - Should CommandHandlers Invoke other CommandHandlers

Just trying to get some opinions on whether or not CommandHandlers can/should communicate with other CommandHandlers. Here is a simple case I just ran into. I have a ChangePasswordCommandHandler who's command looks like the following: public class ChangePasswordCommand : Command { public string Email { get; } public string OldP...

Factory Method pattern to avoid instantiation of objects based on conditional logics

In a scenario like below where an object needs to be intantiated based on some conditional logic, can the factory method pattern help to avoid client code getting cluttered due to number of if/elseif conditions (which would also be a maintenance nightmare if more and more products needs to get created due to different variations of logic...

What's the best way to implement a decision tree in Python?

How to do it? What design patterns? Ideally would be sample code in the answer. ...

Which is the best book to learn and implement Design Patterns using C#?

Which is the best book to learn and implement Design patterns available in the industry with examples? like Creational Patterns,Structural Patterns, Behavioral Patterns ? ...

Pattern for updating database through a property when using an internal mapping

I've reached a bit of a problem in my app and I'm not sure how best to resolve it. I'm using Linq to Sql and I have a domain object which wraps the Linq object so I don't directly expose Linq objects to my front end. So I have something like: class MyOrder : IOrder { Order _order; // this is the Linq entity public MyOrder(Or...

What are the main friction points when moving from WPF to Silverlight and how do you fill the gaps in functionality?

Okay, to give a little background, I learned WPF about 3 years ago and have kept reasonably up to date with what's happened since in various different versions. I looked at (and implemented) MVVM on a couple of projects, had a good look at frameworks like Prism so I think I'm pretty well versed in most areas of the framework. I've also...

What's this pattern called?

Some I'm reviewing some code within my team's code base, where we traverse over one hierarchical data structure and build a new data structure from it. There are no nested loops -- every level of the hierarchy has its own dedicated function. So we have code like this: public void DoA(A a, Transform transform) { foreach(B b in a) ...

Singleton pattern

When should we use the Singleton pattern and why? ...

A design pattern question regarding multiple database with slightly different structures

I am working on a rewrite of a very old Perl project. This project for employee performance evaluation. Every year an employee will be evaluated by his supervisor(s). The project was first put into use in 1994 using mysql. In 1995, a new mysql database was created for 1995 evaluation and the source code was modified. Then 1996, 1997, ....

Android application architecture - what is the suggested model?

In the same way a web or desktop app might have 3 or n tiers - UI, Business, Data for example - what is the suggested structure for an Android application? How do you group classes together, what layers do you have etc? I'm just starting Androi dev (an internet based app that must respond to incoming notifications) and have no real fee...

Top misrepresentations in programming?

I often find that design patterns, libraries, and frameworks promise great things and sound awesome - until you actually study them and realize that what they say sounds better than it actually is. Completely modular and stackable - use only what you need! For example, how do you properly Unit Test your database if your applica...

How to name this key-oriented access-protection pattern?

Apparently this key-oriented access-protection pattern: class SomeKey { friend class Foo; SomeKey() {} // possibly non-copyable too }; class Bar { public: void protectedMethod(SomeKey); // only friends of SomeKey have access }; ... doesn't have a known name yet, thus i'd like to find a good one for it so we can refe...

Can we increase the re-usability of this key-oriented access-protection pattern?

Can we increase the re-usability for this key-oriented access-protection pattern: class SomeKey { friend class Foo; // more friends... ? SomeKey() {} // possibly non-copyable too }; class Bar { public: void protectedMethod(SomeKey); // only friends of SomeKey have access }; To avoid continued misunderstandings, ...

Is this a "recognised" OO pattern? Need sanity check!

Say if I want to extend the functionality of a range of objects that I cannot change - for instance for adding formatting, and don't want to derive a huge amount of classes to extend the functionality - would the following considered bad? (I'm using int and float as an example, but in my program I have about 20 or 30 classes that will e...

Why is .NET ObservableCollection<T> implemented as a class and not an interface ?

Hi, In reading about the Observer design pattern, I noticed that it is implemented using interfaces. In Java, the java.util.observable implementation is also a class. Shouldn't the C# and Java versions use interfaces ? Scott ...

An architecture for almost complete JavaScript-based web applications?

Hi, I know that MVC is highly acclaimed for PHP applications, but I am not sure at all that it fits in JavaScript. If you think otherwise, then please explain how and where you handle common scenarios like AJAX requests, data saving (offline storage), presentation, how do you handle controller logic (do you have a front controller?), an...

Finding groups of similar strings in a large set of strings.

I have a reasonably large set of strings (say 100) which has a number of subgroups characterised by their similarity. I am trying to find/design an algorithm which would find theses groups reasonably efficiently. As an example let's say the input list is on the left below, and the output groups are on the right. Input ...