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

learn more… | top users | synonyms

2
votes
0answers
37 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
42 views

Java class: for getOrder, getData, updateData operation

Problem Statement : Design a class for three operations for given set of integers : ...
1
vote
0answers
20 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
32 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
40 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
30 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
73 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
119 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
116 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
50 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
74 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
52 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
84 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
64 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
275 views

Reusable Unit Of Work Interface / Factory

Given my IUnitOfWork interface using System; public interface IUnitOfWork : IDisposable { void Commit(); } I then ...
2
votes
2answers
88 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
64 views
4
votes
3answers
100 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
128 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
592 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
71 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
93 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
44 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
28 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
65 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
110 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
67 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
118 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
89 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
29 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
56 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
212 views
3
votes
1answer
59 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. ...
14
votes
4answers
1k 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
34 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 ...
4
votes
2answers
68 views

Code organization when using threads

From OOP & OOD point of view, is it good idea to define Java-threads inside of the static method or in this case it's better to use instance-based method? ...
3
votes
1answer
63 views

Design for container that holds multiple instances of same base class

I have four different classes. First being a base class for the second and third. The fourth being a container class that holds instances of second and third (stored as first). My base class for ...
1
vote
0answers
59 views

Making a CRUD function reusable

I uses slim router and made a folder model controller view, below is one of my model files; I made one database with one model. I have some problem in my project: there are several databases like ...
1
vote
0answers
54 views

Using the Template Design Pattern to reduce code duplication between two algorithms

I have made a Skyline query solver which for now can solve the query with two different algorithms. The first is Block-nested loop (BNL) and the second is Sort filter skyline (SFS). The two are ...
3
votes
3answers
99 views

Cancelling an order with a side-effect of logging the operation

I have a data access layer method to cancel an order. This operation should have an associated "operation history" entry. My first (naïve) implementation looks like this: ...
6
votes
2answers
318 views

Implementing both poor-man's MVP and MVPVM framework

I'm actually building some kind of framework to promote code reuse without over-reusing it. Besides, sometimes as it occurs with generic types, one expects type parameters to be constrained for the ...
3
votes
0answers
67 views

“Table Data Gateway” pattern

Using the table data gateway (TDG) pattern, I created a class QuestionGateway for retrieving, adding, updating, deleting, and sorting multiple-choice questions. ...
2
votes
1answer
69 views

Is there a better design pattern for a SDK?

At work I decided it would be better to reverse engineer a SDK for one of our pieces of hardware. Because it is work related I can't share the exact code.. but I can give enough of a gist of the code ...
5
votes
3answers
507 views

I command thee: do SOMETHING

I am currenly contributing to a Chat-Bot to be used across the whole SE-Network's chat which is implemented in Java 8. This bot is supposed to have commands. These commands again are supposed to be ...
-2
votes
1answer
57 views

Creating new types that facilitate safety, flexibility, and DRY-ness [closed]

Disclaimer: I realize that a lot of my trouble has to do with how I'm grounded in the OO way of thinking. If you can point out exactly how I'm trying to force OO thought on Haskell, I would be very ...
0
votes
1answer
32 views

A function which collates data from various API calls. Help on design-pattern

Help on the appropriate design pattern for this. Program details: A scheduled script that fetches all the data from various framework-based API's - ...
2
votes
1answer
40 views

Detaching logic from listener implementation in “Smart UI” approach to follow a proper pattern

I took this code segment from existing source on Android, but it applies to anything from ASP.NET Forms to anything else where the UI has an event callback, and the logic is implemented directly in ...