design-patterns

Where should conversion of presentation values be made in multi-tier architecture?

I'm building an application that is multi-lingual, multi-timezoned and n-tier. All dates are stored in the database in UTC and all model objects are populated with UTC times. However UTC times are never displayed (unless the user happens to have their timezone set at UTC). This then means that I need to convert time properties to the co...

"if" statement vs OO Design

I have enum say ErrorCodes that public enum ErrorCodes { INVALID_LOGIN(100), INVALID_PASSWORD(101), SESSION_EXPIRED(102) ...; private int errorCode; private ErrorCodes(int error){ this.errorCode = error; } //setter and getter and other codes } now I check my exception error...

RIA Services and the generic Repository pattern

Hi, I'm working on a Silverlight project that uses RIA Services. My question is that I can use generic repository pattern with RIA Services on the client side? What is the best practice how I should organize the RIA Services method on the cilent side? l. ...

Is it a good practice to catch all exceptions and re-throw them as a particular type of exception in terms of classification?

Hi! Is it a good practice to catch all exceptions and re-throw them as a specific type -basically to classify all the exceptions thrown from a particular part (or service) of an application? Something like: // This class is used to label all the exceptions occured on // Race Cars Service calls as RaceCarsServiceException public clas...

Running long experiments from a web interface.

Hi all, I'm building a research web app that runs a long batch analysis that can last hours. I'm using Grails but I think this is a general design issue. The batch process can be started by a URL, e.g. http://mydomain/experiment/run?a_lot_of_params And this page returns info about the experiment (whose data are stored in the back end a...

What's a good approach to disabling functionality that's not supported?

I suppose this question is language-agnostic, tho I'm asking it in regards to building an iPhone app that uses the new Game Center API, but please feel free to answer in general software engineering terms. I'm building a game for the iPhone that takes advantage of the new Game Center capabilities (i.e. Auto-matching, leaderboards, achi...

What design pattern, or anti-pattern?

I'll describe what I'm trying to do, and hopefully, somebody can tell me what design pattern this is or point out a better alternative. I have a method doing a bunch of complicated stuff that involves an approximation. It is possible to compute the result without the approximation but this involves more work. What I want to do is get o...

Where does my DDD logic belong?

I’ve been persuaded by Eric Evans’ book and am integrating DDD into my framework. All basic elements (services, repositories, bounded contexts, etc) have been implemented and now I’m looking for feedback on how to correctly integrate this. I have some business logic which has to be performed when an entity is created or modified. This e...

Is PRISM meant for large scale application development ?

I am developing a silverlight application for the past 6 months using prism framework. When I look at the code base now it has grown huge with lots of modules, event aggregators, inter module communication code etc. On hindsight I am contemplating whether I made the right choice. Is there any other simpler framework I should have gone fo...

Building objects at runtime

I have a number of objects that I need to create and add to an array. However the code below seems dirty and difficult to maintain in the long run. What I'm thinking is, I should store the Name and Value properties in a table and build each comCommand object at runtime. However, I'm not exactly sure what the best method to about doing t...

factory class that prevents direct instantiation

How to create a factory class that prevents direct instantiation of a class ? say, i have class Comment that should only be instantiated from a class CommentFactory. I don't want Comment to be able to be instantiated directly. I figured I could do this : public partial class Comment { private Comment(){} public Comment Cre...

LINQ to SQL with Repository Pattern

Hi all, Currently I'm trying to implement LINQ to SQL in my project. I'm trying to use LINQ to SQL with the famous repository pattern. here is what I was trying to do: Create table, for example customer table. Generate LINQ to SQL (.dbml) for my customer table. It generated partial Customer class complete with all the properties and s...

JPA ORM Design Patterns

dear all, I need new design patterns in JPA/ORM instead of POJO/JDBC/DAO patterns. Is there any recommended link? RGDS ...

Why both SqlConnection and SqlTransaction are present in SqlCommand constructor?

I wonder, what is the reason to have this SqlCommand constructor overload: public SqlCommand( string cmdText, SqlConnection connection, SqlTransaction transaction ) ? When I need to create an internal method that does its bit using a transaction provided as an argument, I always find it sufficient to only pass an SqlTrans...

Javascript - Designpattern suggestion needed.

Hallo, I have 3 Different function in Javascript, the first one replaces HTML Selectboxs width custom selectbox created with ULs. and the other 2 replace Checkbox and Radio buttons respectivly. Now I want to derive classes out of these functions, and need your suggestions, what will be the best way to organize these functions into cla...

Thinking About Using Command Design Pattern.

Hi there. I have some code which updates a list of people to email. This list is updated often, with people being added and removed before the actual "send email" portion of the code is called. Currently my code to take care of this is something like this: if (instructorEmailType == InstructorEmailType.AddToCourse) { ...

How can I implement the decorator pattern without forcing someone to reimplement everything?

Lifting this example from Wikipedia: // the Window interface interface Window { public void draw(); // draws the Window public String getDescription(); // returns a description of the Window } // implementation of a simple Window without any scrollbars class SimpleWindow implements Window { public void draw() { // d...

How to address this RMI Extensive Usage scenario?

Dear Experts, I am working on a distributed animation of moving BALLS with RMI. My goal is to move multiple balls in a way, so that multiple clients observe the same movement/position of balls, i m using ball object which is remote object. registering objects: public MyMultiRemoteBallServer() { try { RMIball[0] = new R...

Patterns / strategies for creating a complex nested AJAX / jQuery form

We need to build quite a complicated form, which will allow creation / updating of multiple instances of entity A, where entity A can have multiple instances of entity B. Both types of entities are quite complicated (lots of fields and dropdowns) but only a few of these fields need filling in on creation. The requirement is to be able t...

Polymorphism in Design Pattern

I have observed that most of the design patterns (I refer mostly from the Gang of Four book) are all based on polymorphism. That leads me to a "enlightened" moment that OOP's polymorphism is the most important feature in the paradigm. Some of the patterns use polymorphism are: strategy, factory, bridge... With that, I don't understand ...