[ https://issues.apache.org/jira/browse/OFBIZ-7521?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Divesh Dutta updated OFBIZ-7521: -------------------------------- Description: We should favor the use of interfaces rather than class to refer to objects where ever possible. It is entirely appropriate to refer an object by a class rather than an interface if no appropriate interface exists. But wherever appropriate interface exists we should use them to refer to objects. For example: {code} ArrayList<EntityCondition> itemsExprs = new ArrayList<EntityCondition>(); {code} should be written as : {code} List<EntityCondition> itemsExprs = new ArrayList<EntityCondition>(); {code} Writing this way will make code more flexible . If you want to switch implementations, all you have to do is change the class name in the constructor and all surrounding code will continue to work. This is parent ticket, we will create logical tasks for each component and collection class to improve this code. There are very less such occurrences and most of the code is written following the best practice. But we could improve the code which has not followed this best practice. was: We should use favor the use of interfaces rather than class to refer to objects where ever possible. It is entirely appropriate to refer an object by a class rather than an interface if no appropriate interface exists. But wherever appropriate interface exists we should use them to refer to objects. For example: {code} ArrayList<EntityCondition> itemsExprs = new ArrayList<EntityCondition>(); {code} should be written as : {code} List<EntityCondition> itemsExprs = new ArrayList<EntityCondition>(); {code} Writing this way will make code more flexible . If you want to switch implementations, all you have to do is change the class name in the constructor and all surrounding code will continue to work. This is parent ticket, we will create logical tasks for each component and collection class to improve this code. There are very less such occurrences and most of the code is written following the best practice. But we could improve the code which has not followed this best practice. > Refer to objects by their interfaces rather than class when instantiating > Collection implementation classes in Java files > --------------------------------------------------------------------------------------------------------------------------- > > Key: OFBIZ-7521 > URL: https://issues.apache.org/jira/browse/OFBIZ-7521 > Project: OFBiz > Issue Type: Improvement > Components: ALL COMPONENTS > Affects Versions: Upcoming Branch > Reporter: Divesh Dutta > > We should favor the use of interfaces rather than class to refer to objects > where ever possible. It is entirely appropriate to refer an object by a class > rather than an interface if no appropriate interface exists. But wherever > appropriate interface exists we should use them to refer to objects. > For example: > {code} > ArrayList<EntityCondition> itemsExprs = new ArrayList<EntityCondition>(); > {code} > should be written as : > {code} > List<EntityCondition> itemsExprs = new ArrayList<EntityCondition>(); > {code} > Writing this way will make code more flexible . If you want to switch > implementations, all you have to do is change the class name in the > constructor and all surrounding code will continue to work. > This is parent ticket, we will create logical tasks for each component and > collection class to improve this code. There are very less such occurrences > and most of the code is written following the best practice. But we could > improve the code which has not followed this best practice. -- This message was sent by Atlassian JIRA (v6.3.4#6332)