A design pattern is a general reusable solution to a commonly occurring problem in software design.
4
votes
2answers
45 views
Would this be considered MVC?
For many days, I've been re-designing my application, applying some custom pattern and making our code looks like a framework. I have something like this for separate the business logic, from views:
...
3
votes
1answer
56 views
Should I null coalesce EventArgs?
When I implement events, it usually looks something like this:
...
4
votes
1answer
44 views
Message Based Communication Design
I'm trying to design an API.NET for some communication purposes with Testing Equipment and I cannot figure out a proper way for designing the architecture.
Basically, we have different (physical) ...
4
votes
4answers
73 views
How to name template method properly so it makes better sense?
Some might not think it's worth asking but I consider good function names quite important. I am not sure what should be the overridable function name in what I think is template design pattern. I am ...
3
votes
1answer
41 views
Unit of Work / Repository nHibernate
I have a Unit of Work / Repository pattern in place to abstract away some nHibernate. Most examples I've seen though use the pattern a little differently.
In ...
6
votes
1answer
87 views
Abstract Factory Pattern C# Example
I am working through more tutorials on Design Patterns and came across the Abstract Factory Pattern. I extended it out a bit (the example that is) and want your opinion:
...
1
vote
1answer
34 views
How am I supposed to write a binary tree (S-Expression) pretty printer in C?
OK, I feel like I am doing something really wrong here. I'm just trying to create a binary tree, and a pretty printer for it. My approach is looking so bad I can't even...
...
7
votes
1answer
121 views
Unit conversion activities
Please review these activities which handle converting units in an Android app:
I would appreciate any guidance and advice on code refactoring and different design patterns or strategies that I ...
3
votes
0answers
35 views
Laravel - Repository and Entity patterns
I've spent quite a bit of time studying the repository and entity patterns and this is what I came up with. I would appreciate it if you could post suggestions and critique.
...
3
votes
1answer
55 views
Model Implementation That Calls RESTful API
I am working on a ground-up rebuild for an app that has a relatively simple purpose. Users can view/favorite entities that are backed by a RESTful API. I own both the client code as well as the API. ...
4
votes
1answer
36 views
Secure Functions in a Database Class
I am trying to solve as many issues as possible with my Database Class and bind statements as far as possible without actually doing it in the front-end. The goal is to do all of the heaving lifting ...
3
votes
1answer
40 views
An attempt to extend an enum to prevent branching without violating the Open-Closed principle
I love making utility State enums, and giving them methods that do useful things based on which instance of the enum is provided. This works when the enum is very specific to the class I'm working on, ...
4
votes
0answers
119 views
DRY + principle of least knowledge + MVC in JavaScript
Is there any way of improving this code? (Here's a JSFiddle with an example and comments)
Example: A Hotel greeter can greet guests and accepts tips, but it's impossible to see the total of tips a ...
2
votes
0answers
40 views
Abstract factory pattern implemented in Java
I need a code review on my Abstract Factory pattern written in Java.
Find the two enums AnimalType.java and DietType.java below.
...
2
votes
0answers
35 views
Proof of concept and learning exercise for the 'ports and adapters' architecture
The script creates a simple app with a GUI containing a input field and a button to select a folder. On startup a default value is set to the input field. If the user types a value or selects a ...
1
vote
2answers
194 views
Code duplication for just an if condition
I have two methods that are near-perfect duplicates. There is of course a code smell. The only thing that changes is the condition to increment a variable.
Language: Java7
...
4
votes
0answers
37 views
Static Multilevel Inheritance with CRTP (Fast Intrusive Pointers)
I wanted to have a way to be able to static_cast to the proper derived type pointer of a base class to simulate a virtual call. Here the virtual call is for a ...
0
votes
0answers
14 views
Need to provide an interface (for plugins) for taking input Type A, and returning output Type B [migrated]
public interface IMyInputProviderPlugin
{
IMyOutput Provide(IMyInput data);
}
This is an interface I need to provide so that I can dynamically load the dlls ...
2
votes
1answer
70 views
Is this a meaningful Intrusive Pointer Class?
Is this intrusive pointer implementation correct? I tried to use the CRTP Pattern to avoid a virtual destructor in my class ReferenceCounting which provides the ...
2
votes
0answers
73 views
Decoupling with a self-descriptive mediator function
I don't have a lot of experience writing libraries and just recently started thinking a lot about structure and patterns.
I wrote a tiny module manager based on the facade and mediator design ...
5
votes
3answers
96 views
Use of mediator design pattern with mailing list implementation
I have implemented the following scenario for the Mediator pattern sample:
MailingListMediator: Manages the subscription and send the mail back and forth.
...
9
votes
2answers
72 views
Scalability of running commands from user input
Here is some code I have that has been extracted and shrunk down from a project of mine.
...
1
vote
0answers
22 views
Good practices with Angular Google Maps directives and JavaScript
Is this code good practice? What kind of design pattern should I use for this specific situation?
The following function creates a new marker on a map. It sets a new image for it, except when the ...
0
votes
1answer
38 views
Factory Pattern to Abstract Factory Pattern [closed]
My Product Factory
public interface IProdctFactory
{
void Drive(int miles);
}
My Vehicle Factory
...
1
vote
0answers
35 views
Is this model a good management for the pattern UOW / Repository with NHibernate?
Searching on Stack Overflow and Google, I find many and many different implementation but none of that really convinced me, each had some small defect that prevented me from using it. So I tried to ...
2
votes
0answers
40 views
Implement.js JavaScript module pattern
I have been playing with a new JavaScript module pattern to see what I can come up with. I think it's quite powerful and wanted to know if it is something people would find useful?
I'm looking for ...
1
vote
1answer
55 views
Finding an entry in a Hashmap
I've been playing around with functional programming for a while now and just started learning Clojure. So the problem I'm trying to solve is the following:
I have a tree-like hashmap of tasks where ...
9
votes
2answers
188 views
Decoration Freak, or OCP in action?
I'm writing C# code to read and eventually parse VB6/VBA code modules. I have an interface like this:
...
2
votes
1answer
85 views
Should my service access layer communicate with my data layer?
I have separated my application into two pieces. The first piece is my core functionality project. The other piece is the UI of the application. The core functionality should communicate with web ...
2
votes
2answers
104 views
Refactoring conditional statements among different classes
I wonder there is any method of refactoring nested condition. It's just the same content with different contents and different classes which looks bad. I really want to reform this code which looks ...
7
votes
3answers
745 views
Usage of Decorator pattern in baking program
Is this a good usage of Decorator pattern? I'm trying to use Interfaces instead of Abstract classes.
(Component) Interface
...
6
votes
2answers
98 views
Create and organize some classes (hierarchy)
I'm trying to figure out what is the best way to create some objects in my application. The application is already running, but I want to structure things well and clean.
These objects represents ...
1
vote
0answers
39 views
Feedback for a mostly auto-generated generic data layer
I'm trying to make a reusable data layer that is mostly generated from a database via T4 templates. On top of this data layer, I'd like to have WebAPI endpoints for each repository, with most of the ...
1
vote
1answer
74 views
Am I using the JavaScript “module pattern” correctly?
I am reading this article about how you can organize JavaScript code for large projects.
I am attempting to write a simple events calendar as a way to play with some of these design patterns.
Using ...
5
votes
3answers
137 views
5
votes
2answers
49 views
Using the builder pattern to build mock objects and nested builders
No, this question has no roosting construction workers.
I'm not sure if what I'm doing is a good use of the builder pattern or whether its a bastardization of what its intended purpose was. I'm ...
5
votes
1answer
75 views
Generic Converter framework
I find myself frequently converting between formats so I have come up with the following conversion framework:
The converter interface surfaces a method to convert from a source type to a target ...
2
votes
1answer
67 views
Improvements in repository pattern [closed]
I am trying to learn the clean architecture by Uncle Bob. I wanted some basics and following this good post I tried to implement it in python with some minor differences.
...
3
votes
2answers
78 views
5
votes
2answers
96 views
UnitOfWork, removing abstraction of abstraction (Repository)
I'm creating a small project, but in the past I've used a Repository pattern for it, and it just seemed too bloated. I ended up having repo classes with huge amounts of queries. I'm trying to move ...
3
votes
2answers
85 views
Is my code overdesigned? Does it rely too heavily on interfaces?
Context:
I am using XNA to create a simple game / learning project.
Problem:
I have three interfaces, each with a different purpose in mind. However, the way I use them, as well as their ...
8
votes
2answers
326 views
3 tier architecture ado.net application
I would like to develop a student management system with repository pattern using ado.net (no EF or MVC).
I decided to create the model (business objects) and interfaces as one project ...
1
vote
1answer
65 views
Text-Based Simulator in C++/Qt with many commands
The following is an excerpt of a mostly text-based simulator of the iRobot Roomba robot vacuum. I made a class called Roomba that handles everything the roomba does. For those familiar with QT; There ...
11
votes
3answers
313 views
Validate and import data from an Excel file
I have recently designed a module which will do bulk upload for different contents. Basically the user will upload an Excel file, I will have to read and validate headers of excel then each value of ...
0
votes
1answer
29 views
Where the validation should be done in a 3 layers Entity-Repository-Service application? [closed]
I am struggling to define where the validation process would be better placed in the different layers of the application? (I am not talking about user input validation here, I'm really talking about ...
3
votes
2answers
114 views
Is this an acceptable implementation of the Adapter pattern?
I've used the UK Plug -> US Socket and US Plug -> UK Socket analogy. I've also made it possible for UK plug to use a UK socket and a US plug to use a US socket. The output of the SSCCE below is
...
2
votes
1answer
48 views
std::tuple objects or rvalue references?
I have some small "plugin system" (not sure this is right name). It allow you to store objects (plugins), and then call some methods from each of them. With this approach we have absolutely no ...
1
vote
1answer
58 views
Implementing command pattern in Python
I did some study on the command pattern but most of its examples were in Java so, there must be some difference in implementation in Python. I implemented it in Python with some minor differences, ...
11
votes
1answer
517 views
Problem: Traffic Flow
I have the following task:
The Shallow Alto city council has organized a special committee to
review the traffic situation in the city. Despite the fact that there
is nothing whatsoever to do ...
7
votes
1answer
103 views
Observer pattern implementation without subclassing
I have not yet seen an implementation of the observer pattern in Python which satisfies the following criteria:
A thing which is observed should not keep its observers alive if all other references ...