design-patterns

Open source examples of well designed applications

Do you know of well designed open source applications that are instructive to analyse? Specifically, I'm interested in practical applications object-relational mapping in C++ based programs, where there is a good separation between a domain model and persistence/serialization functionality. ...

Open source examples of well designed Python applications

Do you know of well designed open source applications that are instructive to analyse? Of course this question is strictly related to this other post, but I am specifically interested in applications written in Python. ...

Abstracting data connection layers and presentation layers in an enterprise application

We are building an enterprise application in which we will incorporate multiple platforms for user interfaces (i.e. ASP.net webapp, Windows Application, and someday, Mobile Apps) and multiple platforms for back-end databases (i.e. SQL Server, XML, Oracle). An additional neccesity is that these back-end DBs either be centralized and acce...

ASP.NET MVC - Should business logic exist in controllers?

Derik Whitaker posted an article a couple of days ago that hit a point that I've been curious about for some time: should business logic exist in controllers? So far all the ASP.NET MVC demos I've seen put repository access and business logic in the controller. Some even throw validation in there as well. This results in fairly large,...

designing business msgs parser / rewriting from scratch

I take care of critical app in my project. It does stuff related to parsing business msgs (legacy standard), processing them and then storing some results in a DB (another apps picks that up). After more then a year of my work (I've other apps to look after as well) the app is finally stable. I've introduced strict TDD policy and I have ...

What design pattern to use for User Authentication in Java

There are certain common components that are used across projects: User Authentication and Authorization Exception Handling Logging E-mail DataBase Access Caching etc Is there a consistent design pattern that can be used for each of these common modules? By the way, the framework can vary like JAAS/JNDI for User Authentication and Au...

How could I improve this code ( C++ )

Hello ! I want your suggestion on the following pseudo-code . Please suggest how could I improve it,whether or not I could use some design patterns . // i'm receiving a string containing : id operation arguments data = read(socket); tokens = tokenize(data," "); // tokenize the string based on spaces if(tokens[0] == "A") { if(to...

Learning/Implementing Design Patterns (For Newbies)

I'm a confused newbie and hobbyist programmer trying to get a grip on this, so forgive me if my question is a little off or doesn't make much sense. I see a lot of questions on SO revolving around the use of design patterns, and I'm wondering if anyone has a good resources for learning about, and implementing design patterns? I understa...

Unit testing Visitor pattern architecture

I've introduced visitors as one of core architecture ideas in one of my apps. I have several visitors that operate on a same stuff. Now, how should I test it? Some tests I'm thinking of are a bit larger then a unit test should be (integration test? whatever) but I still wanna do it. How would you test code like the C++ sample from wiki ...

How do you balance Framework/API Design and TDD

We are building a framework that will be used by other developers and for now we have been using a lot of TDD practices. We have interfaces everywhere and have well-written unit tests that mock the interfaces. However, we are now reaching the point where some of the properties/methods of the input classes need to be internal, and not v...

Removing repeated conditions using polymorphism and the Factory pattern

<?php /** * My codebase is littered with the same conditionals over and over * again. I'm trying to refactor using inheritance and the Factory * pattern and I've had some success but I'm now stuck. * * I'm stuck because I want to derive a new class from the one * returned by the Factory. But I can't do that, so I'm obviously * d...

Pattern name for flippable data structure?

I'm trying to think of a naming convention that accurately conveys what's going on within a class I'm designing. On a secondary note, I'm trying to decide between two almost-equivalent user APIs. Here's the situation: I'm building a scientific application, where one of the central data structures has three phases: 1) accumulation, 2) a...

What is a mono singleton?

A friend of mine was recently asked in a job interview to tell the difference between a standard singleton and a mono singleton. I have never heard the term before and a simple google search does not return any meaningful results. My friend suggested that it is an object where the constructor is public but all the members are static. T...

What is the best way to implement protocols?

Say you are writing an application that must implement the HTTP protocol. Protocols are quite complex and may allow several commands depending on which stage of a transaction they are in. As an example, look at SMTP. An SMTP server must throw an error if the "data" command is sent before receiving "rcpt" and "mail". My question is: wha...

Explain Facade pattern with c++ example?

I have checked with the wikipedia article, and it seems like it is missing the c++ version of a code example. I am not able to fully appreciate the Facade pattern without this, can you please help explain it to me using C++? ...

Design pattern or code smell, denormalised data as a result of functional decomposition

I'm a big fan of http://highscalability.com/ and have been looking in my current development to decompose my application along functional boundaries as a route to being able to scale out the server side, specifically the database layer. What this involves is implementing different functional components of the application (we have several...

Iterator Pattern VB.net (C# would use yield!)

Hello, I want to implement the iterator pattern in VB.net, which does not have the yield keyword. Any ideas or links please? ...

Should a user interface be implemented using the Singleton design pattern?

I can't think of many reasons (or any at all) in which multiple independent user interfaces should be instantiated in a desktop application. Is it good practice to implement the UI as a singleton? Are there are advantages or disadvantages to this approach? ...

Misused design patterns

Are there, in the canonical Gang of Four list, any design patterns that you often find misused, misunderstood or overused (other than the highly debated Singleton)? In other words, is there a design pattern you would advise to think twice before using? (And why?) ...

Singleton Data Access Layers

In our data access layer at work we have this standard implementation where the class is accessed through a singleton public property which looks something like this: public static CustomerController Instance { get { lock(singletonLock) { if( _instance == null ) { _instance = new ...