A design pattern is a general reusable solution to a commonly occurring problem in software design.
-1
votes
0answers
20 views
Why is it bad, if an entity can save itself? [on hold]
with a few ORM I can see that:
$entity = new TableName();
$entity->setName('username');
$entity->setPassword('zxbvc');
...
4
votes
2answers
75 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 ...
0
votes
0answers
20 views
I am currently writing my code in which my Business Layer matches my Data Layer , how can I change this? [closed]
Currently I am calling from my console application into a business layer and then that calls into a data access layer. The issue is that it doesn't seem to be gaining me anything when my DAL and BAL ...
1
vote
0answers
17 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
48 views
Refactoring ValidationContext from inheritance into decorator
In one of my questions I used a ValidationContext class that looked like this:
...
3
votes
2answers
95 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 ...
-4
votes
0answers
37 views
is using `br.readLine()+br.readLine()` is like putting bug in code? [closed]
while reading lambada got this point
...
1
vote
1answer
94 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 ...
1
vote
2answers
75 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
82 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
68 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
25 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
50 views
View/renderer for a polymorphic model
I need to render polymorphic models in different situations.
Model's base class:
...
2
votes
1answer
78 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
42 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
77 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
56 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
71 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
42 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
130 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
38 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
96 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
7
votes
1answer
102 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
52 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
72 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
41 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
64 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
57 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
43 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
106 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
59 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
53 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
691 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
82 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
159 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
202 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
209 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
170 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 ...