Transfer to Object-oriented Code

I’m trying to change my code to a code with classes and objects to make it more flexible and easier to change. How should I do this? What steps do I need to take first?

Transitioning to object-oriented code can be daunting if you’ve never worked with classes before, but well worth the time. The best advice I can give, besides reading C++ tutorials, is to do some pattern matching. Look at other people’s code for robotics and see how they organize their classes, and try doing the same things. You’ll get your code running in no time.

1 Like

Do you have some examples of robotics C++ codes with classes in them? I was looking at EZ-template but its a jumble of code.

WPILib is well structured and has good (and advanced) object-oriented design patterns. Not directly applicable to Vex, but learn from them

1 Like

EZ-Template is the example I learned from. I don’t have a better source, I’m afraid.

Back in the very early PIC days WPILib had a version that was in C and it was a thing of beauty.

I can also recommend it as a great base to start with to see a robot oriented platform, the WPILib team goes to great lengths to refactor to keep things clean.