How to know whether to create a general system or to hack a solution

Posted by Andy K on Programmers See other posts from Programmers or by Andy K
Published on 2014-08-25T14:18:52Z Indexed on 2014/08/25 16:27 UTC
Read the original article Hit count: 1406

I'm new to coding , learning it since last year actually.

One of my worst habits is the following:

Often I'm trying to create a solution that is too big , too complex and doesn't achieve what needs to be achieved, when a hacky kludge can make the fit.

One last example was the following (see paste bin link below)

After explaining my issue, one nice person at stackoverflow came with this solution instead

When should I keep my code simple and when should I create a 'big', general solution? I feel stupid sometimes for building something so big, so awkward, just to solve a simple problem. It did not occur to me that there would be an easier solution.

Any tips are welcomed.


© Programmers or respective owner

Related posts about algorithms

Related posts about code-quality