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
474 views

Why is inheritance only defined at compile-time?

I found this statement from the gang of four's "Design Patterns" particularly odd; for some context, the authors are comparing inheritance versus composition as reuse mechanisms [p. 19]: "...you ...
3
votes
1answer
309 views

State pattern vs Inheritance

In the following image for the State Pattern from Applying Domain-Driven Design and Patterns: With Examples in C# and .NET I'm trying to persist the SalesOrder entity into the database. Normally I ...
16
votes
8answers
21k views

Web Developer interview questions

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 ...
0
votes
1answer
223 views

Anemic domain models - what sort of methods a domain object might need?

This question might seem strange, but it's something I've faced sometimes. I've been trying to adopt DDD, however I'm always facing the problem of anemic domain models. The problem is that when I ...
1
vote
3answers
222 views

Are design patterns essential for good code? [duplicate]

Are design patterns (e.g. factory pattern, observer, etc...) required to be known to write good code? I often have no idea of what people mean when they talk about inserting pattern name here pattern ...
0
votes
1answer
187 views

Need an OOP pattern or strategy for “pluggable” property

I'm using OOP and MVVM in a WPF c# application. The goal is for the resulting object (data-bound to user interface) to accurately represent a product. One specific area of the product is highly ...
1
vote
1answer
174 views

Notifying multiple listeners

I am building an Android guitar application and I need a way for GuitarString objects to notify multiple listeners that it has just been played. This includes the current Activity and all instances of ...
7
votes
3answers
4k views

How to make an ASP.NET MVC site modular

I'm in the planning stage for an employee intranet system to be built with ASP.NET MVC 4. We'd like the site to consist of separate "modules", each of which provides a different feature: messaging, ...
1
vote
1answer
250 views

Creating a System Sequence Diagram from an [extended] use case

As I have been taught - one controller = one use case. But I have: OutsiderController SupplierController (which extends OutsiderController) SubContractorController (which also extentds ...
1
vote
2answers
242 views

What design pattern (in python) to use for properly seperate runtime infos with core code?

I am not sure if this is a clear question. I work on a python project that is based on terminal(console), for which I am planning to implement a GUI. I am not major in CS so I really have no idea ...
0
votes
1answer
133 views

detect if a combination of string objects from an array matches against any commands

Please be patient and read my current scenario. My question is below. My application takes in speech input and is successfully able to group words that match together to form either one word or a ...
0
votes
2answers
111 views

How does one design his various architecture/business models?

I'm currently learning about various application design approaches and there's one thing I can't really get my head around. Let's say I have a physical device in my network, an IP surveillance ...
15
votes
4answers
9k views

How to avoid big and clumsy UITableViewController on iOS?

I have a problem when implementing the MVC-pattern on iOS. I have searched the Internet but seems not to find any nice solution to this problem. Many UITableViewController implementations seems to ...
-4
votes
1answer
2k views

Singleton: Is Singleton an Anti-Pattern [duplicate]

Was reading an interesting blog post on Singleton design pattern which is so widely used. If it's stupid or as in some quora posts, its an anti-pattern why is it so widely used even in frameworks. ...
1
vote
1answer
137 views

Optimizing mindmaps by finding the least amount of redundancy

When using mindmaps, you order them based on how you think it fits best. So for instance (tab means subtree) requirements dinner food forks spoons breakfast food forks this ...
1
vote
2answers
183 views

Modeling an extensible Domain Driven Design project

Say that we are developing an application with modules (Sales, Accounting, Purchasing, etc). An example case here is : Sales module is the basic / primary module available, and Accounting module is ...
1
vote
3answers
124 views

How to conceptually consider and implement user interface rules for numerous controls and data inputs?

I have a user interface with numerous controls and data inputs on it. Buttons, text fields, and checkboxes, etc. Imagine the following "rules" exist for a sample UI with 2 of those controls: B2 ...
3
votes
2answers
165 views

What are the advantages of dynamically binding a method to class instance?

I came across Instagram's API client written in Python. In their class InstagramAPI, they bind the methods to a function in bind.py. When called, the function returns an instance of the class ...
4
votes
1answer
601 views

Design patterns for multi-threaded messaging server

I'm designing an instant messaging server as a personal exercise to improve my understanding and application of multi-threading and design patterns in Java. I'm still designing, there's no code yet. ...
0
votes
2answers
672 views

Designing application flow

I am creating a web application in java where I need to mock the following flow. When user trigger a certain process (add product to cart), I need to pass through following steps Need to see in ...
1
vote
2answers
813 views

Why separate class CommandHandler with Handle() instead of handling method in Command itself

I have a part of CQRS pattern implemented using S#arp Architecture like this: public class MyCommand { public CustomerId { get; set; } // some other fields } public class ...
2
votes
3answers
431 views

Is the Observer pattern adequate for this kind of scenario?

I'm creating a simple game development framework with Ruby. There is a node system. A node is a game entity, and it has position. It can have children nodes (and one parent node). Children are always ...
14
votes
4answers
535 views

Is it possible to loosely couple an application to its framework?

Let's say I'm developing a web application. My first choice is to use PHP with Fat-Free Framework (F3) and MVC pattern. Next year, I might decide I want to switch to Zend Framework, or maybe even ...
4
votes
2answers
724 views

Patterns for a tree of persistent data with multiple storage options?

I have a real-world problem which I'll try to abstract into an illustrative example. So imagine I have data objects in a tree, where parent objects can access children, and children can access ...
3
votes
2answers
228 views

Help with inheritance hierarchy design

I'm having trouble designing an inheritance hierarchy. In the figure: Base class: This uses the Template Method. Contains core logic/algorithm that calls virtual/abstract methods Derived ...
47
votes
9answers
4k views

“Everything is a Map”, am I doing this right?

I watched Stuart Sierra's talk "Thinking In Data" and took one of the ideas from it as a design principle in this game I'm making. The difference is he's working in Clojure and I'm working in ...
2
votes
1answer
183 views

Recommended architecture for an interactive table widget with multiple behaviors in Javascript / jQuery

Use case: For an administration UI, I want an interactive table widget with a number of behaviors: Collapse / expand (yes, this means the rows are a hierarchy) Update of data in a child cell based ...
5
votes
2answers
300 views

Constructor Injection, Single Responsibility and List initialisation

Given the class: public class Foo : IFoo { private IBarRepository repository public Foo(IBarRepository repository) { this.repository = repository } public IList<IBar> Bars { ...
5
votes
5answers
4k views

What are the advantages of the delegate pattern over the observer pattern?

In the delegate pattern, only one object can directly listen to another object's events. In the observer pattern, any number of objects can listen to a particular object's events. When designing a ...
3
votes
1answer
86 views

Development console commands registration

I have a DevelopmentConsole class. I am making functionality to register console commands for the subsystems. I don't want the console to know about them but also I don't want them to contain a debug ...
5
votes
2answers
397 views

Game server code design

I'm designing a multiplayer game server where the players are in rooms. Right now I have classes to take care of the client, networking, etc. I'm struggling however to find a design for this Room ...
1
vote
1answer
215 views

Decorator Pattern in Head First Design Patterns

I'm trying to teach myself some design patterns using a book that I was recommended, Head First Design Patterns. I came to the chapter on the Decorator Pattern, and although I understand the purpose ...
4
votes
5answers
218 views

Loose coupling and shuffling dependencies

I have a bunch of classes that look something like this: public class MyGame() { private Graphics graphics; private Player player; public MyGame() { graphics = new ...
2
votes
2answers
67 views

Ordering menu items fed from multiple modules.

I have a main application that can load modules (or plugins). Each modules can define one or more links (or items) that will be displayed in a side menu defined in the main application. Right now, my ...
6
votes
2answers
536 views

Help to understand the abstract factory pattern

I'm learning the 23 design patterns of the GoF. I think I've found a way to understand and simplify how the Abstract Factory works but I would like to know if this is a correct assumption or if I am ...
10
votes
4answers
1k views

When to use repository pattern

I have read recently that it is not good practice to use the repository pattern in conjunction with an ORM. From my understanding this is because the abstraction they provide over the SQL database is ...
1
vote
2answers
274 views

If every instance of a type is to be random, how should the Random generator object be stored?

It seems to me that this is often encountered in practice and I was wondering if there is a design pattern for the following: Suppose I have a class that represents a card: public class Hand { ...
1
vote
1answer
72 views

Should I use the new method/action to retrieve records? (Rails)

I have an admin controller that is just used for its index action which renders a view with the most recent updates to certain resources: class AdminController < ApplicationController ...
21
votes
6answers
3k views

LSP vs OCP / Liskov Substitution VS Open Close

I am trying to understand the SOLID principles of OOP and I've come to the conclusion that LSP and OCP have some similarities (if not to say more). the open/closed principle states "software ...
1
vote
0answers
258 views

Which interface allows you to use a design pattern that is characteristically changed with the instantiation of objects?

I am doing a research on this and can't find my answer to this question: Which interface allows you to use a design pattern that is characteristically changed with the instantiation of objects? ...
5
votes
2answers
857 views

Open Close Principle (OCP) vs Dependency Inversion Principle (DIP)

I was trying to understand the difference between Open Closed Principle (OCP) and Dependency Inversion Princible (DIP). Based on research I've made on the internet so far, I came to the conclusion ...
5
votes
3answers
278 views

Interface at the class or function level?

I have been falling into a pattern lately where I have been defining routines that rely on an interface defined by a function that is specified as a parameter to the routine. (The language is C#, but ...
2
votes
3answers
490 views

How does a chess engine decide what move to make?

I'm writing a simple chess engine in LISP. I actually know how the engine decide the move, it evaluates and reads some opening books. But that's not what i mean. This is my design. 57 58 59 60 61 62 ...
4
votes
4answers
578 views

.NET Programming and POCO classes

I was having a think tonight while pondering over some application I need to change and it got me thinking. Entity Framework Entities are POCO (Plain old CLR Objects) and models used in ASP.NET MVC ...
11
votes
3answers
2k views

How to avoid “managers” in my code

I'm currently re-designing my Entity System, for C++, and I have a lot of Managers. In my design, I have these classes, in order to tie my library together. I've heard a lot of bad things when it ...
9
votes
4answers
608 views

What is the meaning of “inversion” in Dependency Inversion design principle?

I'm reading about design patterns. I know what this principle does. High-level and low-level classes depend on abstractions. But why we say this is inversion?
2
votes
4answers
359 views

How to genericize foreign key references in table?

I am trying to design a table to store references to multiple tables as a "target" of the item in each row. An example should clarify what I am trying to do: Imagine you have 4 tables (images, ...
0
votes
2answers
684 views

Model-View-Controller — Where does a factory class go?

I'm working (slowly) on a small Flask project. One of my models is a class called Post, which is a lightweight namedtuple. Post objects are created by a PostFactory, because creating a Post involves ...
8
votes
4answers
476 views

Does Abstract Factory Pattern scale?

I'm still trying to understand design patterns here, after learning the Abstract factory pattern , I realised that this pattern will not scale well. Take a look at the uml diagram of the abstract ...
1
vote
2answers
262 views

What design pattern matches this problem the closest?

I have two objects, one is a User object and the other is a Content object. The User object has properties like 'reads_articles' or 'reads_books'. The Content object has properties like 'is_article' ...