How many times are u supposed to indent normally? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How many times are u supposed to indent normally?

i was just wondering in a while loop how many times should i indent

2nd Sep 2017, 10:14 PM
Efe Onobrakpeya
Efe Onobrakpeya - avatar
1 Answer
0
A rule of thumb I follow is to limit indentations to 4 and in extreme cases, 5. These numbers may vary wildly depending on who comes along to maintain the code. Any more levels and the load on the reader's mind is too much. Similarly, I limit method definitions to 4-5 pages when printed on a4 paper. For anything requiring more indentation or pages, a serious work on refactoring is overdue.
2nd Sep 2017, 10:48 PM
Venkatesh Pitta
Venkatesh Pitta - avatar