A design pattern is a general reusable solution to a commonly occurring problem in software design.
-1
votes
0answers
3 views
Backbone communication between views , a different pattern [on hold]
I've read about mediator, event aggregator, using, backbone.events ...etc
I need advise about another potential pattern below, do you think this is evil ? or good ? if not good what are the ...
6
votes
3answers
106 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
35 views
Signing timestamped API queries
Goal
The following code should prove to offer sufficient security for public API so my main concern is about design flaws in process.
Provided code is meant to describe the process and eventually ...
-3
votes
2answers
97 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
44 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
35 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
671 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
72 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
43 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
67 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
98 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
197 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
157 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
59 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
64 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
78 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
6 views
A property that can represent both a fixed date and a day range: How to properly model that? [migrated]
I work in a system that can represent a "shipping estimate" in two ways:
A specific date: The item is guaranteed to ship at that date
A day interval: The item will be shipped "X to Y" days from ...
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
45 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
50 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
107 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
90 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
181 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 ...
0
votes
0answers
20 views
Database stored procedure with a “preview mode”
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
26 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
153 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
64 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
242 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
28 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
56 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
71 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
59 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
32 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
43 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
78 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:
...
9
votes
1answer
90 views
Portfolio object made of Asset classes and Securities
I am learning Swift and object oriented programming. I am new to design patterns and protocol oriented programming.
In my test code I have several related objects:
...
6
votes
1answer
105 views
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 code better? How can I avoid casting in this code? What if I add new Object like WaterTank ...
2
votes
1answer
56 views
Abstract factory pattern for implementing AdNetworks on multiple platforms [closed]
Here's the link to the github project.
I want to implement abstract factory instead of adding platform-dependent compilation flags in just one file and make it ugly, hence decoupled code. Moreover, ...
1
vote
0answers
31 views
Pattern-matching-esque code
I've come across a need for code like this a few times - you have an object (or objects) that may or may not have certain properties and values within those properties. Consider a program with ...
1
vote
0answers
33 views
TreeNode with nested super as parent
I found a way to use the JLS as a tree-structure (at least in let the parent-field disappear).
Please ignore the main-method.
It works, but from OOD would you say this is ok?
...
2
votes
1answer
83 views
Unity3D script for controlling a character
This is a Unity3D script I wrote for my game to control a character. I don't consider myself a highly-skilled coder, so I come here to ask for suggestions. Is my code clean enough? How can I improve ...
2
votes
0answers
74 views
Dynamic graph in C++11 with shortest path algorithm
I've been designing a dynamic graph to improve my understanding of C++11. The dynamic aspect means that it could represent the hyperlink structure of a chunk of the internet, with node deletion ...
1
vote
0answers
45 views
Find the appropriate transformer for an abstract value
I want to get rid of the following code duplication within the MyFacadeBean. Consider the following situation:
...
0
votes
1answer
41 views
Implementation of bridge design pattern for a web scraping app - follow-up
Earlier today I tried to implement an example of the bridge design pattern, but I ended up misinterpreting it.
I made a lot of changes:
...
0
votes
1answer
49 views
Implementation of Bridge Design Pattern
I made an implementation of the Bridge Pattern to handle ever-changing in crawler APIs that I'm using in my APP.
...
3
votes
1answer
47 views
Class structure to handle API exchange
I'm developing a simple application that crawls web pages to obtain some information. For this I used and tested some libraries, like crawler4j, jsoup, jaunt and htmlunit. I change the crawler APIs ...
3
votes
1answer
86 views
Wrapping decorator pattern with a builder
I'm working on a booking application and am in the process of porting some legacy code to a more SOLID and testable architecture. Right now I'm working on the process of canceling bookings. Over the ...