Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 212935

Summary: ConnectionEndHandle is declared as a final class.
Product: [Tools] GEF Reporter: Antoine Toulmé <antoine>
Component: GEF-Legacy GEF (MVC)Assignee: Anthony Hunter <ahunter.eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ahunter.eclipse, hudsonr, ppshah
Version: 3.4   
Target Milestone: 3.4.0 (Ganymede) M6   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
ConnectionEndpointHandle Class
none
ConnectionEndpointHandle none

Description Antoine Toulmé CLA 2007-12-13 16:01:43 EST
I don't understand why the class ConnectionEndHandle is declared as final.

It contains a protected method that I want to override in a particular case.
Comment 1 Randy Hudson CLA 2007-12-14 00:01:42 EST
> It contains a protected method that I want to override in a particular case.

Well, there's only one method in the class...
Comment 2 Antoine Toulmé CLA 2007-12-14 03:30:28 EST
(In reply to comment #1)
> > It contains a protected method that I want to override in a particular case.
> 
> Well, there's only one method in the class...
> 

And three constructors.

So what is the minimal number of protected methods necessary to declare the class non-final ?

I had to copy the code of the ConnectionEndHandle and ConnectionStartHandle classes into nested private classes, just to change one ls ine in each of them.

This code will be committed soon to the STP BPMN component, I will add a link here when it's ready.
Comment 3 Pratik Shah CLA 2007-12-14 11:04:44 EST
Unless there's a good reason to mark the class final, we shouldn't.  Copying code, however little, has licensing implications.  If the class is expected to change, marking it as internal is better than preventing it from being subclassed.
Comment 4 Anthony Hunter CLA 2007-12-14 11:25:22 EST
(In reply to comment #3)
> Unless there's a good reason to mark the class final, we shouldn't. 

Since ConnectionEndHandle is already public, we can make it non final as requested.
Comment 5 Randy Hudson CLA 2007-12-17 00:18:21 EST
(In reply to comment #3)
> Unless there's a good reason to mark the class final, we shouldn't.

Maybe the class is marked final because it is copied in two places. We have ConnectionStartHandle, and ConnectionEndHandle. As soon as you start subclassing, you need to keep your two duplicate subclasses in sync.

Antoine, would a single ConnectionEndpointHandle class that could be either a start or end handle, and is non-final, be preferred?
Comment 6 Antoine Toulmé CLA 2007-12-17 01:53:55 EST
Hi Randy,

that would be indeed work.

Thanks!
Comment 7 Anthony Hunter CLA 2007-12-21 11:53:22 EST
Created attachment 85721 [details]
ConnectionEndpointHandle Class

Attaching a proposal for ConnectionEndpointHandle
Comment 8 Antoine Toulmé CLA 2007-12-21 14:07:12 EST
Could you do the same for ConnectionStartHandle ?

I'll be happy to provide a patch, just removing the final keyword if you'd like.

Merry Christmas!
Comment 9 Anthony Hunter CLA 2007-12-21 14:23:26 EST
(In reply to comment #5)
> Antoine, would a single ConnectionEndpointHandle class that could be either a
> start or end handle, and is non-final, be preferred?

The intent was that my patch was a new ConnectionEndpointHandle as Randy described.

Now that I look at the code again and the confusion that would be two sets of classes, it is makes the most sense to make ConnectionStartHandle, and ConnectionEndHandle non final.

I will make ConnectionStartHandle, and ConnectionEndHandle non final.
Comment 10 Randy Hudson CLA 2007-12-25 22:12:17 EST
What about the issue with sub-classing in two different hierarchies? Anything the client overrides has to be copied into both subclasses.

Would making both Start and End Handles subclass Endpoint handle work? And then start and end handle could be deprecated. ConnectionEndpointHandle's name would be consistent with the existing ConnectionEndpointLocator, and ConnectionEndpointTracker.
Comment 11 Anthony Hunter CLA 2008-01-02 13:36:06 EST
Created attachment 86008 [details]
ConnectionEndpointHandle

OK, 

Both ConnectionStartHandle and ConnectionEndHandle extend ConnectionEndpointHandle and ConnectionStartHandle and ConnectionEndHandle are deprecated. ConnectionEndpointHandle's name is now consistent with the existing ConnectionEndpointLocator, and ConnectionEndpointTracker.
Comment 12 Anthony Hunter CLA 2008-02-08 15:32:56 EST
Missed M5, so moving to M6
Comment 13 Anthony Hunter CLA 2008-03-26 15:48:18 EDT
Committed the patch to HEAD.

Also corrected ConnectionEndpointEditPolicy to use ConnectionEndpointHandle and not the deprecated classes.