The template method pattern and the strategy pattern do roughly the same thing. I understand the basic differences between them (template method is inheritance based, strategy is composition based), but are there any decent guidelines on when to choose one over the other? It seems like they do basically the same thing.
...
Hi there, i have a question regarding the visitor pattern, I currently have two assemblies. My first assembly contains several interfaces.
public interface INode
{
void Visit(INodeVisitor visitor);
}
public interface INodeVisitor
{
void VisitContainer(IContainer container);
}
public interface IContainer : INode
{
}
And my s...
The decorator design pattern is a very good solution for extending a class functionality. For instance if I want pre and post processing methods on an existing class method I can create a decorator and override the existing method in the base class and call my pre and post processing methods respectively.
My question here is, the requir...
During my last project I noticed, that it is very convenient, to include design patterns names in class names. For example:
ContextLazyFactory
RunOnceMediator
ThirdPartyMediator
MyProjectCliFacade
BinaryGate
It makes the project easy to read. Additional benefit is that you will not use your own names like "RunOnceManager", "ContextDe...
I'm a somewhat advanced C++/Java Developer who recently became interested in Python and I enjoy its dynamic typing and efficient coding style very much. I currently use it on my small programming needs like solving programming riddles and scripting, but I'm curious if anyone out there has successfully used Python in an enterprise-quality...
I'm developing sales promotion system and I just stepped on something that could be probably handled with state machine pattern, but I have no experiences with state machines yet. Maybe the state machine is totally useless in this situation :)
So I have a sales promotion which has some duration, some assigned customers, products, discoun...
In a game, many entities should be updated every frame. Im toying with different design patterns to achieve this. Up until now, Ive had a singleton manager class to which every Logic instance is added. But Im considering the following, a static list in the Logic class itself. This is nice since it would remove a class from the project. "...
I'm just trying to streamline one of my classes and have introduced some functionality in the same style as the flyweight design pattern.
However, I'm a bit confused as to why __init__ is always called after __new__. I wasn't expecting this. Can anyone tell me why this is happening and how I implement this functionality otherwise? (apar...
I'm writing a lightweight IDE. I chose Ruby+Gtk2 for the task. I already have a minimal prototype for it, but right now, most of the code is inside my window class. I'll soon start working on the "real deal", but I would like to know what design patterns should I make use of. I'm planning for plugin support too, so that the app will be e...
Lets assume we have a class which will be widely used throughout the (c#) code, for example a Log class. Say the Log writes entries into XML files in a specific directory. Now one attempt to force the user to initialize the class with the required information would be to make the default (parameterless) constructor private and provide on...
While building by DAL Repository, I stumbled upon a concept called Pipes and Filters. I read about it here, here and saw a screencast from here. I am still not sure how to go about implementing this pattern. Theoretically all sounds good , but how do we really implement this in an enterprise scenario?
I will appreciate, if you have any ...
I am writing a section of code that allows "soft" forms, such as a configurable questionnaire or checklist. The header table/class just groups together a bunch of questions, where each question has a "Text" property for the question itself, an "AnswerType" enumeration (string/boolean/StronglyAgree-StronglyDisagree) etc., an order proper...
With the memento design pattern, is it wrong to have the Caretaker as an aggregate of the Originator?
...
Im somewhat new to design patterns and this is my first post in stackoverflow, so hopefully this question will make sense. Ive created an abstract factory to handle generating xml strings for different chart vendors (dundas, flash, etc...). Below is a code outline of my factory (I can include more if it helps.) Id like for my client t...
I've got a working app that serializes a document (of type IDocument) to disk. From there there's another app that I've made that can open that document (IDocument implements IPrintDocument) for viewing.
Let's assume that I've written an IDocument to disk, and then a week later a field gets added to the IDocument object. Both the progra...
One of the things I'm working on right now has some similarities to a game. For purposes of illustration, I'm going to explain my problem using an example drawn from a fictitious, hypothetical game.
Let's call it DeathBlaster 4: The Deathening. In DB4, you have a number of Ship objects which periodically and randomly encounter Phenomena...
Here is the problem I am trying to solve, (I have simplified the actual problem, but this should give you all the relevant information). I have a hierarchy like so:
1.A
1.B
1.C
2.A
3.D
4.B
5.F
(This is hard to illustrate - each number is the parent, each letter is the child).
Creating an instance of the 'letter' objects is expensive...
I had a geek fight with someone over what the strategy pattern really is and I need a little expert help (read: definitive proof).
We both agree that the strategy pattern allows for the guts of a class (e.g., the behavior) to be swapped out at runtime while maintaining the same interface. However, her contention is that "For [the algori...
I am new to this repository lark, so some help is gratefully received.
I am trying to design a method to have a central payment website for all our sites.
The sites will populate a table that return a GUID. All the sites will pass the GUID across to the central payment site. The central payment site will look at the querystring and use...
I may have designed myself into a corner with this problem but I feel like there's a workable known solution to something like this that I'm not seeing. It may well be that I'm completely overcomplicating the problem and skipped over the obvious solution. Any advice would be greatly appreciated.
I have a set of entities defined as inter...