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

learn more… | top users | synonyms (1)

15
votes
2answers
4k views

What are the drawbacks to the ActiveRecord pattern?

I'm curious what are the drawbacks to using the ActiveRecord pattern for data access/business objects. The only one I can think of off the top of my head is that it violates the Single Responsibility ...
15
votes
4answers
9k views

How to avoid big and clumsy UITableViewController on iOS?

I have a problem when implementing the MVC-pattern on iOS. I have searched the Internet but seems not to find any nice solution to this problem. Many UITableViewController implementations seems to ...
15
votes
6answers
1k views

Strategies for avoiding SQL in your Controllers… or how many methods should I have in my Models?

So a situation I run into reasonably often is one where my models start to either: Grow into monsters with tons and tons of methods OR Allow you to pass pieces of SQL to them, so that they are ...
15
votes
4answers
335 views

Is there a specific design strategy that can be applied to solve most chicken-and-egg problems while using immutable objects?

Coming from a OOP background (Java), I'm learning Scala on my own. While I can readily see the advantages of using immutable objects individually, I'm having a hard time seeing how one can design a ...
15
votes
3answers
913 views

Does the state Pattern violate Liskov Substitution Principle?

This image is taken from Applying Domain-Driven Design and Patterns: With Examples in C# and .NET This is the class diagram for the State Pattern where a SalesOrder can have different states during ...
14
votes
4answers
534 views

Is it possible to loosely couple an application to its framework?

Let's say I'm developing a web application. My first choice is to use PHP with Fat-Free Framework (F3) and MVC pattern. Next year, I might decide I want to switch to Zend Framework, or maybe even ...
14
votes
8answers
2k views

Is the GoF book still the one to read? [duplicate]

Possible Duplicate: Is there a canonical book on design patterns? I'd like to read a design patterns book. GoF for sure is the one to read. But after 15 years is it still valid, I mean ...
14
votes
4answers
613 views

Progressive Enhancement vs. Single Page Apps

I just got back from a conference in Boston called An Event Apart. A really popular theme amongst the speakers was the idea of progressive enhancement - a site's content should go in the HTML, and ...
14
votes
8answers
415 views

When should complexity be removed?

Prematurely introducing complexity by implementing design patterns before they are needed is not good practice. But if you follow all (or even most of) the SOLID principles and use common design ...
14
votes
9answers
3k views

What should a programmer learn first: Algorithms or Design Patterns? [closed]

I have new junior programmers (new graduates) who just joined my team, some of them do not know much about algorithms and design patterns. I am not sure which one should I teach them first?
14
votes
2answers
3k views

What are the main practices and design patterns every .NET guy should know?

In my brief time as a professional programmer I've seen lots of applications written by programmers who's entire education appears to have been reading the first couple of chapters in a .NET 2.0 book. ...
14
votes
2answers
1k views

Equivalent of SOLID principles for functional programming

I've found the SOLID principles quite useful when thinking about object-oriented design. Is there a similar / equivalent set of language-agnostic principles tailored for functional programming?
14
votes
2answers
5k views

Relationship between Repository and Unit of Work

I am going to implement a repository, and I would like to use the UOW pattern since the consumer of the repository could do several operations, and I want to commit them at once. After read several ...
14
votes
3answers
449 views

Learning about design [closed]

How do you improve your ability to design your applications? Where do you get your design ideas from? (I am asking about code design - not about a specific language and not about visual appeal). When ...
14
votes
3answers
717 views

How can you tell whether to use Composite Pattern or a Tree Structure, or a third implementation?

I have two client types, an "Observer"-type and a "Subject"-type. They're both associated with a hierarchy of groups. The Observer will receive (calendar) data from the groups it is associated with ...
13
votes
13answers
2k views

Where is the M in MVC?

I'm trying to refactor my application into MVC, but I'm stuck on the M part. In a database-backed app, the model is implemented in the app code, right? But then, what is in the database -- is that ...
13
votes
9answers
4k views

Are too many if-else statements for validation bad? [duplicate]

From the book Professional Enterprise .Net, which has 5 star rating on Amazon that I am doubting after having a read through. Here is a Borrower class (In C# but it's pretty basic; anyone can ...
13
votes
5answers
5k views

What is the difference between all-static-methods and applying a singleton pattern?

I am making a database to store information about the users of my website (I am using stuts2 and hence Java EE technology). For the database I'll be making a DBManager. Should I apply singleton ...
13
votes
2answers
8k views

Separating data access in ASP.NET MVC

I want to make sure I'm following industry standards and best practices with my first real crack at MVC. In this case, it's ASP.NET MVC, using C#. I will be using Entity Framework 4.1 for my model, ...
13
votes
5answers
1k views

Using functions as a way to stylize [closed]

Have you ever broken up a large function into smaller functions knowing that those smaller functions will not be called by more than one caller? The primary purpose of a function is to promote code ...
13
votes
2answers
1k views

Does the Decorator Pattern exist in the Java IO classes?

For an assignment, I have to find out which of the Gang of Four design pattern the classes java.io.Reader and its subclasses java.io.PushbackReader, java.io.BufferedReader and java.io.FilterReader ...
13
votes
2answers
944 views

What is a 'good number' of exceptions to implement for my library?

I've always wondered how many different exception classes I should implement and throw for various pieces of my software. My particular development is usually C++/C#/Java related, but I believe this ...
13
votes
1answer
530 views

Does Liskov Substitution Principle also apply to classes implementing an interface?

LSP states that classes should be substitutable for their base classes, meaning that derived and base classes should be semantically equivalent. But does LSP also apply to classes implementing an ...
13
votes
3answers
2k views

How to store prices that have effective dates?

I have a list of products. Each of them is offered by N providers. Each providers quotes us a price for a specific date. That price is effective until that provider decides to set a new price. In ...
13
votes
2answers
945 views

Is “Analysis Patterns: Reusable Object Models” Still A Good Book To Use For Its Subject Matter Today?

Is "Analysis Patterns: Reusable Object Models" by Martin Fowler (published 1996) still a good book to use for the content it covers? Are there other good books that cover the same content? Are there ...
12
votes
7answers
2k views

Does MVC apply only to web

It is almost and instantaneous whenever I talk to developers about Model View Controller (MVC) they say you make a request to a url the server builds a entity (MODEL) and provides you with visual ...
12
votes
14answers
4k views

What would be the best real example to explain the usefulness of Inheritance ? [closed]

When trying to explain the concept of Inheritance in OOP, the common example is often the mammals example. IMHO, this is really a bad example, because it will lead the newbies to use this concept the ...
12
votes
7answers
583 views

Should universities put more emphasis on teaching their students about design patterns?

While I've heard about design patterns being mentioned in a few courses at uni, I know of only a single course which actually teaches design patterns. In almost all other areas (algorithms, ...
12
votes
8answers
820 views

Algorithm Vs Design [duplicate]

Possible Duplicate: Is it essential to learn algorithms to be a real programmer? This question is, perhaps, related mostly to web developers who, like myself, code enterprise applications ...
12
votes
4answers
859 views

How to determine whether Design Pattern is implemented correctly?

I am successfully able to scale all my old applications which were not using documented Design Patterns. Whatever pattern it is I don't know. To a large extent, I only felt a need to use simple OOP ...
12
votes
4answers
2k views

Does anyone have a specific example of using the Flyweight Pattern?

I have been studying design patterns and came accross the fly weight pattern. I have been trying to see opportunities to use the pattern in my applications but I am having trouble seeing how to use ...
12
votes
4answers
2k views

What is pattern based programming?

Can somebody explain the obsession with patterns and anti-patterns in programming? I ask because I have absolutely no idea what any of the patterns mean. When faced with a programming task I think ...
12
votes
5answers
9k views

Model-View-Presenter implementation thoughts

I'm trying to get a good grasp of how to implement good decoupling between a UI and the model, but I'm having trouble figuring out exactly where to divide the lines. I've been looking at ...
12
votes
2answers
3k views

DDD - Does an aggregate root's repository handle saving aggregates?

I am using a DDD-like approach for a greenfield module of an existing application; it's not 100% DDD due to architecture but I'm trying to use some DDD concepts. I have a bounded context (I think ...
12
votes
3answers
2k views

Recommended order for learning design patterns? [closed]

I can't help but notice the amount of design patterns that are out there. Does anyone have suggestions on an order I should learn them in? Or should I pick and choose them at random? The only one I ...
12
votes
2answers
664 views

I should have used a factory method instead of a constructor. Can I change that and still be backwards-compatible?

The problem Let's say I have a class called DataSource which provides a ReadData method (and maybe others, but let's keep things simple) to read data from an .mdb file: var source = new ...
12
votes
2answers
391 views

Looking for some OO design advice

I'm developing an app that will be used to open and close valves in an industrial environment, and was thinking of something simple like this:- public static void ValveController { public static ...
12
votes
3answers
3k views

Static factory vs factory as a singleton

In some of my code, I have a static factory similar to this: public class SomeFactory { // Static class private SomeFactory() {...} public static Foo createFoo() {...} public ...
11
votes
8answers
507 views

What is a good code practice of when to make a function/method for small repetitive code segments?

Many times throughout writing larger programs I have questioned after how many copy and pastes does it make sense to put the code into a function or method and what is a good rule of thumb? I have ...
11
votes
3answers
2k views

How to avoid “managers” in my code

I'm currently re-designing my Entity System, for C++, and I have a lot of Managers. In my design, I have these classes, in order to tie my library together. I've heard a lot of bad things when it ...
11
votes
6answers
1k views

How to Be a Software Engineer?

My problem is kind of weird so please bear with me. I have been working in a start up concerned basically with mobile development since my graduation 2 years ago. I develop apps for iOS but it's not ...
11
votes
11answers
938 views

What are some techniques to teach programmers design patterns? [closed]

I'm in a position where my developers are asking to learn design patterns. So far we have done a book club reading Heads First Design Patterns. During this we worked through examples and talked about ...
11
votes
3answers
559 views

Is using unit tests to tell a story a good idea?

So, I have an authentication module I wrote some time ago. Now I'm seeing the errors of my way and writing unit tests for it. While writing unit tests, I have a hard time coming up with good names and ...
11
votes
7answers
506 views

Introducing design concepts/patterns/principles to co-workers

I've read Joel's article about getting things done when you're a "grunt", several times in fact, but I've never been able to do any of the things it mentions. I work as part of a small development ...
11
votes
4answers
806 views

Is it a “pattern smell” to put getters like “FullName” or “FormattedPhoneNumber” in your model?

I'm working on an ASP.NET MVC app, and I've been getting into the habit of putting what seem like helpful and convenient getters into my model/entity classes. For example: public class Member { ...
11
votes
3answers
809 views

Tips/advice on how to reduce the use of “manager” classes?

I sometimes hear that having too many "manager" classes in your program's design is code smell and add an unnecessary layer of complexity. To me it makes sense that people want to use manager classes ...
11
votes
2answers
337 views

What are the advantages of separating 'result' from 'status'

Let's say you have some automated processes that generally go through the following states; scheduled - initiated - validating - executing - completed On top of that these processes can prematurely ...
11
votes
3answers
3k views

Improvements to Joshua Bloch's Builder Design Pattern?

Back in 2007, I read an article about Joshua Blochs take on the "builder pattern" and how it could be modified to improve the overuse of constructors and setters, especially when an object has a large ...
11
votes
4answers
1k views

Create a behavior/Component based system for games

Background I do game development as a hobby, and am looking for a better way to design them. Currently, I am using a standard OOP approach (I have been doing enterprise development for 8 years so it ...
11
votes
5answers
626 views

Is overloading an example of the Open/closed principle?

Wikipedia says "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification" The word functions caught my eyes, and I now wonder if we can ...