You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Bryan Duxbury (JIRA)" <ji...@apache.org> on 2008/06/19 02:53:45 UTC

[jira] Created: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
--------------------------------------------------------------------------------------------------------------

                 Key: THRIFT-42
                 URL: https://issues.apache.org/jira/browse/THRIFT-42
             Project: Thrift
          Issue Type: Improvement
          Components: Compiler (Java)
            Reporter: Bryan Duxbury
            Priority: Trivial


Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 

I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Reiss resolved THRIFT-42.
-------------------------------

    Resolution: Fixed
      Assignee: Kevin Ballard

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Assignee: Kevin Ballard
>            Priority: Trivial
>         Attachments: 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch, 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch
>
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613404#action_12613404 ] 

David Reiss commented on THRIFT-42:
-----------------------------------

I took a look and thought it looked good, though on my second look I have a question.  How come in the first hunk you didn't do 'cap_name = "_" + cap_name;' like you did in the second?  I think that would be a slight improvement.

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Priority: Trivial
>         Attachments: 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch
>
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "Kevin Ballard (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613405#action_12613405 ] 

Kevin Ballard commented on THRIFT-42:
-------------------------------------

Mostly because I wrote that hunk first, then realized I had to do 'cap_name = "_" + cap_name;' to get the second hunk to work cleanly. It doesn't make much difference, but maybe it would be better to be consistent and do it the same way both times.

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Priority: Trivial
>         Attachments: 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch
>
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "Kevin Ballard (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevin Ballard updated THRIFT-42:
--------------------------------

    Patch Info: [Patch Available]

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Priority: Trivial
>         Attachments: 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch
>
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "Kevin Ballard (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevin Ballard updated THRIFT-42:
--------------------------------

    Attachment: 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch

Ok, I've attached a new version of the patch

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Priority: Trivial
>         Attachments: 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch, 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch
>
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "Kevin Ballard (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kevin Ballard updated THRIFT-42:
--------------------------------

    Attachment: 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch

The attached patch (0001) implements a new generator option nocamel which, when used with beans, prevents CamelCasing the field accessors. I am not a Java user myself, so I'd love it if someone could verify that this looks correct.

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Priority: Trivial
>         Attachments: 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch
>
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12609743#action_12609743 ] 

Bryan Duxbury commented on THRIFT-42:
-------------------------------------

What if we added a command line switch that could select the case used to generate? Something like --not-camel-case? Then it would just be a case of implementing the underscored-style name generation. 

Ideally it wouldn't have to be a command line option. I'd like it if we had compiler directives or annotations or something that let us make these options part of the .thrift file itself. (I am aware that would be a nontrivial operation, though.)

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Priority: Trivial
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12610004#action_12610004 ] 

David Reiss commented on THRIFT-42:
-----------------------------------

I just remember running into a bunch of snags when we added the docstrings: rules getting evaluated too early and stuff like that.  Although, now that I think about it, that might have been due to the fact that we were overloading the comment syntax.  One thing to keep in mind is that we should have a different keyword for whole-file options and struct-specific options.  Otherwise, you don't know how to apply
{noformat}
setopt "foo" "bar"
struct baz { 1: i32 qux; }
{noformat}
I don't see why doing fields would be any harder than doing structures.  Just look at optional and required (which could be made into local options).  We could eliminate the XSD stuff and Erlang's "slist".

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Priority: Trivial
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12609967#action_12609967 ] 

Bryan Duxbury commented on THRIFT-42:
-------------------------------------

Option to the java generator sounds good.

I like the idea of generic directives at the whole-file level. I think it would give the capabilities that I was thinking about. As far as setting options per-entity, what would be hard about it? You'd have to change the grammar to accept the "setoption" keyword inside structs/enums/services, and the internal object model to have the options map available to the generator. Per field would be hard though, I agree.

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Priority: Trivial
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12613364#action_12613364 ] 

Bryan Duxbury commented on THRIFT-42:
-------------------------------------

This looks pretty good. Anyone else want to review, or can we go right to commit?

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Priority: Trivial
>         Attachments: 0001-java-Add-nocamel-option-to-not-CamelCase-field-acce.patch
>
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-42) javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-42?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12609759#action_12609759 ] 

David Reiss commented on THRIFT-42:
-----------------------------------

I think that in this particular case, it would be best as an option to the java generator.  --gen java:beans,nocamel

It would not be too hard to add a generic directive to the thrift files like:
setoption "key" "value"
But doing it per-structure or per-field  is trickier.  Of course, there are already docstrings on those, so we could start inspecting them (HACK!).

> javabean generated code assumes camel-case and makes very ugly getters and setters if not camel cased properly
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-42
>                 URL: https://issues.apache.org/jira/browse/THRIFT-42
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Java)
>            Reporter: Bryan Duxbury
>            Priority: Trivial
>
> Let's say you name your fields in underscored lower case (my_cool_field). The bean-style generator only upcases the first character of the name and mashes it onto get, set, etc. You end up with something that looks like "getMy_cool_field". This gross hybrid is pretty terrible. 
> I propose that we either add a case-style compiler option, or at least try and detect the casing and convert it appropriately.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.