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

learn more… | top users | synonyms

0
votes
0answers
40 views
+100

Splitwise clone done right

I have started this project basically for learning perspective and wanted to learn good object oriented design. What I am trying to do is making clone of something like this but this is a command line ...
1
vote
1answer
22 views

Using Bluebird with fs to read a file within each of an (variable length) array of directories

I'm reading an array (of unknown length) of modules package.json files in order to extract the "style" property and store it in an array of its own: ...
-3
votes
0answers
9 views

Inheritance: Pass values in constructor or override method [closed]

If you have multiple classes inheriting from ParentClass, and ParentClass needs to access a specific value from each child class,...
3
votes
2answers
73 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 ...
2
votes
1answer
97 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 ...
5
votes
0answers
48 views

Elegant way to alter datasets with explicit filters

I would like to write a small helper to filter datasets. Each dataset is a dictionary and some filters I want to apply are common to all the datasets. That my needs, I wrote this following pattern: <...
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 ...
0
votes
2answers
46 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
73 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
51 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
22 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
111 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
314 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
52 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
74 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
81 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
80 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
127 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
158 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
61 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
43 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
103 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
87 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
294 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
59 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
34 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
56 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
38 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
82 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
56 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
121 views
2
votes
4answers
139 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
180 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
89 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
120 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
138 views

General Retry Strategy

Let’s say we copy some file using retry strategy (it might be blocked, etc.): ...
2
votes
2answers
57 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
94 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
vote
0answers
38 views

Customized JPanel desing pattern

This is an example of the Java Swing application I've wrote. I'm trying to follow the first Effective Java items. I wrote some classes similar so I've posted only this class for the review. ...