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

learn more… | top users | synonyms (1)

0
votes
2answers
126 views

How to present a stable data model in a public API that allows internal data structures to be changed without breaking the public view of the data?

I am in the process of developing an application that allows users to write C# scripts. These scripts allow users to call selected methods and to access and manipulate data in a document. This works ...
2
votes
1answer
172 views

Is there a Design Pattern for preventing dangling references?

I was thinking about a design for custom handles. The thought is to prevent clients from copying around large objects. Now a regular handle class would probably suffice for that, but it doesn't solve ...
0
votes
0answers
132 views

What's the best way to expose a Model object in a ViewModel?

In a WPF MVVM application, I exposed my model object into my viewModel by creating an instance of Model class (which cause dependency) into ViewModel. Instead of creating separate VM properties, I ...
2
votes
4answers
207 views

Callbacks: when to return value, and when to modify parameter?

When writing a callback, when is best to have the callback return a value, and when is it best to have the callback modify a parameter? Is there a difference? For example, if we wanted to grab a list ...
1
vote
0answers
72 views

Processing a list of atomic operations, allowing for interruptions

I'm looking for a design pattern that addresses the following situation: There exists a list of tasks that must be processed. Tasks may be added at any time. Each task is wholly independent from all ...
39
votes
2answers
4k views

What is the “Free Monad + Interpreter” pattern?

I've seen people talking about Free Monad with Interpreter, particularly in the context of data-access. What is this pattern? When might I want to use it? How does it work, and how would I implement ...
1
vote
1answer
44 views

Handling Types for Real and Complex Matrices in a BLAS Wrapper

I come from a C background and I'm now learning OOP with C++. As an exercise (so please don't just say "this already exists"), I want to implement a wrapper for BLAS that will let the user write ...
0
votes
1answer
97 views

Does my use of the strategy pattern violate the fundamental MVC pattern in iOS?

I'm about to use the 'strategy' pattern in my iOS app, but feel like my approach violates the somehow fundamental MVC pattern. My app is displaying visual "stories", and a Story consists (i.e. has ...
4
votes
5answers
129 views

Preferred way for dealing with customer-defined data in enterprise application

Let's say that we have a small enterprise web (intranet) application for managing data for car dealers. It has screens for managing customers, inventory, orders, warranties and workshops. This ...
-1
votes
2answers
170 views

Help with MVC design pattern? [closed]

I am trying to build a java program for user login but I am not sure if my MVC design is accurate. I have the following classes: LoginControl - servlet LoginBean - data holder java class with ...
0
votes
2answers
213 views

How to design console application with good seperation of UI from Logic

Is it considered an overkill for console application to be design like MVC , MVP or N tier architecture? If not which is more common and if you can link me to simple example of it. I want to ...
5
votes
3answers
199 views

How to refactor my design, if it seems to require multiple inheritance?

Recently I made a question about Java classes implementing methods from two sources (kinda like multiple inheritance). However, it was pointed out that this sort of need may be a sign of a design ...
1
vote
1answer
200 views

Confused about implementing Single Responsibility Principle

Please bear with me if the question looks not well structured. To put you in the context of my issue: I am building an application that invoices vehicles stay duration in a parking. In addition to ...
0
votes
2answers
105 views

What are the benefits of using a 'decorator factory' that decorates objects?

In a project I decided to implement the Decorator pattern. I have a class Thing with methodA(), and a class AbstractDecorator that inherits from Thing and that all decorators inherit from: ...
19
votes
4answers
2k views

Builder Pattern: When to fail?

When implementing the Builder Pattern, I often find myself confused with when to let building fail and I even manage to take different stands on the matter every few days. First some explanation: ...
1
vote
2answers
121 views

Flags with deferred use

Let's say I have a system. In this system I have a number of operations I can do, but all of these operations have to happen as a batch at a certain time, while calls to activate and deactivate these ...
9
votes
2answers
217 views

Using packages (gems, eggs, etc.) to create decoupled architectures

The main issue Seeing the good support most modern programming platforms have for package management (think gem, npm, pip, etc), does it make sense to design an application or system be composed of ...
7
votes
1answer
101 views

Restructuring a large Chrome Extension/WebApp

I have a very complex Chrome Extension that has gotten too large to maintain in its current format. I'd like to restructure it, but I'm 15 and this is the first webapp or extension of it's type I've ...
2
votes
1answer
185 views

Best practice to collect information from child objects

I'm regularly facing following pattern: public abstract class BaseItem { BaseItem[] children; // ... public void DoSomethingWithStuff() { StuffCollection collection = new ...
0
votes
0answers
45 views

NCurses, scrolling of multiline items, “current item” pointer and “selected items”

I am looking for hints/ideas for the best (most effective) way on how to scroll multi-line items as well as emphasizing of the "current item" and "selected items" such as: 1 FOO ITEM 1 Foo sub-item ...
0
votes
0answers
74 views

Is this considered an implementation of the Template Method design pattern?

Please consider a StringBank class. This class holds a list of Strings and can return them to the client. It's code (irrelevant stuff omitted): abstract class StringBank{ List<String> ...
3
votes
1answer
156 views

Does this Decorator implementation violate the Liskov Substitution Principle?

Please consider the following implementation of the Decorator design pattern: WordBank objects store strings and return them to the client through the method getWords(). The decorator class, ...
1
vote
2answers
183 views

global try-catch in presentation layer

I have a 3-layered app structured as follows. Presentation Layer (ASP.NET MVC project) Business Logic Layer (Services for controllers in PL) Data Access Layer (Repositories) Each Controller in PL ...
2
votes
1answer
407 views

A small project but I want to use design patterns to do it right

I've got a project coming up, a very a small system, but one that needs to be extended in the future. Here's how I've designed it so far. It's 3-tier: presentation, business and data. For the ...
0
votes
2answers
247 views

Why don't we completely de-couple frontend JS frameworks and backend APIs? [closed]

Whenever we implement a frontend framework in the likes of Backbone, AngularJS etc. there's an integration process involved with the backend technologies like NodeJS, Rails, Yii etc. (like setting up ...
1
vote
2answers
257 views

Correct way to inject dependencies in Business logic service?

Currently the structure of my application is as below Web App --> WCF Service (just a facade) --> Business Logic Services --> Repository -> Entity Framework Datacontext Now each of my Business logic ...
0
votes
7answers
345 views

Using a Simple/Static Factory vs. instantiating directly: new Thing() vs. factory.createThing() - what's the benefit?

Here are two ways to instantiate an object: Option 1: Thing thing = new Thing(); Option 2: (the factory is a Static Factory, but it could also be a Simple Factory). Thing thing = ...
0
votes
1answer
62 views

Algorithmic Forecasting and Pattern Recognition

Say a user could enter project data into my software. Each project has 2 variables "size" and "work" and they're related but the relationship is not known. Is there a way to programmatically determine ...
-1
votes
1answer
142 views

Correct pattern for Worker Processes involving Queues & Tables

Edit: OK, so, people said it is unclear what I am asking. I am asking for feedback on this design. Here is an example user story: As a group admin on the website I want to be notified when a user in ...
0
votes
1answer
46 views

Restricting object types that can be added to each other using the Composite Pattern

The Situation: I am building a custom PHP application framework. I have implemented a composite pattern so I can build a object tree representing the page to be rendered. Example: abstract class ...
-4
votes
1answer
110 views

How is the Decorator Pattern actually used in practice? [closed]

I understand completely how to implement the Decorator pattern, and I also understand what it's intent is. The Decorator is used in one of two cases: As an alternative to subclassing - when there ...
0
votes
2answers
134 views

Is using interfaces on internal code a good idea? [duplicate]

I'm working on a set of automated tests that we use internally at work. Lately, we've been designing classes that implement interfaces in addition to inheritance. As I understand it, interfaces in ...
0
votes
1answer
170 views

pattern to share objects between API and application

I'm having serious doubts about the design for my Web application. I wanted to separate the business logic from the interface so I made a Web API that handles all the requests to the database. It's ...
2
votes
1answer
137 views

Adapter Pattern: Design Patterns

So far as I know, there are two forms of the Adapter Pattern: the class adapter and the object adapter. Could someone please explain to me the following limitation of the class adapter and why it is ...
0
votes
0answers
25 views

Organizing an image processing pipeline for on-the-fly video analysis

I'm trying to design a system that performs image analysis on video streams from the internet. I have a few rudimentary ideas for how to organize such a system, and I was hoping you guys could ...
3
votes
1answer
79 views

Access items of a container with a pattern

I've two C++ classes with a relation: a container class which has a list of items. For example a library has got many books. The classes are the library and the book. Now from the external world I ...
2
votes
1answer
91 views

What's the right OO way to create a counter/inventory class that works for both differentiated and undifferentiated countables?

You are writing a videogame about trading beans. Red beans, black beans, pinto beans, you name it. As everybody knows all beans are the same. You write the "Inventory" class for a trader in that ...
0
votes
0answers
59 views

Build a map with city blocks and road

Is there a design pattern or well known algorithm to build a simple map with roads and city blocks? To have an idea of what's my target i describe some of the constraints and the context: a matrix ...
2
votes
1answer
67 views

Use adapter pattern for coupled classes

I need (for unit testing purposes) to create adapters for external library classes.ExchangeService and ContactsFolder are Microsoft's implementations in its' EWS library. So I created my adapters that ...
2
votes
2answers
208 views

What do I gain by using the Strategy pattern in this case?

I wrote a program with Java that plays simple music. Currently chords have only one way ('strumming pattern') to be played. I want to expand this and create different 'strumming patterns' that chords ...
0
votes
1answer
73 views

MVC: Where should I store interchangeable algorithms used by the Model (whose names also need to be accessible to the View)?

Please consider a program, where the user chooses an algorithm from a list, and the Strategy pattern is utilized to set this algorithm as the model's operation. For example, an image procession ...
6
votes
1answer
153 views

Javascript MVC application design (canvas)

I'm having difficulty grasping how to structure/architect a canvas application using an MVC like approach in Javascript. UI will be fairly fluid and animated, the games fairly simplistic but with ...
5
votes
4answers
209 views

How to take things step by step

This is about the third time I've had to write software to control a cellular modem. For those unfamiliar with the process, you have a sequence of steps you have to take. Each step takes a certain ...
1
vote
4answers
130 views

Dealing with similar objects with different method signatures

I am fairly new to OO design and have problems with the design of some software and looking for a pattern or a combination of patterns that could help me solving my problem. I have a type that has a ...
1
vote
0answers
75 views

Methods for structuring JavaScript SDKs

I've built a REST API and have been using Backbone models throughout a couple different applications to communicate to it. I would really like to build a single JS SDK that can be used in any ...
0
votes
0answers
55 views

RESTful composition/inclusion of other resources

I have a few HTTP resources, and i'm wondering if including the models of one in the other is acceptable or if there is a cleaner method. In this example, we have a ton of "news" resources, and users ...
0
votes
1answer
142 views

Domain Services vs. Factories vs. Aggregate Roots

After dealing with DDD for months now, I'm still confused about the general purposes of domain services, factories and aggregate roots in relation to each other, e.g. where they overlap in their ...
0
votes
2answers
47 views

Handling ignorable failure conditions in a method

I'm working on a coarse API for performing higher level business functions. Under many conditions these functions may fail in a way that is expected (not exceptional), ie. the function may not be ...
-1
votes
4answers
183 views

Where should you put functions and variables that are only needed by one function in a class?

Say you have a Car class. Properties that make sense for a Car class might be: var make; var model; var year; var turnOn; // a function But the turnOn function is very complicated and ends up ...
1
vote
2answers
90 views

Logging events for reporting purposes

Are there any design patterns or best practices around logging events for use in reporting and BI systems. For example in a system which manages orders from a website, it would be beneficial if a ...