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

Modulizing vs Performance benefits

Modulizing software from my empirical experience seems to decrease performance, most of the overhead can be communication of modules, redundancy in computation, storage and depending on the ...
0
votes
1answer
39 views

Architecture for multi-tenant application

We've built a custom CRM for one of our clients. Stack: asp.net MVC, SQL Server, Azure Some of the logic / features were hardcoded specifically for this one client. Now, more clients want to use our ...
0
votes
0answers
31 views

How to apply Single responsibility principle on spring MVC architeture?

Since service class will handle all business logic together, how do I separate the service class to fit the Single responsibility principle? It looks like they are opposite principle.
0
votes
1answer
88 views

Can a class factory also save the object to a database?

How can a factory also save the object in the database? I want to create an object that consists of other objects. Pseudocode: firstObject = db.get....; secondObject = db.get....; expectedObject = ...
-1
votes
0answers
13 views

What architecture or design pattern fits for a API serving an application as retrieving data from content management system?

I want to create an app that gets data from content management system and serves an API to another app for using the content. So too many parsing objects and maybe manipulating them before serving in ...
0
votes
1answer
51 views

Java Design Pattern to Use for switching between 2 different endpoints

I have a legacy service that is running on-prem and have built a new service that runs on cloud which provides the same functionality. I have another java (spring) service which consumes the on-prem ...
1
vote
1answer
62 views

The main reason for using the command design pattern for game AI

I've been going through all the design patterns in context of game programming form this book, before starting my next big project. Apart from that I've been reading about them in more general context....
1
vote
1answer
42 views

Database Methods on Entities

I'm starting a new project and there is some internal debate on the right approach to writing objects to a database. CRUD operations require 3 parameters: DB Handle, DB Name, Collection Name. All ...
0
votes
0answers
12 views

Best way to design federated contribution and consumption of java modules

The problem I am trying to solve is, I am trying to write a platform where people can write and contribute certain tasks (java code following a contract to identify it as task) to the platform. And ...
0
votes
0answers
14 views

What pattern/framework would fit? Need to do soap-fetching multiple result pages hasMore-then-nextSoapCall

Core reason: Mainframe developers exposed search soap-services for different entities. Those soap services, have inconsitent indicator for pagination, xml tags are different, so that would require ...
0
votes
1answer
63 views

Design a 1D parking lot that could park a two wheeler (1 slot), a car (2 slots) or a bus (4 slots)

This question is an extension to this question. I am also brainstorming on this problem statement wherein a 1-dimensional parking lot having N slots will be having varying size parkings to do. A two-...
0
votes
0answers
27 views

Design pattern for fetching associated entities

I have a User model which has "Payments" in quotes because depending on the user, there could be multiple sources of payments, like StripePayments or BraintreePayments. Instead of writing all the ...
1
vote
2answers
85 views

Is passing an ErrorMessage to be populated inside the receiving method an anti-pattern?

I come from a Java background, and my colleague is from .NET. We are working on a Java project and I saw him create a method like this: public Object myMethod(Object[] param1, ErrorMessage ...
0
votes
1answer
24 views

How to resolve multiple user serve on multiple location appointment booking system

I'm trying to build an appointment system but at one point I stuck Problem: I define available slots for the next 7 days with help of a cron. I have multiple users serve service more than one ...
0
votes
1answer
61 views

How to model either relationship?

I am working on a project where a user can send email to either a contact from his directory (Internal) or type an email address explicitly (External Contact) or a mix of both. We also show the read ...
1
vote
1answer
49 views

Build an object from two data sources - Which design pattern would be suitable?

Problem statement - I have to construct an invoice (having line-items, legal details, payment details etc) using booking and payment information of a hotel booking. There are two sources for these two ...
1
vote
1answer
79 views

How to set nullable/optional property of database object to NULL in backend?

We are building API which mainly passes database objects back and forth between user and database, so the main flow of information is quite basic: Table (view) <-- ORM --> C#/Java/etc. Objects &...
0
votes
1answer
86 views

Can I use the memento pattern with multiple relationships and persistence?

I need to implement a rollback system and the memento pattern gets mentioned regularly as a solution to this requirement, but in all cases a single object is used and it works in memory, persistence ...
2
votes
3answers
162 views

Wrapping Object VS Copying Fields

Almost every software has a number of internal data structures that we don't want to expose externally (through APIs for example). Let's say we have a few classes representing 1:1 database tables - ...
0
votes
2answers
88 views

Can I add other methods to the classic Singleton Implementation?

I've seen Singleton design pattern represented like below. Always with just getInstance() method. My doubt is: once I get the instance of the object I need, if I would like to modify it don't I need ...
1
vote
3answers
45 views

REST Routes depending on Roles

I'm currently working on a project which will use a REST API and that's exactly what I'm working on and I'm using nodejs with express, mongodb and mongoose. I've users that can have 4 different roles:...
1
vote
1answer
78 views

Handling application-wide notifications from various layers of the application?

I have recently started updating portions of our corporate platform, and I've been trying to find ways to make the entire platform more efficient, better structured, and just cleaner in general. With ...
0
votes
1answer
64 views

Design issue with delegation, inheritance and dependency injection

My question relates to usage of delegation together with inheritance and dependency injection. I have a MailerService class that requires a delegate in order to do its job. Furthermore, I have a ...
1
vote
1answer
37 views

Repository pattern, call another API that updates a SOR's from service or repository class?

We are working on API's that call other API's that will inevitably retrieves/update a system of record like an SQL, MySQL or other database. Sometimes we'll have 3/4 layers of API's before the SOR is ...
1
vote
2answers
171 views

Can a state machine transition depend on the previous state?

I was wondering what the state machine for a video player would be like. I can think of two states : playing and paused. When the video is playing and the user clicks on a point in the progress ...
2
votes
3answers
217 views

Why is the Command desing pattern useful for game AI?

I'm trying to learn the Command design pattern and apply it to the game I'm working on. First I read about the general implementation, and I feel like I understand it pretty well. Now I want to know ...
4
votes
1answer
324 views

Why do we imlpement the Command design pattern like this?

I trying to learn the Command design pattern, I already know how it works and where it is used, but I'm a little bit confused about the implementation. So I know we need to set the context by ...
1
vote
0answers
52 views

How to represent a set of ephemerides?

I am writing software that deals with ephemerides—tables describing the positions and orientations of celestial bodies or spacecraft—and I am struggling with how to represent them in the ...
0
votes
1answer
79 views

Orchestrating Object Instantiation and Intercommunication

We have a C++ project managed by UML software, which generates code for instantiating and passing data between objects. Unfortunately, this software adds a lot of overhead to our builds and ...
0
votes
2answers
73 views

Appropriate design for restoration of previous states

This is a very common feature in software, and I am sure there is a whole deal written about it, but I really don't know what the technical term is, so here I am: I am talking about giving your ...
0
votes
1answer
40 views

Wrapping WCF client with Stream for disposing

I need to consume data from a WCF service, which pipes it through a stream. The data itself is contents of an archive file, so it needs additional logic, which I am splitting off into a separate class....
1
vote
2answers
102 views

Difference between MVC and ECS

Following reading Thomas Owens response (many thanks to him) on Is it reasonable to build applications (not games) using a component-entity-system architecture? and his explanation on what is ECS ...
0
votes
1answer
62 views

Passing messages through a chain of containers in python

When I write python code for simulations, I often end up with the following situation: I have a class describing the general environment which contains a list of instances of a class that describes ...
0
votes
0answers
30 views

Should I use the same class for the configuration and the runtime object representing the same entity?

I am building an reporting application. The database already exists, is populated by an other system, and contains an 'cuurent balance' table, with columns CustomerId and CurrentBalance In the ...
1
vote
0answers
69 views

Expected behavior from client when thinking about design patterns?

I'm confused about the behavior I should expect from a client when thinking about design patterns. To be more precise, I'm reading the Head First Design Patterns book, and on the difference between ...
0
votes
2answers
84 views

In what layer are the DTOs stored with CQRS?

The Domain has the Domain Models. The Infrastructure layer has Commands and Queries, forming CQRS. Commands return Domain Models, and Queries return DTOs. In any API, the DTOs are stored in the ...
-2
votes
0answers
25 views

Should subscriber contain application logic?

Should subscriber/listener contain application logic? For example my subscriber is listening Post object for send mail. Manage for sending (setting the recipient, sender, subject and content and ...
-2
votes
1answer
74 views

what is the real use of JS/Jquery in Asp.NET MVC application?

I am planning to design a new web application using ASP.NET MVC 5. I used to write a lot of JS/Jquery code on UI when I was a beginner with Web forms applications. After reading/learning a lot of ...
0
votes
2answers
162 views

What's the difference between Observer pattern and listeners?

I have used some kind of "listeners" where I have an interface implemented by classes that need to be notified of some event (e.g.: CurrencyListener, with a method currencyUpdated(Currency currency)) ...
-4
votes
2answers
172 views

Is this an anti pattern in Javascript?

A common pattern I've been using for JS/NodeJS applications is the following: import { utility1, utility2 } function exampleScript() { utility1() utility2() // Does something } Basically my main ...
1
vote
0answers
66 views

Hierarchy of models while designing a client for a RESTful service

I am trying to write a client for a restful service. I am confused in designing the models. Below are the details: I have a Model named UnicastMessageRequest, it's definition is like this: ...
3
votes
0answers
74 views

Optionally runtime properties

I’m looking for information on a pattern that I have used recently. The basic idea is that there is a type with a property that can either be compile-time (template parameter) or runtime (member). std:...
1
vote
1answer
160 views

to ISP or not to ISP?

I've got a design problem, and I figure it's not something totally uncommon so there must be some good practices out there. I have 2 domain entities: Process and Task. A Process is essentially a list ...
4
votes
1answer
214 views

Is it worth considering State pattern in this case

I've got the following state diagram that can be seen in Webgraphviz: digraph reload_states { rankdir=LR; size="8,5" node [shape = doublecircle]; Requested; node [shape = circle]; ...
0
votes
2answers
114 views

How to handle state of an object? And how to enrich the state transition logic?

I am designing a class that has a state. I wonder if I should expose that state in the interface in view of allowing a decorator to enrich the state transition logic. Shall my design expose ...
1
vote
1answer
80 views

Change request of a behaviour implemented deep in the call stack but is configured in the first calls

Problem: I have a complex system with many layers of abstractions. I need a different behaviour low in the abstractions, but to be configured high in the abstraction. Solution 1: Having a parameter ...
0
votes
2answers
104 views

Design Pattern to extract arbitrary field from arbitrary file format

Lets say I have multiple file types: .json, .csv ... etc These file types come in different formats: Second json structure Extra column added to csv etc. I need to extract fields from these files;...
6
votes
3answers
208 views

Repository Pattern vs DAL Object Creation

As far as I've learned, the IRepository should contain CRUD. Then we inherit this IRepository in our other Interfaces like IProductand implement IProductconcrete class ProductRepository, with methods ...
1
vote
1answer
65 views

Building object with arbitrary functionalities

I am trying to look for the right design pattern for the below scenario. I am trying to create an object/binary with different modules, a module is a functionality that I want to provide to that ...
2
votes
0answers
56 views

Coupling form fields to functionality: using a Command Bus?

I built an app where the app owner can build custom forms for each of his clients. The forms have default fields like "name" and "message" as well as custom fields for each client requirement, like "...