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

learn more… | top users | synonyms

1
vote
0answers
31 views

Populate tree from 3 different data sources and show its content

The task is to build a WinForm app which populates a tree from 3 different data sources and shows its content. 1 ComboBox at top - to choose datasource. (File System, XMLFile, SQLDB) 1 Button next ...
1
vote
1answer
28 views

Interfaces & Factory for generic container supporting PeekMax, PeekMin, Sum, and PeekNextToMax

This is a partial update of this question. An implementation of these interfaces is in this question. To summarize, the class is a generic container similar to MaxHeap, but only needs to support the ...
3
votes
1answer
50 views

Unit testing a service to return items from a database

I have been a developer for many years and get core development concepts, as well as unit testing ones such as DI/Ioc, Mocking etc. I also understand the values, importance of unit testing and writing ...
0
votes
2answers
35 views

Observer pattern implementation

I'm reading Head First Design Patterns and I'm currently reading about the observer pattern. Is what I produced correct? ...
0
votes
0answers
39 views

Optimising nested for loops Java [closed]

I am having a code that does scheduling of a days events based on the exact fit basis. I am kind of having three nested for loops and I'd love to hear thoughts on ...
0
votes
0answers
19 views

Dilemma cash flow modeling [closed]

I'm studying a modeling form to be the most generic and reusable I can with the cash flow design, but there's many variables in the model. Am I on the right way? My model It is too fragmented? Is ...
3
votes
1answer
25 views

Insertion sort in Common Lisp

This is my first bit of significant code in Common Lisp, an implementation of insertion sort. Being new to Lisp in general, I'm wondering if this code follows best Lisp practices in regards to program ...
3
votes
1answer
90 views

Observable template in modern C++

I'm trying to create a modern template class for a generic observable: ...
1
vote
2answers
46 views

Replacing an application service class with multiple command handlers

I have a Controller which uses an application service to accomplish its tasks. The service class is starting to grow big and developing multiple dependencies. So I am thinking of replacing the single ...
7
votes
2answers
137 views

Building an IDE, block by — er, mock by mock

The opening sentence of an answer I received in my previous post snowballed, and led to completely ditching the previous approach. Mocking my IDE with a MockFactory ...
6
votes
1answer
49 views

Connect 4 (glorified tic-tac-toe) implementation

I'm posting here my implementation of the game Connect 4. It's obviously a pretty trivial game and code but I'm primarily interested in any advice concerning improvements to the code structure: types, ...
5
votes
1answer
40 views

Type Validation using State Monad

I am attempting to build a compiler for a stack-based (or concatenative) programming language in Haskell. I've done fine getting the lexer and parser up and running, but now that I'm into the meat of ...
7
votes
1answer
54 views

Using delegates to avoid duplicate creation of resources

I'm writing a PCL that uses an HttpClient to go visit a few sites and extract data from them. My initial code looked like this: ...
4
votes
4answers
220 views

Engineering a minimalist image interface without templates

I'm practicing different ways of class design, so I'd like feedback on the design characteristics. Of course code practice comments are also welcome. It was a conscious decision to omit templates. My ...
1
vote
2answers
72 views

Adding action id to a history repository

In my system I have a history repository. My history class is big and with a lot of information regarding operations. My ...
4
votes
2answers
60 views

Decorator pattern for an application

I've created a decorator in my Rails application. However, the initializer has 3 params. Is this generally acceptable in decorator or should I refactor this or try a different pattern? ...
1
vote
0answers
52 views

Soccer game using libgdx and an Entity System Framework

I'm working in a game as a hobbie. I'm using an Entity/Component/System architecture using Libgdx as Engine and Ashley as Entity Framework. I have a GamePlayScreen in which I initialize my system, ...
7
votes
6answers
157 views

Super Market Checkout Pricing Strategies

I saw this question and thought it looked like a great opportunity to try my hand at the Strategy Pattern. I've never used it before, but I think I did pretty well. Did I? The code below can also be ...
5
votes
4answers
505 views

Database adapters

I'm writing adapters for some MS Access database because I really didn't like that automatically generated code that Visual Studio was providing. Right now I just need to get data, not updating ...
1
vote
2answers
44 views

Separate Ajax code in separate modules

This is the first time I am working on OOJS code and I am a beginner in JS. I think I have pretty much messed it up. I am planning to modularize my code, but with the inclusion of ...
1
vote
1answer
64 views

Creating various types of menus using dependency injection

I am here to discuss what are the possible improvement can be made in order to make the following code covering all the principles of programming paradigm ( SOLID , DRY ...etc ). Basically, I am ...
3
votes
1answer
61 views

Communication between View and Controller in MVC implementation

I'm working on a moderately complicated (not super basic, but not a feat of programming strength) project to create a virtual tabletop for a tabletop game I play. I'm trying to conform to good design ...
0
votes
1answer
55 views

Define constants in Util class or not

Which is best? I have a bunch of components in my projects. It's related to Ashley (a java entity system) to libgdx (a game engine). this components are like that: ...
-1
votes
2answers
42 views

Varying the parent class dynamically in Python

I am trying to dynamically pick a parent class in Python 2.7: ...
3
votes
0answers
51 views

Representing trajectory points using inheritance

Problem Background I need to represent trajectory points and trajectories (encapsulating these points) in the form of a collection of classes. All trajectory points have two essential elements: time ...
11
votes
2answers
294 views

C++ Observer design pattern implementation

I'm using the Observer design pattern in order to manage events in the game I'm currently developing. I based myself on the implementation demonstrated here but improved it in order to ease its use. ...
4
votes
1answer
62 views

Number Wizard standalone (UI independent) implementation

I was inspired by Number Wizard game question and I decided to write my own version of the game. My goals were to follow the SOLID principles and make the logic UI independent. I'm a bit confused ...
3
votes
1answer
75 views

Linq-to-SQL DAL on a Windows Forms project

I just started out a new job as a C# programmer on .NET 3.5. My manager gives me total independence on how I build my modules, which is generally a good thing, but there are minuses too. Having too ...
1
vote
1answer
38 views

Fruit game using nape physics with refactoring to Builder Pattern

I am doing a game that uses nape physics in ActionScript, but my question isn't about language. It is about the use of patterns. I had fruits in my game. I did one interface ...
3
votes
1answer
62 views

Is it an anti-pattern to let ViewModel fill itself from a domain object?

Let's say you have a Employees table mapped to a Employee class. Now you want to code a Edit page for general information. You need a ViewModel with all the properties you need to build the page, so ...
2
votes
2answers
58 views

Generating classes from enum

I have a system that receives messages. Each message has a type defined. These types are declared in an enum: enum MessageType { TYPE1, TYPE2, ... , TYPE999 } ...
6
votes
2answers
152 views

Performing multiple validation checks

I have a validation which checks that a string is a valid asset number. There are currently three formats it could be in, like: 001-123456, ...
1
vote
1answer
43 views

Manager for customer billing and subscriptions in Rails

I'm looking to get rid of a couple dependencies that I have a sneaking suspicion are present in the code that I'm writing. Right now I have a service class that manages my subscriptions for part of ...
1
vote
2answers
86 views

Handling errors of nested promises

This is in one of my AngularJS controllers: ...
1
vote
1answer
43 views

Organizing museum artwork

I have a small Django project to help organize museum artwork. In my models.py file, my museum object is defined as follows: ...
1
vote
1answer
65 views

PHP Memento design pattern implementation

I am a self-taught programmer. I decided to learn design patterns by reading about them, and then coming up with their implementation in PHP. I know that learning would be virtually impossible without ...
6
votes
1answer
136 views

Manage Connection Without 'using' statement

I replace this common statement: ...
1
vote
0answers
70 views

Replacing IUnitOfWork with a Factory Pattern

As a follow-up to this blog post and this question, I wanted to post my idea of replacing the IUnitOfWork with a factory pattern. It seems to me that in the case of this blog post the IUnitOfWork ...
1
vote
1answer
54 views

Exposing includes to client over webservice for database queries

I am using a CQRS type patter for querying data in my application. I am currently using entity framework to connect to the database. ...
0
votes
2answers
211 views

Library management system in C++

I am doing a beginner C++ project and it's simply a library management system where a student will hire, give back a book, book and hire records are stored in a binary file etc. I'm approaching the ...
6
votes
2answers
119 views

System for registering people

For a small administrative program, I have to be able to register people and their data. But, files are sometimes created through a phone call "on the fly" and then later certain data is added to the ...
7
votes
1answer
212 views

Creating composite objects using the builder pattern

I need to decode and encode TLV (Tag, Length, Value) data which is a composite part-whole tree structure. ...
2
votes
2answers
39 views

Functions and a GUI for entropy-related calculations

I wrote a script with utilities for calculating the entropy of iterables and included a Tk GUI that shows a quick overview over a text's properties in real-time. (on GitHub) I tried to follow PEP 8 ...
2
votes
1answer
35 views

Is it bad practice to have executable code in my channel state object?

I have a CommunicationStateMachine object that's attached to my channels. It keeps track of who's turn it is to speak, how far along the conversation the server and ...
2
votes
0answers
27 views

Functional, Loaner-Like Pattern For Consuming SQS Queues, Deleting Queue Items On Success

My program fetches input from a RabbitMQ or Amazaon SQS-like queue. There is not always input available in the queue. If a message is available, it triggers work. If that work is successful, ...
4
votes
1answer
88 views

Observer Pattern with an Observer observing multiple Subjects

Is the below a good solution for an observer to monitor multiple subjects. My only fear is that if an observer was monitoring a wide range of subjects then the update method could get quite large ...
1
vote
2answers
117 views

Generic repository object design + static DAL helper

I would like you to review the solution I came up with to the following scenario: In attempting to model a generic Repository object (that receives a generic type parameter) to interface with my ...
3
votes
2answers
130 views

Building a chain of responsibility in Ruby to apply transformators on an object

I try to make a middleware stack system in the rack way (but not for HTTP request). Here is the main class: ...
2
votes
1answer
53 views

Shared access point

In my game, people connect to my server. The server creates a GamePeer per connection. GamePeer creates one ...
3
votes
2answers
133 views

Service Layer Design

I have written the following service class for my application and at the moment it only contains a single method which is responsible for carrying out the necessary actions to add a new team to the ...