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

learn more… | top users | synonyms (1)

0
votes
1answer
41 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 ...
1
vote
1answer
49 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
147 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 ...
3
votes
2answers
120 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 ...
1
vote
1answer
47 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 ...
1
vote
2answers
185 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
60 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
111 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 ...
2
votes
3answers
187 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
45 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
137 views

Elevator design challenge [on hold]

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
2answers
102 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 ...
-4
votes
0answers
58 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 ...
0
votes
1answer
67 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 ...
1
vote
3answers
184 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
131 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
4answers
206 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 ...
-1
votes
2answers
189 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 ...
0
votes
1answer
31 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) {} ...
0
votes
3answers
101 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 ...
5
votes
3answers
221 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 ...
3
votes
0answers
62 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
votes
1answer
157 views

Want Some Advice on Structuring My Text-Editing Program

I want to make a small command-line-run program that looks for a word or phrase in a target .txt. or .docx file, prints out a corresponding blurb about that phrase, and then replaces it with a ...
2
votes
3answers
173 views

Unit of Work AngularJS

I am writing an application in Angular JS (1.5), and I need to be able to track a model for changes (updates/deletes/additions). For example, I have an ng-model that holds an array of user pets. This ...
1
vote
2answers
197 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
2answers
153 views

Which pattern to use when I want to encapsulate large blocks of code?

I have a data structure, a large dictionary, that is mutated by several functions. Each function does a database call, some calculations and then changes the value of a key in the data structure. Each ...
6
votes
5answers
586 views

What does it mean to “write code for patterns in problems” and not “for instances”?

I was reading this post on what it takes to become an elite developer: http://www.aaronstannard.com/what-do-you-need-to-become-an-elite-developer/ It says: "Write code for patterns, not specific ...
-1
votes
1answer
95 views

What is a good design pattern for monitoring a protocol handshake? [duplicate]

I am writing a program for monitoring communications between a server and multiple clients on a network. In particular Websocket protocol based communications. I construct monitoring objects for every ...
1
vote
4answers
134 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 ...
1
vote
0answers
62 views

What would you call this design pattern? MVC or PAC

I have been reading and researching about MVC, HMVC, MVP, MVVM and PAC design patterns when I came accross this article by larry garfield > MVC vs. PAC My Implementation: Think of a modular app ...
0
votes
0answers
108 views

A modification of singleton pattern

"Singleton" is widely considered anti-pattern ("bad" in everyday language). What about this alternative modified singleton pattern? An object constructor for our class ensures that at any given ...
0
votes
2answers
92 views

Static factory method in base class

An increasingly popular definition of factory method is: a static method of a class that returns an object of that class' type. But unlike a constructor, the actual object it returns might be an ...
0
votes
0answers
13 views

Design pattern for application development [duplicate]

I have a Window class, which represents a window (there is only one instance of it), and has an instance of every object inside it. For example: class Window { public: //... private: Button ...
1
vote
3answers
81 views

Return values for a delete function in php

I am writing a wrapper function for database calls, and I am confused about the best way to handle the error cases. The function has only one argument, the id of the object to be deleted. I've ...
-1
votes
1answer
99 views

How to design property files

I always wonder what is the best way to design your property files. I have few questions that I didn't find an answer to them Do we place all our labels / error messages in one file? Do we split the ...
1
vote
3answers
266 views

Business rules design pattern?

I'm working on an interface for implementing business rules in order to improve SOLID-ity; so I can move a lot of logic out of Web API controllers and into a business library. The Common Problem being ...
0
votes
0answers
26 views

The best implementation for fromJson factory method and json-mappings with inheritance?

I have BaseComponent (with field "type") and it's subclasses TextComponent, ListComponent, etc. Some of them has same fields. I want to create them and init their fields from json. Some of possible ...
3
votes
0answers
53 views

Where should view-specific data/logic be defined in a PHP MVC application?

After many hours of research and thinking I have found an understanding, then coming to question it again, I am struggling to find something concrete which I can grasp and apply to my code in a ...
6
votes
4answers
239 views

Is it too verbose to always have 'modified' time stamps on all entities within a database?

The question can be summarized as: In a database (regardless of type), would it be considered a good practice to always include updated, created (and possibly deleted) properties, for all entities,...
2
votes
2answers
98 views

Can a single Factory be used to create similar in purpose, but different in focus objects?

I am concerned about whether or not I am using FactoryMethod correctly. Background: I am refactoring legacy code and I have identified a pattern: there is a God Object that is created in memory,...
0
votes
2answers
88 views

How to remove circular reference when there is inter-dependence

I made an extensive research in previousv related questions, but since my questions is somewhat peculiar, I decided to create this new one. I am implementing a visualisation application (in JS). ...
9
votes
4answers
283 views

According to Demeter's law, is a class allowed to return one of its members?

I have three questions concerning Demeter's law. Apart from classes which were specifically appointed to return objects - such as factory and builder classes - is it okay for a method to return an ...
0
votes
0answers
23 views

Abilities interacting with aspects of other abilities - how to implement efficiently

In my game I want characters to be able to cast spells which deal a certain amount of damage of a certain type to other characters in the game. I also want abilities that negate an amount of damage ...
1
vote
1answer
60 views

UML: do I use aggregation or composition in this case?

I would like to draw a UML sketch to communicate part of a software but the type of relationship between classes does not seem very clear cut to me. Let's say I want to periodically fetch the recent ...
1
vote
1answer
82 views

How to decouple backend app?

I have heard this term many times, and it makes sense in theory. That app is doing many things and it'd be easier to manage, scale, test and improve them if they are not completely connected to each ...
2
votes
2answers
130 views

Ubiquitous language and resource based REST API?

I have posted a question regarding Ubiquitous language and maturity level in REST API. Ubiquitous language and maturity level in REST API? After some extensive coding I realized that further ...
0
votes
1answer
67 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
1answer
73 views

MVC: Display requsted content via the View

I'm trying to learn how the MVC pattern works so have been playing around a bit. I just wrote this, which was making sense to me, until I wanted to display the array content which has been collect by ...
0
votes
1answer
27 views

Should I create a settings provider implementing an interface for each handler?

Let's say I got a series of services that are handled by a central hub, part of the behavior of the application is controlled by a series of settings that are stored on a file. Right now when I get a ...
0
votes
2answers
126 views

Stateless vs Stateful ViewModel

Here are two links which briefly describe the difference between the two: stateless, stateful In short in the "Stateless" scenario we bind views directly to models, view models just expose the whole ...