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

learn more… | top users | synonyms

0
votes
0answers
12 views

Launching background job from model [on hold]

In Rails, we've got a Location model. This model stores Location with a field (info) that stores raw data from a third party ...
3
votes
3answers
102 views

Classifying a person by name, gender, and age using Chain of Responsibility pattern

I am very new to design pattern. Recently, I learned about the Chain of Responsibility pattern, so I tried to practice it. These nested conditionals are what I'm trying to replace with polymorphism ...
3
votes
2answers
167 views

Stopwatch that uses the abstract factory design pattern

I have wrote code for a stopwatch that utilizes the abstract design pattern and would like to get some feedback on the code, so be as harsh as you can. Note: I used ...
1
vote
0answers
49 views

Watch that uses the abstract factory design pattern

I have wrote code for a Watch that utilizes the abstract design pattern and would like to get some feedback on the code, be as harsh as you can. Also, I would like ...
-3
votes
1answer
30 views

Functional object and array iteration with mess? - Object.keys, Array.map, Array.reduce, Object.assign. Ugh

Oftentimes my JavaScript/TypeScript code becomes riddled with annoying code flow structures like below. Is there a way to do concise [functional] one-liners without being messy? Input: ...
-1
votes
0answers
24 views

Member variable in generic abstract base class? [closed]

I have a hierarchical data model and am trying to implement their CRUD operations in my Web Application. Currently I have code inheritance for CRUD operations of my entities (resources) as follows: ...
0
votes
1answer
102 views

Menu that utilizes the composite design pattern

I have made a menu that utilizes the composite design pattern and would like to get some feedback on the code, so be as harsh as you can. Menu.h: ...
4
votes
1answer
72 views

Full integration test for a Console application

I'm sill experimenting with different design patterns for full integration tests for Console applications (and later also Windows Services) and I wasn't quite happy with the result of the refactoring ...
0
votes
1answer
49 views

Class Design : Parsers for different file type and ParserFactory

I have come up with a class design for parsers (for xml,csv etc) and parser factory. I will be using it in my project.I will be configuring these as beans in the spring context file. I would like to ...
-1
votes
2answers
42 views

Same computational flow, but different functionalities

Recently I wrote a small piece of code for my project need and the code works fine... ...
6
votes
2answers
94 views

Connection Pool in Java 8 using Strategy and Factory Pattern

How can I improve the following code and features? It is based on active911's C++ connection pool. The full code and unit tests are here : https://github.com/spakai/connection_pool the README ...
2
votes
0answers
39 views

Using blocking queue to calculate data stream - Generalized

A followup on my previous question Using blocking queue to calculate data stream. This time suppose we have a list of blocking queues as stated in the following manner: Suppose you have a list of ...
0
votes
0answers
44 views

Using blocking queue to calculate data stream

I was coding for the following programming question: Suppose you have two independent blocking queues that will keep getting new data, the new data will always be greater than the last element of ...
2
votes
0answers
54 views

Designing domain models for hierarchical data (in DDD)

It is my first attempt in DDD and I'm trying to wrap my head about this concept. In my examples a lot of validation is omitted for simplicity. I have two types of InterfaceConfigurations: VistaLink: ...
1
vote
0answers
57 views

VIPER Architecture

I write Swift and architect apps mostly based on VIPER pattern. The thing I always wonder is, is it a proper to store some temporal values in Interactor? Let me ...
7
votes
3answers
115 views

Succinctly implementing newtypes for multiple scalar units

I am working on a project where we work with some angles. Some of the angles are stored as radians and some are stored as degrees. Storing everything as either radians or degrees is an undesirable ...
0
votes
0answers
33 views

Proper use of Strategy design pattern for a simple networking layer in swift

Does the following code demonstrate proper use of Strategy design pattern for a simple networking layer in swift 3? Some code smells I'm unsure about: violates Single responsibiility principle. ...
4
votes
2answers
114 views

Fixed size Memory Pool Implementation

Here is an attempt at implementing a fixed size Memory Pool1: pool.h ...
3
votes
1answer
73 views

Cloning Windows Forms controls from a template

In a recent project I needed a way to clone windows forms controls from a template which had predefined Size, Font, etc. Since ...
6
votes
1answer
107 views

Create six hash tables - 2 hashing schemes x 3 collision handling schemes

I was asked to solve the following task: Given two methods for hashing (division and multiplication) and three methods for collision handling (chaining, open addressing w/ quadratic probing, ...
4
votes
2answers
99 views

Validating Shift class through builder pattern

I have a Shift class that looks like this: ...
2
votes
1answer
117 views

Generic repository with UoW and simple injector

I'm implementing a generic repository + UoW pattern with EF6 and simple injector. I feel there is room for improvements. Please let me know if I left out some relevant code, I tried to keep it breif. ...
3
votes
1answer
95 views

2D Physics Simulation (game-like)

My program is meant to simulate 2D physics(hopefully 3D as well in the future), namely classical mechanics and eventually electromagnetism. Currently it simulates projectile motion by firing a ...
0
votes
1answer
69 views

Motorcycle rental station with flyweight pattern

The definition of flyweight pattern: Flyweight design pattern uses sharing to support large numbers of objects that have part of their internal state common and other parts of state can vary. ...
3
votes
1answer
68 views

Object Literal Pattern in Typescript

My goal is to use the object literal pattern in TypeScript. Here is an example of the object literal pattern in JavaScript. I created a simple example of the object literal pattern in TypeScript. ...
3
votes
1answer
138 views

Decorator pattern implementation

I plan to use this code as not a learning demo, but a production-ready (all names / comments to be modified of course) code snippet in my work and add it to my snippet database. I would like to verify ...
3
votes
0answers
97 views

Simple files parsing and info extraction

First let me describe the problem, we want to solve: We have hierarchical directories structure with different types of templates. Each type of templates is located in dedicated folder. Hierarchical ...
15
votes
2answers
308 views

A KenKen puzzle/solver in Python

I've written a simple KenKen puzzle/solver in Python. I'd love some feedback on the design of the puzzle, as well as the architecture for the solver. To model the puzzle, I have the following classes:...
3
votes
1answer
51 views

Convert MQTT messages and publish them to Rabbit MQ

I'm looking for advice on how to find a balance between keeping this code flexible/maintainable, while also keeping it readable. It reads MQTT messages in JSON format from four different topics, ...
4
votes
0answers
64 views

Load data from WebAPI to the ViewController

My current code working perfectly, it is for data load from web api to the UIViewController (UITableView). But I am confused ...
3
votes
2answers
84 views

Managing rental charges for movies

The condition for refactoring is: Define 2 new rules with respect to rental charges that are applicable and with the ability to add new categories of movies. Ex: Rental amount for children's ...
1
vote
2answers
55 views

Chain Responsibility Pattern to filtering messages

Is this a good implementation of a Chain Responsibility Pattern? This code attempts to filter a message received (for instance, in a chat application). ...
1
vote
2answers
68 views

Factory design pattern with Shapes

I'm making the very common example of Factory design pattern which creates a factory of shapes and return an instance of the type Shape. I wonder which is the best way to replace that bunch of nested ...
5
votes
2answers
130 views

Program to model stress on furniture

I found this question in Glassdoor and CareerCup, this is an OOP design question. Many people claim to have solved it using different design patterns. I think It can be solved either with bridge ...
3
votes
2answers
205 views

Builder pattern and dependency injection

I'm working with the unit of work pattern to glue together my application logic. To create such a unit of work object I use the builder pattern. But my unit of work classes need access to the ...
3
votes
3answers
106 views

Table builder pattern

Trying to combine functional style (immutable objects) and flexibility of property setters. For the sake of example, let’s say we have a soil types table with two attributes: Color and Name. I am ...
4
votes
1answer
97 views

Searching files in directory with various filters

Requirements Note: the requirements are invented by me for practicing functional programming. Functional Requirements Given a directory, all files below the directory (and its sub directories) ...
0
votes
0answers
26 views

Self registration in factory class

I currently want the base class also be the factory with static Create function. To make base class does not need to know the imp concrete classes, I try to forward the two core jobs of factory to the ...
5
votes
1answer
122 views

N-Layered REST API

I am writing a pretty simple REST service in ASP.NET WebAPI with Entity Framework and I decided to use it as an opportunity to learn N-layered enterprise application architecture with some unit/...
3
votes
0answers
57 views

Generic repository accessor in a unit of work

I'm giving the repository + UoW patterns my first shot on the server side, so bear with me. Also, it's worth mentioning that I haven't used an IoC container on the server side before either, so I'll ...
3
votes
0answers
47 views

Unit of Work pattern for NHibernate

I have the following code implemented in C# for NHibernate: ...
2
votes
0answers
31 views

STTCL FSM framework based on the GoF State Pattern, Part III: Policy based design of higher level State Machine constructs

Preface I have decided to let my pet project created some years ago to undergo a code review here. The review will be broken into parts according to meta question Multiple reviews or one big review?...
1
vote
0answers
21 views

STTCL FSM framework based on the GoF State Pattern, Part II: Abstraction of asynchronous/concurrency features

Preface I have decided to let my pet project created some years ago to undergo a code review here. The review will be broken into parts according to meta question Multiple reviews or one big review?...
6
votes
0answers
49 views

STTCL FSM framework based on the GoF State Pattern, Part I: The basic interfaces

Preface I have decided to let my pet project created some years ago to undergo a code review here. The review will be broken into parts according to meta question Multiple reviews or one big review?...
-1
votes
1answer
21 views

Html SEO tags generator usually renders collections except for <title> tag [closed]

The context: I am currently struggling with a conception problem: I am building a SEO tags generator in PHP. I already managed to render some beautiful tags like these: ...
0
votes
0answers
32 views

Downloading data from webserver and storing it into database

I am trying to create a mobile app where in I am downloading data from webserver and storing it into database. To call a server and fetch data I am using HttpClient...
0
votes
0answers
85 views

Repository Pattern and raw ADO.NET

first of all I know this has already been discussed, but I couldn't find a situation that matched my case. I've been trying to implement the Repository Pattern and Unit of Work for a while now, ...
3
votes
1answer
84 views

Pizza lover program with Builder Pattern of GoF

I love pizza and design patterns. This is my first program to practice the builder pattern of GoF, without fluent interface. I put emphasis on the structure and characters of builder pattern. Here ...
2
votes
1answer
82 views

Zorua's happy chat room with Mediator pattern

The following is my little chat room system/structure. I've tried to follow the definition/intent of mediator pattern by GoF: Allows loose coupling by encapsulating the way disparate sets of ...
1
vote
1answer
79 views

Decorator Pattern in PHP Simple implementation

I am learning decorator design pattern in PHP. Please see what i am doing is correct or wrong, would appreciate your review, feedback, comments, suggestions. ...