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

Developing a calculator using the command pattern

In an attempt to solidify my understanding of the command pattern, I decided to write a calculator application that utilised it. After making some progress, I realised that my choice of application ...
4
votes
1answer
150 views

Am I using the factory method design pattern correctly, or which creational pattern should I use?

I've been studying creational design patterns for the past week or so because I have a common use case that keeps coming up, and I can't figure out which pattern fits the bill. Here is a simplified ...
0
votes
2answers
129 views

C++ class vs function header file

I'm using C++ for implementing a project that requires to import a file once. All the data in this file needs to brought in memory as key value pairs, but only when the file is imported. Since this ...
2
votes
4answers
118 views

Are names like OrderCreation and UserRegistration suitable names for business logic / domain classes

We have moved to a more SRP model and found coming up with class names challenging. Previously we had a Order class that looked something like this: public class Order { public void Create() ...
3
votes
4answers
228 views

Is Template Pattern a good way to implement DRY?

Here is my problem: I have and class structure like this: class Base { private: SomeType something; bool isSomeValue; public: virtual void myMethod() = 0; ...
0
votes
0answers
69 views

Should we add an extra class to this code sample

I have a shopping website which allows users to place orders. In my web application when the users click 'Create Order' i call an OrderService class which looks like the below: public class ...
3
votes
4answers
241 views

Defining logic without nested if-else statements

I'm working on a somewhat simple game. Currently trying to implement the game logic for moving the pieces around. Logic is something like this: does player have pieces in inventory? if yes: ...
5
votes
2answers
145 views

DDD: Creating reusable modules and service type distinctions (Domain, Infrastructure, Application)

So after reading "Implementing Domain-Driven Design by Vaughn Vernon" I've decided to refactor my code for better re usability by isolating what I believe to be core domain concepts into separate ...
1
vote
3answers
106 views

What should be in my business logic class

We are currently having an internal debate on how our business logic classes should be structured. At the moment we structure our business classes like this: public class OrderBL { public void ...
1
vote
1answer
161 views

What could be the better c# design for following requirement? [closed]

I am working on creating a c# design for following requirement. I am creating this for a fitness website. I have an article (as Text) and a exercise (as Image or Videos) as the base entity. Now i ...
0
votes
0answers
62 views

SQL/HQL in a Play framework controller and Service Layer pattern

I started using the Play Framework a couple of months ago. It "redefines" many conventions from the traditional Java world (like the way of using static methods among other things). I was browsing the ...
2
votes
1answer
119 views

Are nested private classes considered composition?

Background I am considering a design that includes a public API class containing many nested private classes. I am doing this for the following reasons: Why private nesting? They will have no use ...
0
votes
2answers
199 views

Per my design requirements, does this design hierarchy seem reasonable?

Background Construction Note that I am using C# here, but it may not be necessary to provide input to my conceptual questions about design. Consider the following design methodology... I work at a ...
1
vote
2answers
103 views

How to implement application that will connect to server allowing the server to request data

I'm not sure what to title this question or if this is the right place to ask it. After Googling and continually coming up empty, I'm turning here as a last resort. I've developed a SAAS web ...
19
votes
5answers
4k views

Is it okay for a class to use its own public method?

Background I currently have a situation where I have an object that is both transmitted and received by a device. This message has several constructs, as follows: public void ReverseData() public ...
0
votes
1answer
56 views

Change stock calculation depending on warehouse

I have a currently-existing stock management dashboard. The user selects a warehouse, and it displays the current stock in this warehouse. The stock management teams wants to display a date, ...
7
votes
4answers
209 views

Encapsulation for complex queries

I tried asking this question first on StakOverflow in a more concrete manner, but after being pointed here I realized I should rephrase it in more general terms; however, you can still review the ...
0
votes
1answer
87 views

How to use the MVP pattern in embedded systems?

I am defining the architecture for an embedded system provided with an LCD touch screen for interacting with the user. To describe my problem I can use a washing machine provided with LCD touch screen ...
1
vote
0answers
67 views

Guaranteed message sending for messages of different priority for different modules

We have created a message que system using priority messages. The idea behind this is as follows: We have a list of clients. All clients know if (and what kind of priority) messages they have ...
-1
votes
2answers
104 views

Chat Protocol Implementation

For a school assignment we need to implement a homebrewed protocol. We make usage of plaintext commands to send and receive messages. The commands underneath are currently supported by the messaging ...
1
vote
2answers
182 views

Software Design, a fitting Design Pattern?

Currently we need to interface with a REST API. The only problem we have implementing this is choosing the right approach. We’ve done this by using Resources – for example a Photo Resource that has ...
-1
votes
1answer
131 views

Does this pattern have a name?

I have a large XML file that I extract information from. I am extracting the information using a list of classes with a main method of the type ParsedValue[] GetValue(BigXmlFile). This is a bit like ...
6
votes
4answers
227 views

How to separate public and “mostly private” code in C#? (Friend classes, PIMPL pattern, etc.)

Reminder: If you have tips, please remember to put the reason objectively, such as "having two distinct SetInt() functions in the same file violates reader expectations that they'll be overloads, and ...
8
votes
7answers
339 views

A property that can represent both a single date and a date range: How to properly model that?

I work in a system that can represent a "shipping estimate" in two ways: A specific date: The item is guaranteed to ship at that date A day interval: The item will be shipped "X to Y" days from ...
2
votes
0answers
46 views

Mocking third party web service

I am working on a project to create a wrapper library which will be used to interact with a web service provided by the client's IT team. The reason for this library is that we interact with this ...
2
votes
4answers
128 views

How to enforce how an interface is consumed

Imagine I have an interface: public interface MyInterface { void CallMeFirst(); void CallMeDuringApplicationLifecycle(); void CallMeOnApplicationExit(); } What is the best way of ...
2
votes
1answer
55 views

Inferring system configuration using the existence of a file? any good?

This is a generic question about the idea of inferring some of the system configurations from the existence of a file or the lacking of it. For example, we have a module of the system which is ...
2
votes
1answer
136 views

In a polled interface, is it okay for an object representing hardware to start a task responsible for the polling?

I am a hardware/test engineer currently writing a C# application for a device that does not have any event/interrupt mechanisms. Because of this I am forced to poll the device's internal control ...
0
votes
3answers
81 views

How to represent an object with actions that can only be used in a specific situation?

Let's say I'm designing an RPG type game, and this game has a turn-based combat system. There are some things that the player character/non-player characters can do inside and outside of combat. For ...
0
votes
0answers
38 views

Migrating off a Silverlight application to SPA - technologies

We have pretty big Silverlight LOB application. It works great, took many years to write and it's big... Back when we made a choice (2011) JS/HTML5 was in unknown state. Today we have all kind of ...
1
vote
1answer
58 views

How to uncouple and reuse persistence logic, user interface logic and business logic amongs embedded software projects

I have been working in embedded devices business more than 5 years as a software engineer. Most of the times our hardware manufacturers provide a Software Development Kit for their reference boards. ...
0
votes
1answer
76 views

Fault tolerant software design of application running as distributed cluster

Mission-critical software system (such as systems-control software in spacecrafts) often employ multiple redundant software modules developed by different teams (sometimes using different programming ...
1
vote
4answers
100 views

File-Directory Implementation: Does a a file have to own a reference to it's dir?

I am currently issuing a problem while forming the program-design, which is exact like a File-Directory relationship, and to ease it, I am using that as an example. I think it is usual, that a ...
2
votes
3answers
70 views

Calculating a score and a breakdown of the score in different places - should I use the same methods?

I am creating a plugin that uses a metric to determine a score on one page and allows the user to click through to see a more detailed breakdown of the score on a separate page. The trouble is: I ...
2
votes
2answers
145 views

Design for an Android app (pharmacy duties)

I am creating an android app for pharmacy duties for different cities. My approach: I created an Interface with method getDuties, and for every cities I create a class named with name of the city ...
8
votes
1answer
276 views

How is Inversion of Control related to Dependency Inversion

In many articles all over the web the terms Inversion of Control and Dependency Inversion Principle seem to be mixed up and used as synonyms (further confusion is enforced by the tools that are called ...
3
votes
2answers
195 views

Extending the flyweight pattern: an oxymoron?

I'm developing a BNF parser in PHP, for my own flavor of BNF. To keep the resulting parse tree, consisting of objects, as lightweight as possible, I decided to use the flyweight pattern for literals ...
2
votes
1answer
285 views

Strategy Pattern not sufficient for my problem?

Let me sketch the situation: I have multiple users, with certain properties (2 enums) For each user I need to fetch data, for some with some basic filtering, for some extended filtering (= basic ...
1
vote
2answers
188 views

Migrating large silverlight business application to MVC

I have the task to migrate a large silverlight business application in a new living technology. I had choosed asp.net MVC and web api. As we know, silverlight uses MVVM design pattern whereas asp.net ...
1
vote
0answers
116 views

OOP - Modeling a Chat Design Review [closed]

Seeking thoughts on the following design. I know the design could be lot simpler if use Sockets. But I wanted to think of a design with pure POJO classes. User string id; string displayname; ...
0
votes
3answers
154 views

Constructor with tons of parameters vs builder pattern

It is well know that if your class have a constructor with many parameters, say more than 4, then it is most probably a code smell. You need to reconsider if the class satisfies SRP. But what if we ...
0
votes
2answers
126 views

OO design: separation of concerns

I have a collection of classes which model Logical(Boolean) Expressions. There is a base abstract class LogicalExpression, and derived classes : UnaryLogicalExpression, BinaryLogicalExpression, ...
4
votes
1answer
94 views

Does a mutually exclusive Decorator design pattern exist?

We know the Decorator design pattern, but how would someone go about implementing mutually exclusive decorators? Let's say I have a decorator pattern to implement weapon modifiers in a game. The ...
2
votes
1answer
108 views

What is an appropriate pattern for handling a queue of network events in C++?

I'm writing an application that sends and receives messages over the network and pushes them into a std::deque queue. and I'm looking for the appropriate programming pattern to handle all of the ...
2
votes
1answer
82 views

Design patterns to limit cross module logic

I have a web application which has a shopping cart with cart items. The cart items are added to the user session, so must be serializable. I have a checkout class which takes the cart items and saves ...
2
votes
2answers
126 views

Abstraction on Iterator Pattern?

Recently, I had the task to implement a research project where I had to read an XML file. XML file contained a list of messages that I had to send to some other system on a specific port. Each message ...
0
votes
0answers
50 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
111 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
63 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 ...