A design pattern is a general reusable solution to a commonly occurring problem in software design.
0
votes
1answer
56 views
Design Pattern for Object Updates
I have a "Product" class that has some ID, and multiple other fields, and a function updateProduct(id, Product update). The intention is that "update" only contains the changed information - other ...
0
votes
1answer
33 views
Full data history, current values can be rebuilt ignoring provisional or invalidated changes
I would like to create a website for a local school and then offer it to others. The school's main headache at the moment is capturing student marks and comments at the end of each school term. The ...
-1
votes
0answers
37 views
Creating Webhooks instead of API
I have started buliding an API for my service which transfers series of data to other 3rd party.
I am wondering if I should build Webhooks along with my API? Can anyone tell me how webhooks would be ...
2
votes
5answers
202 views
Constructor overloading or allow null?
Which is the preferred design to use, one constructor that allows null, or two constructors where one throws an ArgumentNullException on null?
Two constructors with exception throwing
public class ...
1
vote
2answers
56 views
What design patterns exist for large dataset manipulation within MVC for a rich client data grid?
I want to feed an HTML5 data grid with large data sets that the client will want to manipulate in different ways, e.g. aggregation, grouping, pivoting.
The data comes from different web services and ...
15
votes
8answers
4k views
How can I promote the use of the Builder pattern in my team?
Our codebase is old and new programmers, like myself, quickly learn to do it the way it's done for the sake of uniformity. Thinking that we have to start somewhere, I took it upon myself to refactor a ...
0
votes
3answers
184 views
What kind of development am I doing?
I am doing a webapp for the internals in my company, it has been 8 months and now I want to become more professional about it, and to know precisely what I am doing.
My workflow is to make little ...
6
votes
2answers
129 views
MVP (Supervising Controller) Does the view update the model?
I've been reading about MVP, specifically Supervising Controller. One thing I'm having difficulty wrapping my head around is how the View interacts with the Model.
It was my understanding that the ...
-2
votes
2answers
46 views
How to allow Object creation of a class on only particular classes in PHP?
In PHP, let there be four classes A, B, C, and D. None of them inherits the other. They are all independent classes. Now, I want only B and C to be able to create Objects of the class A. D Should not ...
6
votes
1answer
79 views
How to allow for custom Rules in a Entity Component System designed game engine?
So I've been doing a lot of research into game engines, and Entity Component System (ECS) seems to be the most flexible and extendable design to use.
Just to summarize, in ECS the basic idea is that ...
0
votes
1answer
44 views
Design patterns for ERP software with clients and web service
I'll will make ERP software for managing data for business activities. The solution must have two big parts: a WPF application for all the clients and an ASP MVC Web API application for all the ...
5
votes
3answers
311 views
Best practices for using public, protected, private?
Is it fair to say that it is good practice to default everything to private up front when coding something?
And then only upgrade it to protected if a subclass needs it, or public if another class ...
1
vote
1answer
35 views
Better way to organize query methods in Android?
In my Android app I have a
SQLiteHelper class that extends SQLIteOpenHelper, and takes care of things like table-creation and upgrades.
SQLiteDatasource class that performs CRUD operations on the ...
2
votes
1answer
60 views
Invoking Methods of another component in Observer Pattern
Question:
Are there any techniques for communicating with methods of other components but still keep a "pure" Observer pattern ?
If yes are they indicated/regularly-used or am I just ...
3
votes
2answers
189 views
Using MVC style, where is the best place to put SQL functionality?
I am wondering about best practices here.
MVC (Model - View - Controller) patterns involve separating components of your program that model the data, manipulate those models, and display those ...
4
votes
0answers
60 views
Is the observer pattern suitable when the observers are not independent of each other?
I have a class Car which has 2 properties: int price and boolean inStock. It also holds a List of abstract class State (empty class). There are 2 states which can be applied on the car and each is ...
4
votes
1answer
46 views
What is the best pattern to define own type with definitive collection of values?
I want to define own data type, say a Digit, which would have definite type of values ( 0 to 9 ) and I'm struggling with defining this in a way it's practical. What's the best way (design pattern) to ...
5
votes
2answers
91 views
Design pattern for too many ctor parameters within class hierarchy
Is there some design pattern for handling situation where class hierarchy constructors parameters force the most bottom classes to have too many parameters?
Ideally this would be in C++, if language ...
2
votes
2answers
146 views
Reversible Functions
Currently writing a JSON Importer and creating some POJOs based on the data. I also have a requirement to write an JSON Exporter which take the information in the POJOs and exports a JSON doc.
To me ...
-2
votes
1answer
92 views
Is there an official name for the “one object disease” anti-pattern (iterative single object operations on databases, services etc.)?
It is caused by the naive programming paradigm: focus on just a single object, do something with it, and if you have to work with many objects, you loop, iterate and traverse, repeating the operation ...
5
votes
1answer
83 views
Partially parallel producer-consumer pattern with internal state
I need to implement a producer-consumer pattern for reading, processing and saving electrical values. I have to implement this in C# .NET 4.6.1.
I try to describe this in great detail, so that there ...
2
votes
1answer
120 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
146 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 ...
-2
votes
0answers
58 views
Is there a name for such search model?
The question itself:
Is there a name for such search model?
Section 1. The Background Story
I have some data that should be stored as a GUI table, with the ability to sort and filter it.
At first, ...
0
votes
2answers
113 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
116 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
223 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
68 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
236 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
102 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
100 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
160 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
49 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
117 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
138 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
1answer
74 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
3k 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
55 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, ...
6
votes
4answers
190 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
62 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
62 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
101 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
178 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
130 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
219 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
332 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
42 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
125 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
54 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
131 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 ...