APCS vs FRC

In FRC Programming, you'll use several things you've learned from AP Computer Science here, such as Object-Oriented Programming and boolean zen. But this page is titled "APCS vs FRC" for a reason- there are fundimental differences that make this page relevant. Notably:

Comments

Comments are very important— especially since you're working with other programmers. Try to make them at major/confusing parts of your code. And if you're commenting under a method header, make sure to describe what each parameter is for.

APCS teaches you two types of comments— singleline and multiline comments.

// this is a singleline comment

/*  
    this is a
    multiline comment
*/

Generally, both types of comments work fine. However, if you're writing a comment at the header of a class/method, you should use multiline comments. This is because VSC has a special feature that shows a little tooltip every time you hover/select over a method/class with a multiline comment above it.

GetInstance()

In APCS, you are taught that when you want to create an object, you use a constructor to create one. This works fine for everything, except for Subsystems.

Subsystems can potentially be very beefy— as in some of them potentially having literal thousands of lines of code. Creating multiple Instances (objects) of a subsystem isn't a good idea, especially as non-static variables will not sync between other instances. If you're thinking about making every variable static, that's both an eyesore to the compiler and everyone else.

You might be wondering how we'd use subsystems with OOP then. What if we use a single object instead of creating thousands of them? But how would we give this singular instance to the user? All you need to do is a GetInstance() method!

For a practice problem around creating a GetInstance() method go to Subsystems.

Last updated