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

learn more… | top users | synonyms (1)

2
votes
3answers
236 views

How does Observer create loosely-coupled design?

I completely understand the Observer design pattern, what it is for and how to implement it. I also understand what the term 'loosely-coupled' means. But I'm not sure how Observer makes designs more ...
0
votes
0answers
63 views

Looking for design pattern to represent shared state in music sequencer

I like to give lots of context, but also to state the basic question up top as concisely as possible. Feel free to read a little or a lot. I'm working on a music sequencer, and have been happy so far ...
0
votes
3answers
139 views

Question/Answer for multiple Users - How should I design it?

I'm wondering about a good way to deal with a Question/Answer - Model for multiple Users. My goal is to have an efficient and readable model where all the results of my users are stored. Every user ...
4
votes
3answers
440 views

Model-View-Controller: Does the user interact with the View or with the Controller? [closed]

I have recently learned about the MVC design pattern. I'm learning from the Head First Design Pattern book. According to this book (if I understand correctly): The Model is most of the application ...
1
vote
2answers
125 views

Alternatives to inheritance on complex structures?

I'm working on an ASP.NET Webforms project, using the MVP Pattern (which the presenters as you may know use a Page Controller pattern). I'm given a rather complex inheritance chain for my controllers. ...
2
votes
6answers
333 views

Design pattern for method to accept one of several static items in C#?

I want to illustrated my question by way of a (hopefully) representative example. Lets say I have a situation where I am developing a class library in C# to be used in some simulations. I want to ...
1
vote
0answers
99 views

Run a function when a function in a list is executed?

Goal: I'm currently doing an MVC project and I have this method to update the ViewBag (based on previous actions of the user). I would like to call this function whenever a certain list of MVC Actions ...
0
votes
1answer
110 views

How to design a scriptable communication emulator?

Requirement: We need a tool that simulates a hardware device that communicates via RS232 or TCP/IP to allow us to test our main application which will communicate with the device. Current flow: ...
0
votes
2answers
192 views

Why does the Mailbox app need their own backend?

I am only coding in Objective-C and I have no experience with backend coding, only a high-level understanding. I understand why a lot of programming projects require backend servers but I'm not ...
-1
votes
1answer
106 views

Should We Use Surrogate Primary Keys for Every Table? [duplicate]

We are developing a data model for a marketing database that will import transaction, customer, inventory, etc. files and the directive is ONE process that works for every client. We have been told ...
4
votes
5answers
253 views

How to design my code so that it can use alternative information to help create an object

I have a class named Product, which takes a product model number and number of wheels for that product as part of its creation information, and then it instantiates the product by doing a computation ...
2
votes
3answers
167 views

Building presentation layer directly on data layer

My application is currently quite a mess and I'm trying to untangle it all. My current idea is that I should have 3 separate layers: data layer that knows how to keep stuff in database (and handle ...
5
votes
3answers
156 views

Does the Composite design pattern implement recursive behavior?

The Composite design pattern allows us to call an operation() on a 'composite' node in a tree structure, and this operation() will be called on all of the children, subchildren and so on. When an ...
3
votes
3answers
225 views

OOP what is meant by object-to-object communication

I've been reading in basic concepts of OOP,as i'm trying to make this shift from transactional scripts to more oop manner in php, and i often come across this definition : An object stores its ...
2
votes
2answers
133 views

How to use the Decorator pattern to add little functionality to big objects?

This question regards the usage of the Decorator pattern to add little functionality to objects of large classes. Following the classic Decorator pattern, please consider the following class ...
4
votes
2answers
386 views

Should I expose a “computed” value as a property or a method?

I have a C# class that represents a content type in a web content management system. We have a field that allows a web content editor to enter an HTML template for how the object is displayed. It ...
0
votes
2answers
189 views

Factory Method vs. Factory Method design pattern

I am currently studying design patterns from the book (which, although I didn't try anything else, I find excellent) Head First Design Patterns. I'm confused about two concepts: The Factory Method, ...
3
votes
1answer
83 views

reloading singleton classes and dependency

I have a singleton object. It's a DAO that looks somewhat like this (pseudoish code): class UsersDAO { public usersDAO init(string sDSN){ variables.sDSN = sDSN; return this; } public ...
2
votes
3answers
113 views

When to use tools vs custom development? [closed]

To learn dependency injection in a current side-project, I am writing my own dependency injection container. But this has lead me to wonder, at what point is it worthwhile to use a third party ...
0
votes
1answer
123 views

Why can't the Factory Method pattern create a family of objects? [duplicate]

There are two main differences between the design patterns Factory Method and Abstract Factory. Difference 1 is that Factory Method is mainly based on inheritance. A class in a way uses it's subclass ...
3
votes
3answers
140 views

Why should one subclass instead of composite when using the Factory Method design pattern?

I'm currently learning about design patterns. I learned about the Factory Method pattern. This pattern means that in order to implement a factory to create objects, one should subclass the class that ...
5
votes
4answers
341 views

How much effort should I invest in creating loosely coupled designs?

I am currently learning about design patterns. I think most people would agree that these patterns are great tools, but should be used with moderation and not as the answer for everything. Using them ...
0
votes
1answer
156 views

Interface questions for using Command Pattern and Dependency Injection together

I have many projects that have essentially the same high level requirement: test all hardware on a device. Each device can have a different communication protocol, requires different test equipment to ...
1
vote
3answers
139 views

Does this in the Observer pattern count as composition?

In a classic implementation of the Observer design pattern, the subject has a list of references to all of it's observers, and each observer might have a reference to it's subject. Is this considered ...
1
vote
2answers
139 views

Java Method Returns Unbounded Type

I was reading this article, https://weblogs.java.net/blog/emcmanus/archive/2010/10/25/using-builder-pattern-subclasses, about subclassing a builder class. I understood the article but there was one ...
2
votes
1answer
260 views

xml serialization and deserialization complex situation

I'm considering passing xml back and forth for error messages but each error has different scenarios. one situation at hand is passing diffed text comparison while others are as simple as passing a ...
19
votes
8answers
2k views

Do Design Patterns Stifle Creativity

Many years ago, I was talking with an Economics professor about design patterns, how they were establishing a common language for programmers and how they were solving well known problems in a nice ...
0
votes
2answers
125 views

Best design pattern for library with data model

I am refactoring an old Codeigniter library to be php framework agnostic. There are these core parts: the connection object - this will come from the "user"; ie, the framework's connection, or their ...
-1
votes
1answer
177 views

How to create a some kind of value for sentences? [closed]

I want to identify most matching sentence using some pattern. That means by using java algorithm I want to create identical value for each sentences.Each sentence when entering to that algorithm can ...
1
vote
3answers
146 views

How do I evaluate if an Orchestration is the appropriate design pattern for a given problem?

Say that you're doing a code review, and you find yourself faced with an orchestration pattern: class OrchestrationClass { private Configuration _configuration; private DataStore1 _dataStore1; ...
3
votes
1answer
226 views

What is the difference between Repository Pattern and Facades Pattern?

I've always used the repository pattern in my applications. But I have seen that many people use facades instead of the repository for naming convention, but the operation is the same, I Think. Why is ...
0
votes
0answers
20 views

Composite repository with plugins for multitenant app

Im working on an app that has flexible storage configuration. For example: public class Repo1:IRepository { public void DoSomething(int tenantId, string someKey) { ... } } This ...
1
vote
2answers
95 views

How to build configurable forms?

I'm working on two separate projects now that are essentially just CMSs -- a bunch of forms for recording various bits of information. Each project is built to serve many clients, and each client ...
4
votes
2answers
238 views

How to decouple simple factory and default implementation?

I have a simple factory class (FileResources) with static factory methods providing a default implementation (DefaultFileResource). public final class FileResources { private FileResources() {} ...
2
votes
1answer
129 views

Does a repository belong in this project?

I have a project that gets all of its data from API calls. The server that hosts this API connects with it's own database (not even sure what DB it is, etc). More or less the idea of a repository is ...
0
votes
0answers
57 views

Is Factory method subclass of Abstract factory in essence [duplicate]

Is it correct to say that factory method is essentially just a particular case of the abstract factory which produces the only one object not a group? I know that classic realizations assumes the ...
1
vote
3answers
243 views

Global request context - anti-pattern?

I was talking today to a colleague of mine about Python web frameworks and our impressions about them. I told him I think Flask having a global request smells badly and is an anti-pattern. The docs ...
3
votes
2answers
164 views

Is it an acceptable practice to Get a property, that involve parsing binary, that might throw an exception?

I have a property that is loaded lazily, any time after the ctor is called. It is possible that the binary that my property relies on is invalid. If invalid I might have to throw an exception. ...
0
votes
0answers
60 views

Difference between class clusters and abstract factory in cocoa

I have read that Obj-C class clusters are an implementation of the abstract factory. Can anyone explain if there are any differences between the 2 as design patterns. I read somewhere that there are ...
0
votes
3answers
163 views

Is the Adapter the correct design pattern for this situation?

I have an instance of a class UntouchableClass of which I need to access the member variables to use in my DotLiquid template. Problem is, UntouchableClass has to inherit from Drop if I want to use it ...
4
votes
2answers
219 views

How is the publish-subscribe pattern different from gotos?

My understanding is that Goto statements are generally frowned up. But the publish-subscribe pattern seems to be conceptually similar in that when a piece of code publishes a message, it performs a ...
1
vote
5answers
628 views

How do I deal with global variables in existing legacy code (or, what's better, global hell or pattern hell)?

So... We have this fairly complex project (~10k LOC, but there's duplicated code so it's hard to tell) with hundreds of global variables. The project has more dependencies on other projects, and many ...
2
votes
3answers
297 views

Design for creating a menu based on user type

Problem I am building a PHP application which has a main menu, which in turn contains various "sections" or "subheadings" with various links. There are several user types such as SuperAdmin, Admin, ...
4
votes
4answers
250 views

Design pattern for bidirectional signals/events

This problem feels rather basic, yet I've never known a great solution. I'm looking for a way for components in an application to notify each other while being as decoupled as possible (both at ...
0
votes
2answers
148 views

Whats an Ideal way to pass rules/options to methods that build SQL

We're trying to come up with a way to handle code that builds dynamic SQL for our application, which is very database centric. Things like Linq to SQL and Entity Framework are out of the question, so ...
0
votes
3answers
166 views

“Property Container” design-pattern in-depth definition

Could anybody, please, explain what is a Property Container or at least where can I get information about that pattern on the Internet? I've found that it exists as one of the Fundamental patterns in ...
1
vote
2answers
141 views

Validating objects with each other - Design Pattern needed

I am running a zoo application. My zoo includes an abstract class of 'animal', and several deriving classes - 'zebra', 'elephant', 'orangutan', 'baboon' and so on. Of each class I have several ...
3
votes
1answer
222 views

Is it bad to have classes as properties of all other classes?

I've been making MVC programs for work (I'm an intern) and I feel like I'm doing a pretty good job at abstraction, single responsibility, etc. But I have this feeling about how I keep making objects ...
3
votes
1answer
155 views

implementing dynamic query handler on historical data

EDIT : Refined question to focus on the core issue Context: I have historical data about property (house) sales collected from various sources in a centralized/cloud data source (assume info ...
1
vote
2answers
162 views

Why does a monad use “return” or “unit” rather than “lift”?

This is partly genuine curiosity, and partly a check on my understanding. I'm probably missing the point. In Haskell, why does a monad use operations called return or unit to describe putting a type ...