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

learn more… | top users | synonyms

2
votes
1answer
49 views

Create Database Connection and run the Insert,Delete,Update queries Class in C#

Recently while developing our demo project I had to a write a lot of repetitive code for executing the database queries(Insert,Update,Delete). So, I have put all the repetitive code into a class ...
-4
votes
0answers
23 views

Factory pattern in javascript [on hold]

I am a novice javascript programmer. I am trying to create a wrapper around a javascript library which does the terminal emulation. I want to use a factory pattern to construct the variable ...
-2
votes
1answer
70 views

Decorator pattern using Java 8 [on hold]

Wikipedia has an example of a decorator pattern here: https://en.wikipedia.org/wiki/Decorator_pattern#Second_example_.28coffee_making_scenario.29 I was trying to solve this using functional style ...
0
votes
1answer
34 views

Controller method to modify Active Directory, other systems, and send notification with error handling

I have to handle an Action (Modify) about my web application. The app working with SMTP Email, ActiveDirectory, External System (...
2
votes
1answer
39 views

Validations in filter class

For my web application I have written AuthenticationFilter which validates each request to check against CSRF attacks, Browser Checks, Session Validity etc. Instead ...
2
votes
1answer
21 views

Image-processing filters using decorator pattern in Java

This is a follow-up question of this other one, where I was trying to use the Decorator Pattern in a Python example. I figured, that Java might be a better language for this exercise, so I ported my ...
1
vote
2answers
47 views

JavaScript modular framework for a large web-site

In my ASP.NET MVC project I simply inserted <script></script> into my views - it caused code duplications and spaghetti code. Now, I have decided to ...
0
votes
1answer
38 views

Image-processing filters using decorator pattern in Python 3

The goal of the following short Python 3 program is to improve my understanding of the decorator design pattern. Therefore, I would be mostly interested about feedback on this aspect, i.e. whether ...
2
votes
1answer
56 views

Java member method initialization pattern

To avoid the overridable method call in constructor dilemma this approache delegate the variables initialization and calls to overridable methods to a member method that return reference to the ...
2
votes
0answers
35 views

Input-reading library for Node.JS part 2

Note: This code is a rewrite of the post I mentioned here since according to CR policy I cannot update the same question. This is somewhat didn't went through that much thought process and I wrote ...
3
votes
2answers
81 views

Validation Error Handling - DRY Pattern Implementation

The Country, State and City functions accepts the Integer as Parameter and returns the ...
0
votes
0answers
19 views

Inheritance is better or composition design pattern in this scenario? [migrated]

Design and implement Cash Register: Given a number of items you will be required to calculate the total bill. Items are charged for in a couple of different ways: A given price for each item, e.g. ...
4
votes
1answer
74 views

Rock-Paper-Scissors with the revealing module pattern

In my ongoing effort in learning advanced JavaScript I tried to develop the traditional rock paper scissors game by using the famous revealing module pattern. I'm not comfortable yet with what has to ...
3
votes
1answer
75 views

Factory method that constructs objects that represents MySQL data types from query results

I'm writing a package that is designed to provide a convenient way to inspect the schema for a database. The goal is that I can use it for generator code to suit the schema. The complete code can be ...
1
vote
0answers
37 views

Event log implementation with TDD

Below is some code that implements an 'event log' whose purpose is to record events and periodically check that all events were recorded in chronological order. The collection of events must be ...
3
votes
1answer
84 views

Simple Wizard Goblin User Story Test Driven Development

I have written this to practice Test Driven Development. I would like to know if the process is right and how it could be improved. Problem Statement : A wizard can cast spell on goblin and make his ...
5
votes
2answers
100 views

Illumination as a way of instantiating new objects

Basically, what I mean by illumination is having a method create an object where the caller supplies all the dependencies. This allows us to hide our new keyword ...
4
votes
1answer
101 views

Using a LinkedList type of adjacency list to create the word game: WordLadder

Goal The user puts in a starting word and an ending word. My code creates a ladder between these words of words that are different by one letter. Start: gain End: fire Output: gain gait wait wart ...
-1
votes
2answers
67 views

Java dog hierarchy

I am supposed to write a small java program. The program must contain 3 different kind of dogs. The dogs can bark and move, these methods can be represented just by System.out.println();. Some dogs ...
3
votes
0answers
22 views

Mini school database with JS revealing module pattern

I tried the module pattern for the first time, with this exercise as a problem to solve: http://exercism.io/exercises/javascript/grade-school/readme It's a small exercise requiring simple tasks : ...
6
votes
1answer
101 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 ...
4
votes
2answers
90 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
29 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
55 views

Refactoring ValidationContext from inheritance into decorator

In one of my questions I used a ValidationContext class that looked like this: ...
3
votes
2answers
105 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
112 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
100 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
46 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
96 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
168 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
62 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
79 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
36 views

implementing a StringEnum

this is to be used like an Enum (as parameter mostly), but for string using .net 3.5 Actual Implementation ...
2
votes
1answer
82 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
45 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
88 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
101 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
79 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
44 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
27 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
190 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
51 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
63 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
205 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
41 views

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

Here's a sample code that I made up : ...
7
votes
1answer
112 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
57 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
24 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 ...