Click here to Skip to main content
15,884,176 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: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
Maximilien17-Oct-23 9:16
Maximilien17-Oct-23 9:16 
GeneralRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
Nelek17-Oct-23 11:47
protectorNelek17-Oct-23 11:47 
AnswerRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
Greg Utas17-Oct-23 15:10
professionalGreg Utas17-Oct-23 15:10 
AnswerRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
jschell18-Oct-23 6:08
jschell18-Oct-23 6:08 
GeneralRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
Maximilien18-Oct-23 7:30
Maximilien18-Oct-23 7:30 
AnswerRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
BernardIE531718-Oct-23 10:39
BernardIE531718-Oct-23 10:39 
AnswerRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
tharkaway19-Oct-23 3:13
tharkaway19-Oct-23 3:13 
AnswerRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
WPerkins19-Oct-23 3:31
WPerkins19-Oct-23 3:31 
I have done this many times, doing it now for my current company. Old C code from the early 90s written to run on another OS (embedded) tweaked and tweaked into unmaintainability extreme.
At the end of each phase the programming should produce exactly the same output/changes.
My description here is for C, what I am working on now; it will work for any language(s).

Phase 1 - find and deal with global variables. This is a judgement call as some things are properly global, some are just laziness on the part of some programmer. One tactic, make a structure, move them there to get them all organized. Refer to the globals only as part of the structure and pass only pointers to the structure. Control, you want to get control of the globals or at least make it clear where they are getting changed.
In C/C++ a function that gets the structure read only will be "const", if it changes a value then not const, get it?

Phase 2 - find duplicate (or near duplicate) code and create functions or subs to perform. Replace this code with calls. I call this "mining functions', you are digging them out of the code. Repeat till there are not more easy targets to mine. You can repeat this later in the process.

Phase 3 - now look for unexecutable code - in large systems there will often be some. In the system I am working on now there were subs that never get called, functions that got called but the return values were ignored or tossed away. These really were changing global variables - that would be discovered in Phase 2, right?

Phase 4 - look for bad algorithms and processes. for loops, while loops are the first targets.
Repeat until you've done enough.

Each phase makes it easier to see what to do int the next.
GeneralRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
Maximilien19-Oct-23 4:36
Maximilien19-Oct-23 4:36 
GeneralRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
charlieg19-Oct-23 9:39
charlieg19-Oct-23 9:39 
AnswerRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
Ian Brockbank19-Oct-23 4:36
Ian Brockbank19-Oct-23 4:36 
GeneralRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
Maximilien19-Oct-23 4:43
Maximilien19-Oct-23 4:43 
GeneralRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
charlieg19-Oct-23 4:55
charlieg19-Oct-23 4:55 
AnswerRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
charlieg19-Oct-23 4:54
charlieg19-Oct-23 4:54 
AnswerWhat about the associated costs of V, V & T ??? Pin
etkid8419-Oct-23 6:02
etkid8419-Oct-23 6:02 
GeneralRe: What about the associated costs of V, V & T ??? Pin
charlieg19-Oct-23 9:39
charlieg19-Oct-23 9:39 
AnswerRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
rxantos25-Oct-23 6:18
rxantos25-Oct-23 6:18 
GeneralRe: Strategies to upgrade antiquated C and C++ code to some more modern coding practice. Pin
Maximilien25-Oct-23 6:34
Maximilien25-Oct-23 6:34 
GeneralIn-place OS upgrade - Linux vs Windows Pin
dandy7217-Oct-23 4:40
dandy7217-Oct-23 4:40 
GeneralRe: In-place OS upgrade - Linux vs Windows Pin
abmv17-Oct-23 4:52
professionalabmv17-Oct-23 4:52 
GeneralRe: In-place OS upgrade - Linux vs Windows Pin
dandy7217-Oct-23 5:09
dandy7217-Oct-23 5:09 
GeneralRe: In-place OS upgrade - Linux vs Windows Pin
Jeremy Falcon17-Oct-23 5:38
professionalJeremy Falcon17-Oct-23 5:38 
GeneralRe: In-place OS upgrade - Linux vs Windows Pin
pkfox17-Oct-23 22:01
professionalpkfox17-Oct-23 22:01 
GeneralRe: In-place OS upgrade - Linux vs Windows Pin
OriginalGriff17-Oct-23 4:54
mveOriginalGriff17-Oct-23 4:54 
GeneralRe: In-place OS upgrade - Linux vs Windows Pin
dandy7217-Oct-23 5:02
dandy7217-Oct-23 5:02 

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.