View Single Post
  #13   Spotlight this post!  
Unread 06-09-2009, 17:44
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Re: very basic code help

Quote:
Originally Posted by mikelowry View Post
Ok, thank you.

But what about the constructors for the Joystick and RobotDrive? Why does it make a difference wether or not they are inside the class. It compiles fine either way.
In general, it is best practice to encapsulate the state of a class (i.e. the joysticks and RobotDrive) within the class. This allows you to create multiple instances of the class safely.

It also makes it easier to debug and modify since if they are contained within the class no other objects have direct access to them.

In this case it shouldn't matter since you should only ever have a single instance of the robot class. However it is still best practice.
__________________
Eric Haskins KC9JVH
Reply With Quote