design-patterns

thoughts on configuration through delegates

i'm working on a fork of the Divan CouchDB library, and ran into a need to set some configuration parameters on the httpwebrequest that's used behind the scenes. At first i started threading the parameters through all the layers of constructors and method calls involved, but then decided - why not pass in a configuration delegate? so in...

Is there any OOP way to secure this MVC web app design?

I'm writing a shopping cart application for a family member's online seed business. It's a fairly straight-forward workflow - users select what they want to order, type in their contact information, and the application generates an HTML E-Mail receipt and sends it to the contact address. Now, here's the rub - I've implemented the appli...

Design alternative? Composition and construction

So I'm using composition to bring together a collection of objects, all of which are derived from a base class, lets say Component. E.g: class Component { public: Component(); ... private: int m_address; ... }; class SpecializedComponent: public Component { public: SpecializedComponent() ... //and so on }; class Specialize...

What design pattern best represents the "File Owner" object in the iPhone?

I'm new to iPhone development. I'm reading that the "File Owner" in the xib is the responsible for instantiating all objects defined in the nib... some type of factory pattern comes to mind, but maybe I'm not looking at the big picture... So, what would be the closest design pattern (gof) associated with the "File Owner" concept? ...

Converting ASP.NET MVC to n-Tiered Architecture

I just built an application using ASP.NET MVC. The programmers at my company want to build all future modules using n-Tiered (Presentation Layer, Business Logic Layer, Data Access Layer) architecture. I am not the programmer and need to know why this makes sense? Do I have to completely rewrite the entire code or can it be converted...

Should a Test Data Builder construct defaults for it's non-primitives?

I've created a data builder in order to create test data in my unit tests. My data builders create defaults for all properties so that the tests that use them only need to specify the properties that are applicable to the test. Consider the following builder: public class CustomerBuilder { public int id = 0; public Order order ...

Programming pattern / architectural question

Hi all, I am currently working on a project where I have a BankAccount entity for some other entity. Each bank account as a reference to a bank entity, an account number and optionally an IBAN. Now since an IBAN can be validated, how can I ensure that when the IBAN is set for an account is valid. What would be a clean architectural ap...

Constant Parameter Design

I am working with a Class that contains constants or parameter values that all classes can reference for example; public class Parameters { public static final String JUMP_TO_VALUE = "Parameters.JUMP_TO_VALUE"; public static final String EXCEPTION_ID = "Parameters.EXCEPTION_ID"; } Some of the foundation classes in my applicati...

Would this be a pipeline, a chain of responsibility, or something else?

I'm building a multiprocess architecture that seems to be a strange meld of a pipeline and a chain of responsibility. Essentially, I have a chain of handlers linked up by queues. Each handler will receive an object that represents the input data, forward it to the next handler so that it can start working on it, and then determine if i...

Does this Java Strategy pattern have a redundant Context class?

The following code sample is an implementation of the Strategy pattern copied from Wikipedia. My full question follows it... The Wiki's main method: //StrategyExample test application class StrategyExample { public static void main(String[] args) { Context context; // Three contexts following different strategie...

Code Smell: Configuration Nightmare

How would you identify and fix the following code smell: I've got a small scientific computing app that I'm writing that has to be able to handle lots of variations on the same theme. The inner workings of it are well-factored, mostly using the template method pattern and some higher-order functions. However, specifying how all these ...

Using Command Design pattern

Hi all, Can any one explain with simple example of Command Pattern. I refer in internet but i got confused. Thanks, Ravi ...

Question about decorator pattern and the abstract decorator class?

This question was asked already here, but rather than answering the specific question, descriptions of how the decorator pattern works were given instead. I'd like to ask it again because the answer is not immediately evident to me just by reading how the decorator pattern works (I've read the wikipedia article and the section in the bo...

Design Pattern for using different implementations of a class/method

Sometimes we design more than one algorithm to get the same results. For instance, I have written a class which stores my data in trees, and another class that stores roughly the same data in, say, linked lists. I will publish an interface (abstract class) called ThingStore, and I'll subclass it to TreeThingStore and ListThingStore, eac...

ASP.NET MVC - Passing Grouped data into a View

I've got a LINQ to SQL object, and I want to group the selected data and then pass it into a view. What's the correct way of doing this? I'm sure I need to group the data when I select it rather than grouping it in the view, as this will result in about 200 rather 50000 rows I need to pass into my view. Are there any good examples of ...

WCF Object Design - OOP vs SOA

What is the proper way to handle polymorphic business objects in a WCF/SOAP world? It seems to me that SOA and OOP are at odds with each other - to expose a clean WSDL you need concrete objects, typically not even utilizing inheritance. On the other hand, presumably in the underlying system, you'll want to follow proper OO design. Wha...

Desining a system for mutiple input/multiple output

Background I'm sketching on an application that needs to perform something like this database a >--| |--> fileformat 1 database b >--+--> custom application >--+--> fileformat 2 ... | | ... database n >--| |--> fileformat n The databases in questi...

How far do you go with YAGNI?

I am developing a new revolutionary web application for the enterprise market. Sure, many before me thought that their web app would be revolutionary only to find out it isn't. (Or it is, but the business is not good anyway). So I'm am thinking, in order to find out if my idea has any traction with the lowest cost, to follow an extreme...

Can State Pattern help with read only states?

I'm trying to model a certain process and I'm thinking that the State Pattern might be a good match. I'd like to get your feedback though about whether State will suit my needs and how it should be combined with my persistence mechanism. I have a CMS that has numerous objects, for example, Pages. These objects (we'll use the example o...

C# Garbage Collector question

I have a library which returns a hierarchical list composed of IDictionary, IList and primitive types (string, and ints). At present I cannot change how this data is returned. I have another strongly typed class which is consuming this data and converting it into business objects. There is a list of "properties" in the data returned, wh...