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

learn more… | top users | synonyms

4
votes
1answer
50 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
90 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 ...
-2
votes
0answers
17 views

Design a service to notify any change to internal services [on hold]

Please share your thoughts over this designing question (If you need any more info, pls. do let me know): GIVEN: Let's say we have a popular eCommerce site with lots of sellers and millions of ...
4
votes
2answers
109 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
43 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 ...
-2
votes
0answers
20 views

Little confused about Adapter Design Pattern [closed]

I am trying to learn Adapter Design Pattern via tutorials. Moreover, I see a lot Adapter classes at work but it seems that they are not applying Adapter Design Pattern in correct manner. As far as I ...
3
votes
2answers
66 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
47 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
78 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
60 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
262 views

Reusable Unit Of Work Interface / Factory

Given my IUnitOfWork interface using System; public interface IUnitOfWork : IDisposable { void Commit(); } I then ...
2
votes
2answers
86 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
60 views
4
votes
3answers
97 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
91 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 ...
14
votes
3answers
566 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, ...
1
vote
0answers
70 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 ...
-1
votes
0answers
27 views

design pattern for sync model between two database

I wanna to create an one way sync mechanism from django models to cloud datastore. My first version reference django's manager design. An manager take care of sync ...
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
62 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
100 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
66 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
108 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
42 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
87 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
25 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
55 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
208 views
3
votes
1answer
56 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
32 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
56 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
52 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
98 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
312 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
62 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
68 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
39 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 ...
3
votes
1answer
204 views

Result class which wraps another object

I have a result class which wraps another object if successful or an error if failure ...
-1
votes
1answer
48 views

Observer pattern with different notifications [closed]

I'm trying to create an observer pattern that the subject notifies the observers with different notifications. Normally in observer pattern implementations you can see only one method called ...
0
votes
2answers
57 views

Applying chain responsibility with IFilter

I have an interface IFilter and more types of filters: Filter1, Filter2, ...