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

learn more… | top users | synonyms

0
votes
0answers
5 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 ...
-4
votes
0answers
27 views

Code Refactoring [on hold]

How to Refactor the following code ...
2
votes
2answers
51 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 ...
-2
votes
1answer
42 views

Iterate through a table object to get subobjects [closed]

I have various examples of getting a grid/table data For example I get in personId,CourseId sorted order PersonId, PersonName,Email, CourseId,CourseName I then need to for example email it. ...
-4
votes
1answer
36 views

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

Here's a sample code that I made up : ...
7
votes
1answer
84 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 ...
1
vote
0answers
34 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
13 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
30 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
57 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
30 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
54 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 ...
1
vote
0answers
14 views

Leaky DAL or anemic BLL? [migrated]

Particularly for the sake of unit testing, I'm trying to implement an application with a layered architecture. I'm coding in C# and using ASP.NET Web API for the service layer. I'm aiming at a 3-layer ...
3
votes
1answer
43 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
116 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
42 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
104 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
48 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
44 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
679 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
76 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
47 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
83 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
129 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
203 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 ...
0
votes
0answers
17 views

Reusable Properties File Reader [duplicate]

I have implemented a properties file reader. The goal behind creating the properties reader is to cater to different application teams to import the class and read the properties in their projects. ...
10
votes
3answers
161 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 ...
3
votes
1answer
64 views

Application Settings Helper

I'm developing an app which stores some different user settings in app.config such as connection strings, paths for saving reports, default printer e.t.c For retrieving them I made a static class ...
2
votes
2answers
69 views

Module pattern JavaScript to initialize page, add event listeners, load map

I've written a script that I would love to get feedback evaluating the following: Module Pattern implementation, robustness, conciseness, cross-browser compatibility. My goal is to eventually use this ...
1
vote
1answer
81 views

Throwing exception in the singleton pattern in C#

I'm implementing an HTTP client shell that's going to be used for the lifetime of my application in C#. It needs to be initialized before the instance can be accessed. It looks something like this: ...
0
votes
0answers
30 views

Command and observer pattern to build installer wizard

I've done this mainly as an exercise to understand these design patterns. I'm writing a theoretical install wizard which will allow users to select different options throughout, and have it execute ...
2
votes
2answers
46 views

Instantiating different kinds of error records for a database operation

I've written code to be called from Powershell like so: Rename-DatabaseUser -Name 'someuser' -NewName 'somenewuser' I'm wondering if there's another way I can ...
2
votes
1answer
51 views

Convert custom format to XML Template

I have just finished writing a simple Python3 program which converts a custom input file (or multiple files within the same folder) to an XML template. It works as it is, but I think that I somehow ...
1
vote
2answers
109 views

Strategy pattern using an abstract class and an interface

I have implemented some sort of the strategy pattern using an abstract class and an interface: ...
1
vote
2answers
97 views

Instantiating shapes using the Factory Design Pattern in Java

Trying to learn the factory design pattern, came up with some code based on a Shape Factory (found this example here). Is this the right way to implement the factory pattern? ...
14
votes
1answer
188 views

Simple dictionary storing/viewing application

A TreeView on the left which just displays a list of files saved by the application. A DataGridViewon the right to display data ...
1
vote
0answers
29 views

Database stored procedure with a “preview mode” [migrated]

A fairly common pattern in the database application I work with is a need to create a stored procedure for a report or utility that has a "preview mode". When such a procedure does updates, this ...
0
votes
1answer
31 views

ViewModel class in Typescript

I am trying to refactor a ViewModel class because it has two methods that are really similar called updateRegions and ...
6
votes
2answers
159 views

Dependency problem in C#, through polymorphism, and appropriate design pattern

I'm currently working on a project which involves EntityFramework with a (very) rich model (lots of inheritance). I'm currently facing a problem, quite interesting in my opinion. My model is ...
5
votes
1answer
70 views

Custom Navigation Bar View Implementation

In one of my app, i m using custom navigation bar view to handle all Navigation Bar Properties. Is it good practice to use custom navigation in given below way? Any Optimizations need to be done. It ...
8
votes
1answer
252 views

Business with dbcontext and static class

Many speak of using dependency injection. I do not use repository. The entity framework is uow/repository. What is wrong with using static class like the one below? My context is a new instance per ...
2
votes
0answers
31 views

Implementation of MVC in Java

I've followed several guides on how to implement MVC in Java, and so far I've come up with the classes shown below. From my understanding, MVC follows these guidelines. The Model should be ...
5
votes
1answer
59 views

Message Service

Below is the code to a Message Service. Does anyone have any ideas on how to improve the methods. It doesn't feel clean to me. ...
-1
votes
1answer
38 views

LINQ to SQL code - in models project or in db project

I currently have two projects. One called Models, a second called TaskEntityModels, a model first ...
-2
votes
1answer
73 views

Enum Singleton implementation in Java

I just wanted to implement the enum singleton in java. Here is my implementation where I have tried to create a singleton DataSource instance: ...
2
votes
1answer
62 views

Command design pattern in remote controller model

I'm learning command design pattern right, so I decided to make this project. Basically it's a remote controller and it issues commands to VCR. I've seen different implementations of this pattern so ...
1
vote
0answers
34 views

Decorator to construct a composite in Python

To gain more insight on the language and its advanced features, I coded a decorator to patch a Python class and obtain a composite. The composite can be constructed inferring methods from an interface ...
4
votes
2answers
45 views

Command pattern for non related recievers in Java with command execute and undo operations

Below is the code I have written to enhance my understanding of Command Pattern in Java. As per my study and understanding, when we have some entities [ which we call as receivers ] then Command ...
1
vote
1answer
79 views

Object-oriented implementation of a real-world scenario of using a bathroom - follow-up

This is revised code for the previous question: Object-oriented implementation of a real-world scenario of using a bathroom Is there any object oriented way or design pattern I can use to make this ...
4
votes
1answer
57 views

Controller for a vehicle servicing AJAX app

I am working on a codebase that operates in the following manner: ...