Design Opinion

Design Opinion

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


tna55 posted on Friday, December 07, 2007

Hi friends,

I would like to get some opinion regarding a design problem. In the application I am working on, I have projects and each project can have multiple feature requests. I would like to show, in a treeview all projects and their corresponding feature requests. Simple!

I have made following clases:

ProjectList - A read-only list of projects.
ProjectInfo - A read-only project
ProjectFeatureList - A read-only list of features for a project
ProjectFeatureInfo - A read-only feature for a project

All these are used in two other use cases. First two class are used in use-case 'Maintain a project' where a user is presented with a list of projects, he can select one and then edit it. Second two are also used in similar use case for feature requests.

Now in order to show, in a treeview, a list of projects with corresponding list of features, should I use these classes or create a different set of classes?

If using these existing classes, I will have probably write code behind UI, something like:

'Get Project List e.g. mProjectList = ProjectList.Load()
For Each mProjectInfo As ProjectInfo In mProjectList
   'Get Project Feature List for each Project (e.g. mProjectFeatureList  = ProjectFeatureList.Load(mProjectInfo.ProjectID)
   'Fill tree root node
   For Each mFeatureInfo As ProjectFeatureInfo In mProjectFeatureList
      'Fill tree child nodes
   Next
Next

If I use a seperate set of classes then the logic of of getting project list and corresponding feature list will go in those classes. I have a feeling that creating seperate classes is better option as I can then use those classes to fill treeview, nested grids or a combo and a grid or whatever combination. Also the code will not be behind UI and is thus more maintainable.

I would like to get some opinion on this and would be very thankful.

Tahir

praevsky replied on Saturday, December 08, 2007

I have searched and researched a lot about database applications and treeviews.
I would use only one xxxList and xxxInfo class.
I would probably access the "Maintain a Project" and "Maintain a Feature" actions via a context menu on the treeview, but that's just me.
I don't like System.Windows.Forms.Treeview for this application.
Instead I like FastTreeView by gajatko on www.codeproject.com
This lends itself to a much more object oriented approach.
It has an IFastTreeNodeData interface with a LoadChildNodes method.
This works well because loading projects requires a separate methodology from loading features.
It also provides for not loading a single feature until requested by the UI.




tna55 replied on Saturday, December 08, 2007

Hi praevsky,

Thanks for your reply.

I am actually looking for a suggestions to make my class design. I am using ASP.NET and the tree view should be ok I guess.

You mentioned that you will have one xxxList and xxxInfo class. Does that mean you will do something like I did in my initial question? i.e. you will put the logic of getting features for a project behind UI? Is that a good way to do this or do you think creating another set of classes is better?

Tahir

Copyright (c) Marimer LLC