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

learn more… | top users | synonyms

1
vote
0answers
9 views

Creating a Kinesis stream, Firehose, and lambda event source from config file

I'm in the process of writing a python script for automating a data ingestion pipeline using Amazon Web Service's Kinesis stream, Firehose and lambda. This is my first stab at writing Python, but I do ...
-1
votes
0answers
42 views

c# Builder Pattern Usage Validation [on hold]

I have below class which builds reference data for my app, do you think it's a good implementation of builder pattern. What can I change to improve it? ...
0
votes
0answers
10 views

Python api for an existing Java API [closed]

I am new to python and I have to design a Python API(version - 2.7) similar to an existing Java API Python version - 2.7 The Java API is as follows There is a Process interface ...
0
votes
0answers
55 views

Business rule interface: does this pattern already have a name? [migrated]

I'm working on an interface for implementing business rules; basically, moving a lot of logic out of Web API controllers and into a business rules library. I've done some research and came up with ...
4
votes
2answers
82 views

DB-to-Java value mapper

In my company, I've inherited some Java library that I'm now writing tests to, refactoring and fixing Sonar issues. One particular point that Sonar is complaining about is a big chaining of ...
1
vote
0answers
24 views

Abstraction of NSNotification that removes the existing observer for a notification when a new observer is added

I ran into a problem in my app where under some conditions, a view controller might be loaded more than once before its deinit (where I was previously removing the observer) is ever called. So the ...
1
vote
0answers
52 views

Refactoring ValidationContext from inheritance into decorator

In one of my questions I used a ValidationContext class that looked like this: ...
3
votes
2answers
96 views

Command pattern with structs

I'm using the command pattern to enable actions in my game to be undoable. ICommand defines individual commands, ICommandHandler does the undo-redo logic and might be decorated with other handlers ...
1
vote
1answer
104 views

Call Center Design

Imagine you have a call center with three levels of employees: respondent, manager, and director. An incoming telephone call must be first allocated to a respondent who is free. If the respondent can’...
1
vote
2answers
77 views

Properly structuring SQLite classes/operations in Android

I am new to Android development and I want to ensure I'm learning decent practices for doing things. Right now this is my database class, which currently allows me to make a new instance of the ...
2
votes
0answers
44 views

Data structure of in-memory database [closed]

I am learning OOP, SOLID principles and design patterns. I have designed data structure of in-memory database in C#. Please provide suggestions to improve it better considering solid principles, OOP ...
4
votes
1answer
88 views

Basic Internet banking application

I programmed in Java before, but I feel that I lack the "true way" of programming (OOP concepts, design, algorithm), so I started to learn all of these but I need your opinions and suggestions so I ...
2
votes
4answers
167 views

Implementation of warning storage

I implemented type (UserRuleManager) that will apply list of rules to entity User. I need your code review and your advices. ...
0
votes
0answers
55 views

My take on implementing the Repository Design Pattern in PHP

The past few weeks I've been trying to grasp on nearly any Design Pattern ever invented, but the repository pattern is one I could understand and implement it myself in my project. My application uses ...
4
votes
1answer
69 views

Use of Module Design Pattern in simple D3 “overlay” program

I have been learning JS (mostly using D3) and I wanted to put the Module Design Pattern to use. I wrote a simple script that lets you build a bar chart with more ease / readable code. The end user ...
4
votes
0answers
26 views

implementing a StringEnum

this is to be used like an Enum (as parameter mostly), but for string using .net 3.5 Actual Implementation ...
0
votes
0answers
51 views

View/renderer for a polymorphic model

I need to render polymorphic models in different situations. Model's base class: ...
2
votes
1answer
79 views

Map rental cost strategy

It is the case where data contains some field indicating what type of strategy should be picked. I mean, I often ignore solving the problem like shown below and duplicate the problems that strategy ...
1
vote
1answer
44 views

Python file reader/writer, with processing pipeline and context manager

The following code does three things: The filename is determined by the RawData class The reader and writer send data through a processing pipeline (Hopefully) makes changes and extensions easy ...
5
votes
1answer
78 views

Write a program that, given an age in seconds, calculates how old someone is in terms of a given planet's solar years

Problem: Write a program that, given an age in seconds, calculates how old someone is in terms of a given planet's solar years. Earth: orbital period 365.25 Earth days, or 31557600 ...
2
votes
1answer
64 views

Form validation in core php with oops concept

Here, i build one form validation script in php using understanding SOLID concept. My question is the way i coded my code is true way for ...
3
votes
1answer
73 views

Write a small archiving program that stores students' names along with the grade that they are in

Problem: Write a small archiving program that stores students' names along with the grade that they are in. In the end, you should be able to: Add a student's name to the roster for ...
3
votes
1answer
43 views

Composite implementation of a prototype singleton registry

I am studying design patterns and I've implemented a composite prototype pattern which is also a singleton (one instance per JVM). The main and most important part of the code is the ...
1
vote
0answers
26 views

Save Custom Product Kit using Web Application

How far do I break down individual tasks within a typical scenario of "Web application reacts to user input"? For example, in the case below, say a scenario is "User submits a form, causing user data ...
5
votes
2answers
137 views

Simple builder pattern implementation for building immutable objects

This is a builder pattern implementation to build immutable Person objects: Person class ...
1
vote
1answer
37 views

Old and new shouts controllers

I have a photo_shouts_controller.rb and text_shouts_controller.rb which both have almost similar implementations, and I would like to refactor it. I have implemented a refactoring but I am not too ...
1
vote
1answer
49 views

Implementing builder pattern In Java with a static inner and a Concrete standalone class

I am studying Gang Of Four design patterns and I want to implement a builder pattern in Java. It seems there are two options to build a builder pattern: Using two different classes: A target class ...
0
votes
1answer
41 views

Singleton manager/service classes with mockable dependencies in swift

In our swift project, there are multiple service classes that encapsulate functions, mostly network-api calls. They implement a protocol, and depend on other service classes, e.g. an authorization ...
2
votes
2answers
107 views

Simple singleton database connection pool

I'm studying design patterns, and to demonstrate a singleton, I've implemented a primitive database connection pool. ConnectionPool.java ...
-4
votes
1answer
40 views

Am I violating the SRP in this code? [closed]

Here's a sample code that I made up : ...
7
votes
1answer
106 views

Repository Pattern without an ORM

I'm trying to learn the Repository pattern, and I have some questions regarding my current understanding of it. All the examples I've been able to find of database repositories use ORMs, but for a ...
2
votes
0answers
55 views

Design Patterns in Swift: Visitor

I'm solving the following problem using the Visitor design pattern in Swift: When a quote is requested or an appointment is booked we send out an email to the customer, and build an internal ...
0
votes
0answers
16 views

Design Patterns in Swift: Strategy

I'm solving the following problem using the Strategy design pattern in Swift: We order our parts from three different vendors. Each vendor has its own system for verifying and fulfilling parts ...
2
votes
0answers
38 views

Retrieving the most recent posts from the users someone is following

I have two different implementations for retrieving posts from the users someone is following and I want to know which one you would recommend using. First I'll show you the tables, and then the two ...
2
votes
2answers
75 views

Design Patterns in Swift: Mediator

I'm solving the following problem using the Mediator design pattern in Swift: Assume we track the location of all our mobile mechanics. We have noticed that there are times when a mobile ...
2
votes
1answer
43 views

Design Patterns in Swift: Chain of Responsibility

I'm solving the following problem using the Chain Of Responsibility design pattern in Swift: Not all mechanics are created equally. Some mechanics are more experienced and can do more than ...
5
votes
2answers
65 views

Menu Model class using Model-View-Presenter

The following code is for my Object Oriented Programming class. My program simulate the cashier's machine to order food. The code uses Model View Presenter. This class is the model. I have an ...
3
votes
1answer
61 views

Observer design pattern in Swift

The problem: We have a set of mobile mechanics who are assigned specific zip codes. Each zip code has its own hourly rate. We want to increase and decrease these rates when the number of idle ...
6
votes
3answers
120 views

View programming pattern in C++ without raw pointers

I'm trying to achieve, for lack of a better term, a "view" pattern in C++. It's probably most comparable to "views" in the Database world, where one can make a query, and then perhaps aggregate the ...
2
votes
0answers
44 views

Signing timestamped API queries

The following code should prove to offer sufficient security for public API so my main concern is about design flaws in process. It is meant to describe the process and eventually get included in ...
-3
votes
2answers
107 views

How can I refactor this method in C# with a design pattern? [closed]

I have this method in C# that could be refactored. Should I use a design pattern? I see too much repetition and it gets worse if more conditionals are added. Should I change it to a method call? <...
3
votes
0answers
60 views

Shape inheritance hierarchy

I have managed to build an inheritance hierarchy for shape class object and I am wondering if there is a better solution to combine the following 2 hierarchies. To begin, I have a 4 shapes classes ...
2
votes
2answers
56 views

Sending an SMS message using zenoss and python

I have just finished a simple python script which uses this module to call Zenoss API for getting live events. What the script does: connects to zenoss reads a file which has one phone number on ...
1
vote
2answers
699 views

Which is correct : Open one Connection for inserting List of objects or open connection for every single insertion?

I have written the following method twice but I don't know which is better from performance perspective, code design and best practice. First: ...
1
vote
1answer
85 views

Implementing Entity and Component in a game engine

I'm currently creating a game engine for my personal project. And I'm currently implementing Entity and Component System. Classes and Interfaces Definitions Here the classes and interfaces that ...
0
votes
1answer
60 views

Long running in-process Publish/Subscribe class

I have a Pub/Sub class that will call Notify() when published and that Notify() could take around 10 seconds, so I need to make ...
3
votes
1answer
175 views

UDP Server Design and Performance

What I'm doing I am writing a server to work as my games backend. The server is being written in C# using UDP as the protocol, while the game is in C++. The biggest thing I've been focusing on was ...
5
votes
1answer
218 views

Reading a properties file using design patterns

I am trying to read properties file using a singleton class. I would like to know if there are any best practices and design patterns to read the properties file. I found dependency injection is one ...
2
votes
2answers
212 views

Implementation of Abstract Factory pattern with different vendors for product

I am studying about design principles and design patterns. I have implemented an Abstract factory pattern as per my understanding. The scenario I have considered is as follows : There is an ...
10
votes
3answers
172 views

Pokemon stats calculator

I have a simple working (so it's not a hypothetical stub) framework for calculating Pokemon stats that will later be incorporated in a game. It uses the LCRNG from the first game in order to be as ...