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
48 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 ...
4
votes
2answers
87 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 ...
1
vote
0answers
45 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
149 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
262 views

Is turning a method into a class too use it across many classes bad practice? [on hold]

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 ...
33
votes
7answers
6k 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 ...
0
votes
0answers
49 views

Python Micro-services Architecture

I have a Python-Flask webapp that stores data in MongoDB using an ORM. I want to extend this app and add a Apache Storm based micro-service that will require read & write access to dbs of the ...
0
votes
2answers
85 views

New Project starting point [closed]

So let’s say you are going to start a new project with a bunch of classes, and ready user case etc. How do you start coding it? Do you take one particular class implement it as good as you can, then ...
4
votes
2answers
200 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
91 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
176 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
85 views

Design pattern to holds API exchanges?

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
152 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
1answer
97 views

How to implement strategy pattern on N-Tier application?

Well, i have a N-Layer MVC project which is something like: Domain > Repository > Application > Presentation I have a feature on the website where the user put some monthly expenses (food, gas, ...
0
votes
0answers
62 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
625 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"); ...
0
votes
1answer
98 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): // ...
0
votes
0answers
42 views

Laravel Modules based structure

I am building a social network app and I have decided to have following features as of now. Meetups / Events (Users will create events and other users will have options to join ) Q / A forum (mini ...
-2
votes
0answers
68 views

Using Javascript popups to create a workflow for legal experts writing and editing legislation [migrated]

I suppose this is a ui-flow question. I'm currently working on a project where a couple of the stakeholders are suggesting the use of popup windows, i.e. browser tabs, to create a workflow to ...
1
vote
1answer
73 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 ...
1
vote
0answers
90 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 ...
2
votes
1answer
122 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 ...
1
vote
0answers
44 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 ...
0
votes
1answer
104 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 ...
24
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
52 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
74 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 ...
1
vote
0answers
80 views

Configuration data structure for initialization [closed]

Many applications make use of configuration data structures. One could imagine the different subsystems of the application initializing themselves from the configuration data by walking it ...
2
votes
0answers
58 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
357 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
28 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
48 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
150 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
40 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
105 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: ...
0
votes
0answers
19 views

Better way to build SQL query from form input? [migrated]

Very new to php. Using XAMPP, netbeans. I am using a <form> to send various input parameters as a GET to retrieve data from a very simple two table MySQL db. After filtering the inputs ...
2
votes
1answer
141 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
176 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 ...
3
votes
1answer
136 views

Understanding Generic Repository Pattern

I am trying to understand the generic repository implementation. I have seen this line (or similar to it) in many examples: public interface IRepository<TEntity> : IDisposable where TEntity : ...
0
votes
1answer
84 views

Handling multiple asynchronous events - Wait for pending offers to process on new offer?

I have a programming problem, that I don't know how to solve. And while I have provided a sample of my code, I am interested in a conceptual answer on how to resolve this problem. On a tradeOffers ...
2
votes
1answer
39 views

How to implement Singleton on a Resource / ResourcesManager case?

This is a design pattern academic question exercise. We have a Resource class and a pure fabrication class ResourcesManager to manage objects w/ type Resource. The question is Given the following two ...
3
votes
2answers
170 views

Implementing “buy one get one for free” coupon logic for shopping cart

Trying to solve bogo coupon logic with proper design pattern, but having trouble identifying one. Use case: "Buy iPad get SmartCase for free" Suppose we have the following objects: Product: - ...
2
votes
2answers
145 views

is it bad practice that controller call repository instead of service?

is it bad practice that controller call repository instead of service? to explain more: I figure out that in good design controllers call service and service use repository. but sometimes in ...
6
votes
2answers
161 views

Strategy Pattern Implementation

I have to generate a code that will send through SMS or Email to implement the One Time Password (OTP) requirement of our client. I just finished creating the design using strategy pattern, . . This ...
2
votes
1answer
81 views

How to represent data objects gradually getting augmented in a pipeline [closed]

I'm working on a Scala data-processing program. Essentially we start with a collection of many small data objects, say, (eventId: String, basicInfo: Basic) and gradually filter out some objects and ...
0
votes
2answers
79 views

Which design pattern to choose when supporting multiple analytic tools?

I have spent quite some time learning all possible design patterns but I cannot find the ideal one for the following case. I am developing an iOS app where we are using multiple analytics tools like ...
-1
votes
0answers
44 views

Bind and trigger an event in jQuery pattern [migrated]

Commonly I bind an event with jQuery and then call it immediately afterward, such as when I set up positioning or visibility of some elements and whatnot. $('#myElement').on('click', function () { ...
0
votes
1answer
154 views

Which design pattern is it if any for providing a general logger interface?

I have a library where I want to use a logger but I don't have (and cannot) create any interface for it because I'll be using it on different systems that have nothing in common (and won't have). So ...
6
votes
3answers
290 views

Alternative to Anemic domain objects (Simple example provided)

I want to model (TV)Events and Reminders and I’m wondering what’s ‘the best’ way to model this. The requirements are roughly When an Event has no Reminder, a Reminder can be created When an Event ...
4
votes
2answers
114 views

Name of design pattern for single-observer

Is there an existing named software design pattern similar to Observer, but for the case where only a single observer is supported rather than a collection of observers. I find that I use this ...