Questions tagged [design-patterns]

A design pattern is a general reusable solution to a commonly occurring problem in software design. Use this tag for questions when you're having problems with the implementation of design-patterns. Please don't use this tag on questions about text pattern matching. When using this tag on implementation heavy questions - tag the code language the implementation is written in.

In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.

A design pattern is not a finished design that can be transformed directly into code. It is a description or template for solving a problem that can be used in many different situations.

Object-oriented design patterns typically show relationships and interactions between classes or objects without specifying the final application classes or objects involved. Many patterns imply object-orientation or a more generally mutable state, which may not be as applicable in functional programming languages, in which data is immutable or treated.

Design patterns are generally described using the Unified Markup Language ([tag: UML]) - a class diagram shows the relationship between the design pattern components. In addition, UML has a sufficiently extensive and expressive vocabulary that helps describe the details of patterns.

The seminal book that introduced the concept had four authors, often referred to as the "Gang of Four".

Gang of Four design patterns

Concurrency patterns

Other patterns

Useful links

Books

31951 questions
14
votes
3 answers

What is the use of an IoC framework in an MVC application?

I'm trying to understand the use of an IoC framework like StructureMap, but i can't help thinking that these "design patterns" are just nonsense, making code just more complex. Let me start with an example where i think an IoC is somewhat usefull. I…
w00
  • 26,172
  • 30
  • 101
  • 147
14
votes
3 answers

Runtime dependency injection with Spring

My current project is leveraging Spring, and our architect has decided to let Spring manage Services, Repositories and Factory objects, but NOT domain objects. We are closely following domain driven design. The reasoning behind not using spring for…
Jimm
  • 8,165
  • 16
  • 69
  • 118
14
votes
3 answers

Critique my simple MVP Winforms app

I'm trying to wrap my mind around the MVP pattern used in a C#/Winforms app. So I created a simple "notepad" like application to try to work out all the details. My goal is to create something that does the classic windows behaviors of open, save,…
Keith G
  • 4,580
  • 5
  • 38
  • 48
14
votes
2 answers

The Revealing Module Pattern (RMP) disadvantages

I recently got familiar with the Revealing Module Pattern (RMP) and I've read quite a few articles about it. It seems like a very good pattern and I would like to start using it in a big project. In the project I'm using : Jquery, KO, requireJS,…
Tomer
  • 17,787
  • 15
  • 78
  • 137
14
votes
2 answers

Why can't non-partial active patterns be parameterized in F#?

The following F# code works as I expected, printing `Matched as 'A': let (|Char|_|) convf = function | LazyList.Nil -> None | LazyList.Cons (x, _) -> Some (convf x) let test = function | Char System.Char.ToUpper x -> printfn "Matched as…
bcat
  • 8,833
  • 3
  • 35
  • 41
14
votes
2 answers

best practices for "data layer" in android client apps

Here is one design/ best practices question.. I'm new to android development, and basically new to web/mobile solutions. So, my question is - what are best practices when organizing structure of android application that get data from the remote…
14
votes
2 answers

Factory class returning a generic interface

I have few concrete which uses the following type of interface interface IActivity { bool Process(T inputInfo); } Concrete classes are like as follows class ReportActivityManager :IActivity { public bool Process(DataTable…
Anish
  • 872
  • 5
  • 21
  • 42
14
votes
5 answers

Why split the View in MVC into a view class and a template

I'm relatively new to design patterns but I feel that I've got a good understanding of the MVC pattern and the advantages that this separation of code brings. However, both times I've seen the MVC pattern in action (Magento and Joomla!), there is…
Dom
  • 2,980
  • 2
  • 28
  • 41
14
votes
5 answers

Simple Java caching library or design pattern?

I need to frequently access the result of a time-consuming calculation. The result changes infrequently, so I have to recalculate the data from time to time but it is ok to use the outdated result for a while. What would be the easiest way to do…
nn4l
  • 945
  • 1
  • 12
  • 28
14
votes
5 answers

Design pattern for converting one model to another model

Basically, I have a number of objects in my application and I have to convert them to another third party objects before sending the request. On receiving the response I have to convert these objects back to objects supported by my application. What…
Ashay Batwal
  • 5,415
  • 7
  • 25
  • 30
14
votes
3 answers

Replacing methods that use backgroundworker to async / tpl (.NET 4.0)

My questions are many. Since I saw. NET 4.5, I was very impressed. Unfortunately all my projects are .NET 4.0 and I am not thinking about migrating. So I would like to simplify my code. Currently, most of my code that usually take enough time to…
14
votes
5 answers

how to use the javascript module pattern in a real example?

I am trying to understand the JavaScript Module Pattern. I've seen examples of what it should look like, but I don't understand how to use it. For example, a few things are happening here: $('input#share').on("click", function() { …
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
14
votes
3 answers

A tree, where each node could have multiple parents

Here's a theoretical/pedantic question: imagine properties where each one could be owned by multiple others. Furthermore, from one iteration of ownership to the next, two neighboring owners could decide to partly combine ownership. For…
Dale
  • 1,220
  • 2
  • 10
  • 20
14
votes
2 answers

Design Patterns using IQueryable

With the introduction of .NET 3.5 and the IQueryable interface, new patterns will emerge. While I have seen a number of implementations of the Specification pattern, I have not seen many other patterns using this technology. Rob Conery's…
Brad Leach
  • 16,857
  • 17
  • 72
  • 88
14
votes
4 answers

OO design patterns to use for validation

I am in the process of writing some validation code based on these assumptions: Validation code must be in an external class i.e. no data class contains it's own validation The same object can be validated in different ways e.g. validate…
Peter Sankauskas
  • 2,882
  • 4
  • 27
  • 28