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

learn more… | top users | synonyms (1)

-1
votes
1answer
79 views

Simple explanation of MVC needed [duplicate]

I am trying to understand MVC, but for most of the Q&A's I have seen, the description is great but I cannot quite understand it, I think it works like this scenario I thought of: User ...
0
votes
1answer
59 views

Parsing an object from multiple source files

I receive zip files and they have as content 8 different files, each with it's own metadata inside. I have to combine these files into 1 object containing certain metadata. The big issue here is that ...
1
vote
1answer
72 views

What pattern should one use for multiple interpretations of the same data?

I have a set information that I am able to read in as raw data which corresponds to different physical quantities depending on which device provided that information. Every device contains the same ...
3
votes
5answers
954 views

When are enums NOT a code smell?

Dilemma I've been reading a lot of best practice books about object oriented practices, and almost every book I've read had a part where they say that enums are a code smell. I think they've missed ...
0
votes
1answer
54 views

Dynamic query from view layer

In my current job they are defining a new corporate architecture for java development. It is something like this: ProjectView: JSF view layer. Uses delegates on the ProjectClient layer. ...
1
vote
1answer
142 views

Data structures for designing an online book reader

I want to design an online book reader system as a programming exercise. I wrote down the following requirements: Searching a book by title. Bookmarking a book. Mark a book as favorite. Give rating. ...
0
votes
0answers
87 views

How to improve the design pattern of this Screen Window system?

I have a Screen Window system, a Screen (IScreen as interface), which holds a window, either WindowA or WindowB. System can switch window by calling stateChanged: class IScreen{ public: virtual ...
4
votes
3answers
361 views

Name of this pattern to wrap functionality

I have a system that allows certain functionality to be implemented different ways, but requires that the functionality of each implementing class be wrapped in another layer. For example, each ...
2
votes
2answers
69 views

Design architecture advice on relation between objects and singleton JS

I would like your feedback regarding some best practices on design relationship between objects, specially when a singleton object is involved. Let's imagine I need to simulate a Shop with ...
0
votes
2answers
166 views

What is the pattern that uses multiple instances rather than multiple classes called? When would I use it?

Sometimes I find it useful to have a single class with multiple instances (configured differently via their properties), rather than multiple classes (inheritance). ??? Pattern Single class (Fruit) ...
1
vote
1answer
155 views

Interface Implementation: A parameter I don't need

Pseudo-Code interface IPagingInfo { int CurrentPageNo { get; } int RowsPerPage { get; } ... } interface ResultsRetriver { ResultRows GetResults(IPagingInfo pagingInfo); } class ...
1
vote
1answer
133 views

Interface Design: Specific vs General parameter (A Minimal design vs anticipated use variation)

Code public interface IVehicle { string VehicleMake { get; } int MonthsSincePurchase { get; } bool IsApprovedUsed { get; } ... } public class WarrantyPopUpHandler { virtual bool ...
7
votes
2answers
2k views

how to refactor many singletons

I have a medium-sized python program (~5000 lines of code), which I've built up over time, with no particular plan as I went ahead. The architecture I've ended up with consists of 5-6 large Singleton ...
8
votes
2answers
509 views

Doesn't dependency injection push the testing burden further down the chain?

I'm learning about dependency injection and while I can see the appeal of it when writing functional libraries, I fail to see how it solves anything when you'll also be the one using the libraries. ...
3
votes
1answer
258 views

What architecture should I use for my game entities?

I am working on my final year project and making a multi player game. It's a tank battle game. In the client basically we will have 2 types of Tank. One will be controllable by the keyboard and ...
0
votes
2answers
268 views

Does algorithm design belong to software engineering? [closed]

In academic meaning, it seems to me that algorithm design is studied in a high/abstract level of computation (computability, complexity), although software engineering is also studied in ...
2
votes
1answer
147 views

Should I use strategy design pattern or something else?

I have recently started reading Heads First Design Pattern Book as well as coding on my final year project. In my project I am having Tanks which extends Entity. A Entity can be anything in the game ...
3
votes
1answer
80 views

Could a view call a function of the model directly?

this is a fundamental question about MVC (in particular using AngularJS) and I've found similar questions here, but not the exact same problem: Could the view call a function of the model, or should ...
0
votes
2answers
159 views

Do we need servant pattern? What about implementing in parent class?

From wikipedia: Servant is used for providing some behavior to a group of classes. Instead of defining that behavior in each class - or when we cannot factor out this behavior in the common ...
2
votes
1answer
93 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 ...
4
votes
1answer
121 views

How do I use decision tables to prioritize between objects - or should I do something different? [closed]

I have a case similar to this one: Multivariable decisions The difference is, that it's not a single decision I need to make but more like I have a pool of (let's say 10 object) where each object has ...
20
votes
6answers
3k views

Iterator pattern - why is it important to not expose the internal representation?

I am reading C# Design Pattern Essentials. I'm currently reading about the iterator pattern. I fully understand how to implement, but I don't understand the importance or see a use case. In the book ...
3
votes
2answers
234 views

Deep SQL relationships to a C# object model

I have a database with deep table to table relationships for example Clients (one to many) -> ClientData (one to many) -> ClientJob (one to many) -> ClientProcess (one to many) -> ...
29
votes
4answers
4k views

Does C# 6.0's new null-conditional operator go against the Law of Demeter?

The Law of Demeter states the following: Each unit should have only limited knowledge about other units: only units "closely" related to the current unit. Each unit should only talk to its friends; ...
3
votes
3answers
118 views

Deleting a domain object and ensuring any remaining references are subsequently unusable

If I have a domain class with an instance method Delete(). What is the best way to ensure that any leftover references to an instance that has "deleted itself" are subsequently unusable? This ...
0
votes
0answers
97 views

Should I be using a design pattern when creating these objects?

I have a lot of duplicate code in my program that basically follows this structure: If condition is true Create ErrorRecord object Call ThrowTerminatingError(error object) End if The ...
0
votes
1answer
126 views

Best pattern to write a PHP function that checks on access and returns more then boolean?

I'm prototyping behaviour of a new application, and want to write some functions that check on access based on some variable dates. I just want to write separate functions for that, like ...
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 ...
0
votes
1answer
170 views

Domain Model vs Presentation Model vs General Function

I have been building an app for my company i join for the past > 1 year, we're using Java Spring Hibernate Javascript jQuery Kendo UI And for the structure i can say something like this from ...
2
votes
3answers
146 views

Single responsibility policy problem

I'm a bit stuck using the single responsibility policy. I have a class named Parser, which can be configured to parse input a certain way. For the sake of convenience I will limit the configuration ...
1
vote
4answers
125 views

Should it use counter, or flag inside objects, to indicate progress?

For example, I have a game, it has 5 enemies which attack once sequentially at each round: class Enemy{ }; class Game{ public: Enemy enemys[5]; }; I want something to indicate which enemy has ...
2
votes
1answer
96 views

Observer for two independent events in the observable class

Observer pattern aim: the observer class responds to the changes of the observable class state. Problem. There are different processes inside observable class that should be observed. Those events ...
1
vote
4answers
341 views

What's the alternative to DRY code when it requires too many parameters?

What is the best strategy for maintaining easy to follow code when keeping things DRY means you have to pass a lot of parameters to shared functions? In my specific case, I have a grails based app, ...
5
votes
4answers
351 views

Design pattern for wrapping logging around execution

Introduction I am implementing a abstract Java class of a processing framework*. By implementing the function execute, I am able to add business logical functionality. I would like to add logging at ...
1
vote
1answer
94 views

Stuck on design when attempting to create an object store

I'm working on a small scale API project but as it will be used and maintained by people that are not Software Engineers to trade I am attempting to keep the design as separate and identifiable as ...
4
votes
1answer
120 views

How to represent very specific business logic in classes containing the business logic?

BusinessModel: I have a ice cream shop and I designed classes to do my supplier based financials based on industry types(Lines of business). I sell ice creams of many types, which I buy from different ...
12
votes
3answers
775 views

How to draw programmer's attentions in certain conditions?

Let's start with an example. Let's say, I have a method called export that depends heavily on the DB schema. And by “depends heavily” I mean I know that adding a new column to a certain table often ...
2
votes
0answers
191 views

Assembler vs Entity Translator and Entities vs DTO

I was hoping that someone could explain the exact difference between an Assembler and Entity Translator. Martin Fowler describes the Assembler as a sort of Mapper(?) which converts DTOs into Domain ...
2
votes
1answer
99 views

Does implicit and explicit cast operator overloading violate the D in SOLID principles of OO?

I'm looking at different patterns and techniques for implementing logic to convert object from one class to another, and the most elegant seems to be explicit cast operator overloading (in C#). ...
-1
votes
1answer
148 views

Programming Pattern - Single Data Structure - Multiple Methods [closed]

I have a single data structure that holds a relatively small amount of objects (ca. 1500) and several methods that are acting on it. Is there a programming pattern to iterate the methods over the data ...
4
votes
3answers
234 views

What is the best design principle to add behavior in future to your API? [closed]

I'm designing an API. And, this API will be used by client. Currently I've two behaviors in a class definition. To illustrate the scenario, sample implementation looks like the following- public ...
1
vote
0answers
48 views

Storing reference to a model obtained using DataMapper to be able to call save on it

When using the DataMapper pattern, which involves modeling classes containing business logic and knowing absolutely nothing about persistence, caching,... I usually want the models to represent ...
1
vote
1answer
93 views

Should I share test code between different repositories [closed]

Suppose I have a Repo A that imports a Repo B. I maintain both of them. Currently, I have some convenience functions that are useful for testing of both repos. They live in Repo B's test directory. ...
6
votes
2answers
368 views

How to populate Lazy object from database

I have these classes: public class Order { private Lazy<IEnumerable<Volume>> _volumes; long ID { get; private set; } string Description { get; private set; } ...
19
votes
5answers
4k views

What are the benefits of dependency injection in cases where almost everyone needs access to a common data structure?

There are plenty of reasons why globals are evil in OOP. If the number or size of the objects needing sharing is too large to be efficiently passed around in function parameters, usually everyone ...
1
vote
1answer
100 views

Prevent circular dependencies without introducing intermediary library

TL;DR Below I'm working on a game server (in Java, but that part is less important), and have decided to split up the server logic from the engine logic; in part because they're in two different ...
4
votes
1answer
194 views

How is one supposed to deal with the intermediate buffer of DataReader class?

Summary I am developing a WAV file format reader under WinRT, and for this I need to read random amounts of structs consisting of fundamental types such as int, uint, float and so on. Back in ...
1
vote
1answer
38 views

Deploying and maintaining a script on customer's domains

I am trying to figure the best way (or just the pros and cons of various options) for delivering a service via a script which runs on the customer's site (think Google Analytics). Unlike Google ...
2
votes
1answer
284 views

Is Activity/Fragment already a presenter?

An Activity or a Fragment is where you handle the logic of updating views with model data. However, they are tighly coupled with the Android's framework. Are these classes already presenters? ...
2
votes
2answers
298 views

MVC controller and decoupling explained

In this article you can see that View has (uses or aggregates ) controller and ConcreteView has Concrete model. public abstract class View { public abstract void Update(); private ...