Programming Guide
This guide provides an overview of key programming concepts in Synthiam ARC, focusing on classes, methods, and the importance of case sensitivity.
What is a Class?
In both JavaScript and Python, a class
is a blueprint for creating objects. A class encapsulates data for the object (properties) and methods to manipulate that data. It's a way to bundle data and functionality together.
What is a Method?
A method
is a function defined within a class that operates on the data contained in the class. Methods are used to define the behaviors of an object. The method is invoked on an instance of the class, allowing it to access and modify the properties of that instance.
Class.Method() Notation
In Synthiam ARC's context, when you see a notation like Servo.setServoPosition()
, it means the setServoPosition
method is being called on the Servo
class. This method would typically be used to control a servo's position in a robotic project.
The period (.
) separates the class name from the method name, indicating that the method belongs to the class.
Case Sensitivity
Both JavaScript and Python are case-sensitive languages. This means that servo
, Servo
, and SERVO
would be considered different identifiers. Therefore, it is crucial to use the exact case as defined in the Synthiam ARC documentation when referring to classes and methods.
Example in JavaScript
class Servo {
static setServoPosition(position) {
console.log(`Setting servo position to ${position}`);
}
}
// Correct way to call the method
Servo.setServoPosition(90);
// Incorrect - case sensitivity matters!
// servo.setservoPosition(90); // This will cause an error
Example in Python
class Servo:
@staticmethod
def setServoPosition(position):
print(f"Setting servo position to {position}")
# Correct way to call the method
Servo.setServoPosition(90)
# Incorrect - case sensitivity matters!
# Servo.setservoposition(90) # This will cause an error
Remember to always refer to the Synthiam ARC documentation for the correct usage of classes and methods in your projects.