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

learn more… | top users | synonyms

1
vote
0answers
32 views

Player statistics class architecture

I've made a stats hierarchy for my Unity game project, it consists of 1 base class and few derived ones. abstract class Stats : MonoBehaviour ...
3
votes
0answers
28 views

Designing a toy dependency injection library

Just for learning purpose I thought to write a simple and useful dependency injection service which would just do dependency injection but also it should expose its core too which would let the client ...
3
votes
2answers
60 views

Chain of commands

I need to execute several commands in a specific order but before I excute the main command, another command needs to be executed first and in some situations there are more commands that also need to ...
1
vote
1answer
32 views

Modelling an account manager in OOP

I have this task of modelling a system where given a group of users each can keep track of their expenses. The basic requirements are as followed: To be able to give credit to an user. Find all the ...
0
votes
0answers
22 views

Responsibility to Validate Move in chess game? [closed]

I came across couple of software LLD to design chess game. I have a specific question where behavior to validateMove of pieces should lie ? Should it be part of piece class or validator class ? Per ...
3
votes
3answers
56 views

Presenter creating Views in c# MVP

I have a c# WinForms application in which I have tried to implement the Model View Presenter pattern with Passive View. I create new Views in the Presenter of my 'home screen'. I was wondering if this ...
1
vote
0answers
23 views

Refactoring API endpoint class in Android

I have a class with multiple methods which return a URL string of an API endpoint. Each methods takes different parameters based on what the endpoint have to include. Example, GET: http://api....
0
votes
2answers
43 views

No getter/setter on model with many instance vars

I have been reading a lot of material on how to become better in OOP, DDD etc. While reading Object calisthenics and Getters/Setters. Evil. Period. I got confused. Let me explain it by example. I ...
4
votes
1answer
32 views

Framework for composing algorithms

I am implementing a game in python, which will give the user a sample encryption, and explain each step from plaintext to cipher. The task for the player is to decrypt a word by undoing each step ...
1
vote
1answer
61 views

Using decorator pattern to validate an entity

I am following this article. ...
2
votes
1answer
45 views

Json type-safe builders using jackson-annotations

I have created these builders to help creating fluent acceptance tests for my api. I would really like suggestions for improvements because this is supposed to be a "how to" project on creating ...
3
votes
1answer
108 views

Try again, and again, and again… but not too often because the potatoes won't grow

The delay sequence has been fixed so I can move to the next step which are the Retry and Breaker. (Just ignore the console ...
2
votes
1answer
48 views

A general-use For-comprehensible Loan Pattern

I use Scala's loan pattern in order to ensure and automate the resource aquisition and release after its use. When multiple resources have to be acquired at once, however, the function calls must be ...
2
votes
1answer
21 views

Classical model for database connection provider

Let's forget about Spring Singleton Beans and about other frameworks in Java. We have one or more simple HttpServlets. And we should make database connection. (doesn't matter what is it, hibernate ...
3
votes
2answers
108 views

Implementing SOLID Principles - LINQ TO SQL

I have been using Layered Architecture in my web application. Can anyone please advise if my data layer classes (both Linq and booking class) can be improved? I have just started learning about solid ...
3
votes
4answers
303 views

Alternative to the Josh Bloch Builder pattern in C#

The Josh Bloch Builder Pattern (here after JBBuilder) introduced me to the idea of using a nested class to aid in construction. In Java the JBBuilder pattern is aimed at fixing the telescoping ...
0
votes
1answer
51 views

Abstracting HTTP requests to keep it simple, flexible

The project is an API that will itself make HTTP requests to external webservices. Since this is PHP, we actually chose to use guzzlehttp. Now the library itself doesn't matter much, but I'm scared ...
0
votes
0answers
36 views

App for system that will load ad reports

I need object analysis for this problem. Since I am new to OOP and this is basically my first project, I want to know if I am doing it right. I think it should work as it is stated in assignment (...
0
votes
2answers
72 views

Using getters and setters to change another variable C#

Is it a bad practice to use getters and setters this way? Below is my code: ...
4
votes
1answer
80 views

Visitor that changes the structure of the objects it visits

Brief summary: The vanilla GoF visitor is great for altering items within a tree of elements, but when the visitor visits an element it can only change the children of that element not the element ...
2
votes
2answers
77 views

A trip down the single method interface rabbit hole

I responded to this question about designing around interdependant methods with the strategy pattern. Afterwards I started thinking about the functional additions to java 8 and wondered if I was ...
4
votes
2answers
115 views

Abstract factory using generics

I am learning design patterns and I have implemented the abstract factory using generics C#.NET. Is this implementation correct or not? Or is there any SOLID principle violation? ...
5
votes
2answers
154 views

Simple factory pattern for cooking a pizza

I have developed a command line application which prompts the user to initially select an oven and then requests that they cook a pizza. The oven affects the pizzas cooking time. The pizzas ...
0
votes
0answers
40 views

Handling a user control that needs to be put on my form in WinForms project using MVP pattern

in my application i have a form 'DetailScreenView' which implements 'IDetailScreenView'. It is connected to 'DetailScreenPresenter' by the Passive View MVP pattern. I also have a '...
2
votes
1answer
54 views

Handling an openFileDialog in the View of my MVP WinForms project

I have a WinForms project in which I am trying to implement the Passive View MVP pattern (meaning no business logic in my Views). Each form is a concrete View with an IView interface to which a ...
2
votes
0answers
42 views

Show dialog to add device and tab

I am just into redux. I am developing a dashboard using ReactJS redux and material-ui for components. It's a large app as my dashboard contains various features like add/edit/delete device, add/edit/...
2
votes
2answers
102 views

Combining two classes to hold general and specific properties of an item

I have an ItemData class in my program that stores saved data about a game inventory item that can change, such as its durability, quality, number of bullets in the ...
6
votes
3answers
83 views

Visitor Pattern/Leaky Bucket variant implementation to run an operation at a certain interval

My code is a variant on the Visitor Pattern and a "leaky bucket" variant. The goal is pretty straightforward: the "bucket" will collect a specified number of items (say, for example, 500) and then ...
2
votes
1answer
289 views

MVC design pattern approaches

I am actually more confused rather than understanding the concept. I have been developing a system and want to know the MVC design pattern. which one is best and the concept and usability of the ...
2
votes
0answers
58 views

System to process data from a specific client

I'm working on an important project. We're an IT services provider and we have a project where we have to build a new system to process data from a specific client. The problem is that usually we ...
0
votes
4answers
108 views

Multilingual command handler using inheritance

My problem is that you have a lot of ifconditions to be checked and inside that if condition you have multiple lines of code. I ...
1
vote
1answer
33 views

UnionFind data structure implemented in Python

This class is used to create sets out of nodes to from a graph-like structure (or grouping since I remove most of the normal graph structure and all child nodes have the same parent). Is there ...
2
votes
1answer
53 views

Storing global constants in app delegate or singleton

I am converting a non ARC projecs to ARC. I just found that after login in my old app, the data is stored in app delegate objects, like Home_DataArray, various ...
2
votes
0answers
36 views

Implementing FusedLocationProvider for more than one Activity in Android

I am trying to implement Google Maps in Android. I am also trying to learn different design patterns. I want to use location in more than one Activity hence I have used a class named 'GoogleLocation' ...
3
votes
0answers
77 views

Factory (pattern) of Commands (pattern) with additional dependency injection (dependency inversion pattern)

What would you improve at the following code, except: The problems I'm already aware of, marked as TODO Line width of at most 120 characters (I've run flake8 over ...
4
votes
1answer
55 views

Words Counter using the revealing module pattern

Is the following a good way to use the revealing module pattern? ...
4
votes
4answers
218 views

Client to connect to server and show a text menu

First of all: Sorry for my English, that said... I am developing an obligatory for my University, so far it has a class that provides the user with options to connect to a server (once connected it ...
3
votes
2answers
115 views
2
votes
4answers
138 views

General Retry Strategy #3 with TryResult

I wanted to use the Try helper from @DmitryNogin's General Retry Strategy #2 but each attempt to implement it revealed another thing that is missing. In my review ...
13
votes
1answer
163 views

Ambient Context

What do you think about this way to make logging available across the application without passing log object around? Let’s say we have something which allows us to ...
3
votes
1answer
77 views

Base activity for handling network state changes in Android

I had the need in one of my activies to handle displaying a message to the user when the network disconnected, and then reload the data for a RecyclerView adapter ...
1
vote
1answer
50 views

File-copying Manager

I have the following java class which has many private variables and methods: ...
3
votes
1answer
116 views

General Retry Strategy #2

Previous version Now supports async operations and cancellation. Let’s say we copy some file using retry strategy (it might be blocked, etc.). App code comes bellow: ...
4
votes
3answers
132 views

General Retry Strategy

Let’s say we copy some file using retry strategy (it might be blocked, etc.): ...
2
votes
2answers
56 views

Load/Save application sessions

I'm working on load/save application sessions functionality, and came up with this code: ...
0
votes
2answers
51 views

Compute and Display Engineering Information

I am updating a class in legacy code and having some issue with my calcPressure method. I want to make it nice and clean but there is some convolution in the ...
2
votes
1answer
82 views

Resository Pattern and Unit of Work with ADO.net

I am trying to implement the Repository Pattern with a Unit of work but i dont know if i am on the right direction. This is my Model ...
12
votes
3answers
1k views

Building car factory with custom features per car

I was once asked in an interview to build a factory that makes cars. All cars has common features like price, rating and color and they have some features like fuel injection which can on specific car ...
1
vote
1answer
93 views

Using extension methods in the decorator pattern

After reading an exceptional article here about the decorator pattern applied to functions, I saw an opportunity to reduce a lot of boilerplate code in a console application project I've been working ...
-1
votes
0answers
20 views

Common code in extracted into utility classes [closed]

Recently was working on a project with a lot of duplicated, but simple code. They are mostly for setting, getting and casting values e.g. ...