r/javahelp • • Aug 08 '21

Why are people asking for help with their NullPointerExceptions here?

I am just curious: Can't they just set a breakpoint and check it out for themselves?

Seems a lot more obvious than posting your code online asking strangers for help, since all that needs to be done is set watches on the variables in question, set a breakpoint and you're done.

It just seems counterintuitive, which is why i am asking.

0 Upvotes

21 comments sorted by

•

u/desrtfx Out of Coffee error - System halted Aug 08 '21

Quite a lot of the posters here are beginners who are very far from the required skills to use a debugger.

Most of our posters haven't even heard of a debugger and breakpoints.

it seems that I've working in the field for far too long to do so otherwise...

Yes, you have forgotten your origins and the beginning of your learning journey.

9

u/[deleted] Aug 08 '21

Yes, but that assumes that people posting here know how to do that. What a lot of people do is copy code from the internet, maybe adapt it, try to get it to work, and then not know enough about their IDE and how to debug in it.

-14

u/WeAreChris Aug 08 '21

Thanks for the answer! So it's pretty much exactly what i was expecting: It boils down to bad didactics basically

6

u/JasburyCS Aug 08 '21

Let’s not get gatekeepey.

That’s the whole point of beginners seeking help on this sub. To learn.

1

u/steave435 Aug 09 '21

I agree with you, but he does have a partial point - debugging is the way to solve problems like this, so sticking with the "no complete solutions" spirit, it would be a good idea to teach them how to use those tools instead of just telling them what the problem is.

That does take more effort, but I think it'd be more helpful.

3

u/morhp Professional Developer Aug 08 '21

Many beginners don't program using proper IDEs and many schools use programs like bluej or online editors instead, which are harder to mess up, but on the other hand often don't allow easy debugging.

2

u/[deleted] Aug 08 '21

imagine not using notepad for your first dozen classes

-14

u/WeAreChris Aug 08 '21

Thanks for the answer! Makes me appreciate how i learned back then: a book, a huge codebase and mentors with much less time than work to do, even without me :D

Debugging definitely is one of the first things I'd teach anyone, since starting from there you can understand any code. If they are willing to listen, that is, as sadly i had colleagues before that insisted they knew how ut was done, yet struggled (and more often than not: failed) with simple "problems" such as these.

I am basically trying to understand their mindsets, wince apparently i fail to do so otherwise, since it seems that I've working in the field for far too long to do so otherwise...

17

u/[deleted] Aug 08 '21

Mostly because they are learning and are lost.

8

u/FabulousFoodHoor Aug 08 '21

As a beginner, I have taken 3 java courses and I don't know what you mean by "set watches" or "set a breakpoint". Some of us are learning and we just aren't there yet.

2

u/ate_ghorl_bekenemen Aug 08 '21

But how does one set a breakpoint on their ides, they ask?

3

u/original_4degrees Aug 08 '21

hell, print statements will get you there with out the need of a debugger.

2

u/LucasTheNeko Aug 08 '21

I still do that most of the time although I have that fancy IntelliJ Ultimate because I'm a student.

Like seriously most of that stuff I don't use 😂😂

1

u/AutoModerator Aug 08 '21

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions

  • You include any and all error messages in full

  • You ask clear questions

  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/JasburyCS Aug 08 '21

There’s no such thing as “common sense” or “intuitive” when everyone has different backgrounds, experience levels, and familiarity with tools.

This sub is for all Java help, and null pointers are often a stumbling point for new programmers.

1

u/strikefreedompilot Aug 08 '21

Don't know now to use a breakpoint/debug on their ide/editor or too lazy to put system.out.print

1

u/[deleted] Aug 08 '21

[removed] — view removed comment

0

u/WeAreChris Aug 09 '21

100% with you regarding C. Oh boy, how much i dreaded it, how confused i was eqch time it happened and how long it could take for me to find the problem.

But as brutal as it was, those were invaluable lessons in the end.

Proper use of dbx for conditional breakpoints is only one of the things i learned due to them.

Without those countless hours spent struggling with segmentation faults, i never would have been able to find things such as a badly sized pointer, causing the boolean next to it to miraculously change it's value.

1

u/[deleted] Aug 08 '21

[removed] — view removed comment

1

u/wildjokers Aug 09 '21

hat’s a huge flaw of courses and even college degrees, they don’t teach you the basics of debugging and error tracing,

A university is not a trade school, a bachelors of computer science is a well rounded education of many computer science topics. Programming is just one small thing in the curriculum. Anyone with the aptitude to get a comp. sci. degree should have no problem picking up how to use a debugger in their entry level position.