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

learn more… | top users | synonyms (1)

3
votes
4answers
277 views

Using configuration to determine whether to handle exception or bubble it up

On a side project I'm working on I came up with a way of handling exceptions that's adjustable by configuration. So a try/catch block might look like this: try { fileHelper.MoveFile(file, ...
18
votes
3answers
3k views

Where we should put validation for domain model

I still looking best practice for domain model validation. Is that good to put the validation in constructor of domain model ? my domain model validation example as follows: public class Order { ...
0
votes
1answer
215 views

sqlite trigger or application event?

I've have two event queues(table mapped queues) based on two different states of same data stored in two different tables. The events are generated on create/update/delete on both the tables. ...
0
votes
0answers
165 views

Should you implement a repository pattern with an MVVM javascript framework?

When coding a MVVM pattern I use Dependency Injection (DI) and try and code against interfaces. One of the common patterns is a Repository pattern, so I can swap my data storage provider. If I'm ...
0
votes
2answers
294 views

Where should the ACL handler be called in a MVC architecture?

Thinking about Access Control Lists bound to a web MVC architecture, I have a doubt on where the verification should be done. Within Models? Controllers? FrontController? Imagine a multiple module ...
1
vote
1answer
55 views

modelling staged business process

imagine given a project business object and such (simplified) rules: it's lifecycle is divided into several stages of evaluation; stages flow lineary and represent an evaluation chain; each stage ...
6
votes
6answers
475 views

When to write Abstract code and when to be more specific?

I'm working on a small tool as a toy project to show the difference between two directories, showing which files/directories were added, removed, modified, etc. I was trying to represent these ...
1
vote
3answers
297 views

Problems with Facades and then evolution in software

I initially started a project with Facades and Polymorphism as a way to create simple extensible design following SOLID Principles. Here is a sample code: public interface IInterface { void ...
0
votes
1answer
68 views

Pythonic design for controlling multiple devices through an I2C bus

I'm writing a piece of software in python that will communicate with a bunch of devices via an I2C bus. Each of these devices are going to need some sort of a module or class to handle the ...
4
votes
3answers
596 views

Extension method naming convention [closed]

We are using some utility methods in our company to simplify programming. So we have following string extension: public static bool IsNoE(this string s) { return string.IsNullOrEmpty(s); } ...
9
votes
4answers
348 views

Does an iterator have a non-destructive implied contract?

Let's say I'm designing a custom data structure like a stack or a queue (for example - could be some other arbitrary ordered collection that has the logical equivalent of push and pop methods - ie ...
1
vote
1answer
236 views

Android Data persistence question

I have an android app in which users have sets of items, and each item has about 10 properties. What I do at the moment: items are stored in the server database when the user logs in, I get all the ...
10
votes
2answers
488 views

How do you manage config with dependency injection?

I am a big fan of DI/IOC. It is great for handling/abstracting away hard dependencies, and makes life a little easier. However I have a small gripe with it, which I am not sure how to solve. The ...
0
votes
4answers
536 views

What is this design pattern called? [closed]

I have some code: /// <summary> /// Represents Record Locator class /// </summary> public class RecordLocator : IRecordLocator { /// <summary> /// The Record Locator string, ...
0
votes
3answers
170 views

Doesn’t active record violate SRP and OCP?

I have watched the active record classes in our project grow into large, do-it-all classes. When you need anything about a user, for example, you should go to the Person class. While this makes ...
7
votes
3answers
348 views

How to decompose / model a chessboard

As someone new to programming, I am building a chess web application in JavaScript, both for fun and to learn more about design patterns. I keep running into a wall, which is how to decompose the ...
3
votes
4answers
294 views

Testing all combinations

I need to do some performance measurements inside my application. I want to measure, change some parameters, measure again. There are different algorithms I want to test, and there are various ...
0
votes
2answers
143 views

Best way to display domain object summary information efficiently and in an OO way from a large inheritance tree?

I've provided only simplified code as it's more of an abstract design question. So I have many, many nested business/domain event objects, e.g. public class Event { //bunch of properties and ...
3
votes
2answers
381 views

Design pattern for overlapping actions and animations?

Is there a design pattern for dealing with overlapping UI actions and animations? A few examples: Let's say I have an interactive table row that expands to reveal an extra control when the user ...
0
votes
1answer
181 views

Practical Use of Depency Injection (IoC) Container

I am creating a MVC-ish framework in PHP. I am trying to implement a DI Container to allow the creation of controller objects (among others). My MVC framework is pretty typical. Each module (or ...
3
votes
1answer
1k views

Opensource showcase for MVC in Java Swing [closed]

I've allready created small desktop CRUD applications using Java/Swing. In hindsight I'm not quite sure if the overall design of these applications is good. I've also done some reading on MVC and ...
4
votes
2answers
231 views

Is Convention Over Configuration “Knowledge in the World” or “Knowledge In Your Head”?

In Don Norman's seminal work "The Design of Everyday Things", the author coined the phrases and explains the difference between "Knowledge in the World" and "Knowledge In Your Head"; an example of ...
0
votes
0answers
79 views

Design of a custom query result array with lazy loading

I have a database that generates a query result array, each position of the array being a hash like object. Since each array item must be mapped into a well defined class, I decided to implement an ...
0
votes
1answer
89 views

What is the shortcoming of custom factory comparing to generic factory [closed]

I have a factory method as given below public class AutomobileFactory { Dictionary<string, ICar> internalFactory = new Dictionary<string, ICar>(); public AutomobileFactory() { ...
1
vote
1answer
304 views

Creating a online database creator

I've been thinking of creating an online database creator (think DabbleDB, Zoho Creator, Intuit Quickbase, etc.). I've been thinking of a couple solutions: Have 4 database tables: Tables, Rows, ...
3
votes
4answers
257 views

How to handle affinities?

Assume we have an abstract class having several concrete classes which interfaces publish an information under several equivalent forms, with the difference that each class has a preferred form which ...
-1
votes
1answer
182 views

Naming convention of getters and setters [closed]

Given a string variable variable, for example, the convention to expose it is: public class SomeClass { public String variable = ""; public String getVariable() {return variable;} public void ...
28
votes
7answers
5k views

Is dependency injection essential for unit testing?

Is using dependency injection (DI) essential for unit testing? I can't think of another alternative for isolating code so it can be tested. Also, all the examples I have ever seen use this pattern. ...
4
votes
3answers
308 views

Designing a fitness / weight lifiting routine database

I'd like to create an app similar to Barbell Pro for Android, for practice / interest / educational purposes really. Or even as another example for database purposes, Fitocracy The problem is, I ...
1
vote
4answers
189 views

available methods change with object state

I'm programming a graph object which can be in either a mutable or immutable state. In both states, it has a get method, but only in the mutable state is the set method allowed. The transition occurs ...
2
votes
1answer
231 views

DI or Factory Pattern ? Both ? or a different apprach?

Lets say we have an abstract class called BaseSwitch, inherited by concrete implementations Switch A and Switch B, Each Switch representing a real-life switch (A telephony tool which among its ...
228
votes
13answers
56k views

So Singletons are bad, then what?

There has been a lot of discussion lately about the problems with using (and overusing) Singletons. I've been one of those people earlier in my career too. I can see what the problem is now, and yet, ...
1
vote
3answers
254 views

Pattern for costly precondition check before acting

Let's say I have a method DoTheThing() which requires the precondition-check CanTheThingBeDone() to return true. The latter method is time consuming as it accesses the database. I'm finding it hard ...
9
votes
2answers
3k views

Understanding the bridge design pattern

I do not understand the "bridge" design pattern at all. I have gone through various web sites, but they haven't helped. Can anybody help me in understanding this?
1
vote
1answer
103 views

Factory method - when objects need information to get initalized

Lets look on a simple example: assume that I have three classes implemeting IPersonRepository: SQLPersonRepository, WebPersonRepository, InMemoryPersonRepository. I also have PersonRepositoryFactory ...
3
votes
3answers
385 views

Why should a builder be an inner class instead in it's own class file?

Many Builder Pattern examples make the Builder an inner class of the object it builds. This makes some sense since it indicates what the Builder builds. However, in static a static type language we ...
0
votes
2answers
167 views

How to remove redundant code that enables button. Or “if” statement

I got probably "micro optimization" problem. I got "History number", "Next Number", "Reset" buttons, as well "label" for text. Every time I click At "Next number" button I would like to show random ...
23
votes
7answers
8k views

Self-Executing Anonymous Function vs Prototype

In Javascript there are a few clearly prominent techniques for create and manage classes/namespaces in javascript. I am curious what situations warrant using one technique vs. the other. I want to ...
5
votes
1answer
435 views

Is there already a commonly known name for the 'ensure pattern'?

I use a pattern that I call "ensure" extensively in my repository layer. In short, it does the following when I call an Ensure(...) method: It uses the arguments in the method to attempt to ...
1
vote
2answers
644 views

Why does java.util.Calendar use static factory methods?

It is considered better to have a separate factory class than having static methods in same class. See this question. But the standard API uses both approaches. Separate factory: ...
3
votes
3answers
506 views

Why is inheritance only defined at compile-time?

I found this statement from the gang of four's "Design Patterns" particularly odd; for some context, the authors are comparing inheritance versus composition as reuse mechanisms [p. 19]: "...you ...
3
votes
1answer
319 views

State pattern vs Inheritance

In the following image for the State Pattern from Applying Domain-Driven Design and Patterns: With Examples in C# and .NET I'm trying to persist the SalesOrder entity into the database. Normally I ...
16
votes
8answers
21k views

Web Developer interview questions

I read an article today that listed some basic questions about web development: Describe how POST data was submitted to a server by a browser. Explain a number of HTTP status codes (except maybe 404 ...
0
votes
1answer
225 views

Anemic domain models - what sort of methods a domain object might need?

This question might seem strange, but it's something I've faced sometimes. I've been trying to adopt DDD, however I'm always facing the problem of anemic domain models. The problem is that when I ...
1
vote
3answers
222 views

Are design patterns essential for good code? [duplicate]

Are design patterns (e.g. factory pattern, observer, etc...) required to be known to write good code? I often have no idea of what people mean when they talk about inserting pattern name here pattern ...
0
votes
1answer
192 views

Need an OOP pattern or strategy for “pluggable” property

I'm using OOP and MVVM in a WPF c# application. The goal is for the resulting object (data-bound to user interface) to accurately represent a product. One specific area of the product is highly ...
1
vote
1answer
174 views

Notifying multiple listeners

I am building an Android guitar application and I need a way for GuitarString objects to notify multiple listeners that it has just been played. This includes the current Activity and all instances of ...
7
votes
3answers
5k views

How to make an ASP.NET MVC site modular

I'm in the planning stage for an employee intranet system to be built with ASP.NET MVC 4. We'd like the site to consist of separate "modules", each of which provides a different feature: messaging, ...
1
vote
1answer
251 views

Creating a System Sequence Diagram from an [extended] use case

As I have been taught - one controller = one use case. But I have: OutsiderController SupplierController (which extends OutsiderController) SubContractorController (which also extentds ...
1
vote
2answers
245 views

What design pattern (in python) to use for properly seperate runtime infos with core code?

I am not sure if this is a clear question. I work on a python project that is based on terminal(console), for which I am planning to implement a GUI. I am not major in CS so I really have no idea ...