Re: programming style

new topic     » goto parent     » topic index » view thread      » older message » newer message

The way I comment things:
If a function does things in an orderly fashion (which most of mine do)

    #code#
--1. what this block does (in general terms)
--==============================
    --1.1 what this sub block does 
   #code#
          --what this small section does
          #code#  
          #code#
    #code#
   
    --1.2 what this sub block does 
    #code#  ---what this line does
    #code#  
    #code#  

--2. what this block does (in general terms)
--==============================
etc...

Of course, the granularity of the subheadings is generally high - when
it gets down to the nitty-gritty, there's small comments in places
where code may be difficult to understand (eg  combining 3 subslices
of odd sequences given index values stored in other sequences) saying
what it does.

The high-level headings and subheadings tell you what the code is
doing. It's much easier to look at a 5-line section of code, knowing
what just that section does, than looking at a 50-line function,
knowing in general terms what the whole things does.





-- 
MrTrick

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu