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

learn more… | top users | synonyms (1)

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 ...
16
votes
4answers
5k 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
639 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 ...
9
votes
3answers
2k views

Understanding Loose / Tight Coupling in the “Real World”

I wont say what "community" because I want a non-biased explanation, but let's say you're building a reusable module and that module requires 3+ dependent modules and removing 1 of them causes a ...
24
votes
5answers
13k views

What's the best way to build a factory using NInject?

I am pretty comfortable with dependency injection using NInject in MVC3. While working in an MVC3 application, I developed a custom Controller Creation Factory using NInject, so any controller that is ...
2
votes
2answers
369 views

Factory design pattern - getting the types from a table

I've implemented a generic factory as described here I need to register elements to the factory hard-code like this: Factory.Register(1, typeof(MyClass)); this factory will have to be correlated ...
2
votes
2answers
663 views

Who's the author/creator of the Repository Pattern?

I´m pretty sure it´s not the gang of four. I have a feeling this is a newer pattern. Where was it first published/mentioned?
10
votes
4answers
742 views

Literate programming, good/bad design methodology

I have recently found the concept of literate programming. And I found it rather intriguing. Yet I have not been encountered with claims that it is a bad way to structure a program. It seems not ...
4
votes
5answers
1k views

Java - using single class or multiple class for each type?

I currently have a Java class called "node" which has a number of fields. Which fields in the class are used depends on a field called "type". There are close to 10 (this can grow) different types of ...
6
votes
1answer
2k views

Advanced JavaScript design patterns [closed]

I'm looking for books, online resources or suggestions about how to structure big projects or build a framework in JavaScript. I'm not looking for books explaining how inheritance or closures work. ...
1
vote
4answers
623 views

How should I deal with nested compositions?

I came across the following question on a website for interviews: Here are 3 products: table, chair and bench. Product can be of material: wood, metal, and plastic. Design class structures for ...
3
votes
2answers
2k views

How to get OOAD and Design Patterns hands-on experience in C#?

I have read the concepts and practiced some examples on OOAD and Design Patterns. But when I was asked to implement the singleton pattern in a little bit different manner, I was unable to do it and ...
4
votes
3answers
716 views

Can you point me to a nontrivial strategy pattern implementation? [closed]

We are faced implementing a registration workflow with many branches. There are three main flows which in some conditions lead to one another. Each flow has at least four different steps; some steps ...
4
votes
3answers
2k views

How to use a MessageBox using the MVVM pattern?

I am implementing a UI application using the MVVM design-pattern. The thing is, sometimes when you detect that something is wrong with data that was inputted by the user, you'd like to notify him ...
7
votes
5answers
297 views

How to introduce a new pattern into an existing codebase?

In my quest to better my development skills I learn new design patterns. In sample projects or personal projects it's really easy to adapt new patterns into my code. However at work I have a large ...
2
votes
3answers
562 views

design pattern for describing a variable subpart of a config file

Suppose I have an XML config file like the following: <myapp> <settings/> <output> <mailto>mail service configuration parameters</mailto> ...
5
votes
2answers
972 views

Designing web-based plugin systems correctly so they don't waste as many resources?

Many CMS systems which rely on third parties for much of their code often build "plugin" or "hooks" systems to make it easy for developers to modify the codebase's actions without editing the core ...
8
votes
5answers
469 views

Reengineering the project from scratch [duplicate]

Possible Duplicate: When do you rebuild an application or keep on fixing the existing one I am currently working on a project that has been in development for the last few years used ...
22
votes
6answers
3k views

Is there a design pattern that would apply to discount models?

Are there any known design patterns for implementing discount models? By discount models, I mean the following: If a customer buys Product X, Product Y and Product Z he gets a discount of 10% or ...
3
votes
2answers
671 views

Is there a design pattern for modelling job execution flow?

In my application I have a set of jobs to execute: Each job goes through the states "not started", "started", "completed", "failed" etc. Each job has a set of pre-conditions and post-conditions. ...
6
votes
3answers
303 views

How to correctly chain overloaded functions?

Assuming you have functions which take an increasing number of optional parameters (and a pseudo language which does not allow optional parameters and an arbitrary number of parameters) like this: ...
3
votes
3answers
792 views

Data Serialization to process business logic

Going by the general principle of data abstraction, I normally abstract data in a serialized format(JSON) and pass it as a parameter to the Business Logic(BL) modules such that the BL module always ...
4
votes
1answer
379 views

Splitting Logic, Data, Layout and “Hacks”

Sure, we all heard of programming patterns such as MVVM, MVC and such. But that isn't really what I'm looking into as Layout, Data and Logic is already pretty much split up (XML-Layout markup, ...
12
votes
11answers
1k views

What are some techniques to teach programmers design patterns? [closed]

I'm in a position where my developers are asking to learn design patterns. So far we have done a book club reading Heads First Design Patterns. During this we worked through examples and talked about ...
5
votes
2answers
2k views

Should I put calculation logic in an Entity or in the Business Layer?

Recently I was faced a question about whether a simple calculation should be put in the Entity layer, or should the Entity be pure for just storing the raw data and leave the calculation logics in the ...
24
votes
7answers
12k views

Self-Executing Anonymous Function vs Prototype

In Javascript there are a few clearly prominent techniques for create and manage classes/namespaces in javascript. I am curious what situations warrant using one technique vs. the other. I want to ...
2
votes
1answer
441 views

Most frequently used design patterns in refactoring (my example) [closed]

I've been doing quite a lot of refactoring of C++ and C# code recently, and found that 90% of the patterns I use are: Template method Factory Singleton Are these generally the most commonly used ...
0
votes
1answer
505 views

Wrapping a 3rd party API - Gateway Pattern connections

Given a 3rd party API with a very cumbersome object with many different responsibilities-- we decide to wrap using small, manageable, single-responsibility objects. This is the gateway pattern (I ...
3
votes
2answers
672 views

Adding more responsibilities to Activities in a flexible way

I am considering how I can add tasks to Android Activities in a flexible way. I can only use implementation inheritance for one thing in Java and I would like to use it, if I use it at all, for ...
3
votes
1answer
546 views

What's a good notation for showing MVC interactions?

I'm developing various websites and functionality to cater to various different use-cases up in Django. Is there a good notation for showing what behaviour is at each stage, e.g., swimlanes. I use ...
98
votes
10answers
57k views

What is MVC, really? [closed]

As a serious programmer, how do you answer the question What is MVC? In my mind, MVC is sort of a nebulous topic — and because of that, if your audience is a learner, then you're free to ...
21
votes
11answers
998 views

Choose code design effort or laziness in Bank world

I've worked for two years in a great Investment Bank. I made some technical projects with the desire of creating code the most optimized, respecting the adapted good design patterns, SOLID principle, ...
5
votes
5answers
504 views

I need some counter-points to counter the argument of why NOT to use M-V-P

I whipped up a demo on Friday before the holiday weekend of using the Model-View-Presenter pattern (the "Passive View" version, I believe) that I want to show to my co-workers this week as an example ...
4
votes
5answers
1k views

Are design patterns independent of programming languages?

I have been recently working on Objective C and came across use of Delegate pattern. I had seen most of the common patterns theoretically in Java, thanks to the Head First book. But at times looking ...
1
vote
3answers
267 views

Is the “exposer (hack) pattern” a newly identified pattern or does it have another name?

EDITED FOR CLARIFICATION In the past, I have seen a whole manner of resolutions and fudges. Some really stand out. One particular resolution that I initially thought of as a fudge possibly deserves a ...
7
votes
2answers
347 views

where can I find an overview of known “multithreading systems architectures” design patterns? [closed]

Using C#, I have been doing multithreaded development for about 5 years, and consider myself quite proficient (I wrote my own lock-free queue and task parallel framework before Microsoft made TPF). ...
2
votes
1answer
1k views

How do you do to create the ViewModel part of your MVVM designs?

Sometimes, when I plan to create a program using this architectural pattern, I've got a lot of difficulties when I'm in the View Model phase. I'm using WAF Framework to develop this architectural ...
2
votes
2answers
135 views

Pattern for user interaction and confirmation

Suppose a FileWriter class that needs validation that it will not erase a file already present, if one is found. It would have two functions: public bool FileExists(string filePath) //... public bool ...
0
votes
3answers
110 views

Should I decompress zips before I archive?

I am writing a small personal archiving tool. I frequently work with a lot of client databases for short periods, what my tool will do is in overnight batch jobs it will detach the database and zip up ...
7
votes
3answers
805 views

Data replication patterns / algorithms

I have a series of systems that need to be distributed to a variable number of nodes (at least two, but more likely 8 - 10). For performance reasons, any one piece of state needs to be maintained in ...
17
votes
9answers
4k views

How important are design patterns in programming?

I'm a university student and I've just started learning about design patterns and im struggling to understand the purpose of them. I have tried researching them but all the resources I have found seem ...
3
votes
1answer
211 views

Exposing warnings\errors from data objects (that are also list returned)

I'm exposing Data objects via service oriented assembly (which on future usages might become a WCF service). The data object is tree designed, as well as formed from allot of properties.Moreover, ...
1
vote
1answer
229 views

Pattern for a web application

I'm developing a web application for a university project. My professor wants we to use a multi-tier architecture (Client, Web, Business and Data tiers) with EJB. For the Web and Business I have ...
5
votes
1answer
3k views

Observer pattern; knowing *what* changed?

I've created two abstract classes Subject and Observer that define a classic Observer pattern interface. I derive from them to implement the Observer pattern. An observer might look like this: void ...
12
votes
2answers
2k views

Differences between Design by Contract and Defensive Programming

Could Designing by Contract (DbC) be a way to program defensively? Is one way of programming better in some cases than the other?
0
votes
4answers
351 views

To which layer does this code belong?

When I say "Revisional Data Model", I mean a data model where information is never lost: Deletes never destroy any rows, and updates always cause an insert somewhere else to preserve a row's previous ...
2
votes
1answer
105 views

Is it OK to pass the concrete client to a method on the concrete strategy?

When using the strategy pattern, is it good practice to pass this to a method on this.strategy? I have a strategy interface with one call, TakeAction. The idea is that TakeAction decides which of ...
5
votes
3answers
749 views

What are the disadvantages of unobtrusive script patterns in web applications?

First of all, is there a name for this as a bona-fide design pattern? Currently I've just been referring to it as "unobtrusive javascript". Here is a brief example of what I am talking about: 1.) Use ...
23
votes
11answers
13k views

Is there a canonical book on design patterns? [closed]

I am interested in learning design patterns and would like to know what are considered top tier books in learning this subject. Is there a book out there that's the de-facto standard for describing ...
4
votes
3answers
2k views

Is CRTP used much? and why it is/isn't? [closed]

I'm thinking about curiously recurring template pattern. I find it quite useful, and it's pretty well adjustable for many tasks. But I have to admit, I don't see much of CRTP code in the wild. Is it ...