fredholmP / MNXB01-FinalProject

Final Project for the course MNXB01 at Lund University 2022.
Apache License 2.0
0 stars 2 forks source link

C++ Feedback #6

Open EinarElen opened 2 years ago

EinarElen commented 2 years ago

Hi everyone,

here is some feedback on the C++ part of your project that I hope might be helpful for you. Note: These are not corrections that you need to do, its just for the future!

On the ChrisCode part

fredholmP commented 2 years ago

Thank you for your feedback!

I agree that using external libraries do handle the dates would have been much better, thank you for the suggested library! If I had more time to look more carefully at the csv-parser libraries using those instead of my own implementation would probably also have been much better.

As for some of the points, I agree with that the constructor was way too long. Due to some turn of events, I was not able to spend as much time as I wanted on all the parts of the project and “polishing up” the constructor by implementing member functions for i.e splitting strings and setting up vector structures was one of those things.

As for the confusion about the “rootDataReader.h”, that was not intended to be included in the main.cpp-file, the “dataReader.h” was. When writing the code, I first experimented with using Root in a normal C++ file by including things and using some flags I found on some of the Root forums to pass to the g++ compiler, but after that didn’t work, I decided to try to use a Root macro instead.

Since Root did not play nicely with the translation units, I put everything into the rootDataReader.h-file to be able to include it into a root macro. When trying to debug some issues with the root macro, I added an intermediate step with processing the data in a normal C++ file (the main.cpp file) to see what was wrong. I eventually gave up on using one entire Root macro, but I must have forgotten to change the include statement to dataReader.h. I also probably did not notice since the files are very similar (although not exactly, dataReader.h has a different implementation of getting the first and last year of measurements). This might also explain why I ran into a lot of issues with try{}catch(…) statements not behaving as expected when testing changes to the dataReader.cpp-file when trying to locate what caused “ segmentation errors”.

The issues with doing everything in a root macro turned out to be related to some really strange behaviour where i.e C++ code on Aurora would give errors for very simple code (such as “Hello World” scripts giving errors about missing libraries) that worked just fine when copy-pasted and ran on my local machine. (I had the Gcc module on Aurora loaded)

I had a similar situation with ROOT on Aurora where I located the errors to be caused from i.e trying to access elements of vectors. This even appeared in very simple test macros that worked just fine on my local computer (I tested both with the .L and .L +). I also made sure that I had ran the script for setting up Root on Aurora when trying to identify these errors. These issues are the reason that I added the “localRoot” folder in the top directory to be able to run Root locally.

I am definitely going to keep in mind to delete code I am not using henceforth to avoid these kinds of issues.