DEV Community

Grace Mihiral
Grace Mihiral

Posted on

Day 7: Splitting up planes

Today I worked on trying to figure out how I wanted to split up my current main.cpp that was getting a bit overloaded with all the tasks it was doing. I moved the packet processing into my new dp.cpp/dp.h files and created a switch class that I aim to have manage all the information about a switch so all main.cpp has to do is just create the object and run the start() method.

The current aim for making the split more formal and keeping them in separate files is mainly for readability right now since the functions in main.cpp were already quite separated and it was easy to pull things out. The other motivation was that I wanted to be able to change the switch configuration at runtime from user input kinda like a traditional CLI which I feel like will be easier with proper getter/setter functions that are a lot easier to organize in a class.

I also got to use my test cases for the first time after splitting up the 'datapath' from the rest of main() when I was making sure I didn't introduce any new bugs and it felt really nice not having to manually run everything myself. Maybe testing is helpful...

Anyway, thanks for reading :>

Top comments (0)