Adding controls at runtime & dat binding

Adding controls at runtime & dat binding

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


Dodo posted on Tuesday, May 16, 2006

Hello,

I appriciate any advice i get for these design questions. Please excuse my english.

How should i design my application to allow users to add more fields at runtime. e.g. the application is basically for project management. each project will have a set of milestones. when the user creates the project they should be able to set the milestones. initially they should be able to customize the milestones and workflow of the project. different companies will have different workflows and milestones.

This leads to another problem - the database. should i add lets say for arguments sake, support for 6 milestones and then expose all the fields to the user?

Misled replied on Tuesday, May 16, 2006

You don't want to design things in a way that makes you add fields. You will likely want to create a milestone table with the required fields. Make it have a foreign key related to the Customer table I suspect. Do the same with workflow and create business rules (possibly) that take into consideration the milestones.

Dodo replied on Tuesday, May 16, 2006

Am planning on doing it that way but the problem i ended up having is that different customers have different sets of milestones. which means i have to decide on how many fields to have in the back end. I guess i'll have to consider the worse case scenario and add enough milestones to cater for all their needs.

Thanks for the input Misled

xal replied on Tuesday, May 16, 2006

Dodo,
Always try to avoid getting in a position where you might have to add fields.
Normalize your data model!


if your table is something like:
ID
Milestone1
Milestone2
Milestone3
...
MilestoneN

then you should consider having something like
id
Milestoneid <---This would hold the number of milestone.
MilestoneInfo


Then you add flexibility to your app, and if some day a client needs 20 milestones, then you don't have to go through:
-Adding fields to forms
-Altering your stored procs (or sql code)
-Altering your tables' structure.

Which will definitely be a lot of work against no work at all. Also, having more fields exposes you to having possible null values which will make everything harder....

Also, the milestone id can be a fk of another table of allowed milestones, which can be maintained by the user.


Andrés

Dodo replied on Thursday, May 18, 2006

    Thanks guys.

Copyright (c) Marimer LLC