2 ms·
Write the smallest usable chunks of code and turn them into functions/methods. Add input parameter testing, exception handling and have outputs clearly defined
by davismwfl 11y ago
Write the smallest usable chunks of code and turn them into functions/methods. Add input parameter testing, exception handling and have outputs clearly defined. Write tests for each of these small chunk of code. Group these small chunks into groups and build up modules. At each module level write test code that executes all the integrated paths and keep working your way up.
Of course what I wrote is a bit of an oversimplification but overall it is how I write real production code that must be reliable.
In general I usually wind up with far more test code then executing production code if I do this all. But like everyone I will get lazy on some of it, which is usually where I find some error later.
Also, this basic design lends itself to either a functional or OO style of coding. Modules need not be classes but classes can certainly help you build modules.
Find people that will give you feedback, even if they aren't in you immediate network or peer group. It is amazing how helpful people can and will be if you just ask, respect their time and be honest about your level of experience and understanding.