Click here to Skip to main content
16,004,529 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Legacy Code Documentation Pin
0x01AA31-Jul-24 9:01
mve0x01AA31-Jul-24 9:01 
GeneralRe: Legacy Code Documentation Pin
kmoorevs31-Jul-24 9:16
kmoorevs31-Jul-24 9:16 
GeneralRe: Legacy Code Documentation Pin
Greg Utas31-Jul-24 10:36
professionalGreg Utas31-Jul-24 10:36 
GeneralRe: Legacy Code Documentation Pin
trønderen31-Jul-24 11:31
trønderen31-Jul-24 11:31 
GeneralRe: Legacy Code Documentation Pin
Jeremy Falcon31-Jul-24 11:51
professionalJeremy Falcon31-Jul-24 11:51 
GeneralRe: Legacy Code Documentation Pin
charlieg31-Jul-24 11:10
charlieg31-Jul-24 11:10 
GeneralRe: Legacy Code Documentation Pin
trønderen31-Jul-24 11:22
trønderen31-Jul-24 11:22 
GeneralRe: Legacy Code Documentation Pin
trønderen31-Jul-24 11:21
trønderen31-Jul-24 11:21 
Most developer document the wrong things. Far too often, they repeat what the code line says, whether like "Here we set i to the value 5" or repeat the parameters of the method heading, "explaining" e.g. "numberOfApples: The number of apples".

Or, when asked for more high level, code independent documentation, they present a block chart with Application, Database and Network modules.

What other developers need lies in between: A documentation of the purpose of each code module, of its interaction with other modules. Replace 'module' with 'class' as appropriate. The data structures - how they are interlocked, what they represent as a whole - that usually means, across several object classes.

To draw a line: I want off line - in the sense: off the code lines - documentation to go down to the deepest level where it is still independent of the programming language. You should be able to build those modules, those data structures, in Python, in C++, even in Visual Basic. You document the interfaces between modules, not only the syntax (name, parameters) but the dynamics as well. That will help the next code maintainer on the right track! And, these interactions are far more stable than the individual code lines; you can make a lot of changes without invalidating the documentation. Every now and then it may need to be extended with new interactions or parameter options, yet all the old stuff remains valid.

When you get down to code, you may of course add code comments - but without repeating the off code line documentation; there is no need to. Obviously, you should avoid 'Here we set i to 5' style comments, and you should use descriptive type and variable names. When you delete code lines, you delete the accompanying comments. When you change code lines, you change the accompanying comments. End-of-line comments (lined up at col. 70 or 80 not to blur the code) is a lot better for keeping them up to date than pushing them to the top of the method.

But these code comments are far less essential. You read them after you have studied all the off line documentation, and know the interactions, the data structures, the interfaces. What is left is to understand how these interfaces are realized, within a single module/class. That is usually a far simpler task than grokking the structure of the entire program system as a whole. I do like to have (i.e. both make and read) code comments, but if I could have a choice between code comments and a system documentation from immediately above the programming language dependent level and upwards, I'd gladly take the second. I very rarely have that option.

Bonus rant: I wish that code designers to a much larger degree would forget which programming language they are designing code for. Far too often, I see code that serves more as a schoolbook example of how to use that new feature in the latest language revision, than to illustrate an issue in the problem to be solved. Not only should documentation be language independent, so should a lot more program code. We are here to solve problems, not to boast our intimate knowledge of the latest language definition.
Religious freedom is the freedom to say that two plus two make five.

GeneralRe: Legacy Code Documentation Pin
charlieg31-Jul-24 12:02
charlieg31-Jul-24 12:02 
GeneralRe: Legacy Code Documentation Pin
jana_hus31-Jul-24 15:57
jana_hus31-Jul-24 15:57 
GeneralRe: Legacy Code Documentation Pin
charlieg1-Aug-24 2:14
charlieg1-Aug-24 2:14 
GeneralRe: Legacy Code Documentation Pin
Joe Fallon1-Aug-24 7:33
Joe Fallon1-Aug-24 7:33 
GeneralRe: Legacy Code Documentation Pin
charlieg1-Aug-24 9:30
charlieg1-Aug-24 9:30 
GeneralRe: Legacy Code Documentation Pin
PIEBALDconsult31-Jul-24 17:17
mvePIEBALDconsult31-Jul-24 17:17 
GeneralRe: Legacy Code Documentation Pin
Peter Jamieson1-Aug-24 0:39
Peter Jamieson1-Aug-24 0:39 
GeneralRe: Legacy Code Documentation Pin
charlieg1-Aug-24 2:18
charlieg1-Aug-24 2:18 
GeneralRe: Legacy Code Documentation Pin
Dr.Walt Fair, PE1-Aug-24 7:26
professionalDr.Walt Fair, PE1-Aug-24 7:26 
GeneralRe: Legacy Code Documentation Pin
trønderen1-Aug-24 9:00
trønderen1-Aug-24 9:00 
GeneralRe: Legacy Code Documentation Pin
Dr.Walt Fair, PE1-Aug-24 9:12
professionalDr.Walt Fair, PE1-Aug-24 9:12 
GeneralRe: Legacy Code Documentation Pin
charlieg1-Aug-24 9:36
charlieg1-Aug-24 9:36 
GeneralRe: Legacy Code Documentation Pin
Dr.Walt Fair, PE2-Aug-24 5:16
professionalDr.Walt Fair, PE2-Aug-24 5:16 
GeneralMy New Friend Pin
BernardIE531730-Jul-24 21:22
BernardIE531730-Jul-24 21:22 
GeneralRe: My New Friend Pin
CPallini30-Jul-24 22:51
mveCPallini30-Jul-24 22:51 
GeneralRe: My New Friend Pin
BernardIE531731-Jul-24 2:22
BernardIE531731-Jul-24 2:22 
GeneralRe: My New Friend Pin
raddevus31-Jul-24 9:37
mvaraddevus31-Jul-24 9:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.