A design pattern is a general reusable solution to a commonly occurring problem in software design.

learn more… | top users | synonyms (1)

1
vote
2answers
356 views

how should I design Objects around this business requirement?

This is the business requirement: " A Holiday Package (e.g. New York NY Holiday Package) can be offered in different ways based on the Origin city: From New Delhi to NY From Bombay to NY NY itself ...
0
votes
1answer
4k views

Implementing a ILogger interface to log data

I have a need to write data to file in one of my classes. Obviously I will pass an interface into my class to decouple it. I was thinking this interface will be used for testing and also in other ...
4
votes
2answers
722 views

What is required for a scope in an injection framework?

Working with libraries like Seam, Guice and Spring I have become accustomed to dealing with variables within a scope. These libraries give you a handful of scopes and allow you to define your own. ...
13
votes
8answers
3k views

Does MVC apply only to web

It is almost and instantaneous whenever I talk to developers about Model View Controller (MVC) they say you make a request to a url the server builds a entity (MODEL) and provides you with visual ...
4
votes
4answers
250 views

How do I handle priority and propagation in an event system?

Let's say I have a simple event system with the following syntax: object = new Object(); object.bind("my_trigger", function() { print "hello"; }); object.bind("my_trigger", function() { print ...
1
vote
3answers
424 views

Extra class for writing data to some backend?

What is the common practice to write classes which take some data class and store it to some backend? In my case I have table classes (columns, headers, etc.) which are written to Excel. So I have a ...
2
votes
2answers
178 views

design for supporting entities with images

I have multiple entities like Hotels, Destination Cities etc which can contain images. The way I have my system setup right now is, I think of all the images belonging to this universal set (a table ...
5
votes
1answer
699 views

Why is the Flyweight Pattern practical?

I was reading up on design patterns, to better my understandings of ones I know and reveal ones I didn't. One of the last ones I looks at was the Flyweight Pattern. It preaches about shared common ...
2
votes
2answers
119 views

Pattern for group of entities with one required primary member

Given a parent entity with a collection of child entities where there must be exactly one primary child of the group? To make the question more concrete, I've seen a number of ways that this pattern ...
1
vote
2answers
200 views

Main class passes dbConn obj to all its services, I need to change the dbConn for one of its services. - suggestion for design pattern

There is this main class and there are several services ( which uses db connection to retrieve data ) These services are initialized in the main class db properties are obtained from the property ...
4
votes
2answers
255 views

Help needed with class design and structure

This question is mostly about the best way to approach this problem. Any input is appreciated. The Problem In my application i need to send some data to a number of different destinations (we will ...
18
votes
2answers
19k views

What is a recommended pattern for REST endpoints planning for foresighted changes

Trying to design an API for external applications with foresight for change isn't easy, but a little thought up front can make life easier later on. I'm trying to establish a scheme that will support ...
0
votes
2answers
733 views

HTML5/Javascript + Web Services

If developing web applications using ASP.NET MVC or Ruby on Rails make the application use the MVC design pattern, then if I build my application using only HTML5/Javascript + backend webservices ...
2
votes
1answer
773 views

Best practice for combining a Java Applet/ Android interface?

I'm working on an online game, which I am seriously considering writing a Java Applet for it. The game is not overly complex on the features. I'm considering at some point having at least 3 versions ...
2
votes
1answer
2k views

Subscribe/Publish Model in Web-based Application (c#) - Best Practices for Event Handlers

I was recently exposed to a desktop application that uses an publish/subscribe model to handle commands, events, etc. I can't seem to find any good examples of using this in a web application, so I ...
11
votes
3answers
2k views

What is the pattern name for using method chaining to build an object?

I frequently use a pattern where I using method chaining to setup an object, similar to a Builder or Prototype pattern, but not creating new objects with each method call, instead modifying the ...
5
votes
1answer
561 views

Need advice for approach for a web-based app that loads excel worksheet but exposes only the charts

I'm looking for suggestions on the Visual Studio approach to take for a web application that is in the conceptual stage. My environment has a lot of tools: Windows Server 2008 R2 Standard 64bit ...
8
votes
6answers
3k views

Why is subclassing too much bad (and hence why should we use prototypes to do away with it)?

I was reading up on design patterns, and I read that the prototype design pattern does away with excessive subclassing. Why is subclassing bad? What advantage would using a prototype bring about over ...
6
votes
3answers
468 views

Is it bad practice for a decorator to break the decoration chain?

I'm currently using decorators to apply various modifications to a template prior to rendering it. I'm unsure about my cache decorator, though, because it is currently able to break the chain of ...
5
votes
4answers
286 views

Type mocking frameworks does not change coding practices from testability point?

Many people recommend that we should code against interfaces and avoid statics for testability. Interfaces are not just for testability, they are sometimes a requirement. But sometimes we introduce ...
5
votes
4answers
270 views

Users creating instances from a template - is there a software pattern that corresponds to this use case?

I am looking into designing a system where users build a template item and then create many instances based on this template.They then need to be able customise each instance but I also need for them ...
1
vote
2answers
162 views

Is there a problem with writing an in-memory DAL for testing the BLL/ViewModels?

Mocking the DAL/Repository that I pass to the BLL/ViewModels for testing purposes is not much different than creating an in-memory DAL. Right now I'm using an in-memory DAL in a new project instead of ...
3
votes
1answer
1k views

Forcing aggregate root child access through the aggregate root alone

Context I'm developing an application using a Domain Driven Design approach. I want to use a design pattern wherever appropriate and apply all SOLID principles. Scenario I have an order and I want ...
4
votes
2answers
3k views

Is this a proper implementation of an iOS MVC pattern?

After browsing the apple docs, I came across this sample of their MVC pattern: Using NSNotificationCenter and without using KVO, would this diagram below represent a correct implementation of the ...
3
votes
3answers
326 views

Designing access to file-based “database”

It happened frequently that I have to provide access to a bunch of files organized in a directory tree according to some (sometimes loosely specified) rules. My standard pattern is to provide a ...
2
votes
2answers
220 views

Extensibility data model pattern

I was wondering how you'd be able to map the following criterias to common design patterns. I use PHP 5.3 and MySQL 5.5 and have my own mvc framework for my company but some parts could be better and ...
11
votes
2answers
350 views

What are the advantages of separating 'result' from 'status'

Let's say you have some automated processes that generally go through the following states; scheduled - initiated - validating - executing - completed On top of that these processes can prematurely ...
57
votes
5answers
12k views

When is it not appropriate to use the dependency injection pattern?

Since learning (and loving) automated testing I have found myself using the dependency injection pattern in almost every project. Is it always appropriate to use this pattern when working with ...
25
votes
4answers
4k views

Why was dependency injection pattern not included in the Gang of four?

Why was the dependency injection pattern not incluided in the gang of four? Did GOF pre-date widespread automated testing? Is dependency injection now considered a core pattern?
9
votes
4answers
405 views

Does an iterator have a non-destructive implied contract?

Let's say I'm designing a custom data structure like a stack or a queue (for example - could be some other arbitrary ordered collection that has the logical equivalent of push and pop methods - ie ...
12
votes
1answer
4k views

Learning Asynchronous programming [closed]

Asynchronous non-blocking event driven programming seems to be all the rage. I have a basic conceptual understanding of what this all means. However what I'm not sure is when and where my code can ...
3
votes
2answers
888 views

What is the advantage of implementing a composite design pattern?

Apparently, a composite design pattern represents individual entities and collective entities in the same manner. What is the advantage to this? For instance, if I subclass a class, why would I want ...
6
votes
1answer
764 views

When business rules affect presentation in MVC

The MVC design pattern is supposed to led itself to separating business rules from presentation. But sometimes business rules AFFECT presentation. What is the best way to deal with this? Is that ...
19
votes
2answers
15k views

Separating data access in ASP.NET MVC

I want to make sure I'm following industry standards and best practices with my first real crack at MVC. In this case, it's ASP.NET MVC, using C#. I will be using Entity Framework 4.1 for my model, ...
6
votes
4answers
264 views

Is there a pattern that will help with this data structure

I'm doing a java project. My main structure contains 2 lists with elements of type A the other type B. B itself contains a list of objects which may contain elements of A. It must be that when an ...
1
vote
3answers
590 views

Effective template system [closed]

I'm building a content management system, and need advice on which theming structure should I adopt. A few options (This is not a complete list): Wordpress style: the controller decides what ...
0
votes
1answer
280 views

How do I maintain states

I have a winforms application with a display window that can show 3d geometry. I have another control on which I have a series of options to turn on/off different items in my display window. However ...
3
votes
1answer
688 views

Using the decorator pattern in a deep class hierarchy

How would one use the Decorator design pattern for anything other than trivial toy problems, in a deep class hierarchy? For example, let's say you have the class class Decorated : public Foo, Bar, ...
5
votes
1answer
320 views

What other patterns can I use for this singleton?

I have a bit of code which uses a plugin and core model, revolving around four major objects: the Core, Server, Logger, and Parser, in slightly particular order. The Core acts as the central factory, ...
34
votes
2answers
16k views

Best practice/Patterns for two way data synchronisation

Quite often in my work the idea of 2-way data synchronisation between database systems crops up. The classic example is two slightly different CRM systems (say, Raiser's Edge and Salesforce) and the ...
3
votes
1answer
2k views

Opensource showcase for MVC in Java Swing [closed]

I've allready created small desktop CRUD applications using Java/Swing. In hindsight I'm not quite sure if the overall design of these applications is good. I've also done some reading on MVC and ...
19
votes
4answers
4k views

How should I add functionality to an object that already exists?

I have an interface that has a certain amount of well-defined functionality. Let's say: interface BakeryInterface { public function createCookies(); public function createIceCream(); } This ...
6
votes
2answers
284 views

God Namespace just as bad as God Object?

We have about 3/4 different projects, each sharing a certain level of data. Some data is not shared, but all the data access has ended up in a single namespace that is included in every project. ...
3
votes
3answers
234 views

Patterns for Maintaining Model State in Real Time

While some platform in some languages already address this issue, I would like to keep this semi-language agnostic and to focus on patterns associated with this issue. I have a data model that ...
4
votes
1answer
610 views

PHP Aspect Oriented Design

This is a continuation of this Code Review question. What was taken away from that post, and other aspect oriented design is it is hard to debug. To counter that, I implemented the ability to turn ...
2
votes
2answers
1k views

Right design pattern to use StopWatch class

I have to measure execution time for a blocks of code. I had implemented simple StopWatch class like http://www.goldb.org/stopwatchjava.html. If I will invoke methods of StopWatch class directly ...
1
vote
1answer
1k views

What is the best design pattern for asynchronous message passing in a Chrome extension?

I have a background script that is responsible for getting and setting data to a localStorage database. My content scripts must communicate with the background script to send and receive data. Right ...
27
votes
8answers
7k views

Are utility classes with nothing but static members an anti-pattern in C++?

The question Where should I put functions that are not related to a class has sparked some debate over whether it makes sense in C++ to combine utility functions in a class or just have them exist as ...
17
votes
4answers
6k views

Mediator vs Observer?

Can someone provide me with a canonical answer on the differences between an Observer and a Mediator, and a summary of when you should use one pattern over the other? I am unsure of what kind of ...
9
votes
4answers
659 views

How can a child state machine relinquish control back to the parent state machine?

My top level state machine has some states and edges. I will call this the parent state machine. A ----> B ----> C Any state within the parent state machine can be a state machine too. I will ...