Object Reuse

Object Reuse

Old forum URL: forums.lhotka.net/forums/t/2432.aspx


luterguy posted on Monday, February 26, 2007

   We are using CSLA but have a question about reuse. Right now we building custom objects. They tend to be deep (going down to grandchildren and great-great grandchildren). We have gotten pretty good about building objects as needed, however we already see that we need to be able to reuse our objects and are not sure the best way to do so.

We did start trying to make our objects more generic so we could reuse things...but we are still not sure the best way. Also, we are currently using multiple records sets in our Fetch...however I have wondered if to better enable reuse if I should make certain children self contained (perfrom there own fetch).

Essentially, what is the best way to reuse objects. Do you focus on making the individual objects generic and then inherit them into new objects? That is what we plan on doing, however sometimes they vary enought that we wonder about the trouble of doing that versus creating new ones.

We are a small shop and not typically given much time up front. CSLA has been great so far. We are just looking for advice for stricking a good balance between reuse and ease of creation. Any advice/recommendations/etc would be greatly appreciated.

xal replied on Monday, February 26, 2007

Well, perhaps you should be a little more specific about what you mean with "reuse"...
Also (I don't know if it's too late in the game to consider this, but...) are you sure you need such deep hierarchies?
How much data is loaded in those hierarchies at once (counting all the hierarchy)? translating to total # of db rows, 10, 100, 1000, 10000?


Andrés

luterguy replied on Tuesday, February 27, 2007

I am trying to be generic ...but maybe examples would be good.

Currently we are dealing with Permits and each permit is composed of many different items (some of which can be the same). Example:
Permit1: has customer info, geographical info, interested party info, and survey info (specific to this permit).
Permit2: has customer info, interested party info, vehicle Info, and survey info (specific to this permit).

We are relatively new to true OOP. I feel that the solution probably is to make each of the objects self contained. However, does CSLA then let you thread them together. Currently we are building a Permit object which then has children, grandchildren, etc to make up the whole permit (object). This works fine, however we are missing out on reuse of the objects (Interested Party, Customer, etc).

I did not see a good example in the book, however I would think we would be better off creating our Permit objects by inheriting from existing objects. I am okay with that, however I am not sure how to thread them together using CSLA. I feel like I just need one of those lightbulb moments to pull it together. At the same time I feel that there is likely some issue with this approach. I am hoping that someone that has gone down this path in more detail might be able to point me in the right direction and share some lessons learned. One area that I afraid of getting into is making the objects too complex... for example Interested Party might need to be tweaked slightly in each use. I know it is all in how we build it and can overide, extend, etc... but if I play it out sometime it gets more complicated than I think it might be worth. Any input/advice on this would be appreciated.

As for making the objects simplier. We might just be stuck in the previous application...however the main reasoning is that we currently do it in a single transaction. That is until the permit is completely fileld out correctly we don't want to save anything to the database. That is the main reason our objects are as deep as the permits. I am open to ideas. Currenlty the only idea I have is to store each section of the permit in a temp or duplicate table and once all pieces are done then to have a process to save to the real database when completed. There would be great reluctance to do this...that is why I am currently building very deep objects. If you have alternative ideas, I would appreciate hearing them.

Once again, we are a small shop and still transitioning to a true OOP mindset. I am certain that we need a couple Ahh Haa moments to trully see the possibilites OOP.

Thanks, luterguy

 

Copyright (c) Marimer LLC