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

learn more… | top users | synonyms (1)

3
votes
3answers
683 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 ...
3
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
245 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
748 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
778 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
939 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
549 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
259 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
274 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
12k 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
337 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
910 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
763 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
841 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 ...
6
votes
4answers
990 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
791 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 ...
3
votes
4answers
208 views

How to “translate” interdependent object states in code?

I have the following problem. My UI interace contains several buttons, labels, and other visual information. I am able to describe every possible workflow scenario that should be be allowed on that ...
4
votes
1answer
849 views

DAO/Webservice Consumption in Web Application

I am currently working on converting a "legacy" web-based (Coldfusion) application from single data source (MSSQL database) to multi-tier OOP. In my current system there is a read/write database with ...
1
vote
1answer
381 views

Request / Reply , how should one initiate the actual sending of the transmission?

I'm working on Language level interfaces to web API's. These libraries are of course built around existing HTTP Request/Reply interfaces. I see myself as having a few options submit method on the ...
1
vote
1answer
200 views

Publish/Subscribe/Request for exchange of big, complex, and confidential data?

I am working on a project where a website needs to exchange complex and confidential (and thus encrypted) data with other systems. The data includes personal information, technical drawings, public ...
11
votes
3answers
6k views

Why would a programmer want to separate implementation from interface?

The bridge design pattern separates implementation from the interface of a program. Why is this advantageous?
1
vote
1answer
405 views

What is the “Find-Fix-Verify” pattern? [closed]

What is the "Find-Fix-Verify" pattern, as related to the process of doing editing/spellchecking/debugging, etc.? Where is this pattern best described? What are some advantages and disadvantages of ...
0
votes
1answer
792 views

Model View Presenter for WebForms and Winforms

I have a windows forms project using the Model View Presenter pattern and would like to build a web forms project on top of the same MVP structure. The windows forms project knows nothing of ASP.Net ...
16
votes
8answers
27k views

Web Developer interview questions [closed]

I read an article today that listed some basic questions about web development: Describe how POST data was submitted to a server by a browser. Explain a number of HTTP status codes (except maybe 404 ...
37
votes
13answers
7k views

Design patterns - do you use them?

Being an IT student, I was recently given some overview about design patterns by one of our teachers. I understood what they are for, but some aspects still keep bugging me. Are they really used by ...
33
votes
11answers
5k views

Is the 'C' in MVC really necessary?

I understand the role of the model and view in the Model-View-Controller pattern, but I have a hard time understanding why a controller is necessary. Let's assume we're creating a chess program using ...
3
votes
3answers
306 views

Optimal communication pattern to update subscribers

What is the optimal way to update the subscriber's local model on changes C on a central model M? ( M + C -> M_c) The update can be done by the following methods: Publish the updated model M_c to ...
2
votes
1answer
333 views

Are there design patterns or generalised approaches for particle simulations?

I'm working on a project (for college) in C++. The goal is to write a program that can more or less simulate a beam of particles flying trough the LHC synchrotron. Not wanting to rush into things, ...
4
votes
3answers
141 views

Using “prevent execution of method” flags

First of all I want to point out my concern with some pseudocode (I think you'll understand better) Assume you have a global debug flag, or class variable named "debug", class a : var debug = ...
8
votes
6answers
4k views

What is the simplest human readable configuration file format? [closed]

Current configuration file is as follows: mainwindow.title = 'test' mainwindow.position.x = 100 mainwindow.position.y = 200 mainwindow.button.label = 'apply' mainwindow.button.size.x = 100 ...
5
votes
10answers
2k views

Teacher demands excessive/unjustified use of Design Patterns [closed]

I study computer science and I have a class called "Programming Techniques". Its purpose is to teach (us) good object oriented design principles. During the semester we have homeworks, programs that ...
33
votes
7answers
8k views

Is dependency injection essential for unit testing?

Is using dependency injection (DI) essential for unit testing? I can't think of another alternative for isolating code so it can be tested. Also, all the examples I have ever seen use this pattern. ...
1
vote
2answers
363 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
752 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
255 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
431 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
716 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
120 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
256 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 ...
19
votes
2answers
21k 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
739 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
783 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 ...