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

learn more… | top users | synonyms (1)

2
votes
1answer
99 views

Python Classes and Design Questions

What is the best way to design a class to see if an update occurs on a property? I have a whole bunch of classes, and current am going through a re-design of the python package I created. ...
4
votes
2answers
212 views

Is this too much work for a Gateway to do?

I'm writing a Gateway class that wraps access to a web service which provides information about a player's item inventory in a video game. This web service returns a variety of information, however I ...
3
votes
1answer
170 views

Single source of truth within an enterprise distributed system

Within an enterprise distributed system I have many services - an ecommerce service, a CRM, support desk, finance, billing. Many of these services share common data, such as Customer data. These ...
2
votes
2answers
128 views

Does it break SRP to have concerns of data handling and object mapping inside a single class, as part of the DataMapper pattern?

Summary I want to look into separating the concern of "creating a populated object from database", to use inside my application. DataMapper pattern seems to be doing just that for me. DataMapper ...
-1
votes
3answers
118 views

What design pattern is this? [duplicate]

I'm struggling to come up with the name of a design pattern that I need to write about. I've been lead to think it was abstraction but apparently not. Let's say I had a driver class which has a Drive ...
9
votes
4answers
349 views

Reducing boilerplate in class that implements interfaces through composition

I have a class: A that is a composite of a number of smaller classes, B, Cand D. B, C, and D implement interfaces IB, IC, and ID respectively. Since A supports all the functionality of B, C and D, A ...
3
votes
1answer
144 views

Design: .NET web app architecture problem

I'm taking my first foray into .NET and I'm designing a web app that's heavy on other web services right now. I'm intending to do the following: Take user input (a USDOT number) Request data from a ...
1
vote
1answer
116 views

How to avoid tying these two methods together with global mutable state?

I'm in the process of reading Code Complete 2 and learned that using global state is a no-no. What can I do to avoid using global state in this situation? Some background information: I have two ...
1
vote
1answer
124 views

Design Pattern - Adding features to a class

I'm finding myself unable to solve a design problem. For the sake of my simplicity, I'm going to use C# (Web API). Let's say I have an abstract class RestController: public abstract class ...
1
vote
1answer
102 views

Pattern to share fields in inheritance

I'm trying to figure out the best way to solve a design issue. I have to be able to clone (I'm cloning them to Apache HttpClient) different types of HttpServletRequest (POST, GET...) and then send ...
4
votes
0answers
49 views

Android: Pattern for checking requirements at startup?

My app's launcher activity checks a bunch of requirements like whether GPS is enabled, there's a network connection, the app has device administrator privileges, etc. Some of these checks display ...
1
vote
1answer
35 views

Filtering additions to a list

Hopefully Iʼm posting this in the right SX, and Iʼve tagged it correctly. I have a legacy system that Iʼm making additions to which contains a custom list object. This list object can contain two ...
1
vote
3answers
78 views

Design question concerning extensibility

I am constructing a new class which handles deciding which class should process the requests from a web service. I'm looking for a solution for a problem that I am having regarding extensibility with ...
4
votes
2answers
79 views

Returning a slimmed down domain entity from your view model

I'm wondering how to handle a ViewModel in the traditional sense, which includes both properties and methods, and another "view model" which is simply just the properties -- perhaps the ViewModel ...
2
votes
1answer
122 views

What design pattern best suits managing handles to objects, without passing handles or Manager around?

I'm writing a game in C++ using OpenGL. For those that don't know, with the OpenGL API you make a lot of calls to things like glGenBuffers and glCreateShader etc. These return types of GLuint which ...
4
votes
1answer
107 views

Separate interface for mutation methods

I've been working on refactoring some code, and I think I may have taken the first step down the rabbit hole. I'm writing the example in Java, but I suppose it could be agnostic. I have an interface ...
2
votes
4answers
174 views

Design Pattern for retry and error handling

I'm trying to find a good design pattern, or perhaps series of patterns, for injecting error handling and retry handling when getting data from a webservice. For instance, I have: do { //get the ...
4
votes
3answers
133 views

Nested POJOs, exposing collections, detecting changes

I have a couple plain object classes to represent data read from a file. They look something like this: public class Command { private String name; private List<Message> messages; } ...
5
votes
1answer
80 views

When applying the interface segregation, should you separate interfaces for regular setters and mathematical operations?

When applying the interface segregation, should you have separate interfaces for a straightforward setters and interfaces that perform an operation before setting? For example, say you have a class: ...
5
votes
1answer
126 views

PHP: Injecting the same database connection into multiple objects

Suppose that there are two classes that define objects of vastly different function such that in the datastore, the information they require is divided into two separate databases. For example, the ...
1
vote
2answers
83 views

Efficient way to handle foreign keys

I am building a script that checks a large network of sites for invalid links. The idea is to flag links that continuously show as not available so that they can be cleaned by the administration team. ...
2
votes
2answers
171 views

Has-A or Is-A or some strategy pattern?

I am developing a web based application which is about tracking Fleet units. Actually i have already developed the system but in the last six years things changed a bit. Ordinary the software ...
0
votes
0answers
36 views

What sort of design pattern should I be using here - Tabs Generation

I am fairly new with design patterns, I have been studying them but no practical experience so this is going to be my first try, Graphical representation of GUI is shown in this diagram, Points ...
2
votes
1answer
95 views

Expandable alternative to Visitor pattern for tree traversal?

I have a tree containing various subtypes of the my base node class. I now want to traverse this tree and do something with the nodes depending on their type. The most straightforward idea is to just ...
1
vote
1answer
85 views

OO Design: Algorithm changing State (Information Flow Question)

I have a class Context, which contains an instance of an abstract class State, which has multiple concrete subclasses (this is an implementation of the State Pattern). Each State subclass executes a ...
1
vote
0answers
32 views

Adding fields a good use case for EAV? [duplicate]

Is being able to add fields quickly to a system a good use case for EAV? What would be the frequency or number that would justify using an EAV model?
2
votes
2answers
72 views

WCF service with methods to fetch data

I'm planning on building a WCF service that will fetch data entities from a Sql Server database. And I'm currently struggling with best practices issues. The thing is that there's a few different ...
2
votes
0answers
55 views

What's the best pattern to validate a conditional entity? [duplicate]

I'm developing an ASP.NET MVC 5 website and I have a view with a grid. In this grid I have a column which represents an URL property. This url is a link to download some files, but this url should be ...
0
votes
0answers
54 views

Whats the best way to implement DataMapper design pater and lazy loading (ghost object)

I'm doing a small project and I wanted to keep it simple to mantain. It is a renting management software. To keep it clean I decided to implement the data mapper patern, to keep the domain objects in ...
4
votes
4answers
170 views

Using a one-shot class to store not-quite-global variables

I sometimes find myself writing classes (in Python, in my case) that are used like this: MyClass(some_args).go() In other words, there's only one method in the class that any external code would ...
2
votes
1answer
171 views

Injection, strategies and OO

I'm working on refactoring a project. The business logic looks very much like using the Strategy pattern would be very beneficial, because depending on the values of three properties (let's say age, ...
6
votes
6answers
698 views

What are the most used pattern to manage a lot of interconnected parameters?

I recently start to work on an application that drive different measurement device. Before the user start a measure, she sets the parameters of it. Actually, considering all measurements type there ...
1
vote
2answers
161 views

A Factory could be replaced by a key on the web.config? How would be the trade-offs of each approach?

The Problem We had a Environment class which would choose whether or not to use a webservice (it was set by a web reference) for our authentication methods by reading the host environment and if it ...
2
votes
2answers
131 views

Abstract Property In Base Class To Force Programmer To Define It

I'm coding with a state pattern for an embedded device. I have a base/abstract class called State and then each discrete(concrete) state class implements the abstract State Class. In the State Class ...
4
votes
3answers
153 views

Should dependency inversion be used only with Adapters everywhere?

As I understand the purpose of DI is that I can easily swap a lower level implementation. But it forces the lower level abstraction to be defined inside the higher level. A lower level becomes ...
0
votes
0answers
29 views

Graph curve and actual curve plotted on screen implementation patterns

I'm implementing a graph plotter. There are Curve objects, that contains points of actual XY data. When I plot to screen, I need to calculate the XY points on screen, resulting a PlottedCurve. This ...
1
vote
2answers
405 views

Class becoming God Object what pattern to use

I am developing Android app and my MainActivity is becoming God Object. By the way native Activity class implementation is some sort of God Object already. The problem is that my activity class is ...
0
votes
2answers
154 views

in trouble making a card game with pygame

I am designing a card game playable against the computer. The rule is very simple Both player and CPU gets 10 cards of 1 to 10. Player and CPU plays a single card at the same time, every round. The ...
5
votes
3answers
169 views

Design Pattern - DLL per Strategy

I usually found myself designing my application in the following way: One DLL containing interfaces for a desired subsystem. For example, Company.Framework.Persistence.dll. One new DLL per each ...
1
vote
1answer
153 views

Best solution to switch between new and deprecated code

We have a feature that is currently implemented, let's call it implA. ImplA works but can't do many things. So we have decided to rewrite it. But we can't just replace it right away, so we will need ...
0
votes
0answers
55 views

Command Pattern for Logging/Backup/Testing

I need your input guys on this concept I intend to implement: Use the Command Pattern to record everything in my app. It should encapsulate every single user action and micro-action as a Command and ...
3
votes
1answer
103 views

Design pattern for mapping data fields

I have seen this problem a few times and never can come up with a solution i like. System A Sales Order Entity order_id created line_items_count System B Sales Order ...
2
votes
3answers
189 views

How to use one web page to create and edit database entries

My team and I are developing a java web application which allows our admins to create and edit "methods" which can later be viewed by other users. We are currently discussing the best way to ...
3
votes
4answers
394 views

Application development with fully dynamic controls and processes based on database

All software development projects are moving into separation of design, logic , data in patterns like MVC , MVVM and others. Strangely i got a very strange requirement for a new software; that is : ...
0
votes
0answers
81 views

Addicted to Interfaces - Good or bad? [duplicate]

After 2 years of programming, I usually found myself using the following design pattern: public interface ISomeInterface { void SomeMethod(); void OtherMethod(); } public abstract class ...
2
votes
2answers
263 views

Is this the solution to static inheritance?

I've seen a lot of posts recently on why Singletons should be avoided. However, I can't see any of those problems with the following solution to a common problem: static inheritance. For example, I ...
0
votes
2answers
97 views

Middleware dependencies

I'm trying to convert a legacy PHP app to use the middleware paradigm, similar to connect/express.js. I've started porting the code into separate middlewares so that every feature is neatly self ...
3
votes
3answers
162 views

What is the most efficient way to find a set of locations within a radius of a certain point?

Imagine a dataset of all the restaurants in the US (similar to Yelp, etc), how would you return a set of restaurants within a certain range of a particular zip code. (Assuming you have already a ...
1
vote
2answers
128 views

How can I have objects interacting and communicating with each other without forcing a hierarchy?

I hope these ramblings will make my question clear — I'd totally understand if they wont, though, so let me know if that's the case, and I'll try making myself clearer. Meet BoxPong, a very ...
4
votes
3answers
178 views

Design patterns for implementing optionally supported features

Here's the original problem. There are two classes: Protocol and, say, ProtocolUser (which actully uses the Protocol class instance). Now, I need to support multiple protocols, whose feature sets only ...