design-patterns

Where can I find a good implementation of Adapter Patterns with good examples in C#?

Where can I find a good implementation of Adapter Patterns with good examples in C#? ...

Do I actually have a need for a Singleton?

I'm working on a Firefox extension where I'll want to keep multiple windows in sync with the same information. The toolbar queries a remote server for info periodically, based on when the window was opened. Because Firefox windows are all separately self-contained environments, each with their own toolbar running separate code I thought ...

DRY vs. "prefer containment over inheritance"

There is a general rule of OO design that you should model is-a relationships using inheritance and has-a relationships using containment/aggregation and forwarding/delegation. This is further narrowed by the admonishment from the GoF that you should generally favor containment over inheritance, suggesting, perhaps, that if you could mak...

High Availability and Disaster Recovery Software AntiPatterns

If you had to audit a Java application for worst-practices when it comes to high-availability and disaster recovery, you would probably look for hardcoded IP addresses and suboptimal caching of bind handles. What else should be considered? ...

getting db connection through singleton class

I have created an singleton class, this class returns a database connection. So my question is this connection is also satisfying singleton criteria? If no, than how I can make it singleton. Here is the code. public sealed class SingletonDB { static readonly SingletonDB instance = new SingletonDB(); static SqlConnection con =new...

Web site that collects and discusses Cocoa Touch design patterns?

Does anyone know of one? If it doesn't exist, anyone interested in collaborating to create it? ...

Should I apply state pattern here?

Hi I have a panel that draws alot of things. To make drawing effecient I am using a BufferedImage so that I dont have to draw everything, everytime something happens. My paintComponent only has to 'if' statements: if(!extraOnly) //paint something paint something if(listener.getRectangle() != null) // Paint something I like the ide...

What are the most important patterns for line of business web-applications?

What are the most important patterns you should know, when developing testable n-tier line of business web applications? Repository pattern Model View Controller Dependency Injection Pattern Factory Pattern Singleton What else? ...

What design patterns are most leveraged in creating high availability applications?

Likewise are there design patterns that should be avoided? ...

Measuring the security of code written by software developers

If you are a developer and had access to tools such as Ounce Labs, Fortify Software or Veracode, would you object to metrics on the code you write being made publicly available? If you would object, what would it take for you to feel more comfortable with more transparency in this regard? If metrics were public, do you think this would ...

How to handle different processing based on message type?

I have a process which has a "notify" method which receives as a parameter the base class of the message type. I'd like to do different processing based on the derived type of message. Does this mean I need to add a method called "process" or something similar to the message type, and invoke it using polymorphism? Is it better to add a "...

Design pattern for a single form Windows Forms application

My app is expanding, but the reqs dictate that there should be only one window open at all times, think of Nodepad where there is a menu, with each menu item different functionality but only one window open at all times as opposed to Excel where a user may have few windows open at once. So in terms of Windows forms, I was thinking of pl...

How to answer the interview question: What is a singleton and how would you use one?

I've read the questions on S.O. regarding Singleton and just watched an hour long google tech talk. As far as I can tell, the consensus in the OO world seems to be that singletons are more of an anti-pattern rather than a useful design pattern. That said, I am interviewing these days and the question comes up a lot--what is a singleton...

Connecting modules with in an application.

While working on my hobby projects i split code in to background operations and gui operations. So i end up having library objects that does the actual work and gui objects that represent menus, frames and such. The thing that bugs me every time is that i end up having lots of objects that has to know about other objects. Such as toolba...

The Mediator Design Pattern in OCaml

I am trying to accomplish a mutual binding between two classes in OCaml (a la Mediator Pattern's) and am getting an error upon compilation. class virtual ['mediator] colleague mIn = object val m = mIn method virtual getmediator : 'mediator end;; class concreteColleague mIn = object inherit colleague method getmediator = m end;; (...

What is a real-life use for the builder design pattern?

I've read about it, I understand it's basic function--I'd like to know an example of a common, real-life use for this pattern. For reference, I work mostly with business applications, web and windows, using the Microsoft stack. ...

Would it be wrong to use a static object instead of a database?

This is essentially a design patterns question: I was expecting to query a database to get a list of stocks(shares/securites whatever) that are most highly correlated for a given stock. Instead I thought maybe I should create an object which has a static HashMap and store my data in there. Then "query" it every time I need to. Would ...

Visitor Design Pattern in OCaml

I am attempting to implement the Visitor Design Pattern using OCaml's OO constructs and type system and am running into problems upon instantiation of an Element. class virtual ['hrRep] employee = object method virtual receiveEvaluation : 'hrRep -> unit method virtual getName : string end;; class ['hrRep] accountant myName = object ...

Model a master template: Inherit or not?

I have a scenario which is not easy to explain, but I am sure it is a very common problem. I will try my best to illustrate the problem. Lets say we have a Survey application which allows us to create surveys. Each survey has its own structure (contains questions, questions are grouped and ordered, etc.). Those surveys are managed by an...

Table module samples

Hello, I'm looking for some good open-source sample applications that use the Table Module pattern to organize the business logic (can be any language). Any suggestions? ...