Questions tagged [design-patterns]

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

Filter by
Sorted by
Tagged with
1
vote
2answers
68 views

Validation in BLL, many ifs - Suggestions how to refactor what I think looks smelly

We have an MVC application, which performs actions on a referral. We are added the business logic, to ensure that we can't perform invalid actions on the referral due to it not being in the correct ...
5
votes
1answer
84 views

News reading application version 2

following the answer I got from t3chb0t last time News-reading application using the Observer pattern and also following the example here https://msdn.microsoft.com/en-us/library/dd990377(v=vs.110)....
3
votes
0answers
2k views

Structure and Implementation of Generic Repository and Unit of Work patterns with Dapper and SqlTransactions

I am attempting to update some legacy code that I work with, but my knowledge of data access is limited to a basic use of Entity Framework and simple Dapper. After some research, I have a loose ...
0
votes
1answer
202 views

PHP OOP registration with User class and singleton Database class [closed]

I created registration system with PHP. I have User class that will handle all the input and insert the user input into database, and i created Database class with Singleton pattern that will connect ...
4
votes
4answers
708 views

Initialized Array Template Class (C++)

The problem We want to use a very large array for some computations. When created, all the elements of this array have to be initialized to some value. We'll only use a few values from the array1,...
4
votes
1answer
469 views

Supermarket app using OOP

I am going in a circle over and over trying to write a "supermarket" application using OOP. The app should be useful for the employees of a supermarket. The app reads data from a CSV file which looks ...
0
votes
1answer
44 views

Convert automatically into a centralized bean for multiple domain objects

I am creating a project which will respond to collect multiple bean object, save it to the database and return the status of the transaction. There can be multiple objects that can be sent from the ...
0
votes
1answer
2k views

Object oriented design of chess game [closed]

I was trying to design a chess game in Java. I have just started learning design patterns and am not sure if my approach here is right. Could you please suggest ways to better this design ? Below is ...
1
vote
0answers
71 views

Design code to compute technical indicators

I have a table with OHLCV values stored per symbol and I am trying to compute various technical indicators for the same. I am a newbie to Python and this type of application in general. There are 2 ...
4
votes
1answer
642 views

PHP Application layers

I'm dealing with design layers of an application. Basically what I've so far are: Business Architecture: Client-Server Techonologies: PHP+MySQL, HTML5, JS, 3rd parties APIs My app Data Sources: ...
4
votes
3answers
191 views

Web-app for tracking containers

Nowadays I am learning Domain Driven Design intensively. I am reading the book called Domain Driven Design by Eric Evans, and at the same time I try to apply the knowledge on a real life project I ...
2
votes
1answer
158 views

Design Pattern for initializing Properties of a ViewModel which only serves a display purpose

It's a question which lies me for years on the tongue. Given a LoginViewModel: ...
1
vote
2answers
1k views

Shape area calculation

I know questions with this text has been asked and already answered, but my question is mainly limited to only one method of this flow and where it should be. I have an assembly for Shape's area ...
6
votes
1answer
172 views

Employees and Organizational Hierarchy

Employee hierarchy in an Organization is classic example of modeling Composite design pattern. Following are the details that are to be modeled: There are two type of employees; Manager, and ...
3
votes
1answer
78 views

Pizza-making combining two builder patterns (Bloch's and Go4)

I think I just made a very simple way to implement both builder patterns: Bloch builder (for solving telescoping problem). introduction@Medium, Telescoping problem@SO Go4 builder pattern (The most ...
4
votes
1answer
104 views

OO design for chat protocol

I'm writing a typical client-server architecture for a chat program. My goal is to make the protocol flexible so that I could add more functionality in the future. (Any good software should allow that)...
3
votes
1answer
621 views

Simple packet parsing command pattern

I'm currently creating a small server back-end. My goal is to write an (efficient) packet parser in C++17 using the command pattern. The packets are given by: ...
2
votes
1answer
3k views

Total cost calculator for shopping cart

Problem Statement Design a system which helps calculate the TotalCost of the items in the Cart. You will be given a list of items in the Cart with Discounts like in the example below. The list ...
0
votes
1answer
72 views

Clean implementation of FTP File Cleaners

I was refactoring some of my utility code modules used in my test projects, and wanted to apply my knowledge of clean OOP design patterns and SOLID principles to make these modules more useful and ...
9
votes
1answer
2k views

Factory method done on ReactJS component

A Factory Pattern or Factory Method Pattern says that just define an interface or abstract class for creating an object but let the subclasses decide which class to instantiate. In other words, ...
-6
votes
1answer
120 views

Poor decision of IEnumerable of IEnumerable of IEnumerable [closed]

I wish to improve a class design that causes me readability and performance problems as the code grows. ...
6
votes
6answers
551 views

Return the state of collection based on individual object states

The following code is a simplified version of what I want to achieve. Each object may have one of several states, and the overall collection state depends on the state of each of these objects. ...
3
votes
1answer
461 views

Strategy design pattern in C++ using unique_ptr

1. Introduction This is for my ANN project. Each building block of ANN, neuron, has activation function which determines how to get the output given the input (see formula in on repo I linked). I ...
0
votes
1answer
428 views

Strategy design pattern for writing to a file or to the console

I have this interface for all strategies: type PrintStrategy interface { Print() error } of two types: ...
1
vote
0answers
63 views

Separating out router and model logic

I have an Express router that is doing all the heavy lifting. Should the router be handling all this stuff or is a layer required between these two like maybe a service that makes these calls? ...
9
votes
2answers
4k views

Binary Search Tree Data Structure Implementation in C++11 using Smart Pointers

This implementation is part of my open source project forest. I wrote the following header file to implement a binary search tree data structure that supports the following operations: Insert Search ...
0
votes
2answers
140 views

Reach C++ policy-based common interface with different template parameters from one container

Please review my solution for the following problem. I am interested in: What do you think of the design Improvement tips Usability Efficiency Problem: Need to be store policy-based objects with ...
6
votes
1answer
393 views

Creating URL with Builder pattern

What do you think about this piece of code? How would you design the builder pattern in this situation? ...
1
vote
0answers
43 views

Using Specs when testing the process of assigning offers to a customer 2

Following on from this question: Using Specs when testing the process of assigning offers to a customer. I received some useful suggestions from t3chb0t and paparazzo. Therefore I have decided to ...
14
votes
6answers
2k views

C# Method Chaining for Email

I have been looking into stuff like method chaining, Cascade-Lambda pattern etc. I have created a class which seems to work fine. However, I just wanted to confirm if this is the best way and the ...
1
vote
0answers
64 views

Flexible Image Transport System (FITS) file parser

I have a simple class which currently has some code in the constructor, which makes it difficult to inject and also test. ...
8
votes
1answer
1k views

MVP Passive-View

First of all, I'm really new to the MVP design pattern (Passive-View) and I've been trying to implement it in a WinForms application. Before I'm going any further, I'd be very happy if you guys can ...
3
votes
1answer
89 views

Domain Design Pattern consideration

I've come up with the following pattern that I would like to use within my domain. My question is more opinion than an answer. Use case: Each domain service does one action called submit, a ...
3
votes
2answers
119 views

Image Database Service

I created simply database service with get, insert, get all image names and verify exist method. All images will be store in blob storage with unique filename + postfix size. Next one I have image ...
1
vote
0answers
174 views

JavaFX Audio Visualizer unsure about MVC / Observer / Listerner design patterns

I have a MP3Player Class that does the Fast Fourier Transform and puts the values in a float array (called bands). Then every 20ms it notifys the Observer (VisualizerController) which then uses ...
7
votes
0answers
317 views

C++ Parsing with chain of responsibility

The task was to create the parser for the string input, that would return the std::vector< int > of parsed numeric results and the type of given input (e.g. numbers, division by zero error, out of ...
5
votes
1answer
5k views

ASP.NET Core 2 architecture and design patterns

I started a week ago to split my project into layers: business logic layer, data access layer and UI layer. I took as an example this project: https://github.com/dotnet-architecture/eShopOnWeb. I ...
5
votes
0answers
264 views

ATB strategy MVC architecture refactoring

NOTE: this question isn't as long as it appears to be. I added the comments to the code only to answer some possible questions that may appear. I'm making an active time battle strategy. Its ...
5
votes
2answers
4k views

Repository pattern along with EF and Unit of work

I'm new to this Repository pattern and have seen lot of repository pattern + UoW implementations all over the internet and I'm not able to reach to a conclusion as to which of them is correct . After ...
3
votes
1answer
82 views

Java builder for user contact information, with optionals

I have this simple builder here: ...
3
votes
1answer
1k views

Generic Implementation for Api call in c#

i have created one generic implementation for api call from all over my application. ...
1
vote
0answers
2k views

Swift/iOS component for label with clickable text buttons

So I'm creating a component based on UILabel, which I'm calling RichLabel. The main goal is to add support for clickable links (...
2
votes
2answers
283 views

EventLogger for MVC application

I have worked on one application related for booking space and required to store activity of user into table and access from admin side. For that I have created one database entity and ...
6
votes
1answer
274 views

Send records to messaging queue using either of one policy

I have bunch of keys (clientKey) and values (processBytes) that I want to send to our messaging queue by packing them in one ...
2
votes
1answer
152 views

Apply Coupon Validation in Order

I have created a mvc application for booking space. In this for booking user can applied coupon for booking. I have implemented one coupon service and validate coupon. ...
2
votes
0answers
1k views

Entity Framework with two databases (with UoW, Repository and Service Layer)

I have two databases: one for a warehouse, second for the office (The db design is out of the scope of this question). There are MANY cross-database funtions. One of those functions is ...
4
votes
1answer
533 views

Text adventure game - text input processing

As a fun project with my wife, I decided to make a small text adventure game à la Zork. Instead of using available engines, I decided to roll my own. It won't be that hard since there are no graphics. ...
9
votes
1answer
776 views

State and Borg design patterns used in a Telegram wizard bot

I'm making a sort of a user interface for a telegram bot and my idea was to use State design pattern for making sort of a wizard for all the process, with user inputting data in each step or pressing /...
3
votes
1answer
63 views

Design pattern for startup initialisation of static variables before an engine starts serving its request

I should initialize the startup variables before serving the requests. Few of my variables could be initialized from a local property file (say init.properties) and few would get initialized from a ...
1
vote
1answer
39 views

Assign value based on 100s of switch statement

In the following code I have potentially hundreds of possible cases. (This is just a small subset.) Is there some way to more effectively set state.dimensionQty ...

1
3 4
5
6 7
25