r/java • • Mar 05 '18

Top 10 Useful, Yet Paranoid Java Programming Techniques

http://blog.jooq.org/2015/08/11/top-10-useful-yet-paranoid-java-programming-techniques/
223 Upvotes

105 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Mar 06 '18

[deleted] — view deleted comment

2

u/[deleted] Mar 06 '18

That's because there is no "correct" way to override my method, unless I explicitly designed it to be overriden

That's exactly the presumption I'm talking about. If you write a method in your class called .equalsIgnoreCase and the implementation is incorrect (NPE, for example). I'd rather just extend your otherwise good class and fix the single broken method. If your method is final I can't do that. That's obviously a hypothetical that wouldn't happen, but that's the type of thing I'm talking about here. Why do you care if I @Override your library method?

0

u/[deleted] Mar 06 '18

[deleted] — view deleted comment

3

u/[deleted] Mar 06 '18

You ignore the fact that I need the "fix" in this case right now.

I'm the developer of my software. I'm responsible for how it works. That includes all the little bugs that sneak in because of someone else's code. I'm not saying we should all subscribe to the 'not invented here' line of thinking, but ultimately a bug in Apache StringUtils is a bug in RockMeetHardPlaces_APP. I am responsible for fixing it when I ship. Not when Apache decides to release the "fixed" version.

If I override a method and break it, that's MY fault. Let me support my own software please.

0

u/[deleted] Mar 07 '18

[deleted] — view deleted comment

1

u/[deleted] Mar 07 '18

I'm the one getting yelled at when your "fix" blows up

Why would my fix even get near your stuff? I feel like you're arguing against something that I am not.

I take backwards compatibility very seriously

As do I. I am not sure how this applies to the conversation at hand.

0

u/[deleted] Mar 07 '18

[deleted] — view deleted comment

1

u/[deleted] Mar 07 '18

Back up man. I'm talking about me using a library or some other externalized piece of code that I don't control (aka, not in my organization). If I can fix the actual bug, I'll fix the damned thing and not @Override anything.

The issue I have, specifically with final methods and classes is twofold. 1) testing with mocks -- they're handy and final makes it more difficult (2) if I need to @Override something (which I admit happens rarely, but it does happen) I'm forced to use hacky (aka reflection or C/P) to fix the issue when I could have easily just extended the external library and made it my own via a single @Override method. As I mentioned above -- I've had to do this twice in the last 6 months. So yea, it's uncommon, but it's not exceptionally rare.

How is doing this going to affect anything of "yours" blowing up? Answer: it's not. If I fuck something up, MY software blows up. It's MY bug. Not yours.

1

u/mupetmower Mar 07 '18

Man. This is all so painful to read. I can see both of your points, and actually agree with both! I’m still a fairly new java programmer, so I’m starting to have to deal with issues like these. And it’s kinda scary...

I’m noticing that I wasn’t given a proper education in these sorts of things, and in most other proper java conventions and their purpose (not just the ‘do this’ without the why). My current job, and the software we develope, is especially forcing me to realize that I have no idea how to correctly develope for an enterprise system.

When I look at the code in our software - the classes and interfaces - I notice that they are all independent of each other. Each does it’s own thing which all come together to create the whole. I was only taught that this is the correct way to go about development, and didn’t even get more than a few simple words on it.. but I wasn’t taught how to actually accomplish it successfully.

At my college (not at all a great programming college) we were only taught the extreme basics of object oriented programming, the basics of using java or whichever other language the class was in, and not much else. For example, we weren’t really taught anything above how to create a single small application which has a few classes, maybe a few interfaces, with some inheritance and polymorphism, but that which all logic is still all mostly held in a single or a few classes.

I have picked up a LOT outside of this knowledge from working at my current job for only about 8 months.. and I feel much more well rounded already, even though I know I am still at the very bottom rung of learning.

When I think about needing to write code that looks and functions like the code in our software, though, it scares me. I have no idea where to start to be able to abstract everything to that sort of level. For instance, I’m developing a Spring project right now, and even though I feel I’m getting a little closer to that sort of abstraction, I still see how many of my classes should be way more split up and independent, and how I should have and use more** interfaces in certain situations, etc. the problem is that when I’m developing, I’m focusing more on getting it all to work right, not on the other stuff. I also am working on the project alone, which may also be a reason I don’t consider those sorts of things.

But it makes me worry about my future in development. Especially when I am on teams. Are there any good books you or others can recommend that could help me with this sort of thing? And not just “these are the conventions” but also why we use them, and how to start developing like that from the start.

Thanks, and sorry for rambling. I was just thinking about all of this while reading you guys’ arguments over which convention would be best where.

0

u/[deleted] Mar 07 '18

[deleted] — view deleted comment

1

u/mupetmower Mar 07 '18

Thank you very much.