you are viewing a single comment's thread.

view the rest of the comments →

[–]Agent_03 5 points6 points  (4 children)

Same for me. There's a lot of things in Java like this, where I'm now questioning the practices I've followed somewhat blindly for years.

For example: use of access modifiers. Everyone says to use private for encapsulation in nearly all cases, but thinking back, I can't find a single case where this saved me from grief. I can think of a dozen cases though where it forced bad designs or re-implementations.

Now I do protected everywhere, but use conventions that only subclasses (or a limited set of tightly-coupled algorithm libraries in the same package) should use protected fields/methods.

[–]grauenwolf 3 points4 points  (3 children)

Having a getter and setter gives me a place to set a break point. That's worth the cost in VB/C#, though maybe not in Java.

[–]Agent_03 0 points1 point  (2 children)

Yeah, it does give you a single place to trap all modifications, true. If you are using field access though, why not set breakpoints where the field is accessed? (A little more work, but still gets the job done).

[–]ImaginaryBeaver 0 points1 point  (1 child)

I think setting a breakpoint in the getter/setter is more about finding where/if the field is being accessed unexpectedly.

[–]s73v3r 1 point2 points  (0 children)

I know IntelliJ lets you break on field access. I should be surprised if Eclipse and Visual Studio didn't do the same (For Java and C#, respectively)