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

learn more… | top users | synonyms

0
votes
0answers
13 views

Which pattern to use to avoid code duplication with a value-object transformer

I want to get rid of the following code duplication within the MyFacadeBean. Consider the following situation: ...
0
votes
1answer
30 views

Implementation of bridge design pattern for a web scraping app - follow-up

Earlier today I tried to implement an example of the bridge design pattern, but I ended up misinterpreting it. I made a lot of changes: ...
0
votes
1answer
38 views

Implementation of Bridge Design Pattern

I made an implementation of the Bridge Pattern to handle ever-changing in crawler APIs that I'm using in my APP. ...
2
votes
1answer
41 views

Class structure to handle API exchange

I'm developing a simple application that crawls web pages to obtain some information. For this I used and tested some libraries, like crawler4j, jsoup, jaunt and htmlunit. I change the crawler APIs ...
3
votes
1answer
55 views

Wrapping decorator pattern with a builder

I'm working on a booking application and am in the process of porting some legacy code to a more SOLID and testable architecture. Right now I'm working on the process of canceling bookings. Over the ...
3
votes
0answers
18 views

Grouping functionality in JavaScript using an Object

I am creating a drawing-app. I want to have a toolbar populated with tools. Each tool is defined in a separate js file. Right now i have defined each tool as an object that contains functions and ...
5
votes
1answer
81 views

Option<T> functional type implementation and scenarios

Have you ever being implementing Option<T> functional type? It is discussed here. Basically, it is about using ...
1
vote
1answer
23 views

Need a better way to create subclass instances from a base class reference

FeatureMap contains features, derived classes have some mandatory features that the map should have, say keys (the mandatory part) are added and all the features are fetched from somewhere. Since ...
3
votes
2answers
82 views

3-level deep if-else tree for constructing a neural network

The following code fragment constructs different types of neural networks outputs based on the options supplied. Currently, my code just has a huge note that describes what all the options are ...
1
vote
1answer
55 views

Converting long list of if/else [closed]

In order to convert a code such as: ...
2
votes
1answer
34 views

Dynamic Dispatch replacement for Generic methods

Type erasure is giving me nuts recently. I'm designing a class that performs symbolic differentiation on a math expression represented as a binary expression tree. The question is more on the design ...
4
votes
1answer
143 views

Implement mail sending system elegantly

In my project I need to send emails. Emails will have different credentials and senders. I'm thinking about "abstract factory", but will it be good solution? ...
0
votes
0answers
80 views

Repository pattern best practices

Which option is better? In the first case, I use a universal repository that can work with any entities. The methods of this repository have many parameters, such as string queries, table names, ...
2
votes
0answers
93 views

ASP.NET MVC with automatic testing (follow up)

This is a follow-up of this question regarding MVC application architecture fit for automatic testing. I have rewritten the DI code based on the answer provided there and also created some tests to ...
4
votes
1answer
98 views

Bloch's Builder Pattern / Updater

I'm creating many builders where I use inheritance. My resources have many properties and are stored in a Repository. In rare case I need to update them. When I update, I need to keep the same ...
1
vote
2answers
93 views

Array class to replace all iterator needs

Following dreams, I have started learning Java for Game Programing purposes and, during code I figured out that Iterators such as Queue, Lists, Arraylists and what not are very common. I have written ...
6
votes
1answer
54 views

1 or 2 Player CLI Tic-Tac-Toe

I wrote a simple tic-tac-toe program in Haskell. It runs on the command line, has a one and two player mode, and implements a minimax algorithm when you play against it. I'm used to writing proper ...
3
votes
1answer
37 views

C++ Template for one to many Registration (pre Gang of Four)

I use this template to lookup clients registered for data. The data is associated by name(key) and clients are shared pointers (value) to a class which will consume the data. ...
8
votes
1answer
49 views

Encapsulating Complex Calculation in JavaScript

This is code for performing a calculation that should be repeated with different levels and temperatures. I am concerned about the organization of this code as I feel it may contain too many helper ...
1
vote
1answer
76 views

ASP.NET MVC application architecture fit for Unit Testing with Mocking

I am trying to learn how to professionally work with Unit Testing, so I have refactored a medium sized project of mine (a sort of article aggregator that also does some ...
5
votes
1answer
70 views

How Godly does an object need to be before it becomes unholy?

I've been told that using God objects at all is a Bad Thing™ In object oriented languages, God objects know all, they control too much. I'm trying to build a game (or for the scope of this question a ...
0
votes
3answers
24 views

Filling name accounts

I think the content is too large and I am deeply think about how to refactor it. Does anyone have good advice on refactoring it? ...
7
votes
1answer
89 views

Refactoring of a client API to avoid duplicated code and unclear passage of parameters

I need to develop an API. The functions of the API are requests that call the services exposed by a server. Initially the API worked like this: ...
6
votes
4answers
240 views

Simple factory retrieving object by name

Despite the fact that this code works, I would like to know if there's any situation I did not anticipated, and/or if what I am trying to do is some what wrong. -std=C++11 flag needed ...
5
votes
1answer
74 views

Model of an mp3 player with state and prototype design patterns

After reading about design patterns in general, I decided to try and incorporate them in an actual program. I chose a State machine for my first exercise, or, more concretely, an MP3 player. The ...
12
votes
1answer
94 views

To read a book thou should have it bought, to buy a book thou should have it found! (Search Abstraction)

I started a hobby project to find the books that I read (paperbacks) so that I can keep track of them (reading start date, finish date, number of pages, etc..) The first challenge was to find the ...
3
votes
1answer
99 views

Is my design is still a state design pattern, or some abomination?

I was trying to review state design pattern, and tried to create flexible implementation of it so it could reuse it in future. So I came out with this: ...
5
votes
2answers
82 views

Query Builder pattern with use of FluentApi

Recently, I've come up with an idea of building a custom query builder combine with FluentApi. Expected usage: ...
3
votes
3answers
156 views

Unit of Work Pattern for creating users

CreateUser function assumes the data being delivered via parameters are clean and gets called or initiated from the Business Manager (another class). This function is responsible to do the following ...
-1
votes
2answers
63 views

Is there a better way of modeling the routines in my operations that doesn't involve PROTECTED fields?

In my application, well-defined operations on collections of business entities are modularized and carried out using one or more routines, each of which operates on a unique type of data associated ...
7
votes
1answer
123 views

Using commands as deferred behaviour

I was thinking of building a really flexible fluent API for my persistence layer. One of my goals is to achieve somehow the following result: ...
9
votes
2answers
132 views

Executing a stored procedure with optional attributes

Lately, I have been reading Uncle Bob's Clean Code book, and decided to try and follow some of his principles to make a class that was a somewhat confusing static helper class, with an abundance of ...
4
votes
3answers
159 views

Using factory pattern to create email templates

Firstly I try to explain my model. I have 3 type of notifications which can have N types of email templates related to a specific status. ...
1
vote
0answers
42 views

Arbitrary function redirection at runtime

This code is for my upcoming challenge on PPCG. The key part of this challenge is supposed ability to overwrite functions that other people have written. Overwriting functions will happen at ...
4
votes
1answer
105 views

Abstract Factory Pattern

Hi everyone I've just done an exercise on the abstract factory pattern. And I want someone corrects the exercise by telling me if I follow the rules of the abstract factory pattern or not. Here is ...
1
vote
1answer
39 views

List of variables, split based on pattern

In my application i keep repeating writing this pattern. I just cant figure out how to write it better. Coming to you for suggestions: ...
2
votes
1answer
100 views

Strategy pattern implementation feedback

I would like to have some feedback on my code, basically because I have been spending a few hours visiting other options before I ended up with this one, so I'm not sure I'm clear enough to value it. ...
3
votes
1answer
53 views

Mapping different classes to the same database table

I have several very similar subclasses that I (think I) want to be stored in the same database table. Most of the fields are identical, with each subclass adding 1 or 2 custom fields. My code is using ...
0
votes
2answers
53 views

Anti-pattern or acceptable way of using Promises? [closed]

Whenever I need to use a Promise interface in my NodeJs code and I don't have a promise to start off with, I do this: ...
1
vote
0answers
37 views

Visitor Pattern in Ruby

After reading about the Visitor pattern, I wrote this example in Ruby, loosely based on a Java implementation on the wikipedia page. The choice between modules and classes felt somewhat arbitrary for ...
0
votes
3answers
108 views

CRUD strongly typed data access

I have a data access class: ...
1
vote
3answers
133 views

Visitor Pattern in C++ 11

I have referred some class diagram to actually create visitor. ...
1
vote
1answer
93 views

Price calculator for motors and pumps

Note This question was born in request to post more details from this question on Programmers. Since details may uncover new/different complexity, I'm asking another question here. I also will use ...
1
vote
0answers
20 views

Storing object converters, data sources, loading and updating configurations

I have a static class Configuration holding two collections: one for object converters an the other one for data sources. When I load a configuration from either ...
1
vote
1answer
21 views

Custom DataGridViewColumn to replace a DataGridViewComboBoxColumn

The issue that i'm trying to fix with this code is simple I have a huge dataset and I have to bind it (as readonly) to a DataGridView In that dataset I have some ...
6
votes
1answer
220 views

Saving data in local storage

I have written a small library for saving data on local storage. I am still a learner and I am not sure whether my code is OK for a production level application. ...
7
votes
1answer
111 views

Simple console Snake game following GRASP

I would like to know if there is anything that I missed following the GRASP patterns. The Main Controller class: ...
1
vote
1answer
52 views

QuickSort - 3 pivot choosing methods via factory

I'm happy to hear thoughts and ideas on structure/performance/testing/whatever and multi-threading, which I haven't gotten into yet with Python. Latest code here. Assignment file and a few test files ...
3
votes
1answer
136 views

Controller class pattern

The GetDropdownList() function is being called on a couple of controllers based on this example and it may be called in many other controllers, so this code is ...
-1
votes
1answer
51 views