design-patterns

Does TCL have some concept of function pointers?

Working with TCL and I'd like to implement something like the Strategy Pattern. I want to pass in the "strategy" for printing output in a TCL function, so I can easily switch between printing to the screen and printing to a log file. What's the best way to do this in TCL? ...

Design Pattern to apply conversion to multiple properties in multiple classes

I am using the WMD markdown editor in a project for a large number of fields that correspond to a large number of properties in a large number of Entity classes. Some classes may have multiple properties that require the markdown. I am storing the markdown itself since this makes it easier to edit the fields later. However, I need to co...

When should I use the Visitor Design Pattern?

I keep seeing references to the visitor pattern in blogs but I've got to admit, I just don't get it. I read the wikipedia article for the pattern and I understand its mechanics but I'm still confused as to when I'd use it. As someone who just recently really got the decorator pattern and is now seeing uses for it absolutely everywhere ...

What is a good reference documenting patterns of use of ".h" files in C?

"C Interfaces and Implementations" shows some interesting usage patterns for data structures, but I am sure there are others out there. http://www.amazon.com/Interfaces-Implementations-Techniques-Addison-Wesley-Professional/dp/0201498413 ...

Building a Webapp Around User-Workflow

The more I think about how I use computers, the more I become convinced that 'workflow' is the key factor in terms of productivity, and the way I should go about designing interactions. I'm thinking of workflow as the way we approach and manage data, information and knowledge as it relates to a task. I'm starting out with my first web-...

What is the difference between a Functor and the Command pattern?

I am very familiar with the Command pattern, but I don't yet understand the difference in theory between a Functor and a command. In particular, I am thinking of Java implementations. Both are basically programming "verbs" represented as objects. However, in the case of functors, as I have seen from some examples anonymous inner class im...

Anemic Domain Model: Pros/Cons

I would like to know what the pros and cons are for using an Anemic Domain Model (see link below). Fowler Article ...

Best way to stop a JTree selection change from happening?

I have a dialog where each entry in a JTree has its corresponding options in a different panel, which is updated when the selection changes. If options for one of the entries is set to an invalid state, when the user attempts to change to a different entry in the tree, I want there to be an error dialog and have the selection not change....

Are there any good J2EE value list handler pattern implementations?

Are there any good value list handler implementations available? I've found valuelist, but it seems to be stagnating... besides I really need good control of links the taglib generates, because I need to call some JavaScript from it. Currently I solve it by rewriting the taglib in freemarker and using valuelist's backend. Does anyone ...

When to call the gang of four? [When to use design patterns?]

In The Guerilla Guide to Interviewing Joel says that guys who want to get things done, but are not smart will do stupid things like using a visitor design pattern where a simple array would be sufficient. I find it hard to detect, if the design pattern suggested by the Gang of Four should be applied. Therefore, I would like some exampl...

How to learn "good software design/architecture"?

I just listened to a discussion about a project drifting away from the direction it's supposed to go. The problem was "bad software design". Components are not designed to be re-used; the software is hard to maintain, test, extense, and scales poorly. What did the programmers do wrong? Where/how to learn better techniques? Of course, ...

Extensible rule-based pattern

I control access to some of my static web resources with some PHP logic. Because directory-based authorization through the webserver is not suitable or easily possible. A combination of things determines whether access is granted or denied. And these rules change from time to time. In the beginning it was a simple regex path match, a...

Techniques for adding Achievements to business class software

I was thinking of adding some Achievements to our internal bug-tracking and time logging system. It's connected to an SQL Server back-end. At first I thought that the system could be run on the database, using triggers to, for example, know when: you've logged 1000 hours created 1000 tickets closed your own ticket worked on a ticket t...

Question about decorator pattern

I'm a beginner when it comes to design patterns , and I have a question related to the decorator design pattern . Presuming I have a class named A , and I want to use the decorator design pattern . Correct me if I'm wrong , but for that to work , we'll need to create a decorator class ( ADecorator ) , which will hold a reference to an A ...

How to extend this simple DataMapper?

Can someone please derive a concrete example from the following: http://www.urdalen.com/blog/?p=210 ..that shows how to deal with one-to-many and many-to-many relationships? I've emailed the author some time ago but received no reply. I like his idea, but can't figure out how to implement it beyond simple single table relations. Not...

What applications could I study to understand (Data)Model-View-ViewModel?

I understand the basics of the Model-View-ViewModel pattern or as Dan Crevier calls it the DataModel-View-ViewModel pattern and I understand that it is a good approach to design WPF based applications. But there are still some open question. For example: Where do I put my business logic where my validation logic? How do I decouple the ...

Proper coupling for multiple listeners that need to accessed shared state data

Working with a traditional listener callback model. I have several listeners that collect various stuff. Each listener's collected stuff is inside the listener in internal structures. The problem is that I want some of the listeners to be aware of some of the "stuff" in the other listeners. I enforce listener registration order, so if ...

Does WCF optimize the client's connection under the hood?

We are currently working on an application that will use a WCF service. The host (the client) is using the excellent WCF Service Proxy Helper from Erwyn van der Meer. What I would like to know... is if I open this object multiple times... will it lead to multiple (expensive) connections or will WCF manage it and pool the connections. T...

Design pattern for memcached data caching

It's easy to wrap optional memcached caching around your existing database queries. For example: Old (DB-only): function getX x = get from db return x end New (DB with memcache): function getX x = get from memcache if found return x endif x = get from db set x in memcache return x end The th...

Should an object ever have a property thats result is based on business logic?

Or should they always be a function when business logic is invloved ? Example: Order.RequiresPayment property or function ? There are business rules as for when it is true or not IS there a pattern that may determine this? ...