[jira] Created: (OFBIZ-3985) Using seperate class for constants

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (OFBIZ-3985) Using seperate class for constants

Nicolas Malin (Jira)
Using seperate class for constants
----------------------------------

                 Key: OFBIZ-3985
                 URL: https://issues.apache.org/jira/browse/OFBIZ-3985
             Project: OFBiz
          Issue Type: Improvement
          Components: ALL APPLICATIONS
    Affects Versions: Release Branch 10.04
            Reporter: Pankaj Savita
            Priority: Minor
             Fix For: Release Branch 10.04


Hi All,
 
Why don't we use a separate constant class for defining constants? We can use Parameter Constants Design Pattern in OFBiz.
Database fields & Form Fields can be defined in a Constant class, So that whenever fields name changed no need
to search the entire code. Just need to change it in Constant class. It makes easy maintainable code.
 
I am attaching a sample patch done in accounting component. In this I used a seperate class for a accounting specific constatns
 & a common class for OFBiz specific constants.

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

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (OFBIZ-3985) Using seperate class for constants

Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-3985?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pankaj Savita updated OFBIZ-3985:
---------------------------------

    Attachment: Using_Separate_Constant_Class.patch

Patch with sample code.

> Using seperate class for constants
> ----------------------------------
>
>                 Key: OFBIZ-3985
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-3985
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: ALL APPLICATIONS
>    Affects Versions: Release Branch 10.04
>            Reporter: Pankaj Savita
>            Priority: Minor
>             Fix For: Release Branch 10.04
>
>         Attachments: Using_Separate_Constant_Class.patch
>
>
> Hi All,
>  
> Why don't we use a separate constant class for defining constants? We can use Parameter Constants Design Pattern in OFBiz.
> Database fields & Form Fields can be defined in a Constant class, So that whenever fields name changed no need
> to search the entire code. Just need to change it in Constant class. It makes easy maintainable code.
>  
> I am attaching a sample patch done in accounting component. In this I used a seperate class for a accounting specific constatns
>  & a common class for OFBiz specific constants.

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

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-3985) Using seperate class for constants

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-3985?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12920300#action_12920300 ]

Jacques Le Roux commented on OFBIZ-3985:
----------------------------------------

Hi Pankaj,

It looks like a good idea to me. As it implies a lot of error prone changes, if done on all OFBiz, I'd prefer to have other commiters opinions...

> Using seperate class for constants
> ----------------------------------
>
>                 Key: OFBIZ-3985
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-3985
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: ALL APPLICATIONS
>    Affects Versions: Release Branch 10.04
>            Reporter: Pankaj Savita
>            Priority: Minor
>             Fix For: Release Branch 10.04
>
>         Attachments: Using_Separate_Constant_Class.patch
>
>
> Hi All,
>  
> Why don't we use a separate constant class for defining constants? We can use Parameter Constants Design Pattern in OFBiz.
> Database fields & Form Fields can be defined in a Constant class, So that whenever fields name changed no need
> to search the entire code. Just need to change it in Constant class. It makes easy maintainable code.
>  
> I am attaching a sample patch done in accounting component. In this I used a seperate class for a accounting specific constatns
>  & a common class for OFBiz specific constants.

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

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-3985) Using seperate class for constants

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-3985?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12920305#action_12920305 ]

Adrian Crum commented on OFBIZ-3985:
------------------------------------

This type of design pattern is useful in scenarios where the constant's value is unknown, or it should be hidden from client code. A typical example is a magic number (the java.util.Calendar integers come to mind).

I don't think the use case in this issue is a good application of the pattern.


> Using seperate class for constants
> ----------------------------------
>
>                 Key: OFBIZ-3985
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-3985
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: ALL APPLICATIONS
>    Affects Versions: Release Branch 10.04
>            Reporter: Pankaj Savita
>            Priority: Minor
>             Fix For: Release Branch 10.04
>
>         Attachments: Using_Separate_Constant_Class.patch
>
>
> Hi All,
>  
> Why don't we use a separate constant class for defining constants? We can use Parameter Constants Design Pattern in OFBiz.
> Database fields & Form Fields can be defined in a Constant class, So that whenever fields name changed no need
> to search the entire code. Just need to change it in Constant class. It makes easy maintainable code.
>  
> I am attaching a sample patch done in accounting component. In this I used a seperate class for a accounting specific constatns
>  & a common class for OFBiz specific constants.

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

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-3985) Using seperate class for constants

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-3985?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12920455#action_12920455 ]

Scott Gray commented on OFBIZ-3985:
-----------------------------------

I agree with Adrian.  It also looks like it would make the code less readable due to the verbosity which would actually be a bigger problem than having to manually type a field name (which I don't really find to be a big deal anyway).

> Using seperate class for constants
> ----------------------------------
>
>                 Key: OFBIZ-3985
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-3985
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: ALL APPLICATIONS
>    Affects Versions: Release Branch 10.04
>            Reporter: Pankaj Savita
>            Priority: Minor
>             Fix For: Release Branch 10.04
>
>         Attachments: Using_Separate_Constant_Class.patch
>
>
> Hi All,
>  
> Why don't we use a separate constant class for defining constants? We can use Parameter Constants Design Pattern in OFBiz.
> Database fields & Form Fields can be defined in a Constant class, So that whenever fields name changed no need
> to search the entire code. Just need to change it in Constant class. It makes easy maintainable code.
>  
> I am attaching a sample patch done in accounting component. In this I used a seperate class for a accounting specific constatns
>  & a common class for OFBiz specific constants.

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

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (OFBIZ-3985) Using seperate class for constants

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-3985?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jacques Le Roux closed OFBIZ-3985.
----------------------------------

    Resolution: Not A Problem
      Assignee: Jacques Le Roux

[For the verbosity we could use this tip|http://www.javaworld.com/javaworld/javatips/jw-javatip50.html] but anyway I agree it does not have much interested in our case since the Entities fields names are not changing that much and it's often easy to change them by a S/R.

I close as not a problem

> Using seperate class for constants
> ----------------------------------
>
>                 Key: OFBIZ-3985
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-3985
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: ALL APPLICATIONS
>    Affects Versions: Release Branch 10.04
>            Reporter: Pankaj Savita
>            Assignee: Jacques Le Roux
>            Priority: Minor
>             Fix For: Release Branch 10.04
>
>         Attachments: Using_Separate_Constant_Class.patch
>
>
> Hi All,
>  
> Why don't we use a separate constant class for defining constants? We can use Parameter Constants Design Pattern in OFBiz.
> Database fields & Form Fields can be defined in a Constant class, So that whenever fields name changed no need
> to search the entire code. Just need to change it in Constant class. It makes easy maintainable code.
>  
> I am attaching a sample patch done in accounting component. In this I used a seperate class for a accounting specific constatns
>  & a common class for OFBiz specific constants.

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