design-patterns

How to model cascading settings in an object hierarchy

Trying to put my head around how to model the notion of default values in an object hierarchy. These default values should apply to all objects in the hierarchy unless an object overrides a setting. If a setting is overridden, then it and all of its children would get the overridden value, but other values would be pulled from up the h...

In the Command pattern what do you call a command that groups together other commands?

This should be easy, I am trying to come up with the name for a command class that is a collection of other commands. All the sub commands will be run, when the master command is run. Any ideals? ...

Class design: clearing state

I am designing a class library which will be used like this: Engine eng = new Engine(); eng.AddPart(part).AddPart(otherPart).Run(); The problem with the class is that the parts are kept by the engine so if you want Run it with some other parts you will need to remove the ones that you have already added. There are several possible ...

How do I monitor forum posts to check only new posts, instead of checking the entire list each time?

Im developing software that monitors posts on forums and alerts the admin/moderators when keywords are are matched in the post title (swear words, porn etc). I've set up a timer, every 30 seconds it will monitor as it's a busy forum. My issue is how to store the "last post checked" so next time it runs it doesn't go through the whole fo...

Discount strategy in shopping cart and orders

I am trying to implement a system that can handle multiple discounts applied to my cart/completed orders. I have applied a strategy type pattern to encapsulate the processing of the discounts within the discounts. I have come up with the following: an abstract discount base class with subclasses making up the concrete discounts. These ...

bridge pattern vs. decorator pattern

Hi, Can anybody elaborate the Bridge design pattern and the Decorator pattern for me. I found it similar in some way. I don't know how to distinguish it? My understanding is that in Bridge, it separate the implementation from the interface, generally you can only apply one implementation. Decorator is kind of wrapper, you can wrap as ...

Should I be using the command pattern? Seems like a lot of work...

My Room class has a lot of methods I used before I decided to use the command pattern. Previously, I was invoking a lot of commands and now it seems I have to make a method in my roomParser class for every method. If I wanted to invoke say, setHotelCode I would have to create a method in roomParser that iterates through and invokes the m...

Q: Creating child views in the Passive View pattern

I am very interested in using the Passive View pattern to improve testability, but I am not sure how to call child dialogs. Do you have the parent view create the child view and return an interface to the parent controller, then have the parent controller create the child controller? ...

UI design pattern for true/false/null (for inheritance of values)?

Hi there. I'm trying my best to figure out a succinct, straightforward widget, using standard UI widgets available in any toolkit (e.g., checkboxes, radio buttons, or listboxes), that could model a true/false/null value. Why am I trying to do this? I'm storing a tree in a database (go ahead, criticise me for storing hierarchical informa...

Are there tools to translate any website into the templates its framework is using???

Rails, for example, has a defined set of patterns it uses to define ids and other attributes in html, for example <input id="project[task_attributes][]" .../> is the result of something like <%= fields_for :task %> nested inside of <%= form_for :project %>. I'm sure other frameworks do the same. This means that if you went to a random ...

Dependecy Injection: How To Overcome Cyclic Dependencies

Hello guys, Thanks for reading. I'm using Unity framework to implement dependency injection in my app (ASP.Net MVC). Sometimes there are some cyclic dependencies among services that I want to avoid. So I'm looking for solutions : ) My case well lets imagine 3 services ServiceSally, ServiceJoe, ServiceJudy ServiceSally depends on S...

What are Design patterns useful for Notification system?

Some explanation: there are several machines(hosts) that need to be notified about any changes of some data on certain resource machine. Resource machine all time checks data and if any changes were made it notified all listeners. As I understand I should use Observer pattern, May be Absrtact Factory for generalization, What else? As I...

put different class in hierarchy in one container in C++

Hi, Some times we have to put different objects in the same hierarchy in one container. I read some article saying there are some tricks and traps. However, I have no big picture about this question. Actually, this happens a lot in the real word. For example, a parking lot has to contain different types of cars; a zoo has to contain d...

Memory allocation for singleton pattern

if we use singleton pattern in our web application, when free the specified memory that allocated to our class? ...

Design pattern to organize non-trivial ORM queries?

I am developing a web API with 10 tables or so in the backend, with several one-to-many and many-to-many associations. The API essentially is a database wrapper that performs validated updates and conditional queries. It's written in Python, and I use SQLAlchemy for ORM and CherryPy for HTTP handling. So far I have separated the 30-some...

Pattern for switching a project from using mock objects and real objects.

I am toying with the idea of unit testing a tier within my application using the Mock Object Pattern. The problem i'm facing is how to switch from my mock objects to the real objects when not unit testing. My initial reaction was to reference two libraries (one containing the real objects and one with the mocks) and use conditional comp...

What are the performance implications of using design patterns in PHP?

Hi I know that design-patterns are very useful in creating of big projects. Does anyone have experience in both creating project with normal (OO, procedural ) and using design patterns in respect to performance(speed of execution)? I want to create some big project and I am afraid that using design patterns my scripts would run slower. ...

Notification Model/Pattern

I'm trying to develop an application in which I want the ability for certain forms to be able to notify any subscribers of events happening. I understand that I'm going to have to have forms know about other interfaces in order to be able to subscribe to events etc. I'm just wondering if anybody has any hints and tips, or even a "favor...

Mass assignment on construction from within ruby.

Possible Duplicate: Idiomatic object creation in ruby Sometimes it's useful to assign numerous of a constructed arguments to instance variables on construction. Other than the obvious method: def initialize(arg1, arg2, arg3) @arg1, @arg2, @arg3 = arg1, arg2, arg3 end Is there a more concise idiom for achieving the same re...

Better alternative for "data-only" Objective-C objects?

I run into design choices like this often and struggle a bit; I'm looking for some other perspectives. I often want to keep lists of, or pass around chunks of state that are basically just sets of values. The values tend to be primitive types: floats, NSTimeIntervals, CGPoints, etc. My first inclination is often to create C structures ...