design-patterns

Design problem causing inability to get returned proper dataType

I have an object that has properties of another object and one called DataValue, but the type that I want DataValue to return depends on information contained in the object in the other property. I'm not convinced my way is the best way to do this. I have this business object called an AssetStructure. An AssetStructure object contains...

AOP, DataMappers, and Factories, can they work together?

Platform: C# 2.0 Using: Castle.DynamicProxy2 I have been struggling for about a week now trying to find a good strategy to rewrite my DAL. I tried NHibernate and, unfortunately, it was not a good fit for my project. So, I have come up with this interaction thus far: I first start with registering my DTO's and my data mappers: MetaDat...

ASP.NET MVC Best Pratices

I come from the WPF side of the world and I am used to using the MVVM pattern quite a bit. I am attempting to learn MVC and am having a little bit of dificulty trying to understand where my boundries are in MVC. Here is my scenario: I have 3 objects, Parent, Child and GrandChild. These are custom objects, not using the built in model...

How Does One Go About Saving an Aggregate (Parent and Children) in a Repository?

According to Dylan's answer for the questions 'Using The Repository Pattern, Is It Best To Save Parent and Children Objects Together Or Separately?', a repository saves the entire aggregate (parent and children). How does one go about this, would this be coded in the actually stored procedure (if using them); would you call the child re...

I’m not sure whether lazy load pattern is useful here

Hello, I’m currently reading a book on website programming and author mentions that he will code DLL objects to use lazy load pattern. I think that conceptually I somewhat understand lazy load pattern, but I’m not sure if I understand its usefulness in the way author implemented it BTW - Here I’m not asking for usefulness of lazy loa...

An elegant way to implement shared classes that load heavy resources (in Java)

Hello, I have several classes which work as wrappers over some heavy libs, such as parsers, taggers, and other resources. All these libs have one thing in common: they have a load/init method which takes a serialized model (a large file) as input, and return a class that can be used to do concrete things such as parsing text. To illus...

On using Enum based Singleton to cache large objects (Java)

Is there any better way to cache up some very large objects, that can only be created once, and therefore need to be cached ? Currently, I have the following: public enum LargeObjectCache { INSTANCE; private Map<String, LargeObject> map = new HashMap<...>(); public LargeObject get(String s) { if (!map.contains...

Registry design pattern...good or bad?

The following code is from a tutorial (http://net.tutsplus.com/php/creating-a-php5-framework-part-1/), not mine. I have a few questions about this code... The article claims it is using the "registry design pattern"; is that the universal name for this design in the industry? Is there another similar patter out there that would be a b...

Architecture/Design of a pipeline-based system. How to improve this code?

I have a pipeline-based application that analyzes text in different languages (say, english and chinese). My goal is to have a system that can work on both languages, in a transparent way. NOTE: This question is long because it has many simple code snippets. The pipeline is composed of three components (lets call them A, B, and C), and ...

Alternative to static class for stateless objects

Hi, For the last year or so I have followed the idea that if a method could be static, to make it static, as this can have a performance benefit, and I have therefore ended up with some static classes in my applications. I have since learned the performance benefit is not often large enough to be worthwhile, and also the distinction th...

One sentence explanation to MVVM in WPF?

I heard its the next best thing in building WPF UIs, but all existing examples have dozens of lines of code - can I get a Hello World for MVVM that explains in no uncertain terms what its all about? I'm fairly new to C#/.net as well, so maybe point me to some resources that could help too? Much appreciated! ...

command pattern returning status

Once I had a discussion about design, relative to the command pattern. My peer stated that a command object should not return the status (successful, unsuccessful, and why) after the .execute() method is called. The reason is that you should not be concerned if the command gets executed or not, because the command must contain no state. ...

Design Pattern Orthogonality

Reading up on design patterns, and have found that there are 23(?) some-odd patterns that have been defined. I've seen a bit of overlap in a few (ie. builder and decorator) that would suggest either a. I don't fully understand the given patterns, and the differences between them b. Some of the design features of a few patterns overl...

Anemic Domain Model's vs. Domain Model in a simple domain driven design

I recently read a post on "The Anemic Domain Model Pattern" which caught my attention. As I read though this I found that the Anemic Domain Model description applied to many of the projects that I have worked on and built. I never thought of this as a bad design decision as it felt very natural. I thought that in the case where the do...

How can i write Addon/Plugin-friendly code ?

Hi there , i want to know how i can make my code Plugin/Priendliy. Lets say : I have a program and on the User interface there would be an Addons section , where other developers can offer Plugins.But how do i have to design such an interface , that my code works with other code. i can't imagine :( ...

refactor help - strategy pattern

The object here is to update the UI. I normally do this on the client however this application uses the code behind. Anyways my question is I am trying to clean up these if else statements and I thought the strategy pattern may be appropriate. I don't need everything done for me but if you could give me a couple pointers to get going. Do...

how do you model your javascript ?

I'm trying to model my javascript object using visio, visio doesn't support javascript data types. Then I start thinking, how do you desing model your javascript code? Cheers ...

If SqlDatareader fetches one record at a time, and not one field at a time, then lazy load pattern wasn’t…

Hello, Does SqlDataReader fetch one record at a time from DB or one field at a time? Assume the following query returns a single row: select columns_1, column_2, column_3 from some_Table and suppose readerS ( readerS is an instance returned by SqlCommand.ExecuteReader() )only reads *column_3* before closing the connection: ...

Where Does The Logic Reisde For Deleting Dependent Objects In Domain Driven Design (DDD)?

Where does the logic for deleting/not deleting dependent objects belong in DDD? For instance one has a category that contains products: class Category { IList<Products> products; } A rule might be that a category cannot be deleted unless it has no products. Where does the logic belong that does the check for no products under th...

Should service layer have access to HttpContext?

I'm building an application that roughly follows the repository pattern with a service layer on top, similar to early versions of Conery's MVC Storefront. I need to implement a page that returns all users except for the current user. I already have GetUsers() methods on the repository and service layers, so the question is where to appl...