Bug 515252 - Add prefix/suffix to the resource class names
Summary: Add prefix/suffix to the resource class names
Status: NEW
Alias: None
Product: Lyo
Classification: Technology
Component: Tools (show other bugs)
Version: 2.1.2   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 2.x.x   Edit
Assignee: Jad El-khoury CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-13 09:18 EDT by Andrii Berezovskyi CLA
Modified: 2017-11-06 12:53 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrii Berezovskyi CLA 2017-04-13 09:18:20 EDT
Jim:

> Not a problem, but you can’t use "Application" or "Service" as a resource names as they conflict on import with the generated servlet name Application.java and Service.java. The boiler plate class names should use some prefix to avoid class name collisions like that - allowing the modeler to use the good names.

Jad:

> The domain prefix can be used. I do similar thing if a resource has 2 properties with the same name (from different Domains). There are 2 parts: (1) avoid Java keywords which we can list out for all adaptors (2) avoid application-specific terms that might turn out in the code of the adaptor. For the latter, I need to give the modeller a way to give such a list.

Andrew:

> The clash will happen with any class name you have imported in the template.  E.g. ApplicationDSR (DSR for Domain Spec Resource). Also, if you have defined an RDF prefix, we can add a prefix to the class as well. ‘oslc_rm:Application’ can become OslcRmApplicationDSR. I know it’s ugly but will certainly help. We can then allow resources with the strangest names like Object and Class.
Comment 1 Andrii Berezovskyi CLA 2017-04-13 09:22:13 EDT
Eclipse has wrapping problems:

Jim:

> Not a problem, but you can’t use "Application" or "Service" as a resource
> names as they conflict on import with the generated servlet name
> Application.java and Service.java. The boiler plate class names should use some
> prefix to avoid class name collisions like that - allowing the modeler to use
> the good names.

Jad:

> The domain prefix can be used. I do similar thing if a resource has 2
> properties with the same name (from different Domains). There are 2 parts: (1)
> avoid Java keywords which we can list out for all adaptors (2) avoid
> application-specific terms that might turn out in the code of the adaptor. For
> the latter, I need to give the modeller a way to give such a list.

Andrew:

> The clash will happen with any class name you have imported in the template.
> E.g. ApplicationDSR (DSR for Domain Spec Resource). Also, if you have defined an
> RDF prefix, we can add a prefix to the class as well. ‘oslc_rm:Application’ can
> become OslcRmApplicationDSR. I know it’s ugly but will certainly help. We can
> then allow resources with the strangest names like Object and Class.
Comment 2 Jad El-khoury CLA 2017-04-14 02:54:18 EDT
We should only add prefixes to the boiler plate class names if there is a conflict. 
Reason: In most cases, the models do not contain "Application" terms, and it would be a pity to make the class names cumbersome.
Comment 3 Jim Amsden CLA 2017-04-14 07:08:57 EDT
I'm happy enough to put the prefix on the resource names in the domain specification.
Comment 4 Andrii Berezovskyi CLA 2017-04-14 07:15:34 EDT
(In reply to Jim Amsden from comment #3)
> I'm happy enough to put the prefix on the resource names in the domain
> specification.

Then it means you would be comfortable with a stop-list of resource names in the modelling tool?
Comment 5 Jim Amsden CLA 2017-04-14 08:00:30 EDT
If by stop-list you mean a list of reserved names that should not be used for domain specification resource names, then yes.
Comment 6 Jim Amsden CLA 2017-04-14 08:02:28 EDT
But I would recommend avoiding using good names like Application and Service for class names in generated code. That is avoid, reserving good names by adding your own prefix: TcgApplication, TcgService (for Toolchain Generator). This leave the good names available for users models and reduces the possibility of collisions.
Comment 7 Andrii Berezovskyi CLA 2017-04-15 08:00:59 EDT
(In reply to Jim Amsden from comment #6)
> But I would recommend avoiding using good names like Application and Service
> for class names in generated code. That is avoid, reserving good names by
> adding your own prefix: TcgApplication, TcgService (for Toolchain
> Generator). This leave the good names available for users models and reduces
> the possibility of collisions.

I actually like the idea because once accustomed, developers will easily distinguish the custom code from the generated one. And it will leave the nice names available to the developer, as you have pointed out.
Comment 8 Jad El-khoury CLA 2017-04-17 17:06:49 EDT
(In reply to Jim Amsden from comment #6)
> But I would recommend avoiding using good names like Application and Service
> for class names in generated code. That is avoid, reserving good names by
> adding your own prefix: TcgApplication, TcgService (for Toolchain
> Generator). This leave the good names available for users models and reduces
> the possibility of collisions.


Good idea actually. i now get your main point Jim!

Luckily, the only "bad" names we have to fix is Application (might as well avoid "ServletListener"). All other class names are quite specific.
Comment 9 Eclipse Genie CLA 2017-07-06 12:27:28 EDT
New Gerrit change created: https://git.eclipse.org/r/100861