Preface – This post is part of the Object Oriented Thinking series.
What’s a class? A class is a blueprint for making objects.
Classes describe an object’s general methods and ranges of properties.
What’s an object? An object is something created from a class.
Each object has its own specific properties and can use the methods defined in its class.
Methods: Convert, Create, Delete
Properties: Name (String), Company (String), Employees (Integer), Owner (User)
The difference between objects in Salesforce and objects in code is that objects in Salesforce are stored in Salesforce’s database, while objects in code only exist until your code finishes running.
So why do we need to use objects and classes? Same reason why Salesforce doesn’t combine the Lead, Opportunity, Contact, and Account classes into one – you’re more organized and in a better position to scale if you group things up into smaller components (classes) and relate them to each other, instead of combining everything into one massive entity. This concept is called modularizing.
Start thinking in terms of objects and classes, and you’ll see that everything revolves around them!
Next post: How to create an Apex class!