wiki:GROUP_TEMPLATES_R1

Version 4 (modified by jani, 16 years ago) (diff)

--

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

Error: Macro TicketQuery(summary=GROUP_TEMPLATES_R1, format=table, col=summary|owner|status|type|component|priority|effort|importance, rows=description|analysis_owners|analysis_reviewers|analysis_score|design_owners|design_reviewers|design_score|implementation_owners|implementation_reviewers|implementation_score|test_owners|test_reviewers|test_score|) failed
current transaction is aborted, commands ignored until end of transaction block

Analysis

Overview

  • The templating library needs to be of not great complexity, so that persisting and copying is done easily.
  • The main issue is that when deriving mutable objects and then making changes to them results in derived objects with local changes, which are hard to handle.

Task requirements

  • The goal of this revision is to reduce the complexity of the templating library.
  • It should not be possible there to be a derived object with local changes.

Task result

  • The result of this task should be source code.

Implementation idea

  • The mode should be set recursively to the bottom of the tree, but the mutable objects themselves should not be derived.
  • Create an enumeration for the different modes of a templated property.

How to demo

  • Start Sophie2.
  • Create a page with some frames.
  • Add the page as a template.
  • Create another page and apply the newly created template to it.

Design

The goal of this revision is to make the templating library simplier. For example, in the previous revision it was possible to have a derived object with local changes, which greatly increased complexity. Also, instead of having useTemplate() and locked() properties, an enumeration TemplateMode should be introduced, with the following elements:

  • USE_TEMPLATE - the value from the template is used
  • LOCKED - the own value is used and it cannot be modified
  • CUSTOM - the own value is used and it can be modified.

Also, when setting a value to a mutable object, for instance Frame, it should be set to all children recursevly - for example backgroundStyle(), borderStyle(), contentLocation(), etc. Setting a value to a mutable object, actually does not change its mode in its own TemplateSupport - instead it is only changed in the children. This should insure that there cannot be derived mutable objects. A new interface Templatable should be added, which contains the templateSupport() property. All classes need template support should implement this interface.

Class TemplateField should be rafactored in a way that the TemplateMode enumeration is used.

Class TemplateValueField should be refactored in the following way:

  • value() should always return ownValue() if the object is a mutable
  • derivedValue() should only return immutables

Class TemplateListField should be refactored in a way that either the ownList or derivedList is returned, depending on the mode.

Class TemplateSupport should be rafactored in a way that the TemplateMode enumeration is used.

Updated UML class diagram:

source:branches/private/jani/sophie2-platform/doc/uml-design-diagrams/TemplateR1ClassDiagram.png

Unit test: TemplateTest

Integration test: TemplateIntegrationTest

Demo: TemplateDemo

Unit test for TemplateMode: TemplateModeTest

Implementation

(Describe and link the implementation results here (from the wiki or the repository).)

Testing

(Place the testing results here.)

Comments

(Write comments for this or later revisions here.)