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
13
votes
2 answers

How to implement a maintainable and loosly coupled application using DDD and SRP?

The reason for asking this question is that I've been wondering on how to stitch all these different concepts together. There are many examples and discussions on i.e. DDD, Dependency Injection, CQRS, SOA, MVC but not so many examples on how to put…
cfs
  • 1,304
  • 12
  • 30
13
votes
10 answers

Where do you do your validation? model, controller or view

Where do you put user input validation in a web form application? View: JavaScript client side Controller: Server side language (C#...) Model: Database (stored procedures or dependencies) I think there is validation required by each level: Did…
alumb
  • 4,401
  • 8
  • 42
  • 52
13
votes
1 answer

Different between Module Pattern and Singleton Pattern?

I've seen that in some projects, Module Pattern uses instead of Singleton Pattern and vice versa. I want to know exactly, what's the different between Module Pattern and Singleton Pattern?
Afshin Mehrabani
  • 33,262
  • 29
  • 136
  • 201
13
votes
3 answers

C++ design, how to represent different stages of a protocol with objects

This is not so much of a technical question, but rather a c++ design question. Frequently it seems that I have to design programs which have to manage some a protocol which has some sort of connection, parsing stage and abstract view. Typically I…
111111
  • 15,686
  • 6
  • 47
  • 62
13
votes
28 answers

Which programming technique helps you most to avoid or resolve bugs before they come into production

I don't mean external tools. I think of architectural patterns, language constructs, habits. I am mostly interested in C++
RED SOFT ADAIR
  • 12,032
  • 10
  • 54
  • 92
13
votes
1 answer

Is there an eclipse plugin that creates an outline view for the "javascript revealing module pattern"?

I like eclipse, and with some tweaking it can be used for javascript programming. There's syntax completion, linting, formatting, and there's "outlining", albeit only for simple javascript files. What annoys me is that there is no "Outline View" for…
knb
  • 9,138
  • 4
  • 58
  • 85
13
votes
4 answers

Loading Subrecords in the Repository Pattern

Using LINQ TO SQL as the underpinning of a Repository-based solution. My implementation is as follows: IRepository FindAll FindByID Insert Update Delete Then I have extension methods that are used to query the results as…
Keith Adler
  • 20,880
  • 28
  • 119
  • 189
13
votes
14 answers

How to read code without any struggle

I am a new to professional development. I mean I have only 5 months of professional development experience. Before that I have studied it by myself or at university. So I was looking over questions and found here a question about code quality. And I…
faya
  • 5,535
  • 11
  • 37
  • 49
13
votes
3 answers

Keeping code in a client-server game organized

Background: I help develop a multiplayer game, written mostly in C++, that uses a standard client-server architecture. The server can be compiled by itself, and the client is compiled with the server so you can host games. Problem The game…
faffy
  • 351
  • 3
  • 14
13
votes
2 answers

PHP Data Access Object

I'm trying to figure out if I'm using the DAO pattern correctly and, more specifically, how abstract db persistence should be by the time it gets to my mapper classes. I'm using PDO as the data-access abstraction object, but sometimes I wonder if…
jerry
  • 2,743
  • 9
  • 41
  • 61
13
votes
5 answers

"using" construct and exception handling

The "using" construct looks incredibly handy for situations that require both beginning and separated end parts. Quick example to illustrate: using (new Tag("body")) { Trace.WriteLine("hello!"); } // ... class Tag : IDisposable { String…
Trident D'Gao
  • 18,973
  • 19
  • 95
  • 159
13
votes
6 answers

Javascript immediately invoked function patterns

What do you call these patterns? What is the difference between them? When would you use each? Are there any other similar patterns? (function() { console.log(this); // window })(); (function x() { console.log(this); //…
alnafie
  • 10,558
  • 7
  • 28
  • 45
13
votes
7 answers

Design patterns used in the .NET framework?

One way to increase your understanding of design patterns is to discover how patterns are used in the .NET framework. Have you found any examples of design patterns in the .NET framework? In your answer please give a short description of the…
BengtBe
  • 4,465
  • 1
  • 26
  • 19
12
votes
3 answers

Find First Specific Byte in a Byte[] Array c#

I have a byte array and wish to find the first occurance (if any) of a specific byte. Can you guys help me with a nice, elegant and efficient way to do it? /// Summary /// Finds the first occurance of a specific byte in a byte array. /// If not…
divinci
  • 22,329
  • 11
  • 45
  • 56
12
votes
3 answers

Expose private variables in Revealing Module Pattern

I'm trying to implement the Revealing Module Pattern but I'm unable to expose a modified private property. var myRevealingModule = (function(){ var name = 'Diogo'; function setName () { name = name + ' Cardoso'; } return { …
Diogo Cardoso
  • 21,637
  • 26
  • 100
  • 138
1 2 3
99
100