Exceptional coding style

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Jan 15 08:10:40 PST 2013


On Tue, Jan 15, 2013 at 12:01:46PM +0100, Chris wrote:
[...]
> The spacing section is exactly the coding style I use, and omitting
> the curly braces will rather sooner than later lead to more work.
> Also, "a function should only do one thing" has proven to work for
> me. Although there might be a slight performance penalty if you have
> more function calls, code maintenance is by far easier.

+1. Premature optimization is the bane of aspiring programmers. Code
maintainability should be foremost; merging functions for "performance"
should only be done after extensive profiling has proven that having too
many function calls is the bottleneck.

Too many projects waste too much time "optimizing" the code, with no
proof whatsoever that said "optimizations" are actually helping
performance, with the result that the code is fragile and hard to
maintain, thus costing much more time & effort than it should.  What
programmers habitually blame for performance bottlenecks are usually red
herrings; the real bottlenecks are rarely where people imagine they are.
You don't know until you actually profile the code.  (I learnt this the
hard way.)


T

-- 
Those who don't understand Unix are condemned to reinvent it, poorly.


More information about the Digitalmars-d mailing list