A design pattern is a general reusable solution to a commonly occurring problem in software design.
1
vote
0answers
22 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
68 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
76 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?
...
1
vote
0answers
12 views
Displaying of Data in Application
I've just started creating a Menu/Order Application for the fun of it. Basically it's a program where a user can order certain products off of a menu. I am creating this in Unity3D so I don't have ...
3
votes
0answers
54 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
8 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
19 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
146 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
55 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
220 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
21 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
51 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
33 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
65 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
56 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
30 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
41 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
73 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
56 views
Controller for a vehicle servicing AJAX app
I am working on a codebase that operates in the following manner:
...
9
votes
1answer
87 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
100 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
54 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
30 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
30 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
77 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
66 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
35 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
46 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
76 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 ...
3
votes
0answers
26 views
Grouping functionality in JavaScript using an Object
I am creating a drawing-app. I want to have a toolbar populated with tools. Each tool is defined in a separate js file. Right now i have defined each tool as an object that contains functions and ...
5
votes
1answer
86 views
Option<T> functional type implementation and scenarios
Have you ever being implementing Option<T> functional type? It is discussed here. Basically, it is about using ...
2
votes
1answer
31 views
Need a better way to create subclass instances from a base class reference
FeatureMap contains features, derived classes have some mandatory features that the map should have, say keys (the mandatory part) are added and all the features are fetched from somewhere. Since ...
3
votes
2answers
89 views
3-level deep if-else tree for constructing a neural network
The following code fragment constructs different types of neural networks outputs based on the options supplied. Currently, my code just has a huge note that describes what all the options are ...
1
vote
1answer
59 views
2
votes
1answer
42 views
Dynamic Dispatch replacement for Generic methods
Type erasure is giving me nuts recently. I'm designing a class that performs symbolic differentiation on a math expression represented as a binary expression tree. The question is more on the design ...
4
votes
1answer
159 views
Implement mail sending system elegantly
In my project I need to send emails. Emails will have different credentials and senders. I'm thinking about "abstract factory", but will it be good solution?
...
0
votes
0answers
97 views
Repository pattern best practices
Which option is better?
In the first case, I use a universal repository that can work with any entities. The methods of this repository have many parameters, such as string queries, table names, ...
2
votes
0answers
97 views
ASP.NET MVC with automatic testing (follow up)
This is a follow-up of this question regarding MVC application architecture fit for automatic testing.
I have rewritten the DI code based on the answer provided there and also created some tests to ...
4
votes
1answer
110 views
Bloch's Builder Pattern / Updater
I'm creating many builders where I use inheritance.
My resources have many properties and are stored in a Repository.
In rare case I need to update them.
When I update, I need to keep the same ...
1
vote
2answers
94 views
Array class to replace all iterator needs
Following dreams, I have started learning Java for Game Programing purposes and, during code I figured out that Iterators such as Queue, Lists, Arraylists and what not are very common. I have written ...
6
votes
1answer
56 views
1 or 2 Player CLI Tic-Tac-Toe
I wrote a simple tic-tac-toe program in Haskell. It runs on the command line, has a one and two player mode, and implements a minimax algorithm when you play against it.
I'm used to writing proper ...
3
votes
1answer
38 views
C++ Template for one to many Registration (pre Gang of Four)
I use this template to lookup clients registered for data. The data is associated by name(key) and clients are shared pointers (value) to a class which will consume the data.
...
8
votes
1answer
53 views
Encapsulating Complex Calculation in JavaScript
This is code for performing a calculation that should be repeated with different levels and temperatures. I am concerned about the organization of this code as I feel it may contain too many helper ...
1
vote
1answer
106 views
ASP.NET MVC application architecture fit for Unit Testing with Mocking
I am trying to learn how to professionally work with Unit Testing, so I have refactored a medium sized project of mine (a sort of article aggregator that also does some ...
5
votes
1answer
71 views
How Godly does an object need to be before it becomes unholy?
I've been told that using God objects at all is a Bad Thing™
In object oriented languages, God objects know all, they control too much. I'm trying to build a game (or for the scope of this question a ...
0
votes
3answers
25 views
Filling name accounts
I think the content is too large and I am deeply think about how to refactor it. Does anyone have good advice on refactoring it?
...
7
votes
1answer
101 views
Refactoring of a client API to avoid duplicated code and unclear passage of parameters
I need to develop an API. The functions of the API are requests that call the services exposed by a server.
Initially the API worked like this:
...
6
votes
4answers
243 views
Simple factory retrieving object by name [closed]
Despite the fact that this code works, I would like to know if there's any situation I did not anticipated, and/or if what I am trying to do is some what wrong.
-std=C++11 flag needed
...