|
Re: Procedural v Object Oriented Programming
Do you guys have a programming mentor? If you do get his advice and see what he thinks. In my experience programming for FIRST robots I have used a mix of procedural and object oriented in C++ (in this case I consider procedural calling a function inside the class which the robot started to run, because with the cRIO there must be at least one class).
I do procedural calls in the code to break up the main teleop loop, so I would have a MecanumDrive() function which is called, and then that calls an OO class we wrote to get joystick information. I would create new classes if it were for sensors which we would have multiple of (our sensors for the Swerve Drive is an example), or for something we might use in future years (a class to interact with an Xbox 360 controller is an example). That way there is less repetitious code.
With that method of programming in mind, my suggestion is to use OO to program the robot, because it means that the code is better organized and therefore can be more easily fixed at competitions and during testing. And in my experience OO code has proved to be more understandable for people looking at the code because you can have calls like "FrontSensor->GetAngle();" which when reading it you can see that you are getting the angle of the front sensor.
That is just my 2 cents though.
__________________
- Ian McInerney
Alumni & Mentor, Team 2022 Titan Robotics
Junior, Iowa State University majoring in Electrical Engineering
|