Staying classy
Whether you are implementing a built-in interface, controlling a Visualforce page, or facilitating a trigger logic, classes are the solution. While classes are often used as templates for objects that you construct, most of the examples we've shown so far leverage static methods in these classes. It's actually a best practice to call static methods stored in classes from your triggers, as they are more efficient on the server. There are times though where you want to do more than just call a single method, so let's take a look at some more complex functionality in classes.
When you plan on instantiating your class as an object, you often want to set some default values. If you are going to create multiple instances of this object, then you'll be writing the same code over and over. This is where having a default constructor can be useful, shown as follows:
public class sampleOuterClass { public String myString; public Integer myInteger; public sampleOuterClass(){ ...