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

learn more… | top users | synonyms (1)

2
votes
3answers
298 views

Pattern to use (if any) to co-ordinate loosely coupled classes with strong interdependencies

I have a collection of cooperative classes whose behaviors are interdependent upon one another. But I wish to keep them loosely coupled, so I've created appropriate interfaces. I want to determine an ...
2
votes
1answer
67 views

Unique Identifiers for classes - Java with Spring

My use case requires me to implement multiple validators which implement the interface: public interface Validator { boolean validate(Object o); } Based on the business group of the Object o, a ...
1
vote
2answers
109 views

What would the best way to design a giant API wrapper class with multiple 'sections'?

Here's the problem I'm trying to solve: There's a rather large API I'm trying to write a wrapper class around. The simplest approach would be to make one class with a method representing each ...
2
votes
3answers
1k views

What Design Pattern is separating transform converters

For converting a Java object model into XML I am using the following design: For different types of objects (e.g. primitive types, collections, null, etc.) I define each its own converter, which acts ...
4
votes
1answer
106 views

Name for design pattern where “token” object manages lifecycle

This is a common design pattern, but what is its name, and are its pros/cons discussed in any open literature? What do you think the pros/cons are? // get a token object that identifies this ...
1
vote
0answers
31 views

Selenium Test Design Struture - Test Granularity for a Large Project [migrated]

Summary I have large Selenium Test project, and I'm struggling with how to manage my test structure in a way that I feel is easily maintainable, scalable, and that provides a good level of test ...
5
votes
3answers
4k views

Best approach for multilingual Java Enum

I'm running into issues with an approach I am taking and am now wondering if I just started down the wrong path and should rethink my approach. Here is what I attempting. I would like to use an Enum ...
2
votes
3answers
102 views

Base Class vs Common Member Class

Imagine I have two classes like this... public class SingleplayerGameSetup { public int Seed { get; private set; } public int AiNations { get; private set; } } public class ...
0
votes
1answer
35 views

Should different data resource types have different data mappers?

In my application I have to consume data from an API, do some processing and then store the data retrieved from the API in my own database. Should I have multiple Data Mappers? One for the API and ...
0
votes
1answer
96 views

Where do I create/instantiate repositories in DDD that are used my Domain Services

From what I understand a DomainService should be implemented against a RepositoryInterface, so we could change with easy the repository (which its a part of the Infrastructure layer) So, if I have: ...
0
votes
1answer
136 views

Is pubsub pattern suitable for my case?

I'm planning to use pubsub pattern with azure service bus in my logistics application.but I'm confused whether pubsub pattern is suitable for my case. My scenarios: users will subscribe set of ...
4
votes
2answers
107 views

Updating multiple entities at once using the data mapper pattern

I have been studying software architecture and design patterns for the past weeks, and for a week now I can't stop thinking about the performance problems that come with the flexibility of the data ...
1
vote
1answer
48 views

How to deal with different configurations with non-overlapping properties?

I am working on a project based on the Java EE technology. First I'd like to tell you what I want to achieve, then what I already tried. Task: Imagine two types of configurations, which you want to ...
4
votes
2answers
147 views

Is it okay to use static classes while creating a wrapper for REST API?

I am consuming a web service in C# using REST APIs. So, I have created a wrapper classes for each endpoint. It seems like a good idea to implement the wrapper using statics. This makes code look much ...
11
votes
4answers
8k views

Is the Entity Component System architecture object oriented by definition?

Is the Entity Component System architecture object oriented, by definition? It seems more procedural or functional to me. My opinion is that it doesn't prevent you from implementing it in an OO ...
1
vote
1answer
55 views

How to prevent “updating” unchanged date using Data Mappers?

In some books the implementation of Data Mappers simply update the whole row of a table using the data inside an object, but in a system is possible that two different operations update different ...
2
votes
2answers
167 views

Is 20 Java classes for just making a REST call too much?

In an Android project, I am using dagger 2 for dependency injection, applying mvp design pattern, and I am writing interface for almost every class. Although it does achieved the separation of ...
1
vote
1answer
52 views

Pattern for creating and accessing temporary data for multiple http request?

I want to store temporary data that can be accessed across multiple http request. The question may be similar to How to persist temporary data over multiple HTTP requests?. The accepted answer is too ...
2
votes
2answers
203 views

Design classes to prevent future code breaks

I'd like to design a robust version of this class (C++11): class Oscillator { private: std::vector<double> trajectory_; // Some numbers that are needed to get the trajectory ...
0
votes
2answers
63 views

Relation between UnitOfWork and DataMapper

I have been studying DDD for 1.5 weeks now, and I came a cross the use of the Unit Of Work pattern together with Data Mapper pattern. I understood why they are both important and when to use them but, ...
0
votes
1answer
124 views

What's the OOP way of dealing with a flow control heavy application?

I'm refactoring a huge WPF application whose complexity stems from the way it deals with flow control. It has a lot of "tiny business rules" that make it really difficult to make a modification ...
9
votes
4answers
693 views

Programming style in Perl

I work in Java so basically I use OOP paradigm during coding. I am about to start working in Perl and I was wondering what is the paradigm that Perl developers follow. In wiki it mentions that it ...
2
votes
3answers
205 views

Preemptive interfaces in Java - good, bad or “a matter of taste”

I frequently come across projects that strictly define an interface for each and every class. 90% of those interfaces feature only a single implementation. Proponents of these "preemptive interfacs" ...
0
votes
0answers
52 views

Did we have an evolution from detached entities to CQRS?

Let's say you have a software solution that has a data layer that accesses a SQL server. It can do this either directly and also over a HTTP connection. In both cases Datasets are used. Now when ...
1
vote
1answer
153 views

Elevator design challenge [closed]

I need to strengthen my OOP skills and hence I thought to implement an Elevator simulator. At first what seem to be a simple design has grown into a complete mess and has left me confused about my ...
4
votes
3answers
558 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 ...
1
vote
4answers
217 views

MVC and RESTful API service

MVC is pretty straightforward. There is a Model, a Controller and a View. When we create a website, it all come together as 'client sends REST keyword request to server -> the server matches the ...
0
votes
1answer
70 views

Questions regarding my MVC application

I'm learning .net MVC while developing a simple word list - Eg. When you learn a new language and create a list of words related to a certain topic. I don't think I'm following the rules or good ...
-4
votes
0answers
61 views

Extensible python project layout

I am developing a bot for a game I'm playing and i am having quite a debate as how should i structure my code. I designed my bot to be extensible, everyone can develop a module to farm something the ...
1
vote
3answers
189 views

Should I create .Clone() on a class or create a copy-constructor?

I'm quite unsure what I should use in C# - both should in theory do the same, but I think both are quite easely overseen. Or is there another possibility I have to take in consideration? I know in C++...
1
vote
1answer
139 views

Inheritance is better or composition design pattern in this scenario?

Design and implement Cash Register: Given a number of items you will be required to calculate the total bill. Items are charged for in a couple of different ways: A given price for each item, e.g. ...
1
vote
2answers
193 views

Repositories, Gateways, Models and Architecture Questions

I am working with a Laravel project and I am looking for a way to solve the issue of bloated models and cross referencing between them. I had started extracting higher level methods to a repository ...
0
votes
1answer
73 views

How to check foreign key dependency in ddd aggregate root

When I want to call a constructor on aggregate root class Task, I am interested how can I check if a passed taskType exists in TaskType repository (enforced later in DB on ORM level). I want to ...
4
votes
3answers
291 views

Generating Java Classes with Compile-time Value Parameters

Consider a situation where a class implements the same basic behavior, methods, et cetera, but multiple different versions of that class could exist for different uses. In my particular case, I have a ...
0
votes
1answer
116 views

Design to link two model classes with different multiplicity

It is usually well known how to deal with model classes that have a 1:N relationship: classical examples are order->items or client->orders. Every layer of the software has its appropriate and ...
0
votes
1answer
89 views

Android, access 1 activity from 2 cases, what design pattern is this?

I'm developing an Android app, encounter this case. There are 2 ways we can enter an activity (named activityB): either from activityA or from notification. 1st case: ActivityA -> activityB 2nd case:...
14
votes
2answers
7k views

Why should a builder be an inner class instead of in its own class file?

Many Builder Pattern examples make the Builder an inner class of the object it builds. This makes some sense since it indicates what the Builder builds. However, in a statically typed language we ...
1
vote
2answers
416 views

Service layer - fat service classes?

Let's say that I have a service for Job Offer entity in CRM app. Job offer is related to many many things, so there will be lot of methods on service layer to interact with above. What should be ...
-1
votes
2answers
191 views

Java - Does extending a class which itself extends a class which itself… and so on… is healthy..?

NOTE : Feel free to edit the title if it is somewhat different than my question. In one of our application, we are maintaining a lot of properties inside Instance object. Obviously it's maintained as ...
1
vote
2answers
199 views

State Design Pattern

I've come across the following State Design Pattern which seems extremely logical and simple to implement: class CeilingFanPullChain { private State m_current_state; public ...
0
votes
1answer
33 views

Separate context-dependent information from the core logic code

Say, I have a code file where all the core logic is located. In addition, I have some custom logic that is defined by some flags, like if (a && b && c) {} if (!e && f) {} ...
2
votes
1answer
233 views

Is there a design pattern to handle construction of complex objects with a [1 → 1..*] multiplicity relationship?

I have two classes (A and B) that are both complex to construct, with multiple properties that must be validated at construction time. I want to use the Builder pattern to construct these objects, but ...
5
votes
3answers
227 views

Java: How to implement a step builder for which the order of setters doesn't matter?

Edit: I'd like to point out that this question describes a theoretical problem, and I am aware that I can use constructor arguments for mandatory parameters, or throw a runtime exception if the API is ...
13
votes
3answers
660 views

Do named arguments replace the builder pattern?

When using a language that supports named and optional arguments, does the builder pattern no longer have a practical use? Builder: new Builder(requiredA, requiredB).setOptionalA("optional").Build()...
0
votes
3answers
104 views

Which pattern to create domain objects from web request objects [duplicate]

I'm a little confuse how to create domain objects right. In all/most web application we have simple objects created from POST request. We need to create domain objects that we will use in deeper ...
9
votes
4answers
505 views

Parallel hierarchies - partly same, partly different

There are quite a few similar questions out there 1, 2, 3, 4, but non seems exactly the case in this question, nor do the solutions seem optimal. This is a general OOP question, assuming polymorphism,...
1
vote
1answer
120 views

Polymorphic constants in Java

I am designing some polymorphic code to perform mathematical operations. The idea is to abstract out the underlying representation of the data, as different use cases require different representations....
3
votes
3answers
1k views

Should I use foreign keys in my database if I use laravel?

I'm creating a website with Laravel for the first time. I checked relationships documentation today and it seems that Laravel just uses simple SQL queries. class User extends Eloquent { public ...
1
vote
4answers
135 views

What layer should contain interactions with external or remote resources which are not strictly data operations?

Assume an application with a layered architecture, i.e. presentation, business/domain/logic, data access: it makes sense to plug access to external APIs in at the data layer if what they do resembles ...
129
votes
15answers
42k views

Do I need to use an interface when only one class will ever implement it?

Isn't the whole point of an interface to for multiple classes to adhere to a set of rules and implementations?