This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 224009 - [api] make all task data classes final
Summary: [api] make all task data classes final
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P2 normal (vote)
Target Milestone: 3.0   Edit
Assignee: Steffen Pingel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 226822
  Show dependency tree
 
Reported: 2008-03-25 19:41 EDT by Robert Elves CLA
Modified: 2008-04-29 03:40 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Elves CLA 2008-03-25 19:41:22 EDT
If users try to extend the task data classes, deserialization can fail due to class load failure.
Comment 1 maarten meijer CLA 2008-03-26 16:10:10 EDT
To further the discussion I quote a bit from http://www.codeguru.com/java/tij/tij0127.shtml
[...]
Here is the output from three different runs:
Duplication via serialization: 3400 Milliseconds
Duplication via cloning: 110 Milliseconds

Duplication via serialization: 3410 Milliseconds
Duplication via cloning: 110 Milliseconds

Duplication via serialization: 3520 Milliseconds
Duplication via cloning: 110 Milliseconds
[...]
So I think that your bug report should somehow identify the problem properly and prefer a proper deep-cloneable implementation, if only for performance reasons.
To loose the subclassing will kill the current work on the generic SQL connector:
bug 184532: [connector] Generic SQL connector
https://bugs.eclipse.org/bugs/show_bug.cgi?id=184532
It will also probably severely hinder connector implementors.
There are just too many open bug reports with the [connector] keyword in it!

Also see bug 206698: [api] provide mechanism for adding AttributeContainer to RepositoryTaskData
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206698 which works against this 
Comment 2 maarten meijer CLA 2008-03-26 16:11:31 EDT
These classes are very flexible attribute containers, most of the setter/getter methods are just convenience methods hiding the repository key.
If these are to become final you lose the flexibility of the attribute container scheme. So it is no longer extensible.

I think the solution is to refactor the deepCopy operation inside TaskDataManager$ObjectCloner.deepCopy so it no longer needs serialization.

If you go for making final, then these classes need a fully orthogonal set of getters/setters.
For example TaskComment misses the following:
- getAuthor(String)
- getTaskId()
- setAuthorName(String)
- setCreated(String)
- setTaskId(String)
- setText(String)

And AbstractTask misses the following:
- getEstimatedTimeHours see bug 222196:[api]renameAbstractTask.getEstimateTimeHoursto getEstimatedTimeHours

If you have some attributes  with convenience getters setters and others without, you become less flexible.

Comment 3 maarten meijer CLA 2008-03-27 04:43:04 EDT
I found a work around for the work on the SQL connector bug 184532 but still feel the setters/getters should be orthogonal.
Comment 4 Robert Elves CLA 2008-03-27 12:34:19 EDT
Thanks for all your input on this Maarten. We will certainly take all this into account when refactoring the offline support for 3.0.
Comment 5 Steffen Pingel CLA 2008-03-27 20:01:19 EDT
I am currently leaning towards turning TaskData into a persistence API and moving connector specific type conversion and attribute mapping into AbstractAttributeMapper. Task comments and attachments will be decoupled from TaskData and provide getters and setters for the attributes that are part of the common schema. 

Cloning of TaskData will most likely not rely on serialization in the future for creating clones but use a more robust implementation that copies attribute values.
Comment 6 maarten meijer CLA 2008-03-28 11:46:32 EDT
(In reply to comment #5)
> I am currently leaning towards turning TaskData into a persistence API and
> moving connector specific type conversion and attribute mapping into
> AbstractAttributeMapper. Task comments and attachments will be decoupled from
> TaskData and provide getters and setters for the attributes that are part of
> the common schema. 
I was thinking about proposing that the editor be made more flexible by declarative attribute naming:
The editor is now a container for attributes with currently two subcontainers: comments and attachments, the attribute keys now contain dot notation, for example:
- task.common.comment.text

The editor is made up of a number of sections:
- main
- attributes
- attachments (sublist) with new attachment section
- description
- comments (sublist) with new comment section
- actions
- people

Wouldn't it make it a lot easier for connector developers if this scheme is extended to incorporate some more information, like section to duisplay, type, rw or ro, etc which would then be parsed by the taskeditor builder:

attribute task.comment.screenshot.image.ro would 
mean that it is a read-only image to be displayed in the comment section 

attribute task.main.producticon.image.ro would 
mean that it is a read only product icon to be displayed in the main header 

attribute task.attribute.duedate.date.rw would 
mean that it is an editable date to be displayed in the attribute section 

attribute task.people.qa.person.rw would 
mean that it is an editable person field to be displayed in the people section 

attribute task.action.closed.option would 
mean that it is an option field to be displayed in the action section 

The attributes would give the proper title in the AttributeFactory.

This would make the editor a more intelligent displayer of the enclosed attributes.
 
> Cloning of TaskData will most likely not rely on serialization in the future
> for creating clones but use a more robust implementation that copies attribute
> values.
That may give performance benefits as well ;-)
Comment 7 Steffen Pingel CLA 2008-03-29 16:18:38 EDT
We are in the process of extending the meta data scheme for attributes. It is likely that there will be a new class in Mylyn 3.0, e.g.:

TaskAttributeProperties {
 boolean showInAttributesSection()
 boolean showInToolTip()
 String getLabel()
}
 
In the current API the type of an attributes is available be invoking AbstractAttributeMapper.getType(RepositoryTaskAttribute). It's an interesting to encode these properties in the attribute key but I would prefer to make this more obvious and explicit in the Java code.

Concerning containers we were discussing to make every attribute a container to enable client to store data structures other than attachments and operations that are complex.
Comment 8 maarten meijer CLA 2008-03-29 19:11:27 EDT
(In reply to comment #7)
> It's an interesting
> to encode these properties in the attribute key but I would prefer to make this
> more obvious and explicit in the Java code.
I understand, but I'm working on the generic SQL connector, where I intend to end up with something where you only ever define the mapping from the SQL database to some property and never touch the java code.
Is there a plan to separate the rendering engine that draws the form editor? If so I can hook in one with this feature.
Comment 9 Steffen Pingel CLA 2008-03-29 21:21:36 EDT
Yes, you can either provide your own editor implementation or extend AttributeEditorFactory to control how attributes are rendered / edited.   
Comment 10 Steffen Pingel CLA 2008-04-29 03:40:34 EDT
TaskData, TaskAttribute and related classes are now final to avoid confusion about the intended extensibility.