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

learn more… | top users | synonyms

1
vote
0answers
18 views

Imgur API implementation using Retrofit

I've recently (an hour ago) started a project for making a wrapper for Imgur's API using the REST client Retrofit. I've only implemented a single endpoint so far as I'm questioning my design. While ...
2
votes
1answer
18 views

Decision tree for binary classification

I want to become a good Python programmer and so I'd like to know what in my code practices I can improve. Overall I feel like a pretty solid programmer but writing this code felt very "Java" so I am ...
2
votes
0answers
43 views

Database Access Object Class

I learned of the Database Access Object design pattern from a friend and decided to implement it recently to my MySQL database. The code uses MySQLi to connect to the Database, and uses prepared ...
0
votes
0answers
4 views

Design of actions handlers requiring some order [migrated]

I have a REST application where 'actions' can be executed to perform anything in the system. For example: user.save, user.get, etc... I also have pre and post execution 'handlers'. For example a ...
0
votes
0answers
11 views

Designing a Solution for generalization and future scope with Inheritance [on hold]

I have below code/classes/interfaces with me: An Interface: public interface Animal{ void fight(A otherAnimal); } 2.Tiger class which is implementing Animal ...
4
votes
1answer
51 views

Creating and saving blurred screenshots in iOS

I am trying to create a class that takes a screenshot of the screen, makes it blurry and saves it to NSUserDefaults. ...
2
votes
1answer
49 views

Querying a database with Dapper

In the current project that I am working on, we are using dapper to query the database and sometime when mapping from dynamic types to concrete types we end up with a messy block of code. I created a ...
4
votes
0answers
38 views

Creating an async consumable object in Node

Background I have a situation where I have fixed number of objects with their own routines that would need to be called with the same initial message. To accomplish this, I have a Factory that ...
4
votes
1answer
47 views

Use of static factory methods for vectors and matrices library

I've been working on a Java-based mathematics library focusing on vectors and matrices. I plan to use it for an important upcoming project, so the classes are analogous to data types available in GLSL ...
2
votes
0answers
25 views

Mediator class to handle a bunch of rules between objects

When a LivingBeing attacks another LivingBeing, an attack roll is made to determine if a hit occurs. If a hit occurs, a damage ...
4
votes
2answers
120 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: ...
10
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
52 views

DDD and Dependency Injection a smell or common [closed]

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
60 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
40 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
72 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
38 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
59 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
203 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
939 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
69 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
54 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
53 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
48 views

Java class: for getOrder, getData, updateData operation

Problem Statement : Design a class for three operations for given set of integers : ...
3
votes
2answers
57 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, ...
3
votes
0answers
58 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
104 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
125 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
133 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
58 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
79 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
57 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
114 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
70 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
331 views

Reusable Unit Of Work Interface / Factory

Given my IUnitOfWork interface using System; public interface IUnitOfWork : IDisposable { void Commit(); } I then ...
2
votes
2answers
93 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
69 views
4
votes
3answers
115 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 ...
2
votes
1answer
328 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
631 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
79 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
67 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
109 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
57 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
39 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
74 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
151 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
74 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 ...