Constructors
Most Classes are meant to be instantiated as an Object. This means that it has its own unique data attributes and methods to access and control them.
When created, a constructor should set up the class, but do the bare minimum amount of work outside of setting up initial values. This is for performance – to speed the creation of your object.
Data conversions, processing, and IO (input/output) should be avoided as all of these are time consuming. Use another method/object to perform these operations.
When the constructor finishes, it returns a new object.
Hint: A good coding practice is to have a default constructor which takes no parameters. It just sets all the values to a default that allows the object to be used. You can even call the default constructor from your overloaded constructor, and then just change the values which you receive in your overloaded constructor.
Extending a Class
Programs of any complexity will often have classes derived from a parent class. Depending upon your language, this could be considered extending a class, a child class, etc.
Using inheritance will dramatically simplify your life when building your class.
Creating Methods
When creating methods, it’s easy to think of the getters and setters. However, Object Oriented Programming is more about thinking about how an object is being used, rather than just data to be stored.
Creating class methods allows us to create methods that we can then logically call based upon what is to be done. A student class might have a method called, registerForClass(Course c), assignGrade(String grade), or changeMajor(DegreeMajor major).
Instantiating Objects was originally found on Access 2 Learn