This project has moved and is read-only. For the latest updates, please go here.

Do I really need to use models and templates in my application?

Nov 2, 2012 at 7:52 PM

Hi,

I got 2 questions.

1. Do I really need to use models in my application if this application has the following peculiarities:

  • Model property mapping is not used
  • Each model object is presented by exactly one shape (not more), and this association is fixed
  • User does not distinguish between "shape" and "model"; from the user's point of view, he is operating shapes from a predefined (and fixed) set
  • Framework's built-in Storage concept is not used: diagram data is stored in a legacy database

Taking into account the above said, can there still be any benefits from using models?

2. Do I really need to use templates in my application if this application has the following peculiarities:

  • User operates shapes from a predefined set; this set is not supposed to be changed dynamically (in runtime)
  • User cannot change shape appearance (color, line type, font etc); in other words, all shapes of the same type look the same
  • Shapes cannot be grouped/aggregated
  • Model property mapping is not used (and even more - I doubt that I really need to use models - see my 1st question above)
  • Framework's built-in Storage concept is not used: diagram data is stored in a legacy database

Taking into account the above said, can there still be any benefits from using templates?

Thank You.

Nov 5, 2012 at 1:00 PM

Regarding the first question:
In other words, your only benefit from using model objects is the 'deactivate unmapped conection points' feature... In this case I would say you don't really need model objects. The main feature of the model objects are the visual property mappings.

Regarding your second question:
I would strongly recommend to use templates even if the end user of your application will not be able to change them.
The benefits:

  • As soon as you decide to adjust the visual appearance, it's sufficient to change the code only in the method that creates the template. When starting your application, call some methods that create templates for your shapes.
  • You can populate the toolbox with the templates created by your application (if you want to do so).
  • When using templates, you can even update previously saved projects with minimum effort: Load the project, change the templates and save the project. 
  • Instead of instantiating shape types with hard coded names, create constants for your template names, set them as Template.Name and create the shapes by calling
    Template t = project.Repository.GetTemplate(myTemplateName);
    Shape s = t.CreateShape();
    You can exchange shape types (e.g. replace a box shape with a RoundedBox shape) without changing any code of your application except the method that creates the template.