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

learn more… | top users | synonyms (1)

2
votes
2answers
2k views

Challenges in multi-player Android Game Server with RESTful Nature

I'm working on an Android Game based on Contract Bridge, as a part of my college Summer Internship project. The game will be multi-player such that 4 Android devices can play it, so there's no BOT or ...
16
votes
2answers
7k views

Relationship between Repository and Unit of Work

I am going to implement a repository, and I would like to use the UOW pattern since the consumer of the repository could do several operations, and I want to commit them at once. After read several ...
6
votes
3answers
324 views

When module calling gets ugly

Has this ever happened to you? You've got a suite of well designed, single-responsibility modules, covered by unit tests. In any higher-level function you code, you are (95% of the code) simply ...
0
votes
4answers
412 views

Why design pattern is not named as implementation pattern?

I find that most of the design patterns are concerned with implementation of a model like mvc, or how to change the implementation with less cost. These are all happened in the implementation phase of ...
1
vote
3answers
1k views

What design pattern do you use to support graceful fallback on old platforms?

Let's say I need to add a drop shadow behind a box. Some old platforms do not support drop shadows, so I have to fake it by putting an image behind the box. Here's the pseudo code of how I'm currently ...
4
votes
3answers
422 views

Create many similar classes, or just one

The goal is to create an application that has objects that can represent some operations (add, subtract, etc). All of those objects will have common functions and members, and thus will either ...
6
votes
2answers
513 views

Given the presentation model pattern, is the view, presentation model, or model responsible for adding child views to an existing view at runtime?

I am building a Flex 4 based application using the presentation model design pattern. This application will have several different components to it as shown in the image below. The MainView and ...
1
vote
5answers
649 views

Can observer pattern be represented by cars and traffic lights?

I wanted to verify with all of you, if I have a correct Observer Pattern analogy. The scenario is as follows: Consider, at a junction, there is a traffic signal, having red, yellow and green lights ...
0
votes
1answer
193 views

Parameterized Django models

In principle, a single Django application can be reused in two or more projects, providing functionality relevent to both. That implies that the same database structure (tables and relations) will be ...
4
votes
2answers
1k views

Who should register input listeners: the controller or the view? (MVC)

I'm using an (C++) SDK (Marmalade) and building a project around the MVC pattern. On my app, user input listeners may be registered on certain UI elements/widgets/etc providing a proper callback ...
13
votes
4answers
18k views

On MVC can several views have the same controller or one view must have one unique controller?

I'm having some questions while designing a architecture for a project around MVC. (It's a C++/Marmalade SDK project, I'm not using any particular MVC framework, I'm making one.) On several articles ...
4
votes
7answers
1k views

Design patterns: moving object references around an application

I'm new to Programmers and I am looking to increase my knowledge of programming. Recently, a user on Stack Overflow told me using singletons is a bad idea, that they encourage tight coupling and that ...
9
votes
1answer
1k views

Peter Norvig's paper cited by Brendan Eich

I'm reading Coders at Work and Brendan Eich cites a paper by Norvig, from when he was at Harlequin, "about how design patterns are really just flaws in your programming language." Can anyone provide ...
0
votes
1answer
322 views

iOS object instance accessible from three separate classes, or load 3 nib files with one class?

I've got three nib files in my project, each of which is driven by its own class (.h and .m files). Each nib has a stylized design with a full screen background image and a few overlay images acting ...
6
votes
5answers
4k views

Two database fields for date and time - should they be merged?

In the following question, field and table names have been changed to protect their identities. If I have two database columns: MONKEY_DATE DATETIME NULL (with data e.g. 2012-05-14 00:00:00.000) ...
9
votes
4answers
5k views

Design Patterns / Strategies For Custom Fields & Data Types

Are there any common strategies or design patterns for designing applications that have either the ability to add custom fields to data objects, or for creating your own custom definition of objects. ...
7
votes
3answers
3k views

Ajax race conditions

Is there a pattern or standard way to handle Ajax race conditions? Take the following example. You have two tables. Clicking a row on table 1 removes the data from DB and then updates table 2 (which ...
183
votes
17answers
46k views

Why is Global State so Evil?

Before we start this, let me say I'm well aware of the concepts of Abstraction and Dependency Injection. I don't need my eyes opened here. Well, most of us say, (too) many times without really ...
13
votes
2answers
3k views

Best overview to modern C++ paradigms? [closed]

I used to write C++ extensively between 8 and 10 years ago. I have since moved on to C# for professional reasons. However, from time to time I see statements like "If you're still manually ...
12
votes
5answers
905 views

Is overloading an example of the Open/closed principle?

Wikipedia says "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification" The word functions caught my eyes, and I now wonder if we can ...
25
votes
9answers
9k views

Alternatives to the singleton pattern

I have read different opinions about the singleton pattern. Some maintain that it should be avoided at all costs and others that it can be be useful in certain situations. One situation in which I ...
3
votes
2answers
314 views

How would I do a “Server over capacity” message with Django?

This probably isnt' a Django specific question, but I'm wondering how those "Server over capacity" messages are displayed. Some examples: Twitter's fail whale Tumblr's Over capacity slash page ...
2
votes
3answers
4k views

Any Course/Lecture videos on Design Patterns

I am planning to read some design patterns and I took the book on "design patterns in C++' by gang of four. However, I am not really some one who reads book and prefers reading slides/watching course ...
-2
votes
2answers
231 views

I have to run certain number of statements (which are executing .exe) in a loop

I have to run certain number of statements (which are executing .exe) in a loop. ForEach(object obj in ListOfVersions) { Step 1: call Exe1 Args=obj.somevalues Log Step 1 completed ...
8
votes
6answers
3k views

Can the Strategy pattern be implemented without significant branching?

The Strategy pattern works well to avoid huge if...else constructs and make it easier to add or replace functionality. However, it still leaves one flaw in my opinion. It seems like in every ...
8
votes
4answers
1k views

Design pattern for handling a response

Most of the time when I'm writing some code that handles the response for a certain function call I get the following code structure: example: This is a function that will handle the authentication ...
4
votes
10answers
1k views

Standardized Data Structure Interface

I want to work with a variety of data structures (arrays, singly/doubly linked lists, sorted structures, etc.) on a plug-and-play basis. For example, I want to be able to easily swap in and out the ...
1
vote
1answer
562 views

MVC, Java Design Pratices, and Flaws of java.util.Observable and java.util.Observer

I am planning learning Model-View-Controller (MVC) development using Java. While reading I came across a post which mentions java.util.Observer and java.util.Observable for MVC development. As I ...
6
votes
2answers
589 views

Does this implementation of the state pattern make sense?

I have the task to implement the state pattern in one of my classes. The assignment referenced a suggested implementation, and upon reviewing that implementation I was confused since I believed it to ...
2
votes
1answer
416 views

How to manage contextual objects without IoC container (session or passing around objects)?

I'm using asp.net (c#). I have a factory that uses a dictionary of keys that are mapped to objects types. I originally used a static variable to track the dictionary but realized it would be shared ...
3
votes
3answers
839 views

A software design pattern to model runtime-dependent behavior

In a interview I was asked, Suppose we are going to create a software that runs on both desktop machines and smartphones. Name a software design pattern that could be used to enable the ...
4
votes
5answers
2k views

Pattern for select case on object type (of interface)

I have read that doing a select case is often a code smell. There are cases however where an interface cannot solve my problem. For instance, I have a set of date filter objects (last 7 days, last ...
6
votes
2answers
260 views

Adapter Pattern to expose different aspects of an object — Is this a correct use?

Quite frequently, I use an Adapter-like design to expose different aspects of data objects. For example, in a 3D modelling application I use an object hierarchy to represent the 3d models in the ...
5
votes
4answers
836 views

Design Patterns for Coordinating Change Event Listeners

I've been working with the Observer pattern in JavaScript using various popular libraries for a number of years (YUI & jQuery). It's often that I need to observe a set of property value changes ...
9
votes
5answers
1k views

When to stop inheritance?

Once upon time ago I asked a question on Stack Overflow about inheritance. I have said I design chess engine in OOP fashion. So I inherit all my pieces from Piece abstract class but inheritance still ...
3
votes
3answers
1k views

Patterns for Handling Changing Property Sets in C++

I have a bunch "Property Sets" (which are simple structs containing POD members). I'd like to modify these property sets (eg: add a new member) at run time so that the definition of the property sets ...
5
votes
2answers
933 views

Development Patterns for dealing with Data Import / Export

I have a ASP.NET web based application that allows the end user to export data to a flat file format. (essentially taking a point-in-time backup of their work) At a later date they can re-upload ...
12
votes
4answers
1k views

Do I suffer from encapsulation overuse?

I have noticed something in my code in various projects that seems like code smell to me and something bad to do, but I can't deal with it. While trying to write "clean code" I tend to over-use ...
3
votes
2answers
1k views

Lazy Processing of Streams

I have the following problem scenario: I have a text file and I have to read it and split it into lines. Some lines might need to be dropped (according to criteria that are not fixed). The lines ...
4
votes
1answer
675 views

Dapper and object validation/business rules enforcement

This isn't really Dapper-specific, actually, as it relates to any XML-serializeable object.. but it came up when I was storing an object using Dapper. Anyways, say I have a user class. Normally, I'd ...
2
votes
1answer
290 views

Composite-like pattern and SRP violation

Recently I've noticed myself implementing pattern similar to the one described below. Starting with interface: public interface IUserProvider { User GetUser(UserData data); } GetUser method's ...
8
votes
2answers
282 views

Low coupling processing big quantities of data

Usually I achieve low coupling by creating classes that exchange lists, sets, and maps between them. Now I am developing a Java batch application and I can't put all the data inside a data structure ...
16
votes
6answers
2k views

Strategies for avoiding SQL in your Controllers… or how many methods should I have in my Models?

So a situation I run into reasonably often is one where my models start to either: Grow into monsters with tons and tons of methods OR Allow you to pass pieces of SQL to them, so that they are ...
5
votes
1answer
13k views

Android Development: MVC vs MVVM [duplicate]

Possible Duplicate: Is Model-View-Presenter (MVP) scheme useful for Android? I've started coding for Android and I'm having difficulty trying to properly partition my code. I always end up ...
3
votes
4answers
360 views

As a tooling/automation developer, can I be making better use of OOP?

My time as a developer (~8 yrs) has been spent creating tooling/automation of one sort or another. The tools I develop usually interface with one or more API's. These API's could be win32, WMI, ...
2
votes
3answers
1k views

Implementing Command Pattern in Web Application

I'm looking to implement the command pattern in a web application (asp.net c#)... Since the commands come in text format from the client, what is the best way to translate the string to a command ...
2
votes
1answer
786 views

Basic design of a data access layer using the DataMapper pattern

I'm trying to understand the DataMapper pattern by implementing it myself for one of my domain objects. So far, I have: class MyDomainObject <attributes> <business logic methods> ...
4
votes
2answers
918 views

Which is a better design pattern for a database wrapper: Save as you go or Save when you're done?

I know this is probably a bad way to ask this question. I was unable to find another question that addressed this. The full question is this: We're producing a wrapper for a database and have two ...
9
votes
4answers
1k views

Should injecting dependencies be done in the ctor or per method?

Consider: public class CtorInjectionExample { public CtorInjectionExample(ISomeRepository SomeRepositoryIn, IOtherRepository OtherRepositoryIn) { this._someRepository = ...
6
votes
4answers
855 views

Command-Query-Separation and multithreading safe interfaces

I like the command query separation pattern (from OOSC / Eiffel - basically you either return a value or you change the state of the class - but not both). This makes reasoning about the class easier ...