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

learn more… | top users | synonyms (1)

4
votes
1answer
223 views

Should I be using separate 'domain' layer?

I have been reading a lot about domain layer and DDD. However I am still confused about it. To me they seem to be a fancy name for business classes however more modelled towards your application ...
2
votes
1answer
579 views

Login with Twitter or Facebook - How to link accounts

I've been developing a site and I've been trying to come up with a method to make sure all Social Network accounts of a certain user are linked together. I've had one snag from the start, and maybe ...
4
votes
1answer
147 views

Designing a better performing total permissions setup for multiple permission levels

We've got a global system that we are attempting to solve a permissions issue around. Currently, our system serves a number of different applications out to our clients and each client has their own ...
1
vote
2answers
146 views

Repository Pattern and custom queries/REST API. Is it the right approach?

I'm in the early stages of working on an application that is using the Repository Pattern to provide a data access abstraction. This application will have some form of a simple REST API but I'm not ...
1
vote
1answer
66 views

Should factory make context or concrete strategies objects in strategy-factory pattern?

In a typical strategy pattern class Strategy { public: virtual int execute() const = 0; } class StrategyA : public Strategy { public: int execute() const override; } class StrategyB : ...
22
votes
3answers
1k views

Caching at business layer vs Caching at Data Layer

I have always worked on projects where caching was done on DAL, basically just when you are about to make the call to database, it checks if data is already there in the cache and if it is, it just ...
2
votes
1answer
232 views

Should I use foreign keys in my database if I use laravel?

I'm creating a website with Laravel for the first time. I checked relationships documentation today and it seems that Laravel just uses simple SQL queries. class User extends Eloquent { public ...
0
votes
2answers
109 views

Should methods perform checks that they accomplished the task they were built for? or should they just throw an exception?

What are some pro's and con's of validating your performed the task intended? public static bool UploadFile(string filename) { // 1. upload the file // 2. check to see if the file now exist ...
9
votes
6answers
1k views

Should I extract specific functionality into a function and why?

I have a large method which does 3 tasks, each of them can be extracted into a separate function. If I'll make an additional functions for each of that tasks, will it make my code better or worse and ...
4
votes
3answers
254 views

One controller to rule them all?

I am developing a single-page application. The page has a toolbar. When the user clicks on any button, it visually creates a tab, and triggers an ajax request to the required controller. Now two ...
1
vote
3answers
309 views

Potential abuse of observer pattern

I have a MeetingRoom object that contains a list of Employees, there is a function on each employee called SetMeetingDate, this method has to take into account the state of all other employees in the ...
2
votes
1answer
97 views

How to add permissions checks 'after the fact'

I have a great number of PHP classes which perform the business logic of my application, e.g. class FileMaker{ public function makeFile(){ //some code here to make a file } } Now I need to ...
9
votes
9answers
2k views

How to split large, tightly coupled classes?

I have some huge classes of more than 2k lines of code (and growing) that I would like to refactor if possible, to have some more light and clean design. The reason it is so big is mainly because ...
0
votes
1answer
115 views

What is a good practical example demonstrating an architectural advantage in interface dependency injection

I need help (preferably by way of a practical example) to understand why/if the following implementation of IoC/DI (in this case using Ninject) provides an architectural advantage: using (IKernel ...
1
vote
6answers
227 views

What is a better design a light weight user or a heavy weight heavy user model?

This is a design question and I am confused about how to design my user object. As in most systems, user is the central part of my application and a lot of information scattered around my database ...
0
votes
3answers
206 views

Check a boolean before setting it in a loop, or just set it

I have a rather tight loop with the following check to see if balance had ever been positive: balance_null = True while (crazy_loop()): ... if 0.0 < balance: balance_null = False ...
-1
votes
1answer
59 views

How to handle authentication to web service from mobile?

I'm making a mobile application, and I use JSON Web Token Authentication (JWT Auth), but I have three questions about: Should I use refresh-tokens or non-expiring access tokens? In case I use ...
2
votes
1answer
70 views

Combining Patterns: Fluent Builder and Null Object Pattern

I am currently wrestling around with some GUI code where I have a table whose rows correspond to some object, let's say a Person object. When the table initializes, it fills the table with the Person ...
2
votes
3answers
278 views

How to implement the repository pattern for an app that will change its database from sql to nosql on in couple of years?

I have been reading a lot about repository implementation. I am confused about which way to implement it for a project I am sure would change its data layer methods because of db migration from MS Sql ...
0
votes
1answer
90 views

Is this the template method pattern?

Could someone tell me whether the following is A) a good solution to the problem of repeating code and B) an example of the template method? Let's say I have one table, named VEHICLES, which I use to ...
0
votes
1answer
80 views

Is it ok for a for a View to dismiss itself?

Currently, I'm working on a project in which a view is dismissing itself. While talking to another programmer on the team for this project, he said that it's fine (in that it behaves correctly), but ...
1
vote
0answers
132 views

Is this a good implementation of the builder pattern?

I'm trying to design an SQL builder in PHP. I'm trying to make it so that the system could work with different database systems (e.g. Oracle, MySQL, MSSQL). Here's what I've got so far. First, I have ...
3
votes
2answers
221 views

How can I avoid tight coupling when practically every decision-logic has to check lots of distributed state?

As the senior developer in our company, I am currently starting to move our commercial php-mysql e-commerce solution (which takes data from a specific ERP-system) from procedural spaghetti-code which ...
4
votes
1answer
232 views

Derive from a base class but not include a condition in the base class's method

The current code looks like this: public class Details { Public void Populate() { WriteChapterDetails(); } public void WriteChapterDetails() { if ( ...
1
vote
1answer
69 views

Trying to Move Logic to DB - Reservation System

So I'm planning a basic resource reservation system. Basically I'm going to have a room (resource) that has X number of open spots per 30 minute increment. When someone reserves a resource I would ...
5
votes
2answers
2k views

Visitor stability vs instanceof flexibility

I am working on a GUI application which generates a configuration file. I have a class hierarchy for the configuration model and I use an object tree of that hierarchy in several different contexts. ...
2
votes
1answer
170 views

Design Pattern to parse array of objects

What is considered a good practice to parse an array of objects returned by an API? I am creating a RESTfull web service and a client which is meant to work with this service. One of my REST ...
2
votes
1answer
87 views

Managing types and conversions in a compiler

I am trying to determine how to manage types and conversions between types within a compiler that I am writing. The compiler is being written in C#. There are a number of different kinds of types. ...
1
vote
1answer
84 views

is a Model exactly the same as a Business Entity?

I've been programming for a long time now, and I have always seen Model classes exactly as a business entity. For instance: sales, users, products, orders, etc... But I have come to certain source ...
8
votes
2answers
348 views

How much logic can be put into a command? Or differently: What kind of logic is command pattern for?

I have been using the command pattern for quite some time but I'm never really sure how much logic I can actually put in the Execute method. My current implementation of the command pattern looks ...
0
votes
2answers
67 views

Architecture for process that can be invoked to return errors as well as silently [closed]

I'm looking for some high level design/architectural input for the following. I have "some business process" I am writing in code (the importing of data from various CSVs into a database. There is ...
1
vote
0answers
142 views

Transaction Management in Hibernate with DAO Design Pattern

I have many Tables, For every Table,we have DAO Interface and DAOImplementation class. Example DAO Interface public interface CancelPolicyDAO { public CancelPolicy insertCancelPolicy(CancelPolicy ...
0
votes
2answers
207 views

Model-View-Controller: who creates whom?

In "Pattern Oriented Software Architecture - Vol 1" (p. 131), the author said that View is responsible for creating Controller. But in "Head First Design Patterns" (p. 562) it is the Controller that ...
6
votes
1answer
159 views

Is the use of DSLs in a state monad a good approach to building complex stateful computations?

First, sorry if that title makes no sense. I am a little out of my depth here with the terminology. So, imagine that I'm writing a text editor in Haskell. For the purposes of this question, let's ...
0
votes
1answer
134 views

How does the Properties Pattern work?

I'm referring to the pattern (aka Universal Design Pattern) as discussed in this blog post Universal Design pattern I guess I'm not entirely clear how to use this in practice. And how it works to ...
2
votes
1answer
127 views

Inject it or create a new instance

suppose i have an interface in some language with two simple methods interface IConverter{ String toString(Object o) Object fromString(String s) } this interface is implemented by many ...
1
vote
1answer
246 views

Is DDD any good nowadays? [closed]

This is not a rant about DDD but rather some experiences and observations I've made through the past 2 years since I first learned about it. With this post, I'd like to hear what other programmers ...
0
votes
1answer
130 views

What is the correct way to bind few classes with similar functionality?

I want to do this in the right way to learn I have a few classes which have only one method. For example: public class RedColorText { public void AddRedColorText(string text) { ...
2
votes
2answers
135 views

Should I use a large if statement inside a view or create a different view entirely?

I'm using the MVC architecture Laravel 4.2 to create a relatively complex web application. This application consists of a website which is very heavily based on whether an event has occurred or will ...
0
votes
1answer
149 views

Implementing a NoSQL and RDBMS compatible DAO

What would be the correct way to design a DAO which implementation is first going to be targeting a MS SQL database with a STAR model, but yet, business requirements specify the application must be ...
13
votes
7answers
2k views

Is there a pattern for a more “natural” way of adding items to collections? [closed]

I think the most common way of adding something to a collection is to use some kind of Add method that a collection provides: class Item {} var items = new List<Item>(); items.Add(new ...
1
vote
0answers
78 views

Concurrent directory-tree search

I am trying to get familiar with concurrent programming, and have picked up an excercise to use a fixed number of threads that search through a directory structure. This is pretty much the way it is ...
-1
votes
1answer
50 views

Know any good resources/information on architecting an iOS app? [closed]

I spent a few months working on an iOS app of mine (in Swift) before realizing it was really a bunch of MVCs (Massive View Controllers). I want to start fresh and build something modular, scalable, ...
8
votes
1answer
1k views

Useful design patterns for working with FragmentManager on Android

When working with fragments, I have been using a class composed of static methods that define actions on fragments. For any given project, I might have a class called FragmentActions, which contains ...
4
votes
1answer
113 views

Extend, wrap, or both to add generics to a class that should have had them?

So I'm using a C# framework that has a great example of where generics would be useful, except they weren't used. For simplicity's sake, we will say it was a list (I know C# has its own list), but ...
1
vote
4answers
174 views

Options for constructing an object that is not logically initialized until all fields are set

I am working on a Pokemon game at the moment, and am running into some design concerns. The easiest example is as follows: Each Species of Pokemon has several traits that are required before it is ...
4
votes
1answer
177 views

Designing interfaces to hardware

I am writing a library in C++ that is used by customers to interface with hardware. There are many different devices that I need to support. For the sake of simplicity, assume I have 2 Widgets, ...
0
votes
1answer
123 views

Global state of games(or other). Example : Waiting,Betting,Battling in gambling game

So I'm making a IRC betting bot. Basically the game/bot has three states of taking-in chat. State 1 : Betting If anyone says "!bet team money" parse it and record. State 2 : Battling Take nothing ...
1
vote
2answers
249 views

How does the consumer-producer solution work?

I'm only a beginner, and my book doesn't cover this subject. I have researched my problem and found that an implementation of the consumer-producer pattern is the ideal solution, and have Googled it, ...
2
votes
1answer
263 views

How to solve this problem of duplicate code with a design pattern [duplicate]

This is what I am doing, Creating a new Pdf document using Aspose Pdf Adding few different types pages you know introduction page, table of content pages etc... Adding some further documents to it ...