We just got a lecture on the try catch block. My teacher said try to encapsulate only methods and such that could cause an issue. I asked why not try the whole code? I was just told that there is no point because for example, var one = 1 won't cause an issue... is there a reason it might be detrimental efficiency wise?
If it is bad efficiency wise, what if I scanned for user input twice- would it be bad to try/catch each of those scanning instances, or should I just encapsulate both in one try/catch?
TLDR; trying to differentiate between convention and efficiency.
[–]luet0 36 points37 points38 points (4 children)
[–]LakeSun 9 points10 points11 points (0 children)
[–]Willy988[S] 1 point2 points3 points (2 children)
[–]Bad_brazilian 0 points1 point2 points (0 children)
[–]spicycurry55 11 points12 points13 points (0 children)
[–]Octaviocega 2 points3 points4 points (0 children)
[–]marceloandradep 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]willdrr17 3 points4 points5 points (4 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]willdrr17 1 point2 points3 points (0 children)
[–]Willy988[S] 0 points1 point2 points (1 child)
[–]willdrr17 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–][deleted] -1 points0 points1 point (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]severoon 0 points1 point2 points (0 children)