Timeline for Breaking down the operations when auto-casting gets complex
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 17, 2017 at 14:46 | comment | added | Kevin Workman | @jameslarge This is code I threw together without really thinking about it. Imho the actual code is secondary to the real "meat" of the answer, which is the exercise in general. Getting hung up on the precise syntax of the code (which is based on example code from the question anyway) is missing the point of the question and my answer, I think. | |
Aug 16, 2017 at 17:17 | comment | added | Solomon Slow |
Smaller is not always better. If it was, then we'd all be writing assembly language. IMO nPlusOne is slightly harder to read than (n+1) . Also, the goal of the exercise is to compare the number of digits in n to the number of digits in (n+1) , but the word "digits" appears nowhere in your "simpler" example.
|
|
Aug 16, 2017 at 12:57 | comment | added | Michel Billaud |
It's about seeing what happens in some parts of the expression (namely: n+"" ), not necessarily refactoring it into many variables until they're all dead.
|
|
Aug 14, 2017 at 16:02 | comment | added | Kevin Workman | @ncmathsadist I'm really not sure what your point is. If this was production code, I might agree with you. But this is code meant to teach the process of breaking things down into smaller steps. Smaller is better in this context. | |
Aug 14, 2017 at 13:33 | comment | added | ncmathsadist | but not too small. | |
Aug 14, 2017 at 2:17 | comment | added | Kevin Workman | @ncmathsadist You understand that the point of this exercise is to break it down into smaller steps, right? And that this type of code is meant for learning and not for production? | |
Aug 14, 2017 at 1:14 | comment | added | ncmathsadist | too many variable names. | |
Aug 13, 2017 at 20:43 | comment | added | Kevin Workman | @ncmathsadist What exactly do you mean by "namespace clutter" in this context? I would assume these are all local variables inside a function. Also please keep in mind that the point of this exercise is to get the student to a point where they no longer need to do this. Code you write while learning != code you write in real life. | |
Aug 13, 2017 at 20:12 | comment | added | ncmathsadist | You have broken this into steps that are too small. There is a lot of namespace clutter here. | |
Aug 9, 2017 at 17:06 | history | answered | Kevin Workman | CC BY-SA 3.0 |