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

learn more… | top users | synonyms (1)

0
votes
0answers
51 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 ...
3
votes
1answer
112 views

A “sort of” Units of Unit of Work

I've read Unit of Work pattern and tons of MVC/EF Unit of Work examples but what I'm trying to do is encapsulate multiple unit-of-work into a large set. Maybe this pattern already exists somewhere, ...
1
vote
2answers
140 views

Suggestions to distributed service pattern

We expose some webservices on a server, written in C#. Now we have to distribute the services to multiple servers, so the solution is distributed. And each request is dispatched to one the servers to ...
1
vote
0answers
65 views

Data Mapper pattern vs. model encapsulation

I am currently developing my first custom data mapper layer but have run into a conceptual problem that seems to be glossed over all books and guides I have read. My problem is as follows. My data ...
3
votes
2answers
126 views

How do you handle sequentiallity in API's?

Consider a use case of the form: The system shows a list of potential filters (by name, by creation time...). User chooses a filter and supplies necessary parameters. System shows a list of ...
0
votes
0answers
93 views

Multiple inheritance in ASP.NET MVC Controller

In one case BaseWizardController should implement background functionality of BaseController->BaseConsumerController, in other case it should implement only BaseController. Any ideas how can I do ...
0
votes
2answers
148 views

Good design pattern to enable/disable certain functionality based on condition

I am working on a paint type application in android. I got toolbar on left contains tools like undoCut, redoCut, box, frame, cutting, coloring, next, previous etc. I wanted to know what is the best ...
1
vote
0answers
61 views

is Command appropriate software pattern for this?

I have following task: I need to send several instructions after each other to the hardware. Next instruction is never sent before either answer to previous instruction comes (valid answer or error) ...
0
votes
1answer
100 views

How to make it clear I'm violating Command Query Separation

Command Query Separation is a useful principle, though it's not always ideal. Sometimes you need to run a process, which will result in useful data you need to return. My specific case is uploading a ...
0
votes
0answers
72 views

Proper way/place to apply decorator pattern for view layer in mvc

I have an array of model objects containing data some of which is states represented by integers. In the view these states are shown as icons and tooltips. The tooltip is needed only in the view and ...
0
votes
1answer
66 views

Architecture of approval process

I want to design an approval process for my work flow but I wonder if there is an architecrural pattern or desing pattern for this solution. For example an engineer will create a work. And program ...
3
votes
2answers
177 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 ...
3
votes
1answer
96 views

Snap to grid functionality in drawing application

I'm working on drawing application and I want to provide grid with snap to grid functionality. I'm trying to find the right way how to do that (ideally some design pattern), but I'm quite confused ...
1
vote
2answers
70 views

How should an entity that abstracts an external service do its operations?

I'm creating a system using some DDD principles and I'm stuck with a problem. To give a bit more of context on what I'm trying to do, let me first describe what the system is about: The ideia is to ...
0
votes
0answers
29 views

Unifying database interface for multiple authentication methods

I'm working on a project with Mongo as the db. Currently, we only allow users to sign up with email and we look them up in the db by email address. But now we're moving to allow users to sign up ...
-2
votes
2answers
131 views

How do you hash 4 doubles into a size_t?

I have bounding boxes the key type. Box { double mins[2]; double maxs[2]; } And I want to have Box as the key type in the D programming language, so I have to implement: size_t toHash() const ...
1
vote
1answer
163 views

Function pointers vs. Derived classes

So I have a Signal class and a client class which manages a list of Signal objects. The class provides a bunch of interfaces, one of them is an update()-function. The update()-code is completely ...
1
vote
2answers
106 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 ...
1
vote
1answer
116 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
181 views

Respectable design pattern for making node modules flexible/testable?

I am looking to get some input from some more experienced testers than what I am. :) I am trying to make my node modules testable, allowing for dependency spying/stubbing/mocking without the need to ...
5
votes
2answers
144 views

Is Module Pattern in JavaScript is useful only for singleton creation?

Some articles (JavaScript Module Pattern In Depth, Mastering The Module Pattern) describe defining modules in JavaScript like in the snippet below (from Addy Osmani's "Learning JavaScript Design ...
2
votes
1answer
142 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 ...
1
vote
2answers
171 views

Is this an appropriate code structure, or is there a better one?

This is an iOS app but I will try to make it as general as possible because I think a wide audience could have good feedback. I have a application I am making for iOS. It has 4 main tabs in a tab bar ...
3
votes
2answers
325 views

Is turning a method into a class to use it across many classes bad practice? [closed]

Let's say I have a sort method inside of my class and another class that has no relationship with that class needs the same method. Instead of writing that method twice and breaking the do not repeat ...
37
votes
7answers
7k views

Why is chaining setters unconventional?

Having chaining implemented on beans is very handy: no need for overloading constructors, mega constructors, factories, and gives you increased readability. I can't think of any downsides, unless you ...
4
votes
2answers
225 views

Does such a design pattern exist? (Multi-Strategy/Multi-Traits)

Is there a design pattern that would allow a class from a hierarchy to 'subscribe to' concrete methods? For example, say you have an abstract base class that requires the implementation of a method. ...
1
vote
1answer
100 views

Compiler design prevent register override

I'm trying to write a compiler for a self-designed CPU with accompanying instruction set. The CPU has 3 registers, 2 input registers (B and C) and one output register (D). When for example an ADD ...
6
votes
1answer
214 views

MVC - Do I create 'joint' layers when dealing with multiple models?

I'm new to MVC and the different layers architecture and this is what I have currently: 2 models: User, Company 2 service layers: UserService, CompanyService 2 interfaces which abstract the ...
0
votes
2answers
98 views

Design pattern to holds API exchanges? [closed]

I'm developing a simple application that crawls in web pages to obtain some information. For this I used and tested some libraries, like crawler4j, jsoup, jaunt and htmlunit. I exchanged several ...
7
votes
1answer
193 views

Is there a term for splitting a function into “prep” and “do” halves?

I'm revisiting old code, and I noticed that the main logic is in one method, which is longer than I'd like (~60 lines). So I split it, and there's a natural seam on which to do so: the first half ...
0
votes
0answers
75 views

File based communication vs Rest or RPC

My company make automation machines (with a PC inside and a custom built software to control it). So, for the purpose of this question, we can say that these are normal PCs. Sometimes we have the ...
6
votes
8answers
668 views

Can “return this” pattern be optimized to no cost performance?

return this (or similar construct) allows method chaining. Lack of it is painful, because you have to write such code (C#): var list = new List<string>(); list.Add("hello"); list.Add("world"); ...
1
vote
1answer
221 views

JavaScript & AngularJs Modules Implementation technique and structure

So Im building an app and I'm trying to implement the structure of the app so that its robust and scalable in future. My app is mostly divided into JavaScript Modules (revealing pattern): // ...
2
votes
1answer
126 views

Is IntentService an implementation of Command Pattern?

According to Wikipedia: In object-oriented programming, the command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or ...
0
votes
0answers
105 views

Option<T> functional type implementation and scenarios

Have you ever being implementing Option<T> functional type? It is discussed here: https://app.pluralsight.com/library/courses/tactical-design-patterns-dot-net-control-flow/table-of-contents ...
1
vote
1answer
137 views

How does the copy and paste mechanism work and is it a standard design pattern as in GoF?

How does the current copy and paste work on a computer? Such as being able to copy some formatted text together with an image, and then when pasted to a text editor, it will intelligently paste only ...
2
votes
1answer
88 views

Message Mapper Design Considerations

Long question context, skip to tl;dr for the meat of it. I am designing an integration between two web applications, and have come to the conclusion that a message pattern would be an appropriate ...
1
vote
1answer
113 views

Intelligent builder pattern - different parameters depending on type - generics?

Lets say we have the famous Joshua Bloch Nutrition Builder and we want to change it so it be a bit like dynamic builder which restricts visibility of setters and propably uses generics : public ...
26
votes
8answers
5k views

Is it a good practice to use List of Enums?

I am currently working on a system where there are Users, and each user have one or multiple roles. Is it a good practice to use List of Enum values on User? I can't think of anything better, but this ...
-1
votes
1answer
67 views

(Re)structuring a Qt Project [closed]

A PySide project I've been working on for a while now has started to grow to a point where it's becoming large enough that I've had to step back and re-think the overall design. I've spent some time ...
2
votes
2answers
96 views

Design pattern for abstracting interaction between multiple resources

So far I've been building applications abstracting data entity operations behind the use of Repositories. Each of them would encapsulate the domain that corresponds to their defined entity. For ...
2
votes
0answers
83 views

Building a generalized notification system: passive vs. active

Recently, I've tried my hand at building a notification system, but I quickly found that notifications are tricky things, especially in the context of building a general model. The diversity of what ...
8
votes
4answers
421 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 ...
0
votes
0answers
49 views

Advantages of having multiple apps or sub apps SPAs in AngularJS SPA

Having you application comprise of multiple child apps is good for readability and debugging. However, other than that is there any advantage over performance or memory management or Garbage ...
2
votes
1answer
152 views

Using prototype/non-Spring managed beans in Spring Web application

I have been working on few web applications/REST web services recently (Spring IoC/MVC/Data JPA etc) and they usually follow the same pattern: Controller classes --> Service classes (which have number ...
2
votes
3answers
178 views

Command pattern and open-closed-principle

Does the command pattern uses OCP ? In a command patter the invoker is only extensible by actually extending the class. If we want to add custom methods to it, we can make our own sub-class or we ...
1
vote
1answer
47 views

Repository Pattern Class Collection examples with Lazy/Eager loading

When implementing the repository it's fairly easy for a stand alone class. Unfortunately, we are unable to use an ORM to manage our data access, so I'm trying to recreate some of the functionality ...
2
votes
1answer
111 views

Improving sampling algorithm

I am having a bit of trouble designing a new feature at the moment. It is part of a resource management system. I was wondering if anyone has experience doing anything similar. I'll try to explain: ...
1
vote
1answer
149 views

Making more than one instance of factory that is supposed to be singleton

However, there are some classes that should have only one instance. Sometimes they are factories, which you can use to create the other objects in the system. If more than one factory ...
1
vote
3answers
179 views

What is the correct name for this data object?

I need to understand the proper name for an object that has cropped up in two projects now. Here is the conventional representation for the MVC pattern: However there is another "Model" that is ...