Search Results

Search found 3 results on 1 pages for 'greeniemeanie'.

Page 1/1 | 1 

  • Java: Is clone() really ever used? What about defensive copying in getters/setters?

    - by GreenieMeanie
    Do people practically ever use defensive getters/setters? To me, 99% of the time you intend for the object you set in another object to be a copy of the same object reference, and you intend for changes you make to it to also be made in the object it was set in. If you setDate(Date dt) and modify dt later, who cares? Unless I want some basic immutable data bean that just has primitives and maybe something simple like a Date, I never use it. As far as clone, there are issues as to how deep or shallow the copy is, so it seems kind of "dangerous" to know what is going to come out when you clone an Object. I think I have only used clone() once or twice, and that was to copy the current state of the object because another thread (ie another HTTP request accessing the same object in Session) could be modifying it. Edit - A comment I made below is more the question: But then again, you DID change the Date, so it's kind of your own fault, hence whole discussion of term "defensive". If it is all application code under your own control among a small to medium group of developers, will just documenting your classes suffice as an alternative to making object copies? Or is this not necessary, since you should always assume something ISN'T copied when calling a setter/getter?

    Read the article

  • Java IDE - find all INDIRECT usages/references of a function or class?

    - by GreenieMeanie
    In Netbeans or in Eclipse, you can use "Find Usages" or "References" from the right click context menu. If a() calls b(), using the functionality from b() will show you a(). However, what I want is to be able to see some kind of tree or have an option to see all usages of a given/class or method, such that if z() calls a() that using the functionality will show both z() and a(). Any IDE plugins or external tools that can do this?

    Read the article

1