A design pattern is a general reusable solution to a commonly occurring problem in software design.
4
votes
2answers
114 views
Separation of concern on micro lvl
The task is to create a DataTable with 1 column + header and 7 rows with content. The content will never change
Implementation:
...
11
votes
4answers
2k views
TicTacToe AI needs optimization
How do I condense this gigantic monster into something more manageable? I heard about command pattern but I can't figure out how to use it. What other solutions are there?
...
-1
votes
1answer
42 views
DDD and Dependency Injection a smell or common [on hold]
I am working on a little something to build up my understanding of DDD. Those of you who are familiar with the game Fantasy Premier League will perhaps understand my dilemma or even maybe inform me I ...
1
vote
1answer
52 views
Car store implementation using abstract factory
I'm studying design patterns and I made this car store implementation. Although I'm confident that the idea is right, I'm not confident that the implementation is good. I would like you to check it ...
3
votes
0answers
27 views
Follow up on CRTP with multi-level hierarchy
I was working on a similar problem to this post, asked a question on the Eigen Mailing List, and Gabriel pointed me to the above post, from which I was able to get my code working again. He further ...
5
votes
3answers
67 views
Design of a remoteControl class for connecting to electronic devices
In a course that I'm taking on learning object oriented programming in java, I have completed an assignment for modeling a home entertainment system and the ability for a user to be able to use a ...
0
votes
1answer
37 views
Design pattern proper usuage where a decorated object may ask for things like “status updates” from the decorator to perform its role [closed]
Here's a situation that has haunted one of my open-source projects for quite some time:
Imagine if you could represent every front-end input form with a single backend object? An object that contains ...
8
votes
2answers
56 views
Adapting a bilingual program to support users with learning disabilities
I have a very large class which serves as the BaseClass for many AdapterClasses. The base class consists of methods that can be ...
4
votes
2answers
193 views
Performing actions based on command line arguments
I'm currently reviewing a bit of an older console application which performs certain tasks depending on the command line argument that is given. These tasks are called through Windows Task Scheduler.
...
4
votes
2answers
919 views
Switch statements in Rock-Paper-Scissors game
I am very much new to design pattern. I'm trying to modify the Rock, paper, scissor game from an example book where I try to add more various design pattern. But I am encountering two similar switch ...
0
votes
1answer
63 views
PHP framework building: initializer and object loader classes
I am building a PHP framework and would like to get some feedback on a few different sections of the project. I consider myself still a neophyte in PHP so I would like to ask if I'm going about ...
5
votes
1answer
50 views
Dynamic display of number converted to different numeral system
The program is displaying given number (right now it is only signed int) converted to different numeral system (binary,octal and hexadecimal for now).
Number can be input in the text box and the ...
2
votes
0answers
48 views
Updating the coordinates of items possessed by a moving person
A Person has coordinates and an Item has coordinates as well, and hence both are derived from ...
0
votes
1answer
46 views
Java class: for getOrder, getData, updateData operation
Problem Statement :
Design a class for three operations for given set of integers :
...
3
votes
2answers
46 views
IRC Server Response Parser for IRC Client
I wrote a parser for the IRC RFC 2812 spec and would like input on my use of the strategy pattern for this.
I created an IrcMessage class that is responsible for ...
1
vote
1answer
36 views
MVC + Events in JavaScript
I'm a bit lost with implementing MCV pattern on javascript.
Where should events (such as 'click','change') come in on MVC in javascript?
I have this event function,
...
0
votes
0answers
50 views
A client with transports that have unique options
How can I improve the following interface implementations and client using it? I feel the transport ideally should be hidden from the user of Client but then how ...
3
votes
0answers
43 views
Web service for Android clients to store images
I wrote this code for Android server interaction. The way I built the client was an onSharePreference of strings includes photo encoded to a base64 ...
4
votes
1answer
87 views
From event handler to command: on my way to MVVM
I have a WPF C# application that I want to move to a MVVM pattern.
My first step is to remove the button click handlers from the code behind of the UI.
I've found some examples online and then ...
5
votes
2answers
123 views
Stack data structure unit testing
I have this contract:
public interface Stack<T> {
void push(T object);
T pop();
int size();
}
I am curious what you think about my test of the ...
4
votes
2answers
128 views
C# static class holding list of member class instances
I was wondering if such a design was a bad idea in C#. Here I have a static class EventLog which holds a list of instances of ...
2
votes
1answer
55 views
Design patterns: choosing the right handler depending on data type
Suppose we have an application which process packets from somewhere. We should choose right handler for the packet depending on packet type and also we know that it might be necessary to change ...
3
votes
2answers
77 views
Communicating messages to objects
In my MUD game engine, I built a messaging api that allows objects to subscribe to concrete implementations of an IMessage interface. Is there anything glaringly ...
4
votes
1answer
55 views
Executing a list of tasks from a database
I have a list of tasks I get from my database (as strings) and then execute. However I'm uncertain on how to implement this correctly.
Currently I have implemented this in the following way:
...
1
vote
1answer
104 views
IRepository Pattern - Interface Segregation Principle
I have an IRepository class that I use a lot. But I noticed that for many of my repositories I do not implement most of the methods. Also, I usually don't have a ...
8
votes
1answer
66 views
Refactoring my Todo List was on my Todo List. How's my MVC?
This is a follow up to Rolling my own Configuration with UI. I got a lot of great advice about the Configuration system I created, but no one touched on how all of my logic for the UI was in the code ...
10
votes
2answers
295 views
Reusable Unit Of Work Interface / Factory
Given my IUnitOfWork interface
using System;
public interface IUnitOfWork : IDisposable
{
void Commit();
}
I then ...
2
votes
2answers
91 views
Text-based Tetris game CRTP 3
Previous question:
Text-based Tetris game CRTP 2
Summary of improvements:
Fixed Issues preventing the code from compiling on Clang
Implemented helper class ...
-5
votes
1answer
66 views
4
votes
3answers
107 views
Moving business logic towards the domain object as a design pattern
My project is composed of several parts: Repositories, Services, Domain objects, etc in a .NET MVC web application.
My repositories handle all data i/o, the services are responsible for CRUD ...
1
vote
1answer
196 views
PHP/Phalcon RESTful API architecture
I'm building a RESTful API in PHP using the Phalcon framework. The API will consist of multiple modules (e.g. api.example.com/mail/users, api.example.com/web/users, etc). So I want to put all module ...
16
votes
3answers
620 views
How to Train Your Dragon
I started out practicing on implementing the builder pattern and somehow ended it up with this 2 hours later. It isn't really much, but it works and I'm hoping review should bring about a lot of ...
3
votes
2answers
75 views
Mediator pattern implementation for game messaging
I am building out a MUD game engine and want my objects to communicate with each other. There is a wide range of message types that will be sent around, all of which implement IMessage.
I adopted ...
4
votes
2answers
66 views
Multiclassing and updating each of its component classes whenever it changes
A Multiclass character can consist of any number of component classes. For example, if Fighter, ...
2
votes
1answer
100 views
Markov text generator
This is a Markov text generator I've created in JavaScript. I'm pretty sure the term "Markov" applies, anyway.
The way the generator works is like this: it first divides the source text into unique ...
3
votes
2answers
50 views
Family and vehicles example using the strategy pattern
I have studied the strategy pattern and understood it w.r.t the example given in the PDF that I referred. I wanted to make sure that my understanding is correct, so I have written a simple program in ...
0
votes
0answers
34 views
Designing entities, use cases and repository
I'm developing an Android application which would remotely connect to an insurance database and perform some basic CRUD operations and I'd like to learn how to keep clean app's architecture from ...
2
votes
1answer
57 views
Large message population design
We are designing a small framework to create and send messages to external parties as a result of internal events. I am reasonably happy with the design, but I am wandering if it can be further ...
2
votes
0answers
70 views
Text-based Tetris game with CRTP - follow-up 2
Previous question:
Text-based Tetris game with CRTP - follow-up
Summary of improvements:
Fixed issues preventing the code from compiling on Clang
Implemented override specifier
Fixed single letter ...
2
votes
0answers
126 views
MVC Login for Android
The code for my Android application is below and so far I'm happy with it. Before anyone comments, I do acknowledge it requires the addition of further validation. The android application is a login ...
7
votes
1answer
69 views
Implement stateless strategy pattern with enum being container
I am implementing a framework for validating orders. User creates a number of orders (Amazon orders for example), before he submits the orders and pays for shipment, whenever he revises anything, I ...
6
votes
2answers
122 views
Strategy Pattern Implementation
I thought I would learn a design pattern today and picked this one. I wrote a simple Android test demo to test the pattern.
main.xml
...
2
votes
0answers
43 views
Binding model to view
What I need - if there are some changes to model in must be rendered in view (HTML). The main problem here is to catch changes in model.
Firstly I tried to use watch. However it can't work with IE8 ...
6
votes
1answer
92 views
Android game setup
I've been working on a basic Android game these days, but I'm a bit uncertain about my setup and need some advice. The basics of the game are simple: there are characters running on your screen and ...
2
votes
1answer
33 views
GSON parsing - nested classes or not
Today I was trying GSON after a while and went to the YQL console to run this query:
...
3
votes
1answer
58 views
Functional organisation of JavaScript functions
In one of the web apps I contribute to, the main.js file has multiple interacting "objects". Unfortunately, I'm so bad at OOP in JavaScript, despite studying other ...
4
votes
3answers
222 views
3
votes
1answer
62 views
Implementing a binary operation for the null object pattern
Today I needed to implement a class for representing rectangular regions with some binary operations such as merging or intersection.
...
15
votes
4answers
2k views
Design a chess game using object-oriented principles
I would like to know if my approach is correct and how could it could be improved? Also, is there a way to get rid of the relation between the Piece and the ...
1
vote
0answers
36 views
How to use the Bridge pattern in hashCode/equals code generation?
We are currently writing a code generation tool to generate hashCode, equals and toString ...