Featured Posts

ITE in AIE: IT Companies and Engineers in AI Era

IT Companies Change or die: Apps? AI is doing it all R&D ? Companies must have R&D department to do what AI is not doing yet. Softwa...

07 April, 2025

No Such Thing as a Perfect Format for Source Code

Some people think there can be a perfect format for source code, but Dan doesn't think so.

Since childhood, started learning programming, Dan faced this issue in his mind, how to format the levelling of conditions in 'if' clause perfectly, but he found out that there's no such thing.

Consider this complex 'if' clause condition:
if ((A.Name==B.Name)&&(A.age>B.age||A.age==B.age))

People with a fixed mindset will put spaces everywhere, similar to this:
if (( A.Name == B.Name ) && ( A.age > B.age || A.age == B.age ))

But Dan thinks it should be situation-based, the point is to make the code clear and easier to read, not rules, he would put it like this, looks better when avoid some spaces for grouping:
if ((A.Name==B.Name) && (A.age>B.age || A.age==B.age))

Dan's way is better with the 3 conditions clearly seen. So there are 2 types of people: Rule-based people, Tactical people😏

No comments:

Post a Comment