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

learn more… | top users | synonyms

0
votes
0answers
21 views

C++ static “factory function” [closed]

Is it good to use static "factory function" like this? I find it much convenient than making Abstract Products, Concrete Products and so on. If it is good, could you suggest some solutions for ...
1
vote
1answer
34 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: ...
-2
votes
0answers
27 views

Is it pythonic to merge multiple function calls in one line? [closed]

I am writing a piece of code, where each subsequent method uses data returned by previous one as an argument. The code looks like below: ...
-1
votes
0answers
24 views

Design feedback [closed]

Can you please give me a feedback about this design implementation ? Suppose i need to calculate a salary of an Employer, this salary is depending on something called : REGIME, the REGIME is either ...
1
vote
1answer
51 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
75 views

Manage Connection Without 'using' statement

I replace this common statement: ...
1
vote
0answers
45 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
36 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
71 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
108 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
158 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. ...
-1
votes
1answer
18 views

Matlab quadractic function with graph

I'm very new to MatLab and I am having some difficulty creating the code and just understanding what to put where. I got my quadratic formula to run and loop(Ex 4.2), but now I've been asked to have a ...
2
votes
2answers
34 views

Functions and a GUI for entropy-related calculations

I wrote a script with utilities for calculating the entropy of iterables and included a Tk GUI that shows a quick overview over a text's properties in real-time. (on GitHub) I tried to follow PEP 8 ...
2
votes
1answer
30 views

Is it bad practice to have executable code in my channel state object?

I have a CommunicationStateMachine object that's attached to my channels. It keeps track of who's turn it is to speak, how far along the conversation the server and ...
2
votes
0answers
25 views

Functional, Loaner-Like Pattern For Consuming SQS Queues, Deleting Queue Items On Success

My program fetches input from a RabbitMQ or Amazaon SQS-like queue. There is not always input available in the queue. If a message is available, it triggers work. If that work is successful, ...
4
votes
1answer
62 views

Observer Pattern with an Observer observing multiple Subjects

Is the below a good solution for an observer to monitor multiple subjects. My only fear is that if an observer was monitoring a wide range of subjects then the update method could get quite large ...
1
vote
2answers
70 views

Generic repository object design + static DAL helper

I would like you to review the solution I came up with to the following scenario: In attempting to model a generic Repository object (that receives a generic type parameter) to interface with my ...
3
votes
2answers
92 views

Building a chain of responsibility in Ruby to apply transformators on an object

I try to make a middleware stack system in the rack way (but not for HTTP request). Here is the main class: ...
2
votes
1answer
47 views

Shared access point

In my game, people connect to my server. The server creates a GamePeer per connection. GamePeer creates one ...
3
votes
2answers
123 views

Service Layer Design

I have written the following service class for my application and at the moment it only contains a single method which is responsible for carrying out the necessary actions to add a new team to the ...
5
votes
2answers
1k views

ViewModel creator design

I am trying to move some logic outside my controller for creating my view models for the view. I have a lot of queries to fire to make sure the complete view model is ready, so to keep my ...
4
votes
1answer
52 views

Factory pattern for creating sub classes derived from interface with generic type

Would like to know if the factory pattern I've implemented for my stat library is the correct way to go. I have an interface IPlayerStatsManager where the type parameter is an interface as well ...
0
votes
1answer
60 views

Service per Controller

We have a base module consuming the company API. In each app I've written almost always a service per controller. Because most controllers are specific to a entity (a single user, a single post, list ...
0
votes
0answers
39 views

Object Oriented design - connection to multiple databases

I have a Python application which uses both SQLite and Postgresql. It has a connector class for each database: ...
3
votes
1answer
177 views

Onion Architecture

After doing a whole bunch of research on Onion Architecture, I have made an attempt at implementing this in a new system that we are developing. We have the Layers as per below: Domain ...
1
vote
0answers
50 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
42 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
1answer
103 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 ...
5
votes
1answer
91 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
92 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
1answer
67 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
69 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
29 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
126 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
71 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
80 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 ...
4
votes
0answers
58 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
117 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
40 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
62 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
218 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
996 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
87 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
65 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
57 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
55 views

Java class: for getOrder, getData, updateData operation

Problem Statement : Design a class for three operations for given set of integers : ...
3
votes
2answers
117 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
63 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
124 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 ...