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

learn more… | top users | synonyms (1)

9
votes
6answers
1k views

What are the practical ways to implement the SRP?

Simply what are the practical techniques people use to check if a class violates the single responsibility principle? I know that a class should have only one reason to change, but that sentence is ...
4
votes
2answers
1k views

Design Patterns (java) — Strategy with fields. Ever acceptable?

Both here on stack overflow and on Java Effective it is suggested that strategy design patterns should be stateless. In fact in the book it is also suggested to make each strategy object a singleton. ...
8
votes
4answers
3k views

JavaScript application design patterns [duplicate]

I need to write a PhoneGap application with JavaScript and I'm thinking of the code design patterns. I've read some books of JavaScript design patterns but can't really see the advantages/...
1
vote
2answers
298 views

What's the name of this pattern involving multiple inputs and what to do based on an input?

If I've got code similar to this (although perhaps not as constrained as warning levels): switch(item.StatusCode) { case StatusCode.SUCCESS: CallSuccess(item); break; case ...
13
votes
8answers
23k views

Is there any design pattern except MVC for web?

I want to know are there any design patterns for web besides MVC? I know there are design patterns as: Registry, Observer, Factory, ActiveRecord ,... and MVC a set of other design patterns and folder ...
2
votes
1answer
2k views

UML representation of specific factory pattern

I have to create an UML class diagram from the following example code (Perl). I don't think that the standard factory pattern match in my case or I don't understand it correctly. I don't have ...
78
votes
8answers
12k views

Are there any design patterns that are unnecessary in dynamic languages like Python?

I've started reading the design pattern book by the GoF. Some patterns seem very similar with only minor conceptual differences. Do you think out of the many patterns some are unnecessary in a ...
3
votes
2answers
311 views

When is using DI and optionally a IoC framework a step too far?

Consider a logging system - used absolutely everywhere in your codebase. (note - logging is just an example, don't take it too literally and point me at your favourite logging system). public ...
6
votes
5answers
984 views

Open source software with good code documentation to improve design skill [closed]

As I'm trying to get better at designing good software I'm wondering if there are out there good (as in well written) open source software with lot of code documentation that aims to explain details ...
12
votes
4answers
1k views

How to determine whether Design Pattern is implemented correctly?

I am successfully able to scale all my old applications which were not using documented Design Patterns. Whatever pattern it is I don't know. To a large extent, I only felt a need to use simple OOP ...
3
votes
2answers
237 views

Are Design Patterns SuperSet of OOP or SubSet?

Initially I started learning OOP and later started grasping concepts of Design Patterns. I wonder whether it is the Design Pattern which is the SuperSet of OOP or it is the OOP itself.
10
votes
8answers
1k views

Why aren't design patterns added to the languages constructs?

Recently I was talking with a colleague who mentioned that his company was working on adding the MVC design pattern as a PHP extension. He explained that they wrote C code for adding Controllers, ...
3
votes
4answers
848 views

When, Where, and How to Unit Test [duplicate]

I'm very familiar with xUnit frameworks and I try to implement unit tests on every project I start. Somewhere along the way, I realize that I'm writing the same tests over and over again, and then I ...
4
votes
2answers
1k views

God Files versus Ravioli Code

Recently I asked a question about whether or not I should refactor my code. the responses I received were most definitely in the camp of going through with the refactoring due to the presence of a God ...
0
votes
4answers
348 views

Is it better to find issues myself or let the computer figure it out?

I'm about to start the process of migrating a program from one component to another. Most of the core functionality will be the same but I'll need to change database calls, etc. I'm sure there will ...
0
votes
1answer
791 views

What pattern to use for this 'constructor'? Decorator vs Factory?

I'm developing a program to generate LARP characters in java and I've hit a snag. Initially I had planned to use a decorator to iterate through the potential 'roles' (effectively classes), and then ...
4
votes
2answers
492 views

Designing a library that is easy to use: composition or inheritance

I have designed a small library for work that consists of a few exposed classes. These can basically be thought of as a server class and client class. But now that I am writing all the test cases and ...
2
votes
2answers
1k views

Design pattern for access to tree-like database in Java?

I'm developing a Roleplaying character viewer/manager programme for a locap LARP system. The Characters have access to skills that are layed out in a tree-like structure. There are a lot of skills, ...
8
votes
2answers
2k views

Are Persistence-Ignorant objects able to implement lazy loading?

Persistence Ignorance is an application of single responsibility principle, which in practice means that Domain Objects (DO) shouldn't contain code related to persistence, instead they should only ...
5
votes
1answer
3k views

How do game programmers design their classes to reuse in AI, network and play and pass mode?

For a two player game where, your opponent could be on the network, CPU itself or near you where you would play turn by turn on the same machine. How do people design classes for re-use ? I am in a ...
0
votes
1answer
142 views

Pending and Approval process

So let's say I have a DB table with 8 columns, one is a unique auto-incrementing used as ID. So I have a page that pulls in the info for each row based on query string ID. I want to give my users ...
2
votes
2answers
232 views

Constructs for wrapping a hardware state machine

I am using a piece of hardware with a well defined C API. The hardware is stateful, with the relevant API calls needing to be in the correct order for the hardware to work properly. The API calls ...
3
votes
2answers
394 views

How do I reuse a state machine in a slightly different way?

Problem I have a big state machine. The design requirements of the project have changed such that I need to re-use this state machine in another place. All the states remain the same in this new ...
9
votes
9answers
2k views

What OO Design to use ( is there a Design Pattern )?

I have two objects that represent a 'Bar/Club' ( a place where you drink/socialise). In one scenario I need the bar name, address, distance, slogon In another scenario I need the bar name, address, ...
3
votes
2answers
2k views

Strategy vs Delegates

Can the Strategy design pattern entirely replace delegates? In Java, for example, there are no delegates. Is it possible to gain all the features of delegates by using Strategy design pattern? Edit:...
3
votes
1answer
338 views

Is the structure used for these web pages a design pattern?

I want to know if the structure for an ASP.NET website I'm working on uses a design pattern for it's web pages. If it is a design pattern, what is it called? The web pages have the following structure:...
12
votes
4answers
3k views

What is the difference between Single Responsibility Principle and Separation of Concerns

a)What is the difference between SRP and SoC? Perhaps that SRP is applied at class level, while SoC can be applied at system, subsystem, module, class or function levels. b) If answer to a) is yes, ...
2
votes
2answers
4k views

What are the best practices to use NHibernate sessions in asp.net (mvc/web api)?

I have the following setup in my project: public class WebApiApplication : System.Web.HttpApplication { public static ISessionFactory SessionFactory { get; private set; } public ...
7
votes
3answers
1k views

When designing a job queue, what should determine the scope of a job?

We've got a job queue system that'll cheerfully process any kind of job given to it. We intend to use it to process jobs that each contain 2 tasks: Job (Pass information from one server to another) ...
3
votes
2answers
2k views

Should this code/logic be included in Business Objects class or a separate class?

I have created a small application which has a three tier architecture and I have business object classes to represent entities such as User, Orders, UserType etc. In these classes I have methods that ...
1
vote
1answer
225 views

How to control messages to the same port from different emitters?

Scene: A company has many factories X, each emits a message to the same receive port in a Biztalk server Y; if all messages are processed without much delay, each will trigger an outgoing message to ...
1
vote
1answer
1k views

Modular Database Structures

I have been examining the code base we use in work and I am worried about the size the packages have grown to. The actual code is modular, procedures have been broken down into small functional (and ...
2
votes
1answer
608 views

A solution for a PHP website without a framework

One of our customers asked us to add some dynamic functionality to an existent website, made of several static HTML pages. We normally work with an MVC framework (mostly CodeIgniter), but in this ...
1
vote
1answer
288 views

The design of a generic data synchronizer, or, an [object] that does [actions] with the aid of [helpers]

I'd like to create a generic data-source "synchronizer," where data-source "types" may include MySQL databases, Google Spreadsheets documents, CSV files, among others. I've been trying to figure out ...
1
vote
1answer
1k views

Design Pattern for Complex Data Modeling

I'm developing a program that has a SQL database as a backing store. As a very broad description, the program itself allows a user to generate records in any number of user-defined tables and make ...
6
votes
5answers
6k views

Which pattern to use with a typical Web Form?

I am writing a simple ASP.NET Web Forms application. I want to improve the code by implementing any design pattern with which abstraction is achieved and increases manageability and understandability. ...
36
votes
12answers
9k views

Is this a decent use-case for goto in C?

I really hesitate to ask this, because I don't want to "solicit debate, arguments, polling, or extended discussion" but I'm new to C and want to gain more insight into common patterns used in the ...
2
votes
2answers
627 views

What is the rationale behind Apache Jena's *everything is an interface if possible* design philosophy?

If you are familiar with the Java RDF and OWL engine Jena, then you have run across their philosophy that everything should be specified as an interface when possible. This means that a Resource, ...
0
votes
1answer
424 views

Building a template engine - starting point

We're building a Django-based project with a template/generator component. This component will be separate from the project as such and can be Django/Python, Node, Java or whatever works. The idea is ...
3
votes
2answers
333 views

Design suggestions needed to create a MathBuilder framework

Let explain what I'm trying to create. I'm creating a framework, the idea is to provide base classes to generate a math problem. Why do I need this framework? Because at first time, I realized when I ...
21
votes
7answers
4k views

How to determine if a class meets the single responsibility principle?

The Single Responsibility Principle is based on the high cohesion principle. The difference between the two is that a highly cohesive classes features a set of responsibilities that are strongly ...
4
votes
4answers
648 views

Entity and pattern validation vs DB constraint

When it comes to performance: What is the better way to validate the user input? If you think about a phone number and you only want numbers in the database, but it could begin with a 0, so you will ...
2
votes
4answers
275 views

Evolution of an Application: how to manage and improve core engine?

The web application I work on has been live for a year now, but it's time for it to evolve and one of the ways in which it is evolving is into a multi-brand application - in this case several ...
1
vote
4answers
2k views

Moving from mock to real objects?

I'm like doing TDD so I started everything mocking objects, creating interface, stubbing, great. The design seems to work, now I'll implement the stuff, a lot of the code used in the stubs are going ...
5
votes
5answers
768 views

When decomposing a large function, how can I avoid the complexity from the extra subfunctions?

Say I have a large function like the following: function do_lots_of_stuff(){ { //subpart 1 ... } ... { //subpart N ... } } a common pattern is to decompose it ...
15
votes
7answers
5k views

Difference between Pattern and Principle

What is the difference between Object Oriented Design Patterns and Principles? Are they different things? As far as I understood both of them try to achieve some common goal (e,g. flexibility). So can ...
5
votes
1answer
3k views

Caching strategies for entities and collections

We currently have an application framework in which we automatically cache both entities and collections of entities at the business layer (using .NET cache). So the method GetWidget(int id) checks ...
4
votes
1answer
194 views

Asynchronous update design/interaction patterns

These days many apps support asynchronous updates. For example, if you're looking at a list of widgets and you delete one of them then rather than wait for the roundtrip to the server, the app can ...
2
votes
2answers
416 views

.Net Application & Database Modularity/Reuse

I'm looking for some guidance on how to architect an app with regards to modularity, separation of concerns and re-usability. I'm working on an application (ASP.Net, C#) that has distinctly generic ...
7
votes
5answers
381 views

Is there a pattern or logical structure I can follow for Event Log Numbers?

What are some ideas or structure I can use when assigning EventID to events that will be saved to the Windows Event Log? Some options I've considered Sequential (0... int.Max) Multiple of 10,...