Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [design-patterns]

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

1
vote
1answer
52 views

Fail over for application that does outgoing requests

We built an application that has a list of fixed intranet URLs and crawls these periodically, transforms the data, stores it in a database. We have the requirement that the application has some kind ...
2
votes
1answer
107 views

Traversing over two similar object structures using a pattern

Let's say I have an Object Structure like this that I import data into from a source: Reporting: Body: ReportingEntity: DocSpec Reports[]: ConstEntities[] DocSpec ...
1
vote
0answers
64 views

Is there a pattern/cleaner way of saving a large object with multiple nested classes?

I'm in the midst of a rather large project which involves decomposing a very old and large ColdFusion legacy application and creating some .NET services in it's place. Due to this, there are some ...
0
votes
2answers
41 views

Passing storage location to factory function vs storing it yourself

I have run across a bunch of code where they are essentially doing void CreateFoo(string foo_param_1, int foo_param_2, vector<Foo> *foo_storage) { Foo new_foo = FooFactory(); new_foo....
1
vote
0answers
108 views

MVC - How should components inside controller communicate?

I'm developing a level editor in Java. I'm designing its code in MVC. From what I've learned: controllers can have a direct reference (fields) to views and models. Views can have direct reference to ...
0
votes
1answer
77 views

Method for loading and running user defined code in .NET windows application

Are there any patterns that address how to have and application load and run user defined code at run-time? I am looking into developing a C# library that the users of a Test Executive application (...
0
votes
0answers
72 views

How microservices and EIP relates

I've been working some time in microservices architectures and have created multiple micro services using Spring Boot framework, let's say UserService, AccountService, BillingService, ...
0
votes
3answers
84 views

Start and exit actions in while loops

Sometimes I find it useful to have loops that do an action at the beginning and/or the end of a while loop. The best way I can think of for representing this in C++ would be: if(condition) { // ...
0
votes
1answer
107 views

Builder pattern in multiple stages

I like using the Builder/Director pattern to build complex objects. It works really well. The only restrictions (maybe it is not really a restrictions) I see is that all of the parameters for the ...
0
votes
1answer
123 views

MVP (Model-View-Presenter) Drawing Application

I'm trying to make a simple drawing application with the MVP pattern. Let's consider I want to be able to draw a circle and drag (move) the circle around on a JPanel. After the drag, the model should ...
3
votes
2answers
444 views

Is it a good idea to use Singleton pattern for an API manager?

So basically I am writing a wrapper for a REST API in objective-c so that our customer can easily use them in their iOS development. I am trying to find a good design pattern for this purpose, it ...
-1
votes
3answers
180 views

Should a simple factory method include the “new” operation?

For example, suppose I have a class to create a button with specific styles common to my app, I can have either Return a new modified object: public class ButtonFactory { public static Button ...
1
vote
1answer
93 views

MVC: How to use data model list in recursive views

I am trying to learn web app MVC in PHP.Most of the articles discussed about 1-to-1 MVC pattern given bellow Controller: gets user request & update model, Model: receives orders form Controller &...
3
votes
2answers
79 views

Is there any design pattern available for pushing data from devices to cloud?

Hopefully I am posting a question in right forum. As per https://meta.stackexchange.com/questions/68384/whats-the-difference-between-stack-overflow-and-software-engineering-se-previo `software ...
1
vote
0answers
47 views

How does “redux” decouple the different components so they can be tested separately in unit tests?

In the past we saw a big move from traditional MVC to MVVM for user interfaces: One of the primary motivations for MVVM is that the view and viemmodel are competely indepedently of each other and ...
1
vote
3answers
296 views

Easy to maintain ways that helps code readability in C#?

Say we start with a base class that states if an object is valid or not (included one interface and two child classes for discussion purpose), like: interface IValid { bool IsValid(); } public ...
14
votes
5answers
2k views

Is the use of ***Helper or *** Util classes containing just static methods an AntiPattern

I am often confrontated with helper or util classes in Java or whatever kind of language. So I was asking myself if this is some kind of Anti Pattern and the existence of these kind of classes is ...
2
votes
1answer
72 views

Persisting domain state without exposing underlying provider(s)

Working on a DDD application where I need to persist state. Here's a very simple example: public interface IRoot { public int Id { get; } void UpdateValue(int value); } public interface IState {...
0
votes
1answer
59 views

Adapting third party conversions

I have a couple of pieces of functionality that are similar but not quite the same. They both involve converting a type that I own to other types that are owned by a third party library, so out of my ...
0
votes
1answer
111 views

API gateway for web-fronted applications, is it worth it?

So am in the process of developing a new application and am welling to adopt a micro-services based architecture (am new to that). The problem is that the application will be exposed to the final ...
3
votes
2answers
226 views

What is abstract about the Abstract Factory?

I've been always wondering why the Abstract Factory Pattern is actually called abstract? I don't understand what is abstract about it? It somehow does not fit in the image of abstract classes that I ...
1
vote
2answers
357 views

Patterns for tracking state in recursive Haskell code

A frequent pattern in my Haskell code is element-wise recursion for transformation of a list with some carried state generated using the data in the list. Usually, this looks something like this: ...
1
vote
1answer
69 views

Cleanly testing multiple Preconditions before throwing an IllegalArgumentException so that all failures are represented

Motivation; I want to report on all the possible problems at once instead of having to peel the onion of every possible problem over and over. It also makes testing much easier because I can ...
1
vote
1answer
57 views

Ensure encapsulation and Open/Closed principle with Command pattern?

I'm developing a small multiplayer game. It'll be served by one websockets server and consumed by multiple consumers. As such I need to be cautious about concurrency errors. The general software ...
1
vote
0answers
65 views

Polling Postgres DB architecture

We are using Spring Integration DB polling which polls a table every second and executes some logic based on result. My questions are: What are some good practices we can implement to account for DB ...
1
vote
0answers
67 views

How to design the Unity Container?

I have three projects: WebAPI, Services and Repository. WebAPI has a reference to Services and Services has reference to Repository. Now I need to add a Unity Container for Services and ...
2
votes
2answers
215 views

Is it an antipattern to introduce complexity into a builder?

I've looked at various definitions of the builder pattern and whilst there's varying definitions, they tend to be focused on the broad definition of incremental construction. However, it seems that ...
2
votes
5answers
239 views

How to pass command line parameters to various parts of program

Consider a large program with many different parts that have a single command line interface, as is the case with most applications. How best do I handle passing various command line parameters, that ...
3
votes
2answers
75 views

Where do I encode value conversion methods in an MVC web app to display values in different unit systems in the View?

I have a use case where I do internal data computations using English system, due to various precomputed graph coefficients and other data already using the English system. But for output I need to ...
0
votes
0answers
56 views

Does putting javascript in my JSP file make it impossible to test?

The project I'm working on has lots of JSP files, some of which have javascript script blocks scattered throughout and some of these scripts interact with other javascript packages that are served ...
0
votes
3answers
766 views

What is a real-world usage for Prototype pattern in Java?

After having studied GoF Prototype pattern and taken a look into Java implementation using the Object#clone() method I am still confused about when to use this pattern in a real application? Please, ...
0
votes
1answer
48 views

How should “preparation” and “usage” of the same data be separated in a DDD application, if at all?

In most domains, there is an app that "prepares" data, and another app that "serves" the prepared data. The data, however, is from the same Core Domain, which causes some confusion in modeling. Some ...
1
vote
2answers
70 views

Should static and historical data be split in the API? To what extend?

The project is a read-only interface for a company database. In the database, there is some 'static' data about departments, in a Departments table. The value of these fields don't change with time (...
-1
votes
2answers
89 views

How to choose the most suitable solution for a problem given some choices?

To ilustrate my main concern let's start by considering a "trivial" typical problem, data filtering & parsing coming from a process and dumping the information onto something {gui console, file, ...
2
votes
3answers
165 views

Is there a pattern to describe a class that symbolises an instance of an instance of another class?

I am currently working on a project that generates videos from templates (a template being a collection of JSON files and assets). It seems natural to have a Template class that contains all the info ...
-3
votes
1answer
99 views

Enforce that all dervied classes and subclasses always define a member function

How to do I enforce that all classes that have class A as base define EveryClassHasThis()? Class A { public: virtual void EveryClassHasThis() = 0; } For example in the below simple case; how to ...
2
votes
0answers
62 views

Memento and releasing resources

Let's suppose we have a class whose state has to be saved and later restored, and we resorted to the Memento pattern for that. What if the state includes resources that have to be explicitly ...
2
votes
1answer
162 views

Designing a pause'able & resume'able task handler

I don't think the title describes the situation exactly. I apologize for the poor description. I'm trying to write a software system, in C++, that will have a heavy job (scanning the file system for ...
0
votes
1answer
101 views

Memento for inherited class

I have the following question. I have an abstract class that manages graphic elements. Let's call it GraphicHost. Something like that: class GraphicHost { class GraphicHostState { List&...
2
votes
1answer
1k views

Implementing a REST API in a Clean Architecture

I have been implementing a proof of concept application using Uncle Bob's Clean Architecture and I have run into a bit of a problem. Uncle Bob's architecture calls for the explicit separation of ...
1
vote
2answers
123 views

Stateless Service

I am currently working on a player design. Without going into details I have two main layers 1. Playback services 2. User Interface. Playback services consist mainly of Player service and Browser ...
-1
votes
2answers
70 views

Should the TotalGrandPrice be property or Order or Invoice

I'm developing a shop. I'm trying to figure out: where should "total_grand_price" belong to? "total_grand_price" = price of all order items - discount + shipping + taxex +- etc.... Should ...
0
votes
2answers
91 views

Which pattern use, Object with subtypes only differing properties

I have a simple class Notification, which has a few properties (title, body, op) and only getters/setters. Among all my project I'll use different kind of notifications, this is Notification objects ...
2
votes
4answers
260 views

Can I assume nobody deletes user generated content off my server's file system?

Situation Currently I'm developing a web service in which users can (generally) upload binary files. These files are stored in the file system of the host OS and some additional metadata about the ...
3
votes
2answers
175 views

Is conditional dependency injection based on environment a bad pattern?

Is it a bad design if we inject dependencies based on the running environment (production, testing, development, etc)? Consider the following container in Laravel as an example: $app->singleton( ...
0
votes
1answer
218 views

How should I manage user session in CLI application?

I'm developing a CLI based application. It has a "login" command to perform authentication: $ myapp login $ Type username: hector $ Type password: ***** $ Login success! Internally, myapp login ...
1
vote
3answers
318 views

How to handle fails caused by business rules and return reason to end user?

Let's say I have a asp.net-mvc application and I have to check that object can be deleted before deleting it. public class ItemController : Controller { public ActionResult DeleteItem(int itemId) ...
2
votes
1answer
121 views

How can i design this?

Say I have different types of operations which i need to perform. I have an abstract class 'BaseOperation' which has all the information common to all operations. Now i need to categorize these ...
2
votes
2answers
153 views

Input based data fetch optimization

Is there a cleaner/ better readable way to maintain and iterate many-many mapping rather than multiple if conditions ? (One way would be to store the mapping of ReportType -> DataSet Req. in the ...
-2
votes
1answer
131 views

Why EJB service Injection requires the specific subclass to be created?

Most Java EE guidelines suggest that we should define Abstract EJB services (APIs) and then define concrete implementations in order to conform with OO design principles. But at the injection point, ...