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

learn more… | top users | synonyms (1)

0
votes
2answers
195 views

Design pattern for multiple companies in AngularJS

We are on the verge of launching v3 of our in-house product. v2 was written completely in AngularJS and V3 will be the same, but written completely in Typescript. We have a few customers that have ...
1
vote
1answer
284 views

mySQL / PHP design pattern - one function multiple queries

So here's the gist of it. I'm looking for a design pattern where I can have one function, say queryHandler that gets the query and the parameters from a number of different functions and returns the ...
1
vote
1answer
197 views

Should I use Strategy Pattern for this task?

I'm setting up a data validator that will iterate through the rows of a spreadsheet, and for each column, perform a validation check. I was thinking that this might be an appropriate task for the ...
1
vote
1answer
79 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 : ...
1
vote
1answer
208 views

Design pattern where decorated object may ask for things like “status updates” from the decorator to perform it's role?

Here's an situation that has haunted one of my open-source projects for quite some time. Imagine if you could represent every front-end input form with a single backend object? An object that ...
22
votes
3answers
2k 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 ...
0
votes
2answers
111 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 ...
4
votes
1answer
238 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
277 views

Change routing to comply with Law of Demeter

I have a Task, Owner and Plan. Charge values are kept in a plan, owner is on a particular plan and task knows its owner. A task needs to setup its charges based on the knowledge the owner has. Owner ...
4
votes
3answers
261 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 ...
2
votes
1answer
107 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 ...
0
votes
1answer
125 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
3answers
311 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 ...
0
votes
3answers
209 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
64 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 ...
1
vote
6answers
229 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 ...
2
votes
2answers
187 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 ...
0
votes
1answer
93 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
82 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 ...
2
votes
0answers
145 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 ...
2
votes
3answers
392 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 ...
3
votes
2answers
236 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
237 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
76 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 ...
2
votes
1answer
192 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 ...
1
vote
1answer
86 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 ...
2
votes
1answer
88 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. ...
8
votes
2answers
364 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
214 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 ...
0
votes
2answers
70 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 ...
2
votes
1answer
128 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 ...
6
votes
1answer
163 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
2answers
108 views

Design pattern for canceling a long task in a sub-thread

Suppose we have a file copy program. It has two threads, a UI thread displaying the progress of the copy operation and a work thread copying the file. The UI has a button for canceling the process. ...
1
vote
1answer
264 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
135 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
2answers
140 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 ...
1
vote
0answers
80 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
53 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, ...
0
votes
1answer
166 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 ...
0
votes
1answer
151 views

How can I decouple query and context in a “query object” scenario?

I'm using a query object pattern (similar to this) to manage disparate queries while avoiding bloaded facades/repositories. A query object takes a number of constructor parameters, representing query ...
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
4answers
175 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 ...
0
votes
1answer
124 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
4answers
195 views

What is the efficient way to eliminate duplication? Design patterns?

I have a helper class which has a method that perform some checks against a field in a model. I have two models, ModelA and ModelB, they have some similarities but not all. One of them is they both ...
2
votes
1answer
272 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 ...
1
vote
1answer
68 views

Application components dependency and decoupling

In my client application I have two major components: Core: wrapper that handles everything about running the actual application NetworkClient: A layer that takes care of communicating ...
0
votes
1answer
127 views

Changing an object's (apparent) class at runtime

I'm looking for a design pattern to solve the following problem: An object (let's say representing a document) can change its type dynamically during its lifetime (e.g. when it is saved with a ...
0
votes
1answer
94 views

Job and workers, pattern / design

I have x number of worker classes which all implement a specific interface, i have a job descriptions Each job description States the different worker classes that should execute to complete the job ...
0
votes
1answer
133 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) { ...
-1
votes
3answers
357 views

Which Design Pattern Is Best Suited?

I have been studying Design Patterns and I am looking to implement them into my latest project. I am working on a Windows Service that regularly checks a database table for a new entry. Depending on ...