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

learn more… | top users | synonyms (1)

2
votes
1answer
286 views

Thoughts on having a generic, reusable grid viewmodel

I'm developing a wpf-based application and I'm currently struggling to find the best way of supporting a recurring scenario in it. This app uses grids a lot. There are a bunch of features I want in ...
29
votes
6answers
5k views

Is an event loop just a for/while loop with optimized polling?

I'm trying to understand what an event loop is. Often the explanation is that in the event loop, you do something until you're notified that an event occurred. You than handle the event and continue ...
1
vote
2answers
155 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 ...
1
vote
1answer
54 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 ...
6
votes
2answers
804 views

How to use SOLID principles in this example

I have reading about SOLID principles last week and decided to try to solve real world problem by using them. So I got the problem of real world ecommerce site managing totals. Problem Statement: ...
2
votes
1answer
109 views

Explain ServiceLocator pattern of ZF2

I am looking at this example: http://framework.zend.com/manual/current/en/user-guide/database-and-models.html Relevant excerpt from above: class AlbumController { public function ...
17
votes
9answers
3k views

Is writing your own Data Access / Data Mapping Layer a “good” idea?

We're currently in a situation where we have a choice between using an out-of-the-box object-relational mapper or rolling our own We have a legacy application (ASP.NET + SQL Server) where the ...
0
votes
3answers
195 views

Client-Server Application Object with child Objects

Actually I'm going to build an Client Server Application, at the Login I recive the User Object from the Server. An user has a List of tasks, but I don't want to load them at the Login. So what would ...
4
votes
2answers
88 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
47 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 ...
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 ...
3
votes
1answer
283 views

is this a valid javascript design pattern when many instances are required?

I have some code that I'm refactoring, right now its just a list of functions, primarily jQuery. The code is a form builder. The user adds sections, questions etc using jqueryUI drag/drop/sort. They ...
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 ...
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. ...
3
votes
1answer
704 views

Do I need JUnit tests for the controller layer on a MVC when I have a database layer

I have a MVC which has this structure: ui controller db model Basically the controller doesn't really do much more than connection ui with db layer. Do I need to provide JUnit tests for the ...
0
votes
1answer
149 views

Object Communication Design

Multiple top-level systems that communicate with each other via messages(events/commands). The Main class of the program wraps around all the systems and has a message dispacher component wich ...
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
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 ...
8
votes
3answers
1k views

Is using interfaces for datatypes an anti-pattern?

Suppose I have a various entities in my model (using EF), say User, Product, Invoice and Order. I am writing a user control that can can print the summaries of entity objects in my application where ...
1
vote
1answer
200 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
4answers
411 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 ...
6
votes
1answer
178 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 ...
11
votes
4answers
3k views

What is the difference between Single Responsibility Principle and Separation of Concerns

a)What is the difference between SRP and SoC? Perhaps that SRP is applied at class level, while SoC can be applied at system, subsystem, module, class or function levels. b) If answer to a) is yes, ...
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 ...
3
votes
1answer
153 views

What design pattern is used in this delegating scenario?

I am currently having to bend some framework API to fit my usecase. The framework provides generic interfaces such as public interface Processor<T> { T process(T t); } with various ...
1
vote
1answer
87 views

Is this a Model or a ViewModel?

In a login screen, a user may expose his username and password data. The same way, in a user list screen, it may expose user name, age, and phone. But none of this views may expose any other user ...
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
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 ...
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
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, ...
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 ...
0
votes
0answers
63 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 ...
-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 ...
51
votes
2answers
19k views

Communication between nested directives

There seem to be quite a few ways of communicating between directives. Say you have nested directives, where the inner directives must communicate something to the outer (e.g. it's been chosen by the ...
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): // ...
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 ...
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 ...
1
vote
0answers
91 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 ...
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 ...
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 ...
3
votes
2answers
774 views

How do you apply Single Responsibility principle to a repository

I am trying to apply "SOLID" whenever I can and try to use common sense and avoid a pattern when I see that a pattern is creating more problems than it's trying to solve. I don't want to apply a ...
8
votes
4answers
2k views

Is the Single Responsibility Principle applicable to functions?

According to Robert C. Martin, the SRP states that: There should never be more than one reason for a class to change. However, in his book Clean Code, chapter 3: Functions, he shows the ...
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 ...
22
votes
4answers
30k views

Should angularjs directive directly interact with services or is it considered an anti-pattern?

Which one is considered better: having a directive that interacts with services directly or having a directive that exposes certain hooks to which controller may bind behaviour (involving ...
1
vote
2answers
124 views

Reusing the logic in another repository in ASP.NET MVC repository pattern

I have an ASP.NET MVC4 web application, with EntityFramework for data access. In the application I have two repositories as follow (this is only an example not my real code): public class ...
3
votes
2answers
238 views

Simple and Composite transactional services: Question about separation of concerns and transactions

I believe I know the answer to this but I'm looking for any holes or anything I may be missing. This is focused on Spring and Java but could really apply to any programming stack. Anyway, we have a ...
74
votes
16answers
57k views

Is it better to return NULL or empty values from functions/methods where the return value is not present?

I am looking for a recommendation here. I am struggling with whether it is better to return NULL or an empty value from a method when the return value is not present or cannot be determined. Take ...
-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 ...