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

learn more… | top users | synonyms

0
votes
1answer
31 views

Java constructor initialization practices [closed]

This code is just a simple idea which takes a query parameter and requests n number of third party services for the given query: ...
2
votes
0answers
35 views

Ember.js blog app architecture

I decided to create simple blog app by using Ember.js which should has the following interface For this purpose I created ...
0
votes
0answers
47 views

Simple Router class

I made a simple routing class that I like to get reviews for, mostly because I do not know how to make it SOLID, since I even made this class separate from the HTTP response, request ... for the sake ...
3
votes
0answers
15 views

Monkey patch data in dictionary

The chart data is stored in a nested dictionary struct @line_charts, and I need to convert the prices to target currency with the function ...
3
votes
0answers
45 views

Event Aggregator Pattern Decoupling

I have an Android application that is using an EventBus architecture with publishing and subscribing events. Usually this is ...
4
votes
2answers
68 views

Printing gitignores

I have written a simple program in Java 7 to write the .gitignore of different file types: ...
2
votes
1answer
43 views

Handling screen rotation with volley request

To handle screen rotation when performing a volley request, I've written this code: ...
1
vote
1answer
30 views

Input field that dynamically monitors model value

This question is regarding my approach to the following implementation requirement. Can you suggest a better alternative that doesn't suffer from the issues I'll point out in my implementation? ...
13
votes
3answers
1k views

RPG Character Builder

This implements a builder pattern for RPG game characters. Is this a valid builder pattern implementation? There are 3 characters: Paladin, Wizard and Elfo. There are 3 items: Potion, Sword, Arch. ...
-1
votes
1answer
67 views

Validate prices in Python [closed]

I am new to Python and OOP. I developed a program and the following code is part of a larger system. I used the facade design pattern. I'm looking for a review of my code and its design. The task of ...
3
votes
1answer
126 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 ...
1
vote
1answer
35 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
54 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
50 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? ...
3
votes
1answer
31 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
99 views

Observable template in modern C++

I'm trying to create a modern template class for a generic observable: ...
1
vote
2answers
51 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
145 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
56 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
42 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
57 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
223 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
76 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
67 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
61 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
174 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
518 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
47 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
71 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
57 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
43 views

Varying the parent class dynamically in Python

I am trying to dynamically pick a parent class in Python 2.7: ...
3
votes
0answers
54 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
379 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
63 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
90 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
42 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 ...
2
votes
1answer
76 views

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

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
156 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
44 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
98 views

Handling errors of nested promises

This is in one of my AngularJS controllers: ...
1
vote
1answer
46 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
66 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
179 views

Manage Connection Without 'using' statement

I replace this common statement: ...
1
vote
0answers
77 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
261 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
231 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. ...