Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#769 Small patch for ItemPointer

1.3.19
closed-fixed
Editor (491)
5
2008-08-16
2008-08-16
Radim Kubacki
No

Even for such a small wrapper Java developers usually prefer to keep fields private and implement getters and setters if they are needed. In this case it can be enough to make all fields final to make sure that this will be immutable object.

Also the hashCode is not optimal - all pointers to the same file will return same number. While this is unlikely to cause user visible problems it can slow down various operation using this objects.

BTW: I do not see any usage of public ItemPointer(Object file2, Location location, Location location2, Definition definition, String zipFilePath). Is it used in pydev_ext?

Discussion

  • Radim Kubacki
    Radim Kubacki
    2008-08-16

     
    Attachments
  • Fabio Zadrozny
    Fabio Zadrozny
    2008-08-16

    • status: open --> closed-fixed
     
  • Fabio Zadrozny
    Fabio Zadrozny
    2008-08-16

    Logged In: YES
    user_id=617340
    Originator: NO

    Hi Rabim,

    Yes, that one with the definition is used in pydev_ext.

    In this case, as equals and hashcode are implemented, making it immutable makes sense... (just applied the patch and make hashCode better).

    As for the getters and setters -- and even being a java programmer for a long time -- I don't usually find real use for them (I know the reason is not to break code if it someday becomes a calculated property -- because java has no support for properties -- but in real life, I find that this happens so rarely that it's not worth the trouble, so, in Pydev getters and setters are not encouraged unless it's really needed -- or if some interface defines it -- which in my view is also a shortcoming of java: not allowing an interface to specify non final attributes).

    And if later that's really needed, a refactoring should suffice.