Modify

Opened 15 years ago

Closed 15 years ago

#2799 closed enhancement (wontfix)

Add new library (Apache Commons Lang)

Reported by: dmuecke Owned by: dmuecke
Priority: minor Milestone:
Component: Core Version:
Keywords: library Cc: Claudius

Description

I foresee benefits in code quality if we would add following library into josm lib directory

http://commons.apache.org/lang/api-2.3

Attachments (0)

Change History (4)

comment:1 by Claudius, 15 years ago

Owner: changed from team to dmuecke
Status: newneedinfo

Could you please provide some of the direct benefits that you see? I could theoretically see some value arising when this library would be added *AND* the existing could would make use of some of the new Utils classes for example. But it would require someone to rewrite that stuff.
Would you be able to provide the code changes that would make these come to effect?

(btw. Apache Lang API 2.4 seems to be the current one).

comment:2 by Claudius, 15 years ago

Cc: Claudius added
Status: needinfonew
Summary: New libraryAdd new library (Apache Commons Lang)

comment:3 by anonymous, 15 years ago

Most of the functions are handy helper to write cleaner and easier readable code.
One is Validate which I used to use in other applications.

    public static double calcDistance(LatLon p1, LatLon p2){
        double lat1, lon1, lat2, lon2;
        double dlon, dlat;

        Validate.notNull(p1,"P1 may not null");
        Validate.notNull(p2,"P2 may not null");

        lat1 = p1.lat() * Math.PI / 180.0;
        lon1 = p1.lon() * Math.PI / 180.0;
        lat2 = p2.lat() * Math.PI / 180.0;
        lon2 = p2.lon() * Math.PI / 180.0;

        dlon = lon2 - lon1;
        dlat = lat2 - lat1;

        double a = (Math.pow(Math.sin(dlat/2), 2) + Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(dlon/2), 2));
        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
        return 6367000 * c;
    }

If this function gets invoked and p1 or p2 is null an IllegalArgument exception gets raised instead a NullPointer exception.

I wouldn't go and rewrite existing running code. I would start to use it when I had to fix bugs or if I want work on a new feature.

comment:4 by stoecker, 15 years ago

Resolution: wontfix
Status: newclosed

I don't see real benefits from my side. Most programmers wont know that library and also don't use it thus.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain dmuecke.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.