Urgent!!--Layer Isolation using ArrayList??
-
I have this case: I am working on a screwed up application in which arraylist are using for implementing layer isolation. i.e., It is using some function to convert each and every values it return from the SQLDataReader into an arraylist and then pass it to the UI Layer. I want to know that whether this will help in anyway or will cause an overhead to the application(remember the appn. is screwed up!!) :confused:
-
I have this case: I am working on a screwed up application in which arraylist are using for implementing layer isolation. i.e., It is using some function to convert each and every values it return from the SQLDataReader into an arraylist and then pass it to the UI Layer. I want to know that whether this will help in anyway or will cause an overhead to the application(remember the appn. is screwed up!!) :confused:
obymathew wrote: I want to know that whether this will help in anyway or will cause an overhead to the application This is the wrong way of decoupling layers: 1. This will add both complexity and overhead - you'll need a lot of casting on the UI layer, as ArrayLists store only objects. 2. Probably your data is being put on specific positions (e.g, al[1] is the customer name, al[2] your customer address, etc. This makes the application hard to debug, and change impact analysis very hard to do. What I suggest: If you still want or need to keep a strong isolation between these layers (e.g., the data or the UI layer can be used with other implementations) you can: Create a 3rd assembly, which will define the interfaces that'll be used by both the data layer and the UI layer. From the data layer, return those interfaces, or arrays of those interfaces. To allow incremental changes, and to not disrupt everything when changing a method, provide a method on each interface that converts that data to an arraylist. Before doing any changes, plan ahead a bit: make a backup (actually, you should use source control), create some basic unit tests and only then start working. Don't forget that you may need to maintain two versions while you're converting things if your users need changes/bug corrections. Yes, even I am blogging now!