design-patterns

friend class with limited access

I want to make a class A friend class of class B. I want to do this as these interact very much and A needs to change internals of class B (which I dont want to expose using public). But I want to make sure it has access to only a few selected functions not all the functions. Example: class A { }; class B { private: void setState();...

Placing Business Rules inside a Repository

I have a table that is storing a list of rules. In my code, I need to retrieve those rules and maintain the list of rules (via. the Repository Pattern) so that I can reuse them. I then need to generate(business logic) a list of objects based on the rules for a particular period of time, eg, a list of holiday objects filtered by the rul...

Is LLVM an exception to the rule for avoiding dynamic casts?

LLVM has it's own hand rolled alternative to RTTI that is a speed improvement over built-in RTTI and allows dynamic casting to classes with no vtable (dyn_cast). However, it can still be used in exactly the way that dynamic_cast<> is used though it does allow it to be used with more classes. dyn_cast<> template documentation LLVM is a ...

Best design pattern for database table joins

I'm looking at programming/design patterns for the model layer of my application, and am wondering which one fits best with the situation where you are doing a retrieval that involves joins across multiple tables. For example, suppose you have the following tables/relations: Customer --> 1..n Accounts --> 0..n Features where a Feature...

Multistep form in PHP - MVC App

Hello, I'm about to program a mutistep form in my MVC App (Self-made MVC framework) in which no data is to be inserted until the last step is finished. I got the following issues/questions I'd really like to find a kind of pattern to solve this problem, is there any? I want it to be easy the perform a go back action, and get the data...

Name of a class that wraps an external process?

What would you call a class that wraps some external process Worker (starts and stops it, reads stdin, stdout, etc.)? WorkerFacade? WorkerGateway? WorkerWrapper? ...

Which design patterns to use to implement this business logic?

Hello all, I am trying to determine the best design pattern to use for a business key validation web service. The basic logic flow is coded below. The program will take a parameter and use a field to help determine the path to take in searching multiple systems where this business key can be found. System1 is searched first, if not f...

How many controller classes are typical in a cocoa app?

When designing my application how many controllers should I have? Is it good practice to have one controller for the entire app, the entire window, or for each class? Additionally how many objects are to many created in the doc window in Interface Builder. Tutorials generally have one called AppController. Do full applications typica...

Design pattern for Core Data iPhone App

Hi Im building an app that will use a Core Data model. I pretty new at Objective C and my usual design patterns does not really apply on Core Data and Objective C, at least I can't seem to find examples that confirms they will. I have been through the Apple Developer examples and different sources on the intertubes. It seems that to l...

Partially encapsulate a field C#

i wanna know if there is any pattern that can overcome this problem: i have a set of properties that needed to be public to serveral classes and to other classes they should be only readonly, the classes must be public. i do not wanna use reflection or any other bad performance makers i know i can make them RO and implement logic insi...

Head First Design Patterns - Decorator Pattern

I'm reading the chapter on the Decorator Pattern in Head First Design Patterns. They use a coffee ordering system as an example to teach the pattern. While the Decorator Pattern seems a useful pattern, it does not seem appropriate for a coffee ordering system. Wouldn't it be simpler to just have a table (or list or some such) of ite...

business object, on the wire object and calculator - which is best

i see this pattern over and over again and wanted to get opinions: Option 1: On the wire object and Business object composition: On the wire object - the data that is serialized and sent back and forth across machines (client / server, etc). This is a POCO object. For example: public class Order { public int Price; publi...

Design pattern for filtering a collection of items?

Imagine the typical type of application where you have a list of items with different properties. E.g. a tree-view with 100 items, each having a name, a rating, a rank-within-the-hottest-items-on-the-planet etc. Probably there are also many-to-many relationships between items and item-catalogs, or between items and item-creators etc etc....

GUI as a finite state machine

To implement application's GUI I would like to have all the logic to go from one form to another centralized. This GUI manager will behave as a finite state machine. Although I think I have seen this kind of implementation somewhere, I can't find a design pattern that matches with this kind of solution. A form will look like this: publ...

Message Design Patterns

For message based passing systems, what are your "message design patterns" e.g. Limit directed messages (i.e. specific destination) Avoid long cascade chains (i.e. react to MsgA with MsgB, MsgC etc.) Have a system "heartbeat" message Other examples? ...

Extending [Namespace]_Model_[Table] classes. is it safe?

Hello ladies and gentlemen! I'm new to php and zend framework and fill very uncertain about following: For example, I have two tables: table1: box(id, height, width, length, weight) table2: labels(id, boxid, text, position) labels.boxid -> box.id (labels.boxid is a foreign_key for primary_key box.id) I've generated two separate sta...

What design pattern is preferable when working with ASP.Net MVC and Entity Framework?

I am not very sure what design pattern is the most efficent to use when working with ASP.Net MVC and the Entity Framework, so any guidance is much appreciated! Would you store the context in the Controller-class, or is it better to create a repository? If you would recommend the repo-design, is it required to initialize the context in ...

Design pattern for a class that works on a collection of other objects?

I have a User model that can hold 1-n UserGroup models, each of which holds data about the user's relationship with a specific group (for example, if they're the admin of the group, when they joined the group, etc.). I'd like to provide some helper methods like isGroupUser() and isGroupAdmin() that work on the entire set of UserGroup mo...

Asynchronous Web Service Design Patterns

When writing a Silverlight app hooked up to a WCF Web Service, the only option we are presented with in using the Web Service is to make asynchronous calls to the WS interface. i.e. WebService client = new WebService(); client.ServiceMethodCompleted += new EventHandler<Args>(client_Handler); client.ServiceMethodAsync(); client.close()...

C# - Is this a 'good' data access pattern and what is it called?

First of all, I apologise for the vagueness of the question title and if this has been asked elsewhere already. I struggled to find a similar answer due to the amount of other 'what is this pattern called' questions. I've got the following abstract class: public abstract class PositionProvider<T> : DalProvider<T>, IDalProvider whe...