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
79 views

Which design pattern to choose when supporting multiple analytic tools?

I have spent quite some time learning all possible design patterns but I cannot find the ideal one for the following case. I am developing an iOS app where we are using multiple analytics tools like ...
0
votes
1answer
155 views

Which design pattern is it if any for providing a general logger interface?

I have a library where I want to use a logger but I don't have (and cannot) create any interface for it because I'll be using it on different systems that have nothing in common (and won't have). So ...
6
votes
3answers
292 views

Alternative to Anemic domain objects (Simple example provided)

I want to model (TV)Events and Reminders and I’m wondering what’s ‘the best’ way to model this. The requirements are roughly When an Event has no Reminder, a Reminder can be created When an Event ...
3
votes
2answers
114 views

Name of design pattern for single-observer

Is there an existing named software design pattern similar to Observer, but for the case where only a single observer is supported rather than a collection of observers. I find that I use this ...
9
votes
8answers
778 views

Designs and practices to guard against erroneous null entries from database

One part of my program fetches data from many tables and columns in my database for processing. Some of the columns might be null, but in the current processing context that is an error. This should ...
16
votes
8answers
2k views

Refactoring a long method which is based on large number of switch cases [duplicate]

We are using Java as a backend development language. One year back, we wrote a method which uses switch cases based on Enums values. Since we are continuously adding enum members and according adding ...
-2
votes
1answer
41 views

Convention for exception argument order [closed]

Just a quick question about a design pattern for creating custom exceptions. The question is more about the order of parameters. If you can specify more data in the exception, should the parameter for ...
5
votes
3answers
457 views

How to solve circular dependency?

I have three classes that are circular dependant to each other: TestExecuter execute requests of TestScenario and save a report file using ReportGenerator class. So: TestExecuter depends on ...
3
votes
1answer
83 views

Builder Pattern : Seperation of construction from representation

I am reading GoF, and the intent of builder is mentioned as to separate creation of complex object from its representation. I couldn't understand what representation means in this context. What does ...
24
votes
6answers
3k views

Is there a design pattern to remove the need to check for flags?

I'm going to save some string payload in the database. I have two global configurations: encryption compression These can be enabled or disabled using the configuration in a way that either only ...
1
vote
0answers
101 views

Can this be used to implement Post Redirect Get pattern?

I am trying to implement proper a Post Redirect Get on a PHP site (question is language agnostic in nature however). I thought about it, and realized that running this code on every request seems to ...
2
votes
1answer
100 views

Pass request as argument to service client vs. pass service client as argument to request [closed]

I need a design recommendation: I have a class that send a http request via another class WebServiceHandler() I am hesitating between the following two implementations, which one to choose?which one ...
3
votes
1answer
105 views

Does my design break modularity and loose coupling?

I want to know if my implementation is modular and loosely coupled such that pieces can be replaced easily. Any concrete class that extends the abstract class HexGridLayout will be expected to ...
2
votes
0answers
31 views

Should my application call statsd directly or should I call statsd based off logs?

I'm planning on incrementing counters in statsd based of various events within my application. I have logging in place for these events. So, from my viewpoint I have two options: Update the ...
1
vote
1answer
69 views

How can I create a client for a service without hiding the parameters needed for each endpoint?

I'm creating a client to a third-party soap web service in my application. Here is the way I'm thinking of doing it: Create a ClientFactory that makes a client based on the wsdl file, and sets ...
6
votes
4answers
259 views

Design pattern for “operation on object allowed, only if object is in certain state”

For example: Only job applications that are not yet in review or approved, can be updated. In other words, a person can update his job appliance form until HR starts reviewing it, or it's already ...
0
votes
0answers
17 views

Which design pattern for interaction with miscoded project [duplicate]

I am actually working on JavaEE application (Spring, Hibernate). I have an old project which is not well coded. I have to not modify any line of code on it. And I have to add classes that uses this ...
16
votes
2answers
1k views

Is it a good idea to define one big private function in a class to maintain valid state, that is, to update the object's data members?

Although in the code below a simple single item purchase in an e-commerce site is used, my general question is about updating all data members to keep an object's data in valid state at all times. I ...
2
votes
1answer
133 views

Should UDP & TCP port numbers represented as a short or integer?

I am currently designing some networking code, and this code expects the caller of the code to give it a port and hostname to connect to. Since I am still in the development phase, I can still change ...
-2
votes
1answer
82 views

What is the difference between Adapter and Delegation design pattern?

I am very confused about Adapter and Delegation design pattern. In Adapter pattern we bring an intermediate class to interact with another class. And in Delegation pattern we also bring an ...
5
votes
0answers
152 views

How do I associate command objects with the right receiver?

I tried to use Command Pattern for implementing Undo and Redo in my project public abstract class Command { protected Form Receiver { set; get; } protected HtmlElement Element { set; get; } ...
2
votes
1answer
108 views

What is the alternative design pattern of a state machine that may have recursive state change?

I have a state machine like code, which has state A,B and C, with a function changeState(char i) which can change the state of a system, and each state can also call changeState(char i) to switch the ...
2
votes
2answers
217 views

Java Game. Preload objects and reuse vs create objects at runtime [closed]

I'm currently developing my first game in Java language. The game is an endless runner with obstacles to avoid and enemies to kill. Unfortunatelly im still not experience enough and many times im ...
5
votes
4answers
346 views

Is it true that for Observer Pattern to work, there probably is some polling mechanism underneath?

The short question is: is it true that for Observer Pattern to work, there probably is some polling mechanism underneath? (update: in a network situation) It was quite amazing that if on my Macbook ...
22
votes
1answer
841 views

Is “StringBuilder” an application of the Builder Design Pattern?

Is the "Builder" pattern restricted to addressing the "telescoping constructor" anti-pattern, or can it be said to also address the more general problem of complicated creation of immutable objects? ...
14
votes
3answers
1k views

Legitimate “real work” in a constructor?

I am working on a design, but keep hitting a roadblock. I have a particular class (ModelDef) that is essentially the owner of a complex node tree built by parsing an XML schema (think DOM). I want to ...
3
votes
0answers
102 views

Refactoring of a client API for avoid duplicated code and unclear passage of parameters

I need to develop an API, the functions of the API are requests that call the service exposed by a server. Initially the API worked like this: class Server: def firstRequest(self, arg1, arg2): ...
2
votes
1answer
89 views

Design Pattern for Library Wrapping Extern Methods

I am working to create a C# library that wraps a C DLL to integrate with our test system. The C DLL has probably close to 100 functions that can be accessed and all from the same DLL. I don't need ...
4
votes
3answers
348 views

Avoiding constructors with many arguments

So I have a factory which creates objects of different classes. The possible classes are all derived from an abstract ancestor. The factory has a configuration file (JSON syntax) and decides which ...
3
votes
3answers
95 views

Relational table design for data ownership

Setup (schema simplified for clarity) Suppose I have a table called resource: +---------------+--------------+------+-----+ | Field | Type | Null | Key | ...
5
votes
4answers
272 views

Object with Customized Properties and Methods

A project I am working on currently models Order information. Right now, there is one class with a bunch of properties and functions that all of orders have in common. In addition, some of our users ...
2
votes
3answers
142 views

What is the purpose of a wrapper class that does nothing but delegate to the object it wraps?

The specific example I have in mind is javax.servlet.ServletResponseWrapper: public class ServletResponseWrapper implements ServletResponse { private ServletResponse response; /** * The ...
5
votes
2answers
171 views

Factories, vectors and smart pointers - Design Question

So, my Business Code needs some Objects. It does not know how much objects it needs and it does not know the exact types (because polymorphism is involved). For me, that sounds for a good reason to go ...
5
votes
1answer
154 views

Call base inside overriden method

I know there are questions about calling the base method inside an overridden method such as this. But what if an overridden method only calls the base class? Is this bad/good deign? It just seems ...
3
votes
1answer
98 views

Single Responsibility Principle : Proxy Pattern for refactoring

However, in cases where the tests did not force the separation, and the smells of Rigidity and Fragility become strong, the design should be refactored using the Facade or Proxy patterns to ...
7
votes
1answer
135 views

Is event sourcing only for when writes are rare?

I'm reading up on event sourcing and can't stop asking myself if it only makes sense in exotic situations where writes are very rare or military-grade auditing is required. A non-exceptional system ...
2
votes
1answer
71 views

How to get the behavior class from its data class when they are separated for the purpose of server-client communication?

I am writing a server-client program with the following idea (analogy for my real program). There are many types of shapes. The client represents the shapes to the user which can queue operations ...
9
votes
4answers
300 views

Parameter management in OOP application

I'm writing a medium size OOP application in C++ as a way to practice OOP principles. I have several classes in my project, and some of them need to access run-time configuration parameters. These ...
0
votes
0answers
23 views

pipeline step with two outputs which will be used by different later steps

I am creating a java package which offers an API based on a pipeline pattern. That is I have a series of steps which can be plugged together in any combination provided their inputs match the Output ...
4
votes
3answers
175 views

Alternatives to Singletons for caching lists of data?

In my project, I have an abstract Cache class that allows me to populate a series of lists that globally persist throughout my application. These cache objects are thread-safe and can be manipulated ...
-3
votes
1answer
124 views

Is there a pattern to map a range of numbers to a string?

I need a function that will take the name of a town and return a specific range of numbers that is assigned to that town. I won't be using a database. The simplest way to do this is //Pseudocode ...
1
vote
3answers
114 views

How To Extend Parent Methods in Children Classes?

There is a parent class with a method which many children use but many children extend the method, what is the best way to extend it without violating DRY? Here are my 2 current solutions: 1: The ...
0
votes
1answer
62 views

Abstract classes with static methods in PHP

Pre: I am looking at a quite big PHP project developed by a company which we need to partly interact with while building a new webapp. The whole application is developed in PHP 5. Most of the ...
0
votes
1answer
177 views

What is the name of this design pattern?

Magento has a class called Varien_Object with a pattern I'm trying to identify. The pattern creates hidden data and allows access to it but the main difference between this and a normal facade is ...
0
votes
2answers
146 views

Tips for working with badly designed software [closed]

Currently in my job im working with a lot of older php systems which don't follow normalised design patterns and are frankly, a mess. As an ethical developer and someone who always strives to better ...
0
votes
1answer
107 views

Could this class be considered as a Factory class? [closed]

I've recently worked on a reusable network service class for a service-aggregator iOS app. This class should retry a failed request if it was caused by expired user token. Plus, this class will be ...
0
votes
0answers
47 views

UML Modeling - Creating flexible Pattern Viewer, extending context leads to too much changes

What I'm trying to make with jsp's java and servlets is a web based 'selector' for patterns. Here you can see all the design patterns there are (like www.oodesign.com). But for learning purposes I'd ...
1
vote
1answer
103 views

Extensible way to create bash program

I have a bash script that should be extensible with additional functions with as little change to the script as possible. The basic function is as follows. It loops through a list of files to check. ...
1
vote
1answer
80 views

How to handle multiple “valid after {date}” in a performant way

We work on an Application which displays a duty roster and also some other DateTime related things. So my Database is full of Relations like in this small Example: This results in big ...
0
votes
1answer
110 views

Should I hold an Id and the Item [duplicate]

Let's say I have a Customer which contains an Address class like: public class Customer { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; ...