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

learn more… | top users | synonyms (1)

0
votes
1answer
16 views

Sharing info objects between objects?

I'm making a game and I have several cards that are created during the game. Each card needs some info, which is shared between cards of the same type. So I have a class CardInfo, which holds a name ...
-1
votes
0answers
10 views

Best way to populate Entity from posted ViewModel in ASPNET MVC?

In form post, I am used to accept a viewmodel in post action method. One way or another, I have to go through each property to assign it to the entity object that the repository module is expecting. ...
6
votes
1answer
66 views

named arguments replaces the builder pattern

When using a language that supports named and optional arguments, does the builder pattern no longer have a practical use? Builder: new Builder(requiredA, ...
0
votes
0answers
29 views

React and simple UI state

I'm starting to playing around with React and have a basic question regarding state. I understand that in React state should only contain data which may change and cannot be computed from elsewhere, ...
0
votes
0answers
53 views

How to deliver messages from a communication interface to a core?

I want to develop an application in near future, where I will receive data via a communication interface. So there exists a Java class, that is responsible for getting the data. After the application ...
4
votes
2answers
107 views

Asking about learning experience while working for outsourcing company [on hold]

i come up with this question because i feel frustrated to learn new things. When i learn new technologies i can remember it for a short time then if i can't apply to the work i almost forget it. For ...
-1
votes
0answers
19 views

I should expose Cursor object to the view object to use it? [on hold]

I developed from the Web to Android Development is doing a App, the need to use SQLite and AdapterView. I wanted to write a DAO class to do all the work associated with the database query and populate ...
1
vote
2answers
47 views

How to maintain atomicity with a service like pattern

Imagine a route in an MVC web project which handles editing a user of your product. You can do things like change their name, their email, their group, their roles and so forth. This data is put in a ...
0
votes
1answer
60 views

How do you name the Visitor implementation? [closed]

I was reading about Visitor pattern and was a little wondering about naming of the methods. Assume we have the implementation of the pattern as follows: public interface Entity{ public void ...
1
vote
0answers
54 views

Partially Fulfilled Specification Pattern

We have a model (IPayableModel) with a boolean property indicating that a user may or may not pay for the item. A set of specifications defining criteria that would disqualify the model from payment ...
3
votes
4answers
152 views

Architecture: Are form default values considered business logic and where should the logic to calculate them be placed?

An example of default form values on a search form might be: Start Date - Today End Date - The last day of the next month Obviously, these are fairly simple examples, but default values can get a ...
1
vote
0answers
100 views

How to to log clicks for a Pay-Per-Click software?

Let say you have a Website with advertising, and each time a user clicks on it, you want to charge an advertiser the amount he bids (basically, a pay-per-click system, like Adswords, with a different ...
0
votes
1answer
77 views

DI container with multiple instances of same object

I'm looking for idea to make a DI container that can store multiple instances of the same object. Usually, a DI container should store either a single instance of the object, or create new object each ...
0
votes
0answers
61 views

When should i sync my data from parse.com to my android app [closed]

I'm making an android application whith parse.com. Here is the situation : I have an offline part on my android app and i'm using LDS (LocalData Storage) to stock my data and send them to parse.com. ...
6
votes
2answers
139 views

Role-based REST API?

I'm building a REST API for which several users with different roles will have access to the resources it contains. To keep the scope simple let's take the "student/teacher/class" domain: GET ...
0
votes
1answer
88 views

Design Pattern for Filtering [closed]

I have a requirement where I get a list of objects say List. Now I have filter Criteria which I need to apply to filter out the objects in the list. Currently I am thinking of using chain of ...
2
votes
1answer
93 views

Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?

I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
3
votes
1answer
132 views

Recursively parse without resorting to ugly design patterns

I'm currently building a crochet pattern parser in Java, and I've hit upon some trouble. I'll call the language used for input Crochet Pattern Code (CPC). I have a rather large writeup on the ...
1
vote
1answer
212 views

How to avoid big class complexity while keeping encapsulation?

I'm developing a PHP library to work with big numbers (at this moment only with a "Decimal" class, but I want to add new classes, to handle Integers, Rationals, and Complex numbers). In any case, the ...
2
votes
1answer
103 views

Builder design patterns: passing parameters from client to the builder

Does the builder design pattern allow passing parameters? If yes, what is right way to achieve it? Overview The builder pattern is about hiding the details of object constructon, it places two ...
0
votes
0answers
93 views

Is this MEAN stack design-pattern suitable at the 1,000-10,000 user scale?

Let's say that when a user logs into a webapp, he sees a list of information. Let's say that list of information is served by one of two dynos (via heroku), but that the list of information ...
0
votes
4answers
200 views

Fixing class Hierarchy design mistakes due to incorrect inheritance

I have a code like this. My derived class man, may not properly have a member function declared pure virtual higher up the hierarchy. eg. WagTail here class mammal{ public: virtual void WagTail() ...
3
votes
2answers
108 views

What kind of base for Decorator: interface, abstract class, non-abstract

What should be at the top of inheritance tree of Decorator design pattern? I mean the base for both components and decorators non-abstract class: has data fields, implements methods abstract class: ...
1
vote
3answers
181 views

Pass the whole object to a method or just parts?

I have an object that has about 50 properties, but one of my methods only uses about 3 of these properties. Is it still better to pass the whole object or parts. A scenario would be were I am using ...
0
votes
1answer
128 views

What is the best way to create DTOs from entities and update entities from DTOs in a layered architecture?

Option 1: At first I would make a call to my service layer, which served as an API for my core domain, to get a domain object or a list of domain objects and then pass them into the assembler which ...
3
votes
1answer
281 views

Beginner Facade Pattern Example

I came across this article: http://didawiki.cli.di.unipi.it/lib/exe/fetch.php/magistraleinformatica/tdp/dp-l10a-facade2014.pdf At the end, it has a question asking: One common problem ...
0
votes
0answers
17 views

What is the best way to create DTOs from entities and update entities from DTOs in a layered architecture? [duplicate]

Option 1: At first I would make a call to my service layer, which served as an API for my core domain, to get a domain object or a list of domain objects and then pass them into the assembler which ...
1
vote
3answers
173 views

C# Subject Observer Architecture question

I'm making a C# application using the Subject Observer design pattern in a slightly different way. I am passing the Provider Class, implementing IObservable (this has the OnNext() method that ...
1
vote
2answers
95 views

Pattern for validating rules having different signatures

I have a class in charge of responding to an input event and maybe triggering another event. To decide, it has several rules to check. I'm trying to get away from a class looking like this: public ...
0
votes
0answers
30 views

Accessing intermittently available resources with transactions and post-access cleanup in a generalized, functional, composable way

The following psuedo-code illustrates what I'd like to be able to do. Is there a way to accomplish something like this in Scala?: trait IntermittentlyAvailableResource trait ...
3
votes
3answers
142 views

Development Time: sql in UI code vs domain model with datamapper

First, sorry for my English guys. Currently this is my first programming job. I am labeled as the most incompetent programmer in my company that's because they measure the performance and ...
0
votes
2answers
105 views

Beginner Decorator Pattern Question

I came across this article: http://sourcemaking.com/design_patterns/decorator After reading it, I am having a little bit of difficulty understanding a concept. If you look in the Structure section in ...
0
votes
0answers
95 views

To KISS or not when coding? [duplicate]

I don't consider myself "ninja" but I don't think I'm bad dev either. Anyway, after many years of development I tend to keep it simple more ofthen than before. For small projects there is no need to ...
0
votes
1answer
84 views

Multiple method calls in the constructor and dependency injection

I was asked to refactor some almost ureadable spaghetti code into object-oriented architecture. I have some doubts regarding a class that I designed. Here is the class' skeleton: require_once ...
0
votes
1answer
86 views

Can you refer to the callback function as an API?

A system design is decoupled into two layers say layer A and layer B. The interaction between layer A and layer B occurs through an interface that is exposed by layer B in form of an API. This ...
0
votes
0answers
53 views

Abstracting the data in a relational database. [duplicate]

While working with data, which is in a relational database I came up with this issue. At first, I was just writing helper functions to retrieve A SPECIFIC data I needed for the current problem but it ...
0
votes
0answers
70 views

Angular Architecture

I have been developing a few prototype apps in Angular, with various backends, including firebase and php/mysql. I'm pretty sure I'm not using a good organization pattern for development because of a ...
1
vote
2answers
93 views

Rich Domain Models, Encapsulation, and the Problem of Constructor Over-Injection

I am refactoring an e-commerce web-application, currently working on the UserBasket class, which will have to handle adding or removing items, changing their quantity, getting total amount, total ...
2
votes
2answers
98 views

For a concrete SQL Repository, should I encapsulate the SQL logic inside or outside the repository methods?

If I have a concrete repository based on SQL data access, should I pass in SQL to the repository methods or encapsulate them within the methods. I feel if I pass them in, then I am coupling my ...
7
votes
1answer
193 views

Should I build undo stack in model or its wrapper?

I am building an application (Python/PyQt). The first-order item will be a tree view/model with many helper functions to add new items, move them around in the tree, etc.. Then I will have a main ...
0
votes
1answer
36 views

Tags DB structure - tags table using one join and GROUP BY, or pivot (join) table using two joins?

I'm implementing tags into my question and answer application. Users will be limited to the tags available by the app, so they can't choose their own. So maybe only 30-50 tags will be available. This ...
0
votes
1answer
119 views

How much to encapsulate when objects being dealt with are pretty similar

As I have been answering questions related to object-oriented design and how to go about reducing the amount of classes to make sure that there is not a lot of "class clutter" and code repetition I ...
1
vote
1answer
233 views

What is better repository design?

I have tables that I insert, delete and update, but I read from views. At times, I may read from the tables as well. What is a better generic interface for a Repository: public interface ...
1
vote
2answers
85 views

Class design for JSON serialization

I've been stuck for some time on a circular reference issue with JSON serialization. I have a card game that I'm pickling to a redis store. As I retrieve the Game state from redis I'm trying to ...
4
votes
1answer
109 views

What is the preferred way to approach this problem in object-oriented design? - virtual disks abstraction

I am writing a program that manipulates encrypted virtual disks and encrypted flash drives (eg. importing disks into my application, mounting/unmounting, changing passwords etc.). I am still new to ...
4
votes
2answers
237 views

What principle is violated by having a button do two radically different things or screens act radically different depending on the situation

I've come upon a situation several times in my career when previous developers have done something funny. They will make a control (button) function radically different depending on how the screen ...
0
votes
0answers
59 views

What is the design pattern name for a class that handles 2nd level caching? [duplicate]

I have a system where I want to start introducing some 2nd level caching. I want to abstract data access a bit and allow some type of other class to do the dirty work of fetching a DTO; it will check ...
3
votes
3answers
509 views

How to model state of leaving/entering home

I have two sensors: One detecting if the door is open or closed, another if movement has been detected in the corridor. I want to detect if the person has left or entered home. Usually the person has ...
16
votes
5answers
3k views

Do enums create brittle interfaces?

Consider the example below. Any change to the ColorChoice enum affects all IWindowColor subclasses. Do enums tend to cause brittle interfaces? Is there something better than an enum to allow for ...
3
votes
3answers
213 views

How granular should we get with repositories?

Is it better to have a repository per model (this could be a class that represents a table from the database) or should just have one big repository for all data access methods? I have done the ...