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

learn more… | top users | synonyms (1)

3
votes
1answer
50 views

Who is the Owner of Information? Memento vs. Originator

Imagine for a second that I'm implementing the Memento Pattern, using the following classes. Classes An Originator class that has public and private, properties and fields respectively A Memento ...
2
votes
2answers
141 views

Class with only one execution

I'm implementing a long algorithm (about 500 lines of C++). The algorithm consists currently of about 10 different methods. Each method I have to hand over multiple data-structures as parameters, ...
1
vote
5answers
160 views

Class design, responsibility granulation, efficiency and performance

I am in a design dilemma. I have a set of data that can be interpreted in numerous ways, but I cannot really decide how finely grained should it be. To illustrate it with some simple code: class Base ...
0
votes
1answer
62 views

Manipulating data for a single file

I'm looking for a best practice solution for creating an object whose responsibility it is to handle file storage for a single file. I want to be able to read data from the file, write to the file, ...
1
vote
1answer
113 views

Understanding Flux pattern

I'm actually studying the flux pattern and there's something that I can't understand concerning the stores. What are they exactly? I have read many articles, and it seems that it concerns the ...
0
votes
0answers
53 views

MVVM with multiple view models that share a model

I have an application where there is an "inventor" model whose data I would like to display differently in different areas of the application. Therefore, I'd like to create different view models ...
-4
votes
0answers
84 views

How to compress and send 36,864,000 numbers per second over a network? [on hold]

You have a 3D mesh made up of 307,200 vertices. Or to put it in programming terms, you have an array with 307,200 entries whereas each entry is an object containing the properties id, x, y and z, each ...
2
votes
4answers
122 views

How to simplify structure of a monitoring software that uses the Observer pattern?

I am working on a project where I have to monitor the status of an elevator. So far, my design looks like this: We are using a third party library to read and monitor real-time values from the ...
5
votes
1answer
92 views

Clean Architecture - How to go from “Database Driven” to “Independent of Database” [closed]

I am looking for some clarity and hopefully some advice on writing clean architecture for a large system. My Companies "Web Solution" is +-10 years old, my job is to rewrite it. It is written across a ...
9
votes
2answers
330 views

Is there a design pattern for managing deep many-to-many relationships?

I'm having trouble defining this data pattern I've come across working on several applications. It consists of: An object type which is composed of many objects itself A second object type, where ...
2
votes
1answer
146 views

Is it a good idea to have separate UI components make their own webservice calls?

I have few UI components in an angularjs web-application. Each display data based upon same input. One shows stats which are calculated on the basis of a time period. Other shows a chart of daily ...
1
vote
0answers
30 views

Abstract Alert Dialog Builders (Same Method Calls, Different Objects)

Currently I'm working on an Android library that creates a dialog which allows to select colors from a palette (examples at the end) and I've stumbled upon an interesting design problem. To create ...
4
votes
3answers
129 views

DDD design question

I have a question on modelling an Entity\Aggregate root in DDD. I am refactoring a project that uses Entity Framework and business logic as services, the services contain lot of logic which I believe ...
0
votes
1answer
41 views

Flux Pattern dispatcher broadcast

I'm trying to get a better understanding of the flux pattern Facebook introduced a while ago. From what I understand the dispatchers dispatches every payload to all registered callbacks. Does anyone ...
-2
votes
0answers
51 views

Builder Design Pattern : Accessing/Passing model data in/to Concrete classes [closed]

First of all Sorry for question if its completely wrong, i am new to Design Patterns. I asked this question here also ...
0
votes
2answers
132 views

Repository pattern with service layer - too much separation?

I have an MVC site which uses the repository pattern. I don't feel like I'm using the MVC style enough, so I'm getting ready to re-architect some of it. But I'm also wanting to do it so if the ...
2
votes
0answers
66 views

Seperate settings and implementation class hierarchies

We use XML serialization to store class settings. Each setting-class has (but doesn't reference) corresponding implementation-class. Therefore we can easily make a "settings dll" without any ...
1
vote
1answer
81 views

Pattern for passing in a field as a parameter

I'm writing a Rails app which uses ActiveRecord ORM and a Postgres DB. I've got two attributes which are similar but are separate fields in the database. The assignment and saving of these is kinda ...
0
votes
1answer
34 views

How should one model an ExchangeService object (in ews-java-api) for sharing MS Exchange connections?

I am creating an application which uses ews-java-api to connect to an MS Exchange server. Once the connection is authenticated, the api dictates use of ExchangeService object for searching mailboxes, ...
11
votes
2answers
665 views

DRY principle in good practices?

I am trying to follow the DRY principle in my programming as hard as I can. Recently I have been learning design patterns in OOP and I have ended up repeating myself quite a bunch. I have created a ...
2
votes
4answers
241 views

Good practice for holding immutable data

I'm wondering what is the best practice for holding immutable data, more specifically in C#. For instance, lets say I have an immutable object called Foo. public sealed class Foo { public int ...
2
votes
2answers
104 views

Where to put the Country Table?

It might sounds like a silly question but here is my problem. We have 100s of databases and in each of those databases, there is a country table. It was ok this way but we ran into minor problems at ...
0
votes
1answer
80 views

How to design resilient web service clients?

I am writing an app that is supposed to talk to a web service. Let's say it's a chat app. It would need to receive a stream of new messages (so that they are pushed to the interface as quickly as ...
1
vote
4answers
180 views

Strategy pattern and “Is a” relationship

Imagine, I have class IAlgo which is an interface. I have derived from him and implemented his single method called matchCount in different implementations - AlgoA1, AlgoA2, AlgoA3, AlgoB1, AlgoB2. ...
6
votes
1answer
140 views

UI Design patterns for non-screen based project

I'm working on a small project coded in Python that uses a single button for input and a RGB LED as feedback, which responds to button presses and asynchronous events from the network. As the ...
2
votes
1answer
62 views

For DI, where to create dependencies (new objects) specifically within framework code?

Basic requirement I'm making a framework for learning purposes (and likely usage on personal sites). I'm using dependency injection in classes and I'm trying to design where would be a good place ...
5
votes
2answers
172 views

Persisting Large/Complex Entities with the Command Pattern — Am I doing it right?

I am in the process of designing and building a large-scale inventory management software-as-a-service that will, hopefully, live a long and fruitful life. Therefore I am exerting a lot of effort ...
-1
votes
2answers
132 views

Modelling a parcel management application

Scenario/Context: I am working on an application which would find out the highest volume of parcel delivery based on the pin code of a particular area by reading a text file which has the list of ...
2
votes
0answers
39 views

Go - idioms/design for determining when an unknown number of goroutines are complete

I have a workflow wherein I walk recursively through a bunch of directories, then for each file perform some action. I'm using goroutines to walk each directory, and also to process each file. The ...
2
votes
1answer
95 views

Thoughts on having a generic, reusable grid viewmodel

I'm developing a wpf-based application and I'm currently struggling to find the best way of supporting a recurring scenario in it. This app uses grids a lot. There are a bunch of features I want in ...
1
vote
3answers
124 views

How to understand if a property is a member of a class or I have to create a different class that holds it?

Sometimes when you create a class you can add there several properties (new data members) that you are not certain if you want to do or not. For example, I have a casino slots game. I have tiles and ...
0
votes
1answer
70 views

Implementing the State Pattern with Object.setPrototypeOf()

Take a look at this implementation of the state pattern in JavaScript: var ON = { switch: function() { Object.setPrototypeOf(this, OFF); this.state = "OFF"; } } var OFF = { ...
4
votes
3answers
135 views

Can a pimpl variation be implemented without any performance penalty?

One of the issues of pimpl is the performance penalty of using it (additional memory allocation, non-contiguous data members, additional indirections, etc..). I would like to propose a variation on ...
0
votes
2answers
115 views

How should I structure these Python classes?

Base Class I have a class called Remote. This class represents a remote machine and has properties such as ip, hostname, username, and password, as well as methods for transferring files to/from the ...
1
vote
0answers
100 views

Does this seem a reasonable design? [closed]

I'm trying to design a program that: Retrieves/saves pages from a MySQL table - each has an id, title, description, and page contents Has the ability to draw pages either in HTML or PDF Here are ...
1
vote
1answer
110 views

How to watch a message queue properly

I have a scenario where I need to 'watch' an Amazon queue. When a message arrives I need to get this message and process it. Right now this is implemented with a do/while and Thread.Sleep when no ...
2
votes
1answer
80 views

Class structure for Entity Framework

I'm using EF (Code first) and I'd like to isolate the properties from the methods (many of the methods reference other libraries that I don't want my database project to have to reference). As an ...
0
votes
1answer
115 views

How to avoid circular patterns in Node?

I'm new to Node and JavaScript (well, asynchronous programming in general) and I noticed when I was working on a project that the following code is a circular pattern and that these are bad practice ...
4
votes
0answers
93 views

What is the correct place to put checking of conditions in this use case?

Here is the situation: I have a database and a class that is basically a representation of a set of fields of different tables in it. Let's call it Message. "Message" does not know of the database ...
0
votes
2answers
67 views

How to better define SRP and “wholesome” objects? [duplicate]

Assume you have a class. It can really be any class that defines a domain concept like an employee, a product on an e-commerce site, or a car. One of those examples that are oldies but goodies. ...
4
votes
1answer
171 views

Understanding factories

I know there are hundreds of questions about this on here. I've probably read fifty different questions, blog posts and textbooks. The problem is I've gotten about 75 different answers. I have seen ...
2
votes
1answer
46 views

Best pattern for manager class that handles syncing objects between client and server

I am writing a client which has support of 'offline mode'. When offline records can be stored locally. When we go online we want to be able to synchronize these records with the remote API. I want ...
4
votes
1answer
56 views

Best practice for defining and keeping related stateless methods together in Objective-C

I have a few methods which are stateless: loginWithEmail: password: completion: signUpWithEmail: password: completion: resetPasswordForUsername: completion: Currently what I do is I create a class ...
2
votes
1answer
46 views

Pattern for “Assembling” result from multiple datasources

I'm creating a server in Java (although this question is language agnostic) that will do the following: Pull a set of "leads" from a database every 10 minutes For all leads with a certain marker, ...
0
votes
0answers
37 views

Is there a good pattern for building nested form objects with validations?

I'm using the form object pattern to handle data normalization and validation in my app. It's working well for simple cases, but some of my form objects are composites (or roll-ups) of multiple other ...
1
vote
2answers
96 views

What is a good way to organize service layer classes?

I had a Service layer in my app and, for a while, there's just one class for API calls Current Scenario MyAPI Class authenticateApp() authenticateUser() Looking in the future, that class will be ...
1
vote
1answer
92 views

Accepted Patterns For Base Class with both Static And User-Defined Data Sources

I have a requirement to build a 'base' profile library (in C# - NET 4.5.2) for various different internal (technical) consumers. This profile consists of metadata fields that would be shared by a ...
0
votes
2answers
152 views

Design Patterns: What design pattern should I use for the following? [duplicate]

I am trying to write an utility which traverses through a list of files and searches for a string in each file. On finding the string in a file, I will add it to a list and display the list. Which ...
4
votes
0answers
58 views

Which is the preferable design for my Gateway?

I'm writing a Gateway class that extracts information from a HTML document. One of the responsibilities of the class is to traverse a table in the document and extract data from its rows. I'm trying ...
1
vote
1answer
181 views

Could there be a use case for C# style auto-properties in Python

I've been doing a lot of work in C# recently (my primary language is Python) and I love that I can do something like public string MyProperty{ get; set; } Going back to Python I miss that sort of ...