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

Why use a enum to create the singleton pattern [duplicate]

Why would you use an enum to create a singleton pattern? To what purpose would it serve over a conventional singleton pattern? I have seen the above used. The code uses an enum to create this pattern ...
2
votes
1answer
22 views

Applying initialization-on-demand holder idiom at variable level rather than class

I was looking for the idiomatic way to implement thread-safe lazy initialization for a configuration collection retrieved from the DB inside a Spring bean. I decided to adapt the ...
24
votes
4answers
25k views

What is the point of using DTO (Data Transfer Objects)?

What is the point of using DTO and is it an out dated concept? I use POJOs in the view layer to transfer and persist data. Can these POJOs be considered as an alternative to DTOs?
0
votes
1answer
141 views

Is this a pattern? If so, which one? (Contexts, Requests and Responses)

In most of my code nowadays, I adapted to an approach which I think I read in the context of "Clean Code". It was some years ago and I cannot find the source again, so I would like to know what the ...
0
votes
4answers
104 views

Client vs Creator in Factory Method and Abstract Factory patterns

This page descibes one important difference between Factory Method and Abstract Factory: http://architects.dzone.com/articles/factory-method-vs-abstract The difference, according to this page, is ...
3
votes
3answers
157 views

Is it misleading to label code as a particular design pattern if it only loosely fits the definition?

Background: I have a rough, but working understanding of ~15 design patterns. It's been my experience using design patterns in my own projects that the resulting implementations usually end up as some ...
0
votes
1answer
359 views

Interface questions for using Command Pattern and Dependency Injection together

I have many projects that have essentially the same high level requirement: test all hardware on a device. Each device can have a different communication protocol, requires different test equipment to ...
0
votes
0answers
65 views

Dealing with several custom getters

I have a data structure with data units containing different types of data. I've wrapped the data in "Field" objects so that each field is able to independently parse user input in a desired way. ...
3
votes
1answer
50 views

How should I represent composeable, associative computations to be repeatedly applied to units of data?

Spoiler My question is the following: Are there any design patterns for representing chainable functions that are for the problem described below? High-Level Decription of the Process I'm ...
1
vote
1answer
174 views

Best OOP pattern to use for creating a commandline SQL API for a proprietary json based company datastore

We need to create a SQL commandline tool for querying a proprietary json based datastore. I'll be using java. Any suggestions on the primary OOP design pattern I should use for building this API? ...
1
vote
1answer
89 views

Should make concrete factories in the same count of families of objects or according to stages in my problem?

I am programming a game. In this game I have 3 stages. In the first stage, there is a static goal and a static shooter in the game. In the second stage, the goal will move. And in the third one both ...
5
votes
2answers
496 views

How should I handle logger failures?

In several of our company's applications, we use a custom logger. It's fairly robust, though we may replace it with something like NLog in the future. One of the logger's tasks is to log any ...
0
votes
1answer
231 views

Is factory pattern a right pattern for the situation described here?

Is factory pattern a right pattern when we want to consolidate the related objects? Problem - In the Set-top box, I have a user-io, basically the interface to control the settop box - The user-io can ...
2
votes
2answers
107 views

Design pattern for composition workflows

Please bear with me as I find this tricky to articulate exactly what I am after (probably not a good sign..). I have several services set up which can be combined in a particular order to create ...
-3
votes
0answers
59 views

Designpatterns that are actually antipatterns or controversial discussed as antipatterns [closed]

Sometimes it happens that you think it is a good idea to use a specific and maybe even praised designpattern when writing some sourcecode. And then, while you are relaxed browsing some developer ...
1
vote
1answer
158 views

PHP - Repository matrix pattern?

I'm trying really hard to refactor some of my legacy code in the project using best practices and design patterns + DDD so I'd love some feedback on an issue I'm currently having. Let's assume that I ...
1
vote
0answers
119 views

When do I reuse or create a new Builder

I've implemented a Builder Pattern in a project I'm working. I'm using this design pattern to created Fields and Components (div, tables, panel (boostrap)). So I have a Director Component class. It ...
5
votes
2answers
409 views

Trying to identify IClass, Class, ClassImpl pattern

I've been seeing a lot of code recently that looks like this: public interface IFoo { int Bar(); } public static class Foo { public static IFoo Create() { return new FooImpl(); } private ...
5
votes
4answers
659 views

Design Patterns for Coordinating Change Event Listeners

I've been working with the Observer pattern in JavaScript using various popular libraries for a number of years (YUI & jQuery). It's often that I need to observe a set of property value changes ...
0
votes
1answer
68 views

Can JUnit be used to test this project?

I currently have an interesting situation occurring with my code, and after hacking away at what turned out to be a dead end for the last two weeks, I'm here asking those smarter than I to educate me ...
2
votes
1answer
103 views

Is Singleton enough for a EMailUtil or there is any better implementation? [duplicate]

I am developing an application, where I have to send lots of emails for user account creations, validation, invites etc. I have implemented a static class EMailUtil which has different methods like ...
2
votes
1answer
88 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 ...
-1
votes
0answers
92 views

How to think of the architecture of an android app? [closed]

How do I go about planning an android app's architecture before developing? I don't have much experience with android development, so I'm having a hard time in knowing which design patterns to use. I ...
0
votes
4answers
412 views

Is it bad to use DI to inject constructor parameters at runtime?

These are two classes, the first one I inject an instance of type IEngine while the second one I inject owner's name, tickets and engine. Version 1: public class Car { public Car(IEngine ...
0
votes
1answer
42 views

How to organize conversion logic for strategy pattern?

I have a Color class. It has a property model which is a class that implements ColorModel interface, this property could be a RGB, Hex or HSL classes which implementing ColorModel interface. // ...
2
votes
1answer
413 views

How do you show the exception handler in a class diagram?

I have one exception handler class. I want to show this class in the uml -- class diagram. But, I do not know how to represent relationship between class <X> and exception handler class. How can ...
1
vote
1answer
418 views

Confused on how to properly employ a Repository Pattern with Service/Business Layer on top

I'm building a ASP.NET Web Api 2 solution for learning purposes, and I've hit a snag. I was wondering if anyone could tell me what exactly it is that I'm missing. My Web Api solution has 4 Layers: ...
1
vote
2answers
327 views

How to present a stable data model in a public API that allows internal data structures to be changed without breaking the public view of the data?

I am in the process of developing an application that allows users to write C# scripts. These scripts allow users to call selected methods and to access and manipulate data in a document. This works ...
0
votes
3answers
101 views

Various methods manipulating same member variable versus each takes inputs and provides output [closed]

As software design paradigm which is better? to let various methods manipulate a member variable, or define each method or function to take some inputs and provide some outputs? For example class ...
0
votes
1answer
175 views

Design Pattern Question

I'm relatively new to the world of OOP, and having read through some design patterns, I'm struggling with that 'aha' moment. I have the following objects Event (Single event, with start time and end ...
33
votes
8answers
10k views

Return magic value, throw exception or return false on failure?

I sometimes end up having to write a method or property for a class library for which it is not exceptional to have no real answer, but a failure. Something cannot be determined, is not available, not ...
1
vote
1answer
75 views

Which design pattern restricts limits class creation to certain classes

I have a fairly simple application that is divided into two classes. The first class is the Manager class and the second class is the employee class. These are simple classes and do not inherit from ...
1
vote
0answers
53 views

Extend, wrap, or both to add generics to a class that should have had them?

So I'm using a C# framework that has a great example of where generics would be useful, except they weren't used. For simplicity's sake, we will say it was a list (I know C# has its own list), but ...
-2
votes
1answer
60 views

Front-end or Back-end Implementation of API? [closed]

Lets say I want to implement an API from an external website, for example like Dribbble or Last.fm. I'm fairly new to this new generation of front-end MVC's (angular, etc), and most example's I've ...
9
votes
5answers
957 views

How to unit test a function that is refactored to strategy pattern?

If I have a function in my code that goes like: class Employee{ public string calculateTax(string name, int salary) { switch (name) { case "Chris": ...
0
votes
1answer
79 views

Should Form Object be considered a DTO?

I got this from one of online video tutorials. Author binds form data not to Value Object directly, but first to validable DTO, and THEN to Value Object, using service. Example: package ...
2
votes
1answer
59 views

In a Table Data Gateway, where do I put queries that use joins

The book Pattern of Enterprise Application Architecture has the following description over the Table Data Gateway pattern: “A Table Data Gateway holds all the SQL for accessing a single table or ...
3
votes
2answers
211 views

implementing dynamic query handler on historical data

EDIT : Refined question to focus on the core issue Context: I have historical data about property (house) sales collected from various sources in a centralized/cloud data source (assume info ...
3
votes
2answers
116 views

What preconditions should be checked while adding/removing a listener?

Imagine the following interface: interface Service { addListener(Listener l) removeListener(Listener l) } Should I check for null values while add/remove? Is it a good idea on remove to ...
0
votes
1answer
331 views

Email Content creation | Proper design

Working on an E commerce application where we need to send so many email to customer like Registration email Forget Password Order placed There are many other emails that can be sent, I already ...
0
votes
1answer
293 views

how to improve design ability [closed]

I recently went on a couple of interviews and all of them asked a one or two design questions, like how you would design a chess, monopoly, and so on. I didn't do good on those since I am a college ...
3
votes
1answer
176 views

Pattern to use to relate multiple data sources to different user data widgets

I have an client x server intranet application the basically gets data from the server, format it and send that data to the client for display. At the server we are using ASP.NET C# running on IIS ...
0
votes
1answer
68 views

Create an Inferface for different data sources but same datastructure [closed]

At the moment I have my sourcedata stored in different excel files but in the future I want to use a database. Since I dont want to write everything new when I have to change the source and maybe in ...
2
votes
2answers
188 views

architecture of database heavy application

A program I'm currently designing is extremely database heavy, almost anything the user does will alter the database, or read from it. Now I have one interface which defines all these operations, and ...
0
votes
1answer
162 views

Good design pattern for linq to sql

I currently have a linq to sql project that was used for one project and not much work was put into it, only the generated context and entities were used. Since then the project has started to become ...
0
votes
0answers
32 views

Transaction Management in Hibernate with DAO Design Pattern

I have many Tables, For every Table,we have DAO Interface and DAOImplementation class. Example DAO Interface public interface CancelPolicyDAO { public CancelPolicy insertCancelPolicy(CancelPolicy ...
1
vote
1answer
141 views

Build a map with city blocks and road

Is there a design pattern or well known algorithm to build a simple map with roads and city blocks? To have an idea of what's my target i describe some of the constraints and the context: a matrix ...
0
votes
4answers
219 views

How to ensure objects unique by equality?

I frequently have this problem but didn't find it as an established programming pattern. I have some Class C whose equality is determined by some key k and I want to prevent time-consuming ...
0
votes
1answer
128 views

How to deal with product owner who refuses to follow UI design rules

We develop Android application. We base on old version of similar application developed in our company. This old application was designed by some noobs which didn't follow UI Android design rules. ...
16
votes
8answers
24k views

Web Developer interview questions

I read an article today that listed some basic questions about web development: Describe how POST data was submitted to a server by a browser. Explain a number of HTTP status codes (except maybe 404 ...