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
1k views

Implementing Context-based Undo/Redo Functionality

I'm currently implementing an undo/redo mechanism using the Command Pattern. Everything works so far. My problem now is to implement the undo/redo functionality in a way that it is bound to a given ...
5
votes
2answers
398 views

Which design pattern is illustrated by inheriting IStructuralComparable interface?

We know that some design patterns are found so useful that they become features of the language itself. For instance, the interface IEnumerator which is implemented by Array object. This helps in ...
11
votes
2answers
680 views

.Net developer trying to learn ruby on rails

I am a .NET developer and I just had the chance to play with Ruby on Rails this weekend. In .NET we separate layers of the application by creating separate class library projects. From the design ...
11
votes
4answers
2k views

Command pattern design

I have this old implementation of the Command pattern. It is kind of passing a Context through all the DIOperation implementation, but I realized later on, in the process of learning and learning (...
5
votes
2answers
209 views

Designing a function with many optional components

I'm trying to figure out a good practice for designing a function with (many) optional components. For a specific example, say I am interested in designing a feature extractor function that takes as ...
4
votes
1answer
2k views

Are Request/Response Parameter Wrappers Good Practice?

I've seen several different ways to design WCF services, and it seems some developers prefer parameter wrappers while others favor 'naked' parameters. To explain what I mean, consider the following ...
2
votes
2answers
401 views

In an event-driven environment, how should a “cancel” function abort all further events?

In my iOS app, things are mostly driven by events. The user presses a button The app listens for an external device to be connected to the iOS device Once the device is detected (is connected), an ...
3
votes
2answers
104 views

Is every page a new view?

I just started building an iOS app and wanted to get some feedback regarding views. I've got specs for Activity Page Activity Recording Activity Create Activity Save Each of the specs show a ...
2
votes
1answer
420 views

What kind of abstraction/SoC should I use here?

I am starting a new project, and I want to follow the separation of concerns pattern, and I have been reading on the topic, and now I am in doubt of how I should go about this. Here is how I ...
3
votes
2answers
411 views

Preventing Liskov Substitution violation

I am reimplementing some component and noticed that the original version has a Liskov Substitution violation. It's not all that critical, though I'd like to get rid of it in the new implementation . ...
3
votes
2answers
430 views

Is there a name for this design pattern? [closed]

I don't like singletons, but I have to compromise now (but only as temporary measure). However I don't want to go completely singleton. I'd rather want to use this pattern: interface ...
1
vote
1answer
432 views

How to selectively update properties of an object on the server

I have a GWT website that displays some data onto the client in a tabular form. Some of the fields are editable, when any change is made the save button becomes active. There are multiple properties ...
21
votes
5answers
1k views

How to avoid giant glue methods?

In my current job, I've been tasked with cleaning up old code a few times. Often the code is a labyrinth and the data behind it is even more tangled. I find myself combing out things into nice, neat,...
4
votes
3answers
232 views

Using the mouse as a multi-tool creates heavy conditional logic for executing commands, how do I change this?

The feature is in many different types of editing programs where a mouse click may have completely different commands to execute (using the Command Pattern) Currently I have an overarching ...
6
votes
1answer
195 views

Ledger or log design for a point-based system?

Right now creating a new service that will integrate into our company's existing platform. The service will be responsible for tracking "points" that a user can generate over time through certain ...
1
vote
1answer
126 views

What is a general solution to allow the client to choose the concrete instance of a method output?

What is the general solutions to allow the client to choose the concrete instance of a method output? For example, in the Lucene API the search method receives and modifies the collector input ...
4
votes
1answer
824 views

Designing status management for a file processing module

The background One of the functionality of a product that I am currently working on is to process a set of compressed files ( containing XML files ) that will be made available at a fixed location ...
2
votes
1answer
122 views

Terminology for class

I am integrating with a Financial Management System (FMS). I have a class that prepares a set of objects (each of these objects is called a TransactionEntity). These are then passed to the FMS. I give ...
9
votes
2answers
1k views

How would I combine 'Command' and 'Composite' to simulate a time delay?

As a learning exercise (I am not in school - just an old guy trying to learn something new), I am trying to write a logic gate simulation that incorporates propagation delay. The user should also be ...
2
votes
7answers
646 views

Are design principles important, and if so, why don't more people use them? [closed]

I am a developer who works for an in-house information communications technology (ICT) department. I am usually quite critical when looking over code that I have not written as I find time and time ...
8
votes
4answers
9k views

How to use Dependency Injection in conjunction with the Factory pattern

Consider a module that is responsible for parsing files of any given type. I am thinking of using the strategy pattern to tackle this problem as I have already explained over here. Please refer to the ...
3
votes
2answers
483 views

Template method within one class without subclasses or inheritance

I have an algorithm with mostly invariant parts that needs to be reused within one class so as to stay DRY. Code duplication with repeating method structure public void save(String key, int value) {...
20
votes
5answers
2k views

How do I convince my boss (and other devs) to use/consider Unobtrusive JavaScript

I'm pretty new in our develepors team. I need some strong arguments and/or "pitfall" examples, so my boss will finally understand the advantages of Unobtrusive JavaScript, so that he, and the rest of ...
0
votes
3answers
1k views

Changing behaviour of abstract class without modifying subclasses

I am facing a problem with changing behaviour of a library (thus cannot or don't want to change its internals because of future updates, etc.). In this library there is an abstract class which shares ...
0
votes
5answers
257 views

Naming for a class that consumes an iterator pattern [closed]

The iterator pattern is very clearly defined. What would you call the consumer of an iterator?
1
vote
3answers
879 views

Is this Observer variant an improvement?

In a C++ code base I've been working on, they have a bunch of instances of the observer pattern, but it's a little different from the classical pattern. In the classic, the Observer is a specific ...
18
votes
3answers
3k views

What is the principle of least astonishment?

In programming what is called Principle of Least Astonishment? How is this concept related to designing good APIs? Is this something applicable to only object oriented programming or does it permeate ...
6
votes
2answers
3k views

Context class in Strategy pattern

I'm trying to understand the strategy pattern and asking myself: is the context class must-have or can I leave it out without compromising pattern's purpose ? I was under the impression I needed some ...
3
votes
1answer
129 views

Parallelization: Choice of communication model

Disclaimer: If you're not into parallelization (on clusters), this question is probably not interesting to you and probably not worth a read. TL;DR: I search for a communication model (preferably ...
1
vote
1answer
435 views

What is a practical level of abstraction in a web application? [closed]

(Originally asked on StackOverflow - http://stackoverflow.com/questions/14896121/what-is-a-practical-level-of-abstraction-in-a-web-application) I still consider myself a newcomer to OO programming, ...
2
votes
2answers
223 views

Should I split out synchronization from my class and what's it called?

When thinking about testability and modular code, I recently thought about whether I should split out the synchronization part of a class from the actual behavior part. By example: The app "needs" ...
1
vote
1answer
641 views

Is this an implementation of the promise pattern?

I am writing a library in C++ (making use of many C++11 features) that (as far as I can tell) implements the promise pattern. The library consists of a class that makes asynchronous network requests. ...
4
votes
3answers
1k views

A design pattern for data binding an object (with subclasses) to asp.net user control

I have an abstract class called Address and I am deriving three classes ; HomeAddress, Work Address, NextOfKin address. My idea is to bind this to a usercontrol and based on the type of Address it ...
14
votes
3answers
6k views

How to avoid “managers” in my code

I'm currently re-designing my Entity System, for C++, and I have a lot of Managers. In my design, I have these classes, in order to tie my library together. I've heard a lot of bad things when it ...
6
votes
4answers
574 views

Applying DRY to an inheritance hierarchy

I'm working on refactoring a legacy application where I implemented the State pattern successfully as shown in the following diagram: As you see there is a common behavior between the 3 states, so ...
9
votes
3answers
838 views

Is it reasonable to build applications (not games) using a component-entity-system architecture?

I know that when building applications (native or web) such as those in the Apple AppStore or Google Play app store that it's very common to use a Model-View-Controller architecture. However, is it ...
1
vote
1answer
187 views

Possible Designs for code block editor

I have started a project where I need to design an application that will work as a code-block editor, much like lego mindstorms and this google project. http://code.google.com/p/blockly/ What are the ...
5
votes
2answers
872 views

In MVP, should presenters instantiate and control other presenters?

I've implemented an application using MVP with GWT, which is working out very nicely for views that have a single purpose. Now, it has evolved into views that are achieving multiple purposes in a ...
3
votes
2answers
612 views

Design Pattern for enterprise application

I read few articles about composite pattern and I want to know whether its applicable in following situation, I found that "A Composite Entity object can represent a coarse-grained object and all its ...
4
votes
4answers
768 views

Should we validate a state transition before attempting it in the State Pattern?

When applying the State Pattern illegal transitions should result in an exception being thrown (or at least that's what I understood from the pattern) I know exceptions are for "unexpected behavior" ...
0
votes
2answers
824 views

Design Pattern For Util Classes and General Static Variables

I am developing a Mojo(think it as just a usual class) for my custom Maven Plugin. There is an Abstract Mojo at top. I have some other custom Mojos in example which makes server side includes. I have ...
3
votes
3answers
851 views

Why don't we use a class and its static members to do what a singleton does?

In Java,C++,Objective C, C#, and all other similar OOP languages, Why don't we use a class with static methods and vars instead of going through a singleton syntax having to deal with various ...
6
votes
4answers
1k views

What the right pattern to Use here

scenario: I have an entity called Member. Members fall into multiple types. Some types are below. Supporter Volunteer Sponsor Player I can create class for each type and inherit from the base ...
2
votes
1answer
560 views

Shift Javascript framework - What pattern is this? MVP, MVC or something else [closed]

I have created a very tiny framework to be able to get away from all the clutter while developing. The point of the framework is not to replace any library of choice but simply segregate the code to ...
5
votes
3answers
2k views

Is it a good idea to register views and view models as singletons in an IOC container?

I understand the benefits of injecting dependencies into objects, but have not found much guidance on the types of objects to inject and when to make them singletons. If we take as as example an ...
3
votes
0answers
102 views

Bridge Design Pattern - I still don't get it [duplicate]

Possible Duplicate: Understanding the bridge design pattern I have read lots of material about the bridge design pattern: http://www.codeproject.com/Articles/3151/Illustrated-GOF-Design-...
2
votes
4answers
185 views

Abstracting out a module or using the Module Singleton directly?

I am working on a module which is dependent on other module for some functionality. Now the dependent module provides a lot of functionality and I need only few of them, hence got the idea to create ...
9
votes
4answers
1k views

Design pattern for polymorphic behaviour while allowing library separation

Let's say I have a hierarchy of Item classes: Rectangle, Circle, Triangle. I want to be able to draw them, so my first possibility is add a virtual Draw() method to each: class Item { public: ...
2
votes
2answers
249 views

Changing __class__ in a factory?

I'm parsing a set of XML files of different kinds (these kinds are known in advance). These are my requirements: I want an object to represent each XML document (object-xml mapping) I'd rather ...
10
votes
4answers
3k views

In MVC, can/should basic data retrieval from the Model be done in the View?

Given the concept of 'skinny controllers, fat models' and the general acceptance that Views can directly call on Models when requiring data for output, should one consider handling the 'get and ...