Intro to FRC Programming - Romi
  • INTRODUCTION
    • Overview
    • Important Links
  • 💽Setup
    • Setting up the Romi's Software
    • Downloading Essential Tools
    • APCS vs FRC
  • How To Code in VSC
    • VSC- Intro
    • A Tour Through VSC
    • Creating a Regular Java Project
  • Intro to Java
    • What is Java?
    • Beginning Steps
    • 🟩Fundimentals of Java
      • Variables
      • Operations
      • Methods
      • Comments
      • If Statements and Conditions
      • Boolean Zen
      • Loops
      • Challenge- Create a Box House
    • 🟨Advanced Concepts
      • Objects
      • Scanners
      • Null Objects
      • Arrays
      • Errors
      • For-Each Loops
    • 🟥Object Oriented Programming
      • Basics of OOP
      • Instance Classes
      • Static Classes
  • 🕑Romi Curriculum- Timed Base
    • Romi Curriculum- Introduction
    • Creating a WPILIB Project
    • Running Your Code
    • The Robot Class
    • Subsystems
      • RomiDrivetrain
    • Cool stuff i will rename this category later
      • Spark Motors
      • PIDs
      • External Controllers
      • Encoders
  • 🖥️Romi Curriculum- Command Based
    • Command Based Code
    • RobotContainer
    • Commands
    • CommandScheduler
  • UNRELATED IMPORTANT CODING KNOWLEDGE
    • Constants
  • SAMPLE CODE
    • Tank Drive Example
      • RobotContainer
      • TankDriveSubsystem
      • MoveRobotCommand
    • Worktop Systems Sample Java Code
      • Belt Elevator Sample Code
      • Rotating Arm Sample Code
Powered by GitBook
On this page
  • Comments
  • GetInstance()
  1. Setup

APCS vs FRC

PreviousDownloading Essential ToolsNextVSC- Intro

Last updated 2 months ago

Read this page only if you took some sort of APCS or APCS-equivelant JAVA course that covers Object Oriented Programming.

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()

This will make much more sense if you understand the basic coding structure of FRC Programming. Come back to this page after you've read Subsystems AND Commands.

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.

💽