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

learn more… | top users | synonyms (1)

1
vote
1answer
87 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
132 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
74 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
75 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
131 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 ...
31
votes
12answers
4k views

Is it a code smell to store generic objects in a container and then get object and downcast the objects from container?

For example, I have a game, which has some tools to increase the ability of the Player: Tool.h class Tool{ public: std::string name; }; And some tools: Sword.h class Sword : public Tool{ ...
0
votes
3answers
149 views

Why do I want this class to extend an interface, and what is the right design pattern for this?

Suppose I have an interface Employee and there are many classes that implement it, such as Bob, Joe, and Mary, none of which may be changed. public interface Employee{ public void work() } public ...
1
vote
2answers
172 views

How can you enforce a “do you really want to do this” confirmation in a publically exposed API?

Is there a commonly (or rarely) used pattern for a "confirming you want to do this" message when calling a function from a library? I have a API that exposes some operations that are potentially ...
5
votes
2answers
121 views

Should repository have a method for every specific database operation?

When following the standard service and repository patterns, should your repository contain a specific method for every database operation or should you just use the general methods, e.g. update? Take ...
1
vote
0answers
66 views

How do I write an API that makes use of many smaller APIs?

I have a solid set of classes that do the following build tables from data and templates advanced form serialization build forms from data and templates launch overlays with forms/wizards short poll ...
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....
2
votes
1answer
100 views

Is it anti-pattern to alter domain model on front end?

We are making a quiz application, I'm trying to integrate my Angular 2 UI with the REST api. Our Quiz domain model consist of the following (simplified) hierarchy: -Quiz -Category -Question -Choice ...
3
votes
0answers
95 views

Generic request processing

I got a webservice that accepts multiple calls that require different handling and validation, using generics I've managed to create a common class that accepts a handler and a validator and it looks ...
0
votes
1answer
66 views

Complex Math Formula: Predict the value of variable if result is known

I have a very complex math formula/equation which involves exponential. Formula: X + 2 = Y *PS: The above is just an example to illustrate my problem. The real formula is way more complex than this....
3
votes
2answers
88 views

Could this be called a decorator pattern?

I want to add some extra methods closely related to Book without extending Book. So I found the decorator pattern. Most examples I have seen are eg. extending an abstract decorator class which ...
7
votes
3answers
506 views

Should a DAO be singleton or not?

I am developing a RESTful API and I think it is convenient to use DAOs for my resources because although I plan on just using memory to store them, I don't want to close a door to whoever is using my ...
2
votes
1answer
75 views

What design pattern(.Net) to use for multiple control design with multiple properties?

I have to design for a bunch of user control types, each of which share some common properties but some of which have special unique properties. For example, the common properties across all the ...
5
votes
1answer
90 views

Designing a flexible API with support for Callbacks

I am writing a Java library that needs to make http GET && POST requests. There will be two types of users of this library: Those with understanding of callbacks and know how to use them. ...
1
vote
2answers
199 views

Design pattern for managing three different objects

I´m looking for the best way to solve following problem: I have three lists of different objects: AppleJuice, OrangeJuice & Juice. All Juice properties exists in AppleJuice & OrangeJuice ...
4
votes
1answer
70 views

Best pattern to track actions inside a presenter

I have a MVP implementation, inside my presenter i have a lot of public methods like onSendMessage() for example. I need to track some of that methods, meaning track just call a trackClient....
1
vote
1answer
63 views

Knowledge base UI pattern

In our database backed (C# WPF / Entity Framework) application, we want to build a system to enter, store, display and search arbitrary content linked to our main entity. The challenge here is to find ...
0
votes
0answers
39 views

Viability of custom framework to serve RESTful API

Context For my end-of-year project at school I had to create a framework to serve a RESTful JSON API. I wasn't authorized to use a project like Ruby on Rails for instance, Sinatra is allowed since it ...
0
votes
1answer
97 views

What are the consequences of eliminating the ORM/ODM in a NoSQL based system?

In Martin Fowler's article OrmHate, he states the following: If you have an application problem that maps well to a NoSQL data model - such as aggregates or graphs - then you can avoid the ...
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: ...
5
votes
5answers
311 views

Do you generally send objects or their member variables into functions?

Which is generally accepted practice between these two cases: function insertIntoDatabase(Account account, Otherthing thing) { database.insertMethod(account.getId(), thing.getId(), thing....
2
votes
1answer
125 views

What functionality to expose in a database abstraction layer?

I'm trying to design a simple way of abstracting away data persistence behind an interface, but I'm having a hard time figuring out how much fine grained control should be exposed to higher layers. ...
0
votes
0answers
72 views

Best architecture for customising the character

I want to customize the game character before starting the level, for example, select what kind of weapon, armor, clothes, etc. There are several components and each component consist of several types....
2
votes
2answers
135 views

Placing preconditions in the right place

I am trying to figure out the best way to define the responsibility of checking preconditions. Let's consider the following case: we have an Event class representing a sports event and a Matchup ...
2
votes
1answer
84 views

What's the difference between an implementation detail and a technical concern

I just wanted to make sure that I understand and can properly articulate the difference between these two concepts. I've always thought of an implementation detail as being the internal workings of ...
13
votes
2answers
1k views

How to go about testing un-injectable code?

So I have the following piece of code in use all over my system. We're currently writing unit tests retrospectively (better late than never was my argument), but I don't see how this would be testable?...
3
votes
1answer
122 views

Is there a good way to use the front controller pattern for command line applications?

I am a PHP developer and I used to build web applications with one PHP file per page for a very long time. This resulted in duplicated logic and messy code (even though I didn't know it at the time). ...
5
votes
3answers
153 views

Breaking large class into smaller classes when they need a common state?

I am writing a parser for a fairly complicated language in C++. The Parser class is given a list of tokens and it builds the AST. Though only a part of the parser is completed, the Parser.cpp file is ...
0
votes
0answers
38 views

Lost in Presenter and other design pattern

I have an entity called Contact , that defines relationships with other entities and fields types (I use Eloquent). For different info non-fields, like getFullName, I use a Presenters like this: new ...
1
vote
1answer
129 views

Is using __import__('module_name') an antipattern in Python?

I'm currently refactoring a Python 2 project which includes the ability to add or remove plugins, which are Python modules implementing a given API. The main app accesses add/remove/update hooks in ...
1
vote
1answer
220 views

Name for this design pattern?

Background Working as a software engineer in the field of electronics, I often find that none of the existing design patterns i.e. GoF typically fit the bill for what I need to do. One of the ...
2
votes
4answers
291 views

Is it strange for a Builder object to have getter methods?

I have a fairly complex immutable data type that I'm using a builder object to instantiate. Currently, I have a setup where I parse a file, setting various fields in my builder, and then build the ...
2
votes
2answers
132 views

How should I represent mutable boolean state?

When I have some object with boolean state that can be changed (like a checkbox's checkedness), there are several ways I can expose it. Getter property, Setter method bool IsChecked { get { ... } } ...
5
votes
2answers
138 views

Recreating complex aggregates from a persistance source

I'm building a web application with C#, and I have an aggregate root which has several entities and value objects. Then I have a repository object which persists the aggregate to the database (I'm ...
4
votes
3answers
230 views

Enums and single responsibility principle (SRP)

I have been experimenting lately with enums, and I found out that in Java they can do much more than simply representing a fixed set of constants. Now, I am thinking about creating a new enum for my ...
0
votes
1answer
69 views

Is it bad practice to simplify constructor dependencies using a simple container when the class represents the entry point for a sub system?

I have a System which depends on Transactions, and a few other things. This list can become very long. Transactions can be (and will be) implemented in two ways or more, so every transaction is an ...
2
votes
0answers
87 views

Architecture design for Web API with single endpoint

Scenario: I have a situation where I need to refactor a Web service with a single API endpoint that uses complex logic to insert, update and fetch data from a database. The clients use one call, and ...
47
votes
10answers
6k views

Should we avoid custom objects as parameters?

Suppose I have a custom object, Student: public class Student{ public int _id; public String name; public int age; public float score; } And a class, Window, that is used to show ...
4
votes
2answers
240 views

What are the advantages of using multi-tenant architecture with separate db schemas per customer?

I have a client that wants me to build a SaaS application with a multi-tenant architecture, where different clients will go in a separate schema on the same db server. I have seen this architecture ...
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 ...
6
votes
2answers
237 views

Is the command design pattern a good way to reduce the number of dependencies in my class?

I recently realized that I have way too many dependencies in many of my classes. Now I am trying to solve that for the most important class. I think I have an idea how but I'm not sure if it is the ...
13
votes
4answers
2k views

Pattern for algorithm that outputs an explanation of how it gets to a solution when needed

The following scenario happened to me several times. I programmed a algorithm that solves a certain problem. It works fine and finds the correct solutions. Now, I want to have an option to tell the ...
3
votes
1answer
84 views

Is it bad to pass a reference to the behavior's owner object to the behavior?

Is it bad to pass a reference to the behavior's owner object to the behavior? For example, if I have a Duck and DuckBehavior class. DuckBehavior is a part of the Duck Class. But what if I need to ...
5
votes
4answers
200 views

Idiomatic pattern matching equivalent in Java

I'm building a simulator which parses some events from STDIN and "runs" them. My background is mostly functional programming these days, so it seemed natural to do something like this: datatype Event ...
5
votes
1answer
375 views

Software design: too many static objects?

About the subject I hesitated for a while between using singletons objects or plain static ones. After having read a lot of different opinions, I made mine: If you don't need to prevent ...