design-patterns

Java generics design problem

i want to dispatch messages to specific handlers through a common message processor // // Library code // abstract class Processor<M extends MessageHandler<? extends Message>> { HashMap<Class<Message>, M> handlerMap; void addHandler(M, Class<Message>); void run() { while(true) { ... } } /...

Is There a Design Pattern to Mimic XML?

I am writing an application in Java that produces a XML file using data obtained through JDBC. This is a recursive one-to-many relationship much like the structure of an XML document. It basically looks like this: Object A contains multiple object B's. Object B contains multiple object C's. And so on. Is there a handy design pattern...

Special access to enclosing object?

Is there a way, in PHP5.3, for an object $enclosed to know which object $enclosing that it is inside of? Essentially I want to make some variables of $enclosing be accessible only to $enclosed without specifically passing those vars in. class Enclosing { private $enclosed;//Enclosed object private $othervar; function __construct(...

Factory & Strategy patterns...

I need to create a class which will be responsible for result set processing but it might happen that different algorithms should be used to process that result set. I am aware of the following options: 1) Use Strategy patern, below is pseudo code: interface Strategy { processResultSet(ResultSet rs); } class StrategyA implements St...

Best way to use StructureMap to implement Strategy pattern

My web app has some slight variations in business logic and presentation logic depending on the type of user that is logged in. It seems like getting variations by injecting different concrete classes based on the user type is a good fit for DI. So I'm wondering what features of StructureMap I should use to achieve this (or if I'm way of...

Why should BLL layer use method overloads instead of separate methods with individual names...shouldn't it be the other way around?

hi I don’t understand why is using method overloads( at BLL layer ) preferred over using separate methods with individual names. For example, if our web app has at DAL layer methods GetAllArticles, GetArticlesByCategory, GetPublishedArticles and GetPublishedArticlesByCategory for retrieving articles from the DB, then it is recommend...

Getting Xcode to drop "No XXX method found" warning when delegating

This could be me doing the design pattern wrong. I'm implementing asynchronous delegation in an application that uses NSURLConnection. An object wraps the NSURLConnection and handles its delegated messages; that works fine. Now I'm defining my own delegates in the object that uses it (NSURLConnection messages ConnectionWrapper, Connecti...

How to test Repository Pattern with ADO.NET Entity Framework?

While using Repository pattern I find it difficult to understand the reason of designing the software with TDD technique while in reality you will have to implement the Interface for your repository in your persistence dataset. To make my point clear I will submit an example: I have the following Interface on my domain model: public i...

Is WSE2 obsolete?

I'm attempting to bring some .net 1.1 legacy code into .net 2.0 and some of it relies on the Microsoft.web.services2 web services enhancements. I could have swore I read somewhere about the objects in that dll being packaged into the .net 2.0 framework, or that they were replaced by something else in the .net 2.0 framework, but I'm not ...

Struts Actions and Composition over inheritance

When I want to apply the DRY principle, i.e. to unify the code of multiple Struts action for different use-cases (for example the administrator role and the operator role ), one option would be to use an abstract base class "BaseAction" for the action and then use "AdminAction extends BaseAction" and "OperatorAction extends BaseAction". ...

SQL design approach for searching a table with an unlimited number of bit fields

Consider searching a table that contains Apartment Rental Information: A client using the interface selects a number of criteria that are represented as bit fields in the DB, for instance: AllowsPets HasParking HasDeck ModernKitchen etc.. We are facing a situation where each new client of our software has additional fields they w...

Setting up polymorphic associations in db when the super is a FK of subclasses?

Using class table inheritance it is recommended that the subclass refers to the superclass and not the other way around. Normally in Rails polymorphic associations work in the other direction--the super refers to the subclass. Recommended vehicle .id car .vehicle_id # PK instead of using id (identity column) boat .vehicle_id...

Complex software architecture

Hi everyone ! I've got a few questions about the architecture of a software that I'm working on ! So basically, this software allow the user to access to some popular sites : Social networks (Facebook, MySpace, ...), Common services (RSS, Mails, Twitter...), Social bookmarkings (Digg, Delicious...), Chats (MSN, AOL...), ... Cur...

Aggregation: Life after death or no?

I have been reading a couple of articles on stack overflow about aggreation and how it compares to delegation and composition. Mainly: http://stackoverflow.com/questions/1384426/distinguishing-between-delegation-composition-and-aggregation-java-oo-design According to this and other articles I have read on here, the concession is that a...

how to design Repository pattern to be easy switch to another ORM later?

I am new to repository pattern but i tried, my goal is to make a design which will let me easily with just some few edits "dependency injection, or configuration edits" to be able to switch to another ORM without touching other solution layers. I reached this implementation: and here is the code: public interface IRepository<T> { T ...

Probable overuse of java interfaces in my implementation of Ms. Pac-Man

I have been a Java programmer for the last 6 years, and since the beginning of this year I got interested in game programming. So, I thought it was a good idea to start with a popular game and I implemented the game Ms. Pac-Man in Java. I can say that my implementation looks about 90% similar to the original game, and I tried to used as ...

Is this a correct interpretation of MVC?

Say you have a customer object and the "customer file" form that manipulates that object. Is the following a correct interpretation of MVC? Customer - Model CustomerForm.cs - Controller CustomerForm.desinger.cs - View Even though CustomerForm.cs and CustomerForm.designer.cs are partials of the same class, it seems to makes sense from ...

Creating two different types of Users (Scala, Lift)

Hi all- I am creating a website which will need two types of users: students and providers. In a traditional java setting I would create a user class (or interface) and then create two classes which inherited from the user. Is this the best course in scala too, using the "extends" and "with" modifiers? If that is indeed the best way ...

Awesome C# Code to learn design patterns and best practices from?

Anyone know any open source c#/asp.net projects that are well documented, use design patterns appropriately and contain the best practices? I want to read high quality code, learn from it and apply it to my job. Thanks. ...

Python Implementation of the Object Pool Design Pattern

I need an Object Pool, and rather than implement it myself, I thought I would look around for a ready-made and tested Python library. What I found was plenty of other people looking, but not getting many straight answers, so I have brought it over here to Stack Overflow. In my case, I have a large number of threads (using the threading...