When code becomes complicated during development, how do you handle it?

WooSeong
2 replies
During development, complex logic inevitably emerges. While I try to keep things as simple as possible, there are times when no matter what I try, I can't make the code simple. It makes me uncomfortable whenever I encounter these situations. How do you all handle development in these situations? I suppose things like adding comments would be one approach.

Replies

onewindow
I think it’s difficult to completely eliminate complex logic. I also try to simplify my code as much as possible, but realistically there are times when that’s just not feasible. In those cases, I break the logic down into smaller units and clearly define the role of each one. If there are inevitably complex parts, I supplement them with appropriate comments and documentation so that others (or even my future self) can easily understand them later. Sometimes it’s also a good idea to hide or abstract the complexity, so I keep the possibility of refactoring open to polish the structure further down the line.
Dongyoung Kwon
If the problem is complex, some complexity in the code is fine. Just make sure it’s understandable! 😄
Share