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

learn more… | top users | synonyms (1)

0
votes
0answers
37 views

Lost in Presenter and other design pattern

I have an entity called Contact , that defines relationships with other entities and fields types (I use Eloquent). For different info non-fields, like getFullName, I use a Presenters like this: new ...
1
vote
1answer
115 views

Is using __import__('module_name') an antipattern in Python?

I'm currently refactoring a Python 2 project which includes the ability to add or remove plugins, which are Python modules implementing a given API. The main app accesses add/remove/update hooks in ...
1
vote
1answer
219 views

Name for this design pattern?

Background Working as a software engineer in the field of electronics, I often find that none of the existing design patterns i.e. GoF typically fit the bill for what I need to do. One of the ...
2
votes
4answers
277 views

Is it strange for a Builder object to have getter methods?

I have a fairly complex immutable data type that I'm using a builder object to instantiate. Currently, I have a setup where I parse a file, setting various fields in my builder, and then build the ...
1
vote
2answers
127 views

How should I represent mutable boolean state?

When I have some object with boolean state that can be changed (like a checkbox's checkedness), there are several ways I can expose it. Getter property, Setter method bool IsChecked { get { ... } } ...
5
votes
2answers
129 views

Recreating complex aggregates from a persistance source

I'm building a web application with C#, and I have an aggregate root which has several entities and value objects. Then I have a repository object which persists the aggregate to the database (I'm ...
4
votes
3answers
218 views

Enums and single responsibility principle (SRP)

I have been experimenting lately with enums, and I found out that in Java they can do much more than simply representing a fixed set of constants. Now, I am thinking about creating a new enum for my ...
0
votes
1answer
69 views

Is it bad practice to simplify constructor dependencies using a simple container when the class represents the entry point for a sub system?

I have a System which depends on Transactions, and a few other things. This list can become very long. Transactions can be (and will be) implemented in two ways or more, so every transaction is an ...
2
votes
0answers
83 views

Architecture design for Web API with single endpoint

Scenario: I have a situation where I need to refactor a Web service with a single API endpoint that uses complex logic to insert, update and fetch data from a database. The clients use one call, and ...
46
votes
10answers
6k views

Should we avoid custom objects as parameters?

Suppose I have a custom object, Student: public class Student{ public int _id; public String name; public int age; public float score; } And a class, Window, that is used to show ...
4
votes
2answers
193 views

What are the advantages of using multi-tenant architecture with separate db schemas per customer?

I have a client that wants me to build a SaaS application with a multi-tenant architecture, where different clients will go in a separate schema on the same db server. I have seen this architecture ...
0
votes
1answer
103 views

Design to link two model classes with different multiplicity

It is usually well known how to deal with model classes that have a 1:N relationship: classical examples are order->items or client->orders. Every layer of the software has its appropriate and ...
6
votes
2answers
223 views

Is the command design pattern a good way to reduce the number of dependencies in my class?

I recently realized that I have way too many dependencies in many of my classes. Now I am trying to solve that for the most important class. I think I have an idea how but I'm not sure if it is the ...
13
votes
4answers
2k views

Pattern for algorithm that outputs an explanation of how it gets to a solution when needed

The following scenario happened to me several times. I programmed a algorithm that solves a certain problem. It works fine and finds the correct solutions. Now, I want to have an option to tell the ...
3
votes
1answer
83 views

Is it bad to pass a reference to the behavior's owner object to the behavior?

Is it bad to pass a reference to the behavior's owner object to the behavior? For example, if I have a Duck and DuckBehavior class. DuckBehavior is a part of the Duck Class. But what if I need to ...
5
votes
4answers
196 views

Idiomatic pattern matching equivalent in Java

I'm building a simulator which parses some events from STDIN and "runs" them. My background is mostly functional programming these days, so it seemed natural to do something like this: datatype Event ...
5
votes
1answer
373 views

Software design: too many static objects?

About the subject I hesitated for a while between using singletons objects or plain static ones. After having read a lot of different opinions, I made mine: If you don't need to prevent ...
0
votes
0answers
77 views

Repository Pattern: How to structure repositories with nested tables?

I'm working on an API and I always seem to run into this thought debate. When designing the code structure that interacts with the database (repositories, data providers ect..) how do I structure the ...
7
votes
3answers
245 views

Using Interfaces for Loosely Coupled Code

Background I have a project that depends on the usage of a certain type of hardware device, while it doesn't really matter who makes that hardware device as long as it does what I need it to do. With ...
6
votes
5answers
180 views

Modular Objects with conflicting implementations

I am working on a game framework that would allow users to use multiple mods/plugins to add additional features to the game. For the remainder of the post, I'll use the following definitions: mod: ...
20
votes
5answers
1k views

Why would a type be coupled with its builder?

I've recently deleted a java answer of mine on Code Review, that started like this: private Person(PersonBuilder builder) { Stop. Red flag. A PersonBuilder would build a Person; it knows about ...
4
votes
2answers
184 views

Ubiquitous language and maturity level in REST API?

According to Richardson Maturity Model there are several levels of maturity in REST approach. http://martinfowler.com/articles/richardsonMaturityModel.html Since DDD uses ubiquitous language, I am ...
2
votes
2answers
132 views

Sharing POJO between different handlers

I am trying to automate Business Process which can be characterized as a pipeline with distinct stages. Pipeline can be perceived as A->B->C, where A,B,C are distinct Business Steps that work ...
4
votes
2answers
177 views

How far should encapsulation in JavaScript go?

I have a variable which I want to use in only one function. I can write my code like this: var theAnswerToLife = 42 var multiplyIt = function(x) { return ++theAnswerToLife * x } I have some ...
1
vote
1answer
45 views

How to use fields from an object after an exception is thrown and the object can't be fully created

The issue that I have is that I need information from an object that a method returns when it throws an exception. It is a little hard to describe so I have this java pseudo code example. I have a ...
1
vote
2answers
90 views

Is it a good idea having default static variables for new instances?

OK let's say I have something like this: public class MyObject { public static int DefaultValue = 9 private int _value = DefaultValue; public int Value { get { return _value; } set { ...
1
vote
0answers
112 views

How to authentication user in REST API (domain driven design)

I am using REST API as a presentation layer of a DDD project. In order to secure API calls I am using token based security. http://www.codeproject.com/Articles/1005485/RESTful-Day-sharp-Security-in-...
2
votes
3answers
139 views

Command Pattern - Correct usage?

I have a scenario wherein I need to do certain specific steps in a specific order. For clarity lets take a simple example. Let's say I have a Student and some Student Properties which I encapsulate ...
2
votes
3answers
100 views

How to clearly define boundaries of a bounded context

After a month or so of reading and researching DDD, I decided to start my own project and created DDD with these bounded contexts> Clients Products Orders Billing Each bounded context has rest API ...
0
votes
1answer
110 views

Is pubsub pattern suitable for my case?

I'm planning to use pubsub pattern with azure service bus in my logistics application.but I'm confused whether pubsub pattern is suitable for my case. My scenarios: users will subscribe set of ...
3
votes
1answer
167 views

Checking preconditions the proper way

I have a class with around 1300 lines and it has many CRUD-like methods that need parameters to be checked, for some of them it's more than just a few rules. For clarity purposes, I am going to use ...
4
votes
3answers
141 views

Who is responsible for checking object properties such as Visible/Enabled?

Say we have a user interface with Forms, Buttons and such. Each item has some properties (such as Visible, Enabled, etc.). Who should check on these properties and decide whenever to render the item ...
3
votes
1answer
227 views

How to pass data to OOP objects?

I'm new to this whole thing, so please tell me if I'm doing this wrong of if there's a better spot for my question. I'm making a game with basic systems for projectiles, npcs and items. This game ...
7
votes
2answers
150 views

How to best design a job queue with constraints?

Consider the following situation: You have a program which creates numerous 'jobs' that need to be processed and places them into a queue. You have other worker programs which grab the next 'job' in ...
2
votes
2answers
141 views

Best way to enforce constraints in Class

I have a class, something like this one (C#): public class MyFavoriteClass { public string Name { get; set; } public string Description { get; set; } (...) public ReferencedClass1 ...
8
votes
2answers
174 views

How to resolve LSP violation based on minimum precondition

I have a class Party that has a constructor that takes a Collection<Foo>. I plan to have two subclasses NpcParty and PlayerParty. All Party instances have an upper limit on the size of the input ...
1
vote
1answer
51 views

Redesigning a builder to make it reusable

Let's say I have a builder class (which by the way is not techinically a builder, but it's not a factory either) to generate different rules for a game: public class RuleBuilder { private Game ...
6
votes
1answer
98 views

Extracting and generalizing “repeated” methods with similar functionality

Let's say we have a class with many methods that do something different but can be grouped together as one "kind of functionality". For example, adding a configuration o setting rules up. Let's go ...
4
votes
1answer
247 views

Help in writing more generic code

I'm doing a php MVC project using code igniter. I have two models, a and b. Each class contains four functions (insert, delete, update and view) and their implementations are almost the same with ...
0
votes
1answer
106 views

Best practices/patterns for generation PDF reports

I have PDF generation feature in my app. I am using iTextPDF for generating reports, so it works well. The problem is not exactly in pdf generation but in approach. Currently PDF generation code looks ...
0
votes
0answers
30 views

Develop an API within ESB to access a database

I am working with a service provider where I need to get data from their service. The service provider wants to give me access to their database to get the data I need. My question is should I ...
13
votes
4answers
1k views

How specific should the Single Responsibility pattern be for classes?

For example, suppose you have a console game program, which has all kinds of input/output methods to and from the console. Would it be smart to keep them all in a single inputOutput class or break ...
6
votes
1answer
717 views

What is priming the pump? Sometimes called a priming read

I was taught this expression and pattern way back in the day. Sure, the name comes from old pumps that needed to be filled with water before they could pump water, but who cares? We're talking about ...
3
votes
1answer
98 views

Getting posts from users that are being followed: two different implementations

I have two different implementations for retrieving posts from the users someone is following and I want to know which one you would recommend using. First I'l show you the tables, and then the two ...
3
votes
1answer
82 views

Simple messaging pattern to replace shared DB? [closed]

There are two modules A and B using the same DB. A imports B as a JAR. I read that messaging patterns can replace the tightly coupled solution of using a shared DB but I am not sure which message ...
7
votes
5answers
213 views

Open Closed principle in design patterns

I am bit confused about how Open Closed principle can be applied in real life. Requirement in any business changes over the time. According to Open-Closed principle you should extend the class instead ...
16
votes
2answers
2k views

Principle of least astonishment (POLA) and interfaces

A good quarter of a century ago when I was learning C++, I was taught that interfaces should be forgiving and as far as possible not care about the order that methods were called since the consumer ...
6
votes
1answer
188 views

Relaxed architecture DAL or anemic BLL?

Particularly for the sake of unit testing, I'm trying to implement an application with a layered architecture. I'm coding in C# and using ASP.NET Web API for the service layer. I'm aiming at a 3-layer ...
1
vote
1answer
146 views

Getting data from a database with the MVC model

I am creating an application which will have a very large database to draw it's information from (a student registration system to be exact). The database is created with Microsoft SQL Server if that ...
1
vote
2answers
143 views

MVC - Database search logic in View or Model

Special Note: I asked a very similar question on Stack Overflow, but I have since decided the problem should be solved from a design standpoint rather than an implementation standpoint. I have ...