Questions tagged [design-patterns]
A design pattern is a general reusable solution to a commonly occurring problem in software design.
4,519 questions
10
votes
1
answer
1k
views
When is a glue or management class doing too much?
I'm prone to building centralized classes that manage the other classes in my designs. It doesn't store everything itself, but most data requests would go to the "manager" first. While looking at an ...
7
votes
3
answers
3k
views
Duplication in parallel inheritance hierarchies
Using an OO language with static typing (like Java), what are good ways to represent the following model invariant without large amounts of duplication.
I have two (actually multiple) flavours of the ...
3
votes
2
answers
3k
views
Anemic Domain Model, Business Logic and DataMapper (PHP)
I've implemented a rudimentary ORM layer based on DataMapper (I don't want to use a full blown ORM like Propel/Doctrine - for anything beyond simple fetch/save ops I prefer to access the data directly ...
4
votes
3
answers
478
views
MVP Pattern Philsophical Question - Security Checking in UI
I have a philosophical question about the MVP pattern: I have a component that checks whether a user has access to a certain privilege. This privilege turns on or off certain UI features. For ...
15
votes
1
answer
8k
views
Software architecture for authentication/access-control of REST web service
I am setting up a new RESTful web service and I need to provide a role-based access control model. I need to create an architecture that will allow users to provide their username and password to get ...
5
votes
4
answers
3k
views
How to learn the practical uses of design patterns
I use OOP programming with inheritance, but I've not yet used interfaces.I want to learn how to use design patterns, but I'm finding them very difficult to learn. Is there is any way to learn design ...
5
votes
2
answers
2k
views
What are the best patterns/designs for stateful API development?
I am about to implement a API for my TCP/IP server written in Java. Right now I have a temporary method that takes a String, executes a command based on the String and returns a String basically like ...
16
votes
10
answers
3k
views
GoF Design Patterns - which ones do you actually use? [closed]
I'm trying to educate my colleagues in the area of design patterns. Some of the original Gang of Four patterns are a little esoteric, so I'm wondering if there is a sub-group of "essential" patterns ...
8
votes
4
answers
2k
views
Modular Architecture for Processing Pipeline
I am trying to design the architecture of a system that I will be implementing in C++, and I was wondering if people could think of a good approach, or critique the approach that I have designed so ...
1
vote
5
answers
566
views
Does this have a name? DRY overloading?
public int foo(int x)
{
int defaultValue = 0;
return foo(x, defaultValue);
}
public int foo(int x, int y)
{
return x + y;
}
17
votes
3
answers
9k
views
Recommended order for learning design patterns? [closed]
I can't help but notice the amount of design patterns that are out there.
Does anyone have suggestions on an order I should learn them in? Or should I pick and choose them at random?
The only one I ...
12
votes
5
answers
2k
views
Do you leverage the benefits of the open-closed principle?
The open-closed principle (OCP) states that an object should be open for extension but closed for modification. I believe I understand it and use it in conjunction with SRP to create classes that do ...
9
votes
6
answers
673
views
Giving a presentation on "code style and design patterns" [closed]
My company (small, about 40 people across 3 offices) occasionally does "developer workshops" online where one of the devs hosts a presentation about some tech topic. It's not necessarily about our ...
2
votes
6
answers
2k
views
Is "call and return" a pattern or an antipattern?
Imagine to have this code:
class Foo:
def __init__(self, active):
self.active = active
def doAction(self):
if not self.active:
return
# do something
f=Foo(false)
f.doAction() ...
9
votes
3
answers
3k
views
Design pattern for window management in a Java Swing app
I've just started creating my very first little Java Swing app. When the program opens, it brings up a single, simple window with a label and a couple buttons. Clicking one of those buttons is ...
26
votes
7
answers
5k
views
The Singleton Pattern [duplicate]
Possible Duplicate:
When is Singleton appropriate?
I am a new programmer (4 months into my first job) and have recently taken an interest in design patterns. One that I have used recently is the ...
7
votes
1
answer
747
views
Can Test-Driven development work in legacy projects?
So here is a question for you, having read some great answers to questions such as Test-Driven Development - Convince Me.
So my question is: "Can Test-Driven Development be used effectively on non-...
3
votes
2
answers
851
views
Is is common to use the command pattern for property get/sets?
Suppose I have a controller class with a bunch of properties. Each time a property is changed, I would like to update the model. Now also suppose that I use the command pattern to perform model ...
5
votes
2
answers
1k
views
How to program for constraints/rules
First the background, during interviews in the past, many times I have been asked to design some or other variation of card game as programming puzzle, and I have tried to design it in OO way, but I ...
2
votes
1
answer
454
views
PHP objects with configurable data interfaces
I have a User class which needs to load data from a variety of sources, e.g. the main user database, WordPress user metadata, authorizations from another app, etc. For the sake of organization, I want ...
3
votes
3
answers
100
views
How to manage tailored/branded web tools?
We produce a number of analysis tools which we re-brand and customise for other businesses to include in their websites.
The tools are typically product comparison, data/trend analysis and report ...
16
votes
10
answers
7k
views
Best way to model a singleton in a relational database
When designing relational database schema for web applications, I often find a case where I end up creating a table just to contain one row, and only one row. It feels like that is the wrong way to ...
5
votes
1
answer
355
views
MVC for our application?
There are some issues about how to manage our program designs and programming styles. I was assigned to find a solution to write reusable code - though, the programming team does not follow the rules.
...
32
votes
7
answers
3k
views
Design Patterns for Javascript [duplicate]
A lot of web frameworks have a MVC-style layout to code and approaching problems. What are some good similar paradigms for JavaScript? I'm already using a framework (jQuery) and unobtrusive js, but ...
3
votes
4
answers
827
views
Which one of the SOLID principles had the largest effect on your code? [closed]
Which if the SOLID principles introduced by "Uncle Bob" Martin had the largest effect on your day to day coding? Please give details!