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

learn more… | top users | synonyms

7
votes
1answer
57 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
82 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
38 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 ...
3
votes
1answer
46 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
16 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
49 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 ...
3
votes
1answer
54 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. ...
13
votes
4answers
892 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 ...
0
votes
0answers
26 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
67 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
62 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
51 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
41 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
95 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
301 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
53 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
67 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
506 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
55 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
31 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
34 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
192 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
41 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
56 views

Applying chain responsibility with IFilter

I have an interface IFilter and more types of filters: Filter1, Filter2, ...
3
votes
2answers
113 views

Parenthesis checker

I am working on a parenthesis checker program in Java that reads in a text stream from standard input and uses a stack to determine whether or not its parentheses are properly balanced. For example, ...
4
votes
1answer
131 views

Factory pattern with controls

I've created factory to create WPF controls. I have string with control name and I map it to enum. I think it's bad implementation of factory pattern. So please show me where I've made mistake. Main ...
2
votes
1answer
60 views

jQuery-Keyframes allows dynamic generation of CSS3 keyframes with callback events

I want to learn best practices for structuring these kinds of small jQuery plugin libraries. I believe I am using a bad design pattern and what I was going for is fewest line numbers and minimal code. ...
4
votes
1answer
51 views

Passing data between themes and the page settings

I'm designing a small CMS with best practices I learned. I came to this conclusion when comes to including page content and themes to each page depending by user or whatever. But how could I make ...
3
votes
1answer
55 views

Swing application: Working with GridBagLayout and Mediator pattern

SCENARIO: As a follow-up of this question on Stackoverflow asked few days back, I am working on a swing application(article tagging tool) where the user(on an initial jpanel) would fill up some ...
5
votes
1answer
98 views

Basic console game architecture

I'm working on some simple console game and I'm starting to get stranded in my modelling. There is some fragmentation and tight coupling going on! In this version I would just want to be able to ...
2
votes
0answers
75 views

GOF Composite Design Pattern Implementation Using Modern C++

After reading about the composite pattern from the GOF design pattern book, I thought to re-implement the code mentioned in the motivation section using the modern C++ concept/idioms. Below is the ...
1
vote
1answer
84 views

Event handlers & helper methods for a Kendo Grid

Below are a few of my handlers and helper methods. This works perfectly fine, but I'm pretty sure I'm breaking about 1001 modern conventions and possibly even optimizations. Could you provide some ...
1
vote
0answers
56 views

WPF Binding to a Repository with Entity-Framework

I have an MVVM WPF application that will make use (hopefully) with a repository and ...
3
votes
3answers
155 views

Chain of Responsibility Design pattern in C++

I am learning design patterns from Design pattern for dummies. From that book I have written a chain of responsibility pattern with two programs. Can someone review and let me know which one is proper ...
15
votes
2answers
202 views
+50

Custom JavaScript validation using the factory / module patterns

I am in the process of diving a bit deeper into JavaScript development and am looking at some common language patterns (module, and factory in particular). In this code, my aim is to create a ...
6
votes
0answers
100 views

Transformation of abstract models

In one of my recent projects I faced the problem of transforming an abstract class into another abstract class. The classes were structured like this and are part of an api for questionnaires: ...
6
votes
5answers
173 views

DP solution to min triangle path

I am studying for interviews for various companies. I wrote a solution to this problem, but if an experience programmer looks at it I am sure there are certain areas the code can be made in to a more ...
15
votes
6answers
1k views

Is wrapping exceptions good practice?

I have recently been refactoring some code in an effort to improve the exception handling, particularly to aid in improving the level of information given to developers during development. However I ...
-1
votes
2answers
112 views

Using singleton and/or factory patterns in business logic layer [closed]

I understand the purpose of singleton and factory patterns, however I have doubts implementing it. My problem is that whenever I need to call a method from BLL, then I have create an instance of BLL ...
0
votes
0answers
52 views

App using JQueryMobile and Cordova

I have received a project that is built on Cordova with JQueryMobile. The app is already published on three platforms and is being used by 100K+ users. Now I have to add new functionality in it. But ...
1
vote
0answers
78 views

Enhance MVC implementation

I know that there are several ways to develop the MVC pattern. To improve consistently my knowledge, I would like to get some advice and feedback. How could I enhance my code? I knew that there are ...
0
votes
1answer
80 views

Polymorphic template cloning class

I have a requirement of a templated clone() method which Base classes can implement through an ICloneable interface and all the ...
1
vote
2answers
80 views

Notifying Students in Courses - Strategically

I have the following implementation, and hope to get suggestions on how to improve the code. treeListViewModel.Courses is an observablecollection ...
7
votes
1answer
118 views

Adapter design pattern

I am referring to the book Design Patterns For Dummies to learn about design patterns. I wrote an adapter design pattern, as mentioned in the book. Is it proper or does it need some modification? ...
5
votes
1answer
60 views

Architecture for manager that gets shared among different components

It started with a simple log manager. Then I wanted to implement more features, for example printing the name of the component that send a message. Later on, I can think of giving each component that ...
-2
votes
1answer
43 views

Suggestion for refactor wpf project

I have done a WPF project and hope everyone can give suggestion for code refactor, especially for UpdateErrorList() method within the MainWindowViewModel.cs ...
6
votes
1answer
128 views

Breadth First Search not SOLID enough v2.0

Here is a link to my original question: Breadth First Search not SOLID enough Here is my first attempt at refactoring. Instead of using a Tuple, I used a ...
4
votes
2answers
209 views

Is this a correct Factory Method implementation?

I'm learning about design pattern and I tried to implement a Factory Method example, based on the GoF book. Can I say that this is a correct implementation of it ? If not I will be glad to find ...
3
votes
3answers
163 views

Implementing a POC Async Web Crawler

I've created a small proof of concept web crawler to learn more about asynchrony in .NET. Currently when run it crawls stack overflow with a fixed number of current requests (workers). I was ...