Timeline for Print 10 × 10 square of X and O characters, split diagonally
Current License: CC BY-SA 3.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 13, 2017 at 12:40 | history | edited | CommunityBot |
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
|
|
Sep 4, 2016 at 1:09 | history | edited | Pimgd | CC BY-SA 3.0 |
added 17 characters in body
|
Sep 3, 2016 at 23:16 | comment | added | carlossierra | This was brilliant. It's always enlightening to see such an structured way of approaching a program refactor. Thanks for a very interesting read. | |
Sep 3, 2016 at 14:51 | comment | added | Pimgd |
@FlorianF I designated no meaning to ft because it was too hard to grasp the meaning of the variable. Leaving ft in would mean describing each iteration in the for loop, which means you'll go over 10 lines of code (which means you'd just better off directly writing the output to stdout a la 200success's remark)
|
|
Sep 3, 2016 at 12:14 | comment | added | Florian F |
I believe you misunderstood the meaning of ft . It looks like it meant "first time in the inner loop". At that time the OP adds all the required X's. The transition from s += "XX"; ft = false; to s += "X"; ft = s.length() < 3; and removing the conditional break is a major change in the algorithm and not a small optimization. And s.length() < 3; should be replaced by j < 3 . At that point you could as well rewrite the whole program. But besides that, nice write-up explaining common pitfalls.
|
|
Sep 3, 2016 at 11:34 | comment | added | Pimgd | @MarkusMitterauer I figured that was covered in the other answers already. | |
Sep 3, 2016 at 10:10 | comment | added | Markus Mitterauer |
Great and detailed job. I just would like to add one remark on the final result: You shouldn't use String concatenation in loops, but rather use StringBuilder because concatenation of immutable Strings is a quite expensive operation, StringBuilder on the other hand is made for that.
|
|
Sep 2, 2016 at 14:55 | history | edited | Pimgd | CC BY-SA 3.0 |
add bottom link
|
Sep 2, 2016 at 14:46 | history | edited | Pimgd | CC BY-SA 3.0 |
I cannot stop rephrasing
|
Sep 2, 2016 at 14:37 | vote | accept | Shammy | ||
Sep 2, 2016 at 13:51 | history | edited | Pimgd | CC BY-SA 3.0 |
added 20 characters in body
|
Sep 2, 2016 at 13:22 | history | edited | Pimgd | CC BY-SA 3.0 |
added 13 characters in body
|
Sep 2, 2016 at 12:04 | history | edited | Pimgd | CC BY-SA 3.0 |
added 127 characters in body
|
Sep 2, 2016 at 12:03 | comment | added | Mast♦ | Not only is the resulting code more understandable, it's also a direct result of the original code being optimized step-by-step keeping it understandable for the author of the question as well. On top of that, there is no longer an awful amount of needless repetition. Code should never be needless. This answer shows how it's done. | |
Sep 2, 2016 at 11:59 | history | answered | Pimgd | CC BY-SA 3.0 |