design-patterns

God Controllers - How to prevent them?

In a few MVC projects I've been working on, it has become apparent that there are a few problematic controllers that have organically grown into God classes - demi-gods each in their own domain, if you will. This question might be more of a matter 'what goes where,' but I think it's an important question with regards to SRP (Single Re...

Any suitable patterns for this problem?

I have a situation in which I am attempting to keep my model and implementation as loosely coupled as possible, however I am faced with a situation where the coupling could potentially get a lot closer than I want. I have a selection of 'Model' classes, all implementing interfaces. Additionally I have 'Data Access' classes, which provid...

Books for Business Apps design and patterns

Hi, I have recognized the fact that i do not have a clear understanding of how forms and business logic layers should be distinctly separated. Especially in business apps this is hard to accomplish at some times as to keep the UI clean from business logic and to be able to minimize repetition among different forms that share some common...

Factory pattern in java

Hi, I was working with java code that is supposedly using the Factory pattern, but I'm not completely convinced by the pattern. My code does this: // the factory class SomeFactoryImpl { Set<SomeClass> getSomeListOfObjects(); } And somewhere in the code: { ... SomeFactory factory = new SomeFactoryImpl(); Set<SomeClass> li...

When should the factory pattern be used?

Just as the title asks, when should a trigger in your head go off signifying "Aha! I should use the factory pattern here!"? I find these moments will occur with many other design patterns, but never do I stop myself and think about this pattern. ...

Constantly Querying Server via Javascript - Good Idea?

I've got a small website that has about 5-10 administrators. I've set it up to monitor what each administrator is doing (adding items, removing items, etc). I had a list within our admin-panel that shows the previous 10 activities performed by the collective administration. Today, I decided to make this self-updating every 30 seconds. M...

Learning .NET practices by reading Effective Java, 2nd Edition

Should I read Effective Java, 2nd Edition to learn .Net CLR 2.0 practices? If so, what sections of the book are not well suited for .Net? Note: My preferred language is C#3. ...

Windsor.Castle: Creating components on-demand + context information

(NOTE: I've updated this question from the initial inquiry about child containers towards creating components on-demand) Here's my design problem: I'm using the Windsor container for the main application workflow, but I have certain actions I need to create on-demand (for example, when the user clicks on a menu item). I want these actio...

How to overcome the anti-pattern "Big Ball of Mud"?

What causes a computer program to turn into a Big Ball of Mud? Is it possible to recover from this anti-pattern? Are there proven refactoring methods that can be applied? ...

Want implement a utility class which methods represent steps in a validation process. Is there a pattern or best practise for that?

Hi, i want to implement a utility class which methods are internal steps of a validation process. Is there a pattern for this or should i use a totally different approach? Im open for suggestions. (I´m coding in abap but i dont think that is important) Edit: Its no frontend validation of text, but a check if certain conditions are mat...

Is it ok to downcast?

I'm designing a framework which users can extend. Basically I will provide them a set of interfaces which they can implement, and my "manager" class will call their implementations like this: abstract1 = factory.GetConcreteExtension1() abstract2 = factory.GetConcreteExtension2() abstract1.DoSomething(abstract2) Where my client impleme...

A project that implements a number of the design patterns?

Someone once mentioned to me about a project (or two), maybe written in Java, that they used in school to help teach them design patterns. It implemented a number of the design patterns but was for learning purposes only. I know you should not try to stuff a bunch of the design patterns into a application just for the sake of using the...

Database design Pattern Name Question (I think it's called the Singleton Pattern)

Hi, I've got a table in my database where there can only be 1 row per non-identity attribute tuple. Whenever we insert a row, we first check to see if a row exists with those values, if not, we insert it, otherwise we use the ID from the existing row. In the example below, there would be a Unique Index on (Id) and (Attr1, Attr2, Attr3...

How to design an application such that it's easily testable using unit testing?

Possible Duplicate: Writing unit testable code? I am new to unit testing. Today on SO I found an answer to a question about interfaces in c#. That got me thinking about best practices for building an applications that's testable by design. I use interfaces very lightly in the main application that I work on. That's made it v...

MVVM - Controls versus Views

I've been doing a prototype in WPF without using MVVM. It's got to such a size now that I'm refactoring it to use MVVM. When I started the project, I jumped straight in and created UserControls for lots of things. I'm now breaking things in Views and ViewModels. But, I'm ending up with Views that contain UserControls; the UserControl...

How to design for JPA in a non-JEE web server (e.g. Tomcat)

Considering there is no @PersistenceContext available to inject the EntityManager, plus you need to manually manage Transactions, what is the best way to design such an application? For the EntityManagerFactory/EntityManager, as far as I can see, you must have each DAO accepting an EntityManager in the costructor e.g. public class DAOI...

How to efficiently save objects to a SQL 2000 database

In the past, whenever my application needed to insert many records into a SQL 2000 db, I would call a stored procedure, once for each record. When inserting many records, I found that performance suffered, particularly when with a fat client, calling a web service to perform the database call. Then I learned that if I passed XML data re...

The data structure for the "order" property of an object in a list

I have a list of ordered objects stored in the database and accessed through an ORM (specifically, Django's ORM). The list is sorted arbitrarily by the user and I need some way to keep track of it. To that end, each object has an "order" property that specifies its order in relation to the other objects. Any data structure I use to sor...

How do you handle Zend_Paginator ?

I was looking at Zend_Paginator in Zend Framework project using MVC, and it looks like an intersting tool. It looks like we can give a select object as argument to the factory, it's interesting because it means that i should return a select object from my model, is it a good way to do ? It seems to be a bit heavy to do this, since it w...

A simple explanation of common design patterns for non-native English speakers

I am often facing design patterns, and I find most articles explaining them a bit hard to understand, especially since I don't speak English fluently. I would very much appreciate if someone could explain simply and in basic English the following design patterns: Builder, Prototype, Bridge, Composite, Decorator, Facade, Flyweight, Proxy ...