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

learn more… | top users | synonyms

3
votes
1answer
77 views

Examining programming laboratory exercise for faculty

I'm developing software for examining programming laboratory exercise for faculty. I have an Error object that can be attached to students work. It can be attached ...
2
votes
0answers
12 views

Is this a design pattern for a Haskell main function? [migrated]

After developing several Haskell applications I've found myself rigorously segregating impure code and failable (partial) functions from their pure & total counterparts. These efforts have ...
5
votes
0answers
28 views

PubSub and two-way data binding

I looked up how to use the PubSub pattern in JS and came across a few articles. I wanted to have two way data binding, so when a one of an Object's Properties value was set, it would update x number ...
3
votes
0answers
85 views

To subclass or to wrap for “default” implementation? [migrated]

I'm creating a toolset in Java consisting of many Natural Language Processing (NLP) tools, such as Tokenizer, POS tagger, Lemmatizer, Sentence parsing, etc. I want to put all good and publicly ...
3
votes
1answer
28 views

Design of colour fading for WinForms controls effect

I wrote this little piece of code to linearly interpolate between a winforms control's background colour and any arbirtrarly chosen colour. I don't like the way I wrote this piece and I was ...
3
votes
1answer
40 views

Factory Class for Game World

The world in my strategy game is comprised of a number of towers. At the start of the game, only one tower is generated, and when the player discovers new towers they are created and added to the ...
0
votes
0answers
10 views

Shall the Presenter depends on the View, or the contrary, in MVP? [migrated]

So far, I have used the MVP architecture pattern a few times. Every now and then, I wonder whether my Presenter shall depends on my ...
2
votes
2answers
159 views

How far should I go with abstraction?

I've been trying for a while to write clean and testable code, with the help of DI and abstractions. I found myself guilty of service-itis, creating 3 or 4 interfaces for something that clearly ...
1
vote
0answers
44 views

Separation of concerns for security checks

I needed a nice typesafe way to implement security checks for various domain objects and actions that can be performed on them. I had an idea how to do it, so I implemented it as a simple proof of ...
1
vote
0answers
20 views

Liskov Substitution and SRP Principle violation - how best to structure this scenario? [closed]

While learning SRP and LSP, I'm trying to improve the design of my code to comply best with both of these principles. I have an employee class that has a calculatePay method on it. Firstly, I believe ...
2
votes
0answers
57 views

Implementation of Command Pattern [on hold]

I'm trying to implement Command Pattern, but it's much harder than I thought. Main marker interfaces first: ...
4
votes
3answers
89 views

An approach to the network messaging service

I'm working on the communication module of an ecommerce application. This module takes care of handling messages that come from other apps over the wire. The awful switch case is never an option so I ...
2
votes
1answer
67 views

Is my design achieving Separation of Concerns in this MVC implementation?

I've read lots about getters and setters being evil, unless there is good call for one, but I cannot figure out how to implement that knowledge into my Model layer. Say in my Model layer I have a ...
-1
votes
0answers
10 views

What is a good design pattern for generating an Excel (xlsx) file in code? [migrated]

I occasionally have projects where I have to output some data as an Excel file (xlsx format). The process is usually: User clicks some buttons in my application My code runs a DB query and ...
0
votes
0answers
6 views

Redundancy caused by polymorphism [migrated]

I have two chat rooms, one has administration behaviour, and one doesn't. I have factored out all of the common code into a base chat room, but the ...
3
votes
2answers
66 views

Should this Method be in TableViewCell or ViewController?

I have a custom tableview cell for displaying different foods, with a star next to each name. If the food has been favorited (i.e., it exists in the database), the star is filled in, otherwise it is ...
4
votes
1answer
40 views

Thin proxy class for hashables

I need some kind of thin wrapper object to mark dictionary keys, like: d = { Required('name'): str, Optional('age'): int, } And these wrappers should behave ...
10
votes
2answers
67 views

Disposable Heroes

I had a bit of an issue with my last piece of code, having to do with cleaning up resources. I needed a way to ensure the database connection was always properly closed, even if there still were ...
6
votes
1answer
44 views

UnitOfWork, an excuse for multiple repositories

I needed a way of attaching multiple repositories to a presenter. Given I already had an IRepository abstraction, coming up with an ...
0
votes
1answer
42 views

Improving design for a CustomerDAO with DatabaseManager object

I'm learning about SRP and had to reduce the responsibility of a customer object, which contained too much info. So I turned that into just a Pojo and pulled out the database logic. I'm trying to ...
5
votes
1answer
44 views

Decoupling Presenter from “child” Repository

Still pursuing the white rabbit, I had an IPresenter interface implementation featuring this method: ...
1
vote
0answers
17 views

Effective usage of multiple joins in Eloquent dependent on variable

I have an Eloquent model that has multiple types of joins that is used to filter out different request to grab the data of movies e.g.: Actors, ...
7
votes
3answers
88 views

Design of class hierarchy for a object formatter API forces derivatives to know too much

While learning object oriented design I'm judging my own design critically. This framework should be able to print objects in either XML, or JSON, I've stubbed in a basic implementation to avoid ...
3
votes
1answer
65 views

Swing MVC and Command Pattern

I am writing an application with Java 8 using NetBeans, and want some reassurance that I am going the correct way with this. I am finding it tough because of the use of Swing. I have gone for one ...
6
votes
1answer
95 views

Memento Pattern implementation

I had just finished work on the Memento Pattern, and now I want to hear your feedback on it. ...
4
votes
1answer
182 views

If-statement consolidation

I often face the problem of stacked if-statements that look repetitive, but usually can't find an easy way to simplify it. ...
4
votes
1answer
79 views

Cart mover- OOP usage and learning design patterns

Firstly, I would like to say that this site looks fantastic... I haven't tried it out yet, but I'm coming from SO, so I think it will be great. My code is for a simple "cart-creation" class and ...
1
vote
2answers
54 views

Implementing DAO with SOLID

I might not be keeping with Single Responsibility with my DAO. I also implement a custom observable through update. It makes sense because when something changes in the data, then it makes sense for ...
2
votes
1answer
90 views

Statefull Strategy pattern [closed]

I have a situation in a class tries to create a group of same type of components and if some component fails then it needs to decide whether it should continue or throw the exception. Now the behavior ...
3
votes
1answer
75 views

PHP e-mail sending class design

I'm working on a class, what will be able to send e-mails for our customers. I need to help with review of my classes design. I'm trying to do it to be easy extendable in future. I'm thinking about ...
5
votes
3answers
77 views

Decoding and Encoding packet layers using decorator pattern

I am trying to use decorator pattern to decode and encode packet layers in my application. I've supposed my packet has three layers: Header, Level2, Level3. So far I've come up with the following ...
-3
votes
2answers
88 views

static factory method alternative to nested switch statements? [closed]

At first I liked the idea of nested switch statements, but on a second-look, it seems a bit confusing to read. I'm iterating through two enum's as so: ...
3
votes
1answer
35 views

Erlang pattern matching excersise

I recently started my first project with Erlang. I've been skimming documentation and various books to get the information I need, and it's going well, but now that I have something that works I want ...
3
votes
1answer
72 views

Splitting My Code Into Classes/Functions

I'm looking for code correctedness, best practices. The player will have different spells, that can be cast on different keyboard key combinations. Right now what I have is one .as file with ...
5
votes
2answers
227 views

Strategy pattern instances based on enums

I have a view which takes a DataPresenterStrategy instance to retrieve the proper text out of some data: ...
7
votes
2answers
79 views

Down the rabbit hole with MVP

Following-up on this post where I implemented a Repository Pattern in vba to abstract ADODB and enable testing my Excel app without hitting a database backend; curious about how far vba would let me ...
2
votes
2answers
134 views

Select item of IEnumerable<T> in UI (MVVM)

Please, help improve following code. I have list of users, item of the list has buttons remove (remove user from list) and profile (navigate to user profile). I use ...
3
votes
1answer
63 views

Implementation of MVC pattern with paintComponent method

Could someone review my code, with respect to OOP, clean code and MVC pattern? Main app: ...
10
votes
4answers
898 views

Decision Table for the Movement AI in a Game

I posted a question on Stack Overflow about how to implement Decision Tables in Objective-C after reading about them for the first time in chapter 18 of Code Complete. Nobody provided an answer, so ...
2
votes
1answer
69 views

Apply Good Patterns about Logging in Executor Process

I have source code for execute a command (ProcessStart) using Impersonate, and I want apply Best practices and good design pattern, and good performance if is possible. Too, I want use good Logging ...
2
votes
1answer
64 views

Module pattern callback implementation

I'm rewriting a simple app using HTML/CSS/JavaScript that creates animations with images using intervals, and there's a bunch of buttons that controls these animations. It's scaling and becoming ...
3
votes
1answer
55 views

Is this Repository/UOW design workable?

I'm using VS 2013/EF 6/WEB API 2. This application of mine which is working on will eventually grow to be big project and I'm in the very beginning stage and need your expertise to make it simple as ...
4
votes
0answers
84 views

Logging strategy setup

I finally set up my logging infrastructure to work as desired, however I feel like I had to do quite a lot things just to fulfill a few requirements. Now I'm worried if my approach has major ...
10
votes
2answers
101 views

YARPI: Yet Another Repository Pattern Implementation

Following-up on this post, I wanted to be able to put a copy of that Excel workbook on a USB key and take it home to keep working on the code a bit (there's more than just one or two tables to ...
17
votes
3answers
1k views

How is my CMS design? Any security, design, or other issues?

I am trying to learn PHP in depth by creating this personal CMS. I try to utilize OOP concepts and do best I can... The way I am trying to design this CMS is to keep including 'modules' within a page ...
11
votes
4answers
204 views

More German overengineering™ - Class mappings and factories

Goals: So the plan was simple: Provide a factory to instantiate implementations of a certain interface (ModelConverter<T>), depending on what model-class you ...
1
vote
0answers
47 views

Repository and Unit of Work asp.net/mvc/tutorials

I'm so confused after reading so many blogs I'm still not sure which way to go and I need help with Repository/UOF pattern using EF 6. As I was following the example here asp.net/mvc/tutorials and ...
1
vote
0answers
30 views

Should I use an abstract repository, or abstract gateway when I have multiple implementations of a single interface? [closed]

I have a single interface called ITask, which several other interfaces inherit from. One being IGTask and another being ...
2
votes
1answer
224 views

Repository pattern best practices using EF 6

Update: Answer to @Ben:----- Interface: I agreed with you and I'm not sure why did I put that and I usually use Get or GetAll ...
1
vote
1answer
50 views

Extend or Encapsulate [closed]

I couldn't find proper tips anywhere, since searching for these general terms isn't very efficient. I deal with this almost everyday, creating Java SWT widgets in particular. Each time I create a ...