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

Should this be a state pattern, a table-based state machine, or something else?

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
votes
1answer
94 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 ...
0
votes
0answers
20 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 ...
3
votes
4answers
214 views

Would implementing a “Throwable Event System” be abusive?

I have been thinking for a couple years now about using Throwable events and implementing a sort of event system that uses throw to dispatch an event, or let a different method handle it with throws. ...
1
vote
0answers
43 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 ...
1
vote
1answer
294 views

How should one model an ExchangeService object (in ews-java-api) for sharing MS Exchange connections?

I am creating an application which uses ews-java-api to connect to an MS Exchange server. Once the connection is authenticated, the api dictates use of ExchangeService object for searching mailboxes, ...
1
vote
3answers
72 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 ...
0
votes
0answers
97 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
81 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
40 views

What's an optimal procedure to create a connected cyclic grid of nodes and edges for A* pathfinding

like the title says, I'm trying to create a grid of nodes that hold edges or connections to each other so I can perform A* algorithm to have objects traverse across them as seen in your standard RTS. ...
0
votes
1answer
78 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
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 ...
0
votes
1answer
111 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 ...
1
vote
3answers
248 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 ...
2
votes
1answer
42 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 ...
0
votes
0answers
24 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 ...
228
votes
11answers
67k views

How accurate is “Business logic should be in a service, not in a model”?

Situation Earlier this evening I gave an answer to a question on StackOverflow. The question: Editing of an existing object should be done in repository layer or in service? For example ...
6
votes
4answers
224 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
97 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,...
5
votes
1answer
308 views

Need to re-build an application - how?

For our main system, we have a small monitor application that sits outside our network and periodically tries to log in to verify the system still works. We have a problem with the monitor though in ...
0
votes
2answers
84 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). ...
8
votes
4answers
261 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 ...
18
votes
3answers
3k views

Equivalent of SOLID principles for functional programming

I've found the SOLID principles quite useful when thinking about object-oriented design. Is there a similar / equivalent set of language-agnostic principles tailored for functional programming?
0
votes
0answers
16 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
50 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 ...
3
votes
1answer
98 views

Getting posts from users that are being followed: two different implementations

I have two different implementations for retrieving posts from the users someone is following and I want to know which one you would recommend using. First I'l show you the tables, and then the two ...
1
vote
1answer
72 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 ...
0
votes
1answer
44 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 ...
1
vote
2answers
166 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 ...
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{ ...
4
votes
2answers
245 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 ...
2
votes
2answers
116 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 ...
6
votes
5answers
368 views

Can a pimpl variation be implemented without any performance penalty?

One of the issues of pimpl is the performance penalty of using it (additional memory allocation, non-contiguous data members, additional indirections, etc..). I would like to propose a variation on ...
1
vote
1answer
76 views

Layer application and token authentication

Suppose we have an application with multiple layers in .Net: Domain layer (entities) Data access layer (entity framework) Business layer Web Services layer (Web Api) Presentation layer (MVC) Now I ...
0
votes
1answer
103 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
86 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:...
1
vote
6answers
522 views

Possible way to make java class builder more abstract by using interface required keys

I'm looking for a more abstract pattern for builders that handles required fields without the need of writing a validator that checks if all requried fields are set. I like this builder. But is ...
3
votes
1answer
579 views

How do I implement role permissions in the service layer?

In my current project I have a Report class, and I am going to implement a service layer for it. Every method will be allowed only for some roles. Like this: public class ReportService : ...
59
votes
9answers
23k views

Why should I use a factory class instead of direct object construction?

I have seen the history of several С# and Java class library projects on GitHub and CodePlex, and I see a trend of switching to factory classes as opposed to direct object instantiation. Why should I ...
3
votes
2answers
132 views

How to use the MVP pattern in embedded systems?

I am defining the architecture for an embedded system provided with an LCD touch screen for interacting with the user. To describe my problem I can use a washing machine provided with LCD touch screen ...
2
votes
1answer
167 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 ...
4
votes
1answer
63 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
2answers
110 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 ...
2
votes
1answer
191 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
2answers
108 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 ...
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 ...
85
votes
4answers
18k views

What is an Anti-Corruption layer, and how is it used?

I'm trying to figure out what the Anti-Corruption layer really means. I know that it's a way to transition/work around legacy code or bad APIs. What I don't understand is how it works and what makes ...
0
votes
3answers
138 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
169 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 ...
13
votes
2answers
6k 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 ...