3 ms·
So... you don't indent your bracket blocks?
by frodowtf 3y ago
So... you don't indent your bracket blocks?
- revskill 3y agoAlgorithm to read scope: - Step 1: Find open bracket - Step 2: Find closed bracket With indentation, the algorithm now becomes: - Step 1: Find something which seems to open a scope. - Step 2: Scan all indentation level until it's done. The difference is huge here.
- xigoi 3y agoStep 1: Find an indent increase. Step 2: Find the first place where the indent becomes lower. It's not hard, human vision is naturally designed for this. What is hard is finding a matching bracket when the code is not indented properly.
- frodowtf 3y agoAlgin your method to the top of your screen. Now scroll one more line down. According to your algorithm, it's now impossible to know which line belongs to which scope. I have a different algorithm: - Find first indented line - Find next unindented line If that does not work for you, your code is bad.
- polotics 3y agofinding open and closed brackets is a massive chore in mis-copied code, so indeed having scope open by spaces makes things very clear and non-ambiguous. Using whitespace for readability and not using it for scope control is one of the many bugs in the design of programming languages like Java. In my very humble opinion.