design-patterns

Polymorphic factory / getInstance() in Java

I'm aiming to create a set of objects, each of which has a unique identifier. If an object already exists with that identifier, I want to use the existing object. Otherwise I want to create a new one. I'm trying not to use the word Singleton, because I know it's a dirty word here... I can use a factory method: // A map of existing ...

Null object design pattern question

I recently watched this youtube tutorial on the Null Object design pattern. Even though there were some errors in it: such as the NullCar that doesn't do anything creates an infinite loop, the concept was well explained. My question is, what do you do when the objects that can be null have getters, and are used in your code? How do you k...

When do you use the Bridge Pattern?

Has anyone ever used the Bridge Pattern in a real world application? If so, how did you use it? Is it me, or is it just the Adaptor Pattern with a little dependancy injection thrown into the mix? Does it really deserve its own pattern? ...

Design patterns vs Frameworks

Can someone illustrate what really is the difference between the two? ...

How to access multiple JPanels inside JFrame?

I have a JFrame that contains a "display" JPanel with JTextField and a "control" JPanel with buttons that should access the contents of the display JPanel. I think my problem is related on how to use the observer pattern, which in principle I understand. You need to place listeners and update messages, but I don't have a clue where to pu...

PHP memcache design patterns

Hi We use memcache basically as an after thought to just cache query results. Invalidation is a nightmare due to the way it was implemented. We since learned some techniques with memcache thru reading the mailing list, for example the trick to allow group invalidation of a bunch of keys. For those who know it, skip the next paragraph...

Good Source Of .Net Design Patterns

I'm looking for a good online resource of software patterns. Preferably something with a comprehensive selection and concise well written explanations, not just a collection of links. .Net examples would be nice, but not essential. ...

Writing a method based on the value of an enumeration without falling into a code smell

Imagine I have a document (word document). I have an enumeration which will indicate how to extract data from the document. So if I want just text, the images, or both (3 members of the enumeration). I have a case statement based on this enumeration, but without falling into a code smell, how can I write code which isn't too repetitive...

Common Design Patterns for use in MVC Web Applications

I am trying to coach some guys on building web applications. They understand and use MVC, but I am interested in other common patterns that you use in building web apps. So, what patterns have you found to fit nicely into a properly MVC app. Perhaps something for Asynchronous processes, scheduled tasks, dealing with email, etc. What ...

Does Functional Programming Replace GoF Design Patterns?

Since I started learning F# and OCaml last year, I've read a huge number of articles which insist that design patterns (especially in Java) are workarounds for the missing features in imperative languages. One article I found makes a fairly strong claim: Most people I've met have read the Design Patterns book by the Gang of Four....

When would you use the Builder Pattern?

What are some common, real world examples of using the Builder Pattern? What does it buy you? Why not just use a Factory Pattern? ...

Single event raising pattern for multiple controls

I have several controls on a page. It happens to be a Silverlight page but I don't think that it matters for this question. When a control's value changes, a change event is raised. In this event I do a calculation and change the value of one of the other controls. This in turn causes the other control to raise a changed event which in ...

Design Pattern: Parsing similar, but differing schemas in text files.

Hi there, thanks in advance for your help. I am wondering if there is a (design) pattern that can be applied to this problem. I am looking to parse, process, and extract out values from text files with similar, but differing formats. More specifically, I am building a processing engine that accepts Online Poker Hand History files fr...

Software engineering and patterns in Matlab GUI application?

I've been asked to develop a simple GUI application using Matlab and GUIDE, which will interact with a separate backend engine (also Matlab). I'm coming from a Java and .Net background. The Matlab documentation is strong on how to technically do this, but says little about the "engineering" process, in particular: How to package/names...

Is Switch (Case) always wrong?

Are there instances where switch(case) is is a good design choice (except for simplicity) over strategy or similar patterns... ...

ASP.NET MVP - Utilizing User Controls

I'm writing my first app with ASP.NET MVP (attempting Supervisory Controller) and Unit Testing (better late than never!), and I've run into a bit of a dilemma. I've written 3 User Controls, all tested and Interfaced up, Presenters in tow. Now I have come to a Page which takes these three User Controls and encountered the following prob...

What are your favorite books about data persistance, persistence patterns and/or techniques?

What are your favorite book(s) about data persistence, persistence patterns and/or techniques? Which book(s) advanced your knowledge in this area the most. Open to all languages/platforms. ...

JavaScript developer looking for inspiration from frameworks such as cocoa

I'm a developer who builds mainly single page client side web applications where state in maintained on the client-side. Lately some of the applications have become very complex with very rich domain models on the client-side and increasingly complicated UI interactions. As we've gone along we've implemented some very useful design patt...

Using hash functions for file storage?

A common technique for storing a lot of files/blobs in a filesystem is to use a hash function to determine the filepath; eg hash(identifier) -> "o238455789" -> o23/8455/789 (there is often a hash-collision strategy too) Does this technique have a name (is it a 'pattern'?) so that I may find it with a search of ACM Digital Library or sim...

What is the "Execute Around" idiom?

What is this "Execute Around" idiom (or similar) I've been hearing about? Why might I use it, and why might I not want to use it? ...