r/Cplusplus • • 22h ago

Discussion Guys help

1 Upvotes

iam going to attend the infosys exam in 2 weeks but iam only able to solve easy questions in leetcode but .There they will be asking medium to hard questions (3 question to be solved in 3 hrs) .atleast 2 i need to solve to pass .SO CAN YOU GUYS TELL ME WHAT TOPICS CONCEPTS SHOULD I NEED TO COVER ANY TIPS (C++)


r/Cplusplus • • 15h ago

Discussion Updating 21 year old C++ software

33 Upvotes

This is just a dump of what I have been doing lately post. Feel free to discuss.

So I recently undertook the task of updating a piece of software that I designed and developed in 2005. It was first written in C++03 using QT 3.3.6 for the GUI. This ran on CentOS 4.3. Over the years as hardware and OS versions were refreshed it was updated to QT 5.9 but still the same logic written in C++03. Now we are on a system that supports C++23 and QT 5.15.

The software runs on all the nodes of our mid scale distributed systems. Acts as a control interface, status display and master logging software and site UPS interface so the system goes down properly when signaled. That is just a top level list of what is crammed into this this one piece of software. Oddly enough it was meant to just display the status of the system in a simple red or green set of indicators. Yeah, scope creep got the better of this one.

Myself and others have hacked in new functionality, updated other functionality and removed old stuff over these 21 years. However, we have kept to the logic patterns that were laid down in C++03. Which is to say this was more C with classes than pure C++. But a lot of C++ in 2005 was still C with classes. It was just the times. Interesting side note: We practice a form of obsoleting code that does not delete old code. It gets commented out and the new code is under it and comments explain why the change was made. So there is 21 years of this stuff commented out. Yeah finally deleting that stuff as this is going to be new major version.

So I have been rebuilding the program as a modern C++23 app using QT 5.15 as the GUI. Moved from a bunch of global variables to a shared data object. Making the app a data driven system that can run headless now if needed. Configs have moved from custom text file format to JSON. A lot of custom stuff executed by script files called by systems calls has been moved from hard coded to part of the JSON data.

So far I have pruned over 4000 lines of code, added about 2000 lines, rewritten around 5000 lines, removed entire classes and redesigned how the app works underneath without changing the GUI appearance which the customers are very use too. Networking has moved from broadcast UDP ( i don't remember why it had to be that way 21 years ago but there was a tech reason) to Multicast. It has been a wonderful journey so far. The challenge is when we drop it in it has to do everything it did before and be a seamless update. So offline testing is going to be extensive.

Things I knew already and this effort re-enforces. 1. Careful with what you write it will come back to haunt you. 2. There is never enough comments. 21 year is a long time and I just don't remember some of the original reasons for things to work certain ways. 3. Software Life Cycle Support can be rewarding and a curse at the same time.

After 35 years of software engineering and systems engineering specializing in mid to large scale distributed systems I can say it never gets boring. At least it is not ADA and COBOL anymore that I work on.