I can't even remember all the times this has hit me. Often times, I'll be working on a module, and the code will just be ugly, hard to understand, hard to write. Then, I'll make a small change to the organization of the data structures I'm working on (normally, literally a change in the set of data that is a field of one struct or another, or a parameter to one function or another) and suddenly everything will become clear. These days, if code is getting ugly, the first thing I try to do is look at whether the relevant data is logically grouped, because nine times out of ten, this ends up being the problem. I only wish I was better at getting it right the first time.
I can't even remember all the times this has hit me. Often times, I'll be working on a module, and the code will just be ugly, hard to understand, hard to write. Then, I'll make a small change to the organization of the data structures I'm working on (normally, literally a change in the set of data that is a field of one struct or another, or a parameter to one function or another) and suddenly everything will become clear. These days, if code is getting ugly, the first thing I try to do is look at whether the relevant data is logically grouped, because nine times out of ten, this ends up being the problem. I only wish I was better at getting it right the first time.