You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by Imesh Gunaratne <im...@apache.org> on 2014/11/08 17:34:27 UTC
Maintaining Better Coding Standards
Hi,
I noticed following domain classes introduced recently in the CLI:
It seems like the naming convention used in above classes Applications,
Clusters, Groups and SubGroups is not correct. These classes look like
collection types but they are single object types.
Class: RestCommandLineService
public void describeApplication (String applicationID) {
try {
ApplicationBean list = (ApplicationBean)
restClient.listEntity(ENDPOINT_LIST_APPLICATION.replace("{appId}",
applicationID),
ApplicationBean.class, "applications");
if ((list == null) || (list.getApplications() == null)) {
System.out.println("Application not found: " +
applicationID);
return;
}
System.out.println("Application : " + applicationID);
System.out.println(getGson().toJson(list.getApplications()));
} catch (Exception e) {
String message = "Error in describing application: " +
applicationID;
System.out.println(message);
log.error(message, e);
}
}
- ApplicationBean class used in the above method has exposed a method
called getApplications() but it only returns an application.
- The above method defines a local variable called list but it only
contains one application object.
Thanks
--
Imesh Gunaratne
Technical Lead, WSO2
Committer & PMC Member, Apache Stratos
Re: Maintaining Better Coding Standards
Posted by Imesh Gunaratne <im...@apache.org>.
On Sat, Nov 8, 2014 at 11:14 PM, Udara Liyanage <ud...@wso2.com> wrote:
> Hi Imesh,
>
> Also in below methods entityName is used only for printing messages. We
> can remove them, right?
>
No, this is how we have generalized CRUD operations and their error
messages. Entity name is needed.
Re: Maintaining Better Coding Standards
Posted by Udara Liyanage <ud...@wso2.com>.
Hi Imesh,
Also in below methods entityName is used only for printing messages. We can
remove them, right?
1. public Object getEntity(String serviceEndpoint, Class
responseJsonClass, String identifier, String entityName) {
2. try {
3. return executeGet(serviceEndpoint.replace("{id}",
identifier), responseJsonClass);
4. } catch (Exception e) {
5. String message = String.format("Error in getting %s",
entityName);
6. System.out.println(message);
7. logger.error(message, e);
8. return null;
9. }
10. }
11.
12. public Object listEntity(String serviceEndpoint, Class
responseJsonClass, String entityName) {
13. try {
14. return executeGet(serviceEndpoint, responseJsonClass);
15. } catch (Exception e) {
16. String message = String.format("Error in listing %s",
entityName);
17. System.out.println(message);
18. logger.error(message, e);
19. return null;
20. }
21. }
On Sat, Nov 8, 2014 at 10:13 PM, Imesh Gunaratne <im...@apache.org> wrote:
> I have now fixed this with commit
> revision: 414a93b7394de6eb3494f7d164e599006032ffcf
>
> On Sat, Nov 8, 2014 at 10:04 PM, Imesh Gunaratne <im...@apache.org> wrote:
>
>> Hi,
>>
>> I noticed following domain classes introduced recently in the CLI:
>>
>>
>>
>> It seems like the naming convention used in above classes Applications,
>> Clusters, Groups and SubGroups is not correct. These classes look like
>> collection types but they are single object types.
>>
>> Class: RestCommandLineService
>> public void describeApplication (String applicationID) {
>> try {
>> ApplicationBean list = (ApplicationBean)
>> restClient.listEntity(ENDPOINT_LIST_APPLICATION.replace("{appId}",
>> applicationID),
>> ApplicationBean.class, "applications");
>>
>> if ((list == null) || (list.getApplications() == null)) {
>> System.out.println("Application not found: " +
>> applicationID);
>> return;
>> }
>>
>> System.out.println("Application : " + applicationID);
>> System.out.println(getGson().toJson(list.getApplications()));
>> } catch (Exception e) {
>> String message = "Error in describing application: " +
>> applicationID;
>> System.out.println(message);
>> log.error(message, e);
>> }
>> }
>>
>> - ApplicationBean class used in the above method has exposed a method
>> called getApplications() but it only returns an application.
>> - The above method defines a local variable called list but it only
>> contains one application object.
>>
>> Thanks
>>
>> --
>> Imesh Gunaratne
>>
>> Technical Lead, WSO2
>> Committer & PMC Member, Apache Stratos
>>
>
>
>
> --
> Imesh Gunaratne
>
> Technical Lead, WSO2
> Committer & PMC Member, Apache Stratos
>
--
Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware
web: http://udaraliyanage.wordpress.com
phone: +94 71 443 6897
Re: Maintaining Better Coding Standards
Posted by Imesh Gunaratne <im...@apache.org>.
I have now fixed this with commit
revision: 414a93b7394de6eb3494f7d164e599006032ffcf
On Sat, Nov 8, 2014 at 10:04 PM, Imesh Gunaratne <im...@apache.org> wrote:
> Hi,
>
> I noticed following domain classes introduced recently in the CLI:
>
>
>
> It seems like the naming convention used in above classes Applications,
> Clusters, Groups and SubGroups is not correct. These classes look like
> collection types but they are single object types.
>
> Class: RestCommandLineService
> public void describeApplication (String applicationID) {
> try {
> ApplicationBean list = (ApplicationBean)
> restClient.listEntity(ENDPOINT_LIST_APPLICATION.replace("{appId}",
> applicationID),
> ApplicationBean.class, "applications");
>
> if ((list == null) || (list.getApplications() == null)) {
> System.out.println("Application not found: " +
> applicationID);
> return;
> }
>
> System.out.println("Application : " + applicationID);
> System.out.println(getGson().toJson(list.getApplications()));
> } catch (Exception e) {
> String message = "Error in describing application: " +
> applicationID;
> System.out.println(message);
> log.error(message, e);
> }
> }
>
> - ApplicationBean class used in the above method has exposed a method
> called getApplications() but it only returns an application.
> - The above method defines a local variable called list but it only
> contains one application object.
>
> Thanks
>
> --
> Imesh Gunaratne
>
> Technical Lead, WSO2
> Committer & PMC Member, Apache Stratos
>
--
Imesh Gunaratne
Technical Lead, WSO2
Committer & PMC Member, Apache Stratos