Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Benutzername30346dDepends on what he wants to build.
What about a lovely server side rendered web app?
TafT3446dI hope you also taught him to handle every exception that you program in and try to catch everyone that could be thrown by calling code too?
For me the answer to "Why do we throw an exception?" Seems too often to be "so it's someone else's problem".
The correct answer for throwing answer is "because you cannot or shouldn't handle the error and the right to handle the error should be given for caller.
For example what would happen when caller divide by 0.
Will you print the error message? Will you provide -1 as result?
The point is that you cannot handle it in reasonable way so the right to handle the error should be given to caller by throwing exception. "
TafT3445d@mr-user that is fine but the cases I am talking about are where people say "it is the responsibility of the caller" all the way up to the operator poking at the CLI or the GUI that hides it all.
Much of the time not only do you throw but you are also the caller. Not in that line of code but often you are writing something that you call. The end user does not want to see you failing to handle a network blip or a full drive or ...
Handle all the thrown things or think about how to handle them is what I am saying.
@TafT You are right every exception should be handle in a reasonable way such as showing reconnect button when network in not available.
Sometime the only reasonable thing you can do it is to show an error message and log the exception message.
I was actually ask "If catching the exception prevent the program from crashing/exiting, will it be better to wrap all the code in try block?"
I was able to convince him why that not a good idea along my example of my past failure.
I try to give my own failure as an example (with some code) since I feel showing your actual failure prevent student-teacher barrier.
I am actually proud of myself that I can convince him why warping everything in if statement is not a good idea.
I am actually having trouble distinguishing what are the thing to teach to beginner and what thing are for advance for me? It's been over a decade since I started writing my first program so it's difficult for me. I am referencing some online course to as reference.
TafT3444d@mr-user in answer to the question of catching the answer is depends. It may make.sense for the lower level code to catch a couple of disconnections and try to reconnect before bothering the end user.
Knowing what to teach is always hard. If you bring up a tool/topic (such as exceptions) then I think need to give an overview of the good and bad bits about them. A few clear cases of what to throw and when to catch with a warning about the large gray area between the clear cases.
It's all about design, decisions and making the best choices you can for the end user after all.
I need to teach him about file IO in our next lesson after that we will go into gui programming (his main interest)
Do you think RAII (__enter__ ,__exit__ in python) is too advantage for beginner?
Of course I will need to explain what are the basic widget (textbox,button,checkbox,panel,--etc) but I am having trouble deciding which gui framework is easier for beginner.
TafT3444d@mr-user I cannot really advise on GUI stuff as I have managed a couple of decades without the need for a GUI in my work 😝
Sometimes someone else has maintained something or I have needed to integrate with semi-auto web generation thing but mostly it's been config files or CLI only for me.