design-patterns

Tips for a light PHP Framework

Hi everyone! I'm trying to write down some concrete ideas for a light framework (on PHP5), with the purpose to handle a lot of requests and to make it scale well in terms of high traffic eventualities. I've already started it, but I'm not really satisfied about the coding style, which is basically composed by simple classes and helpers,...

Does ChannelFactory implement a factory pattern?

I’ve started learning WCF and I’m already utterly confused. I did a bit of reading on factory pattern and I can’t figure out how or why does ChannelFactory<> implement it. Namely, the whole idea of a factory pattern is that factory abstracts the creation and initialization of the product from the client and thus if new type of product i...

Pattern for raising errors/warnings during parsing in a library

I've got a library which has two input formats for the object model described by the library. I currently use an event subscription model for raising errors/warnings/verbose messages to the end user of the library. This hasn't proven to be the cleanest model, and I was wondering if there was a relevant design pattern or something similar...

Is this considered a model or a view object?

My application downloads images from the web and encloses them in custom Image objects. Using my Image class I can extract particular data from the images. That data is eventually presented to the user. With the model-view-controller paradigm in mind, can my Image class be considered a model class or a view class? ...

Circular Dependency in C++

The facts: I have two predominant classes: Manager and Specialist. There are several different types of Specialists. Specialists often require the help of other Specialists in order to get their job done. The Manager knows all of the Specialists, and initially each Specialist knows only their Manager. (This is the problem.) At runti...

Order of message passing for object destruction / teardown

This is a language agnostic question about object oriented design, particularly the passing of messages regarding object destruction. This whole question could just as easily use the terms Parent and Child instead of Factory and Item. Which object should be responsible for an objects tear-down process; the object itself, or the factory...

Can an object's methods act on itself?

I'm not sure where to put some methods. Let's say I want to send an email. Which of the following options should I choose: email = new Email("title", "adress", "body"); email.send(); or email = new Email("title", "adress", "body"); Postman.send(email); Because how can an email send itself? And isn't it better to have a central ob...

Need advice on a web service "request template" pattern

We are designing a system which needs to allow the construction of objects made up of data, sourced from disparate datasources (databases, and back office systems for example) and are looking at ways to facilitate this functionality across a web service interface. To service this requirement we propose creating a "request" object as an ...

Extend a application with out changing main method?

I need to extend several class in my c++ application without changing any code in application. (Product extend as a solution). Is there a specific design pattern to do that? ...

Best Practices? Wait until receive or raise an event on receive

Hi stackoverflow, First of all, I wanted to thank the community. You've been of great support lately ! Usually i don't even need to ask the questions because they're already there. Now i have an issue that's not directly related to code but programming itself. I'm working with a FTDI Chip and C# programming a communication protocol in ...

Does this Rails 3 Controller method make me look fat?

This is a new application, and I have an index method on a Search controller. This also serves as the home page for the application, and I'm trying to decide if I am headed down the wrong path from a design pattern perspective. The method is already 35 lines long. Here is what the method does: 3 lines of setting variables to determine...

What circumstances should someone "try...catch"? Does this apply to libraries?

Suppose you're designing an application (WebApp, Desktop, anything) and you need to define exception handling for the code. Since you want to make things reusable, what logic should you follow when handling exceptions? Are there any patterns to follow? For example, if some DLL is going to use the network and the network is unreliable, ...

should a factory utilize another factory if the object to create needs another object?

If I have a factory that creates an object that needs an instance of another object should i use another factory responsible for this second's object creation or should the original factory handle this? ...

Musing/open questions on OO philosophy

I'm going to use this opportunity to put down a number of related but different thoughts on object-oriented philosophy, as a sort of request for comments. If the admins see fit to close, I may make it a blog post instead. But I am asking questions, so I think it's a suitable community wiki. Suppose I have an abstract class Bird. Supposi...

Object Relational Mapping Design Patterns

I want to start building better persistence layers using NHibernate and other ORMs. What are the best design patterns or important design considerations for implementing persistence with ORM? ...

Design patterns for dependent calculated properties in a class?

I have a class representing a domain entity that contains many calculated properties. Most of the calculations depend upon other properties that are also calculated. In it's simplest form an example of the class could look something like this. public class AnalysisEntity { public decimal InputA { get; set; } public decimal Inpu...

how can I implement factory pattern using C++ class ?

Hi, I am working on a project which was mostly implemented using factory and facade patterns. However I am unable to understand as I do not have a clear concepts of how factory pattern works in C++. Can anybody suggest good sample program or link for the same. Thanks krissam ...

Design pattern as (missing) language feature

Sometimes people refer to design patterns as missing programming language features. To avoid the debate about what is a design pattern, let's say we only consider the original GoF patterns. For instance, the singleton pattern vanishes in Scala which supports singleton objects using the keyword object. There are few resources around abo...

Suggest MVC frameworks that do not use controller base classes.

pseudo-code: class SomeController { def myAction(){ // controler is an property passed via ctor controller.redirect(toWhereever) } } // another variant class AnotherController { def myAction(controller){ // controler is an method argument controller.redirect(toWhereever) } } Any suggestions? ...

does the observer implementation here has memory leak?

maybe i dont know delphi all that well, however i wish to ask you: at this site : http://blogs.teamb.com/joannacarter/2004/06/30/690 i found an implemetation of observer pattern based on iterface. when doing attach , there is a call to this: procedure TSubject.Attach(Observer: IObserver); begin if fObservers = nil then fObse...