Before we begin, it is important to understand the naming conventions of class elements used throughout this book.  The following diagram shows significant parts of a class.


The following table describes terms used in the example.

Name

What is it in the example?

Superclass

The superclass is the parent class that the Invoice class inherits its behavior from.   In this case, the parent class of the the Invoice class is the BaseModel class. If a superclass is not defined, the superclass is Object.  So where there is code that requires a BaseModel, you can pass in an Invoice instead, because an Invoice is a BaseModel with some additions.

Implemented interface

An interface that the Invoice class adheres to. There can be more than one interface listed here.  Other java code already knows how to communicate with the Verifiable interface, but not with the new Invoice class.  It's like planning ten years ago to build many different kinds of USB devices, knowing that they will work with the USB port on a laptop that was built today. USB devices all “implement” the standard USB interface.

Member variables

These are the long-term attributes of the class that define what it needs to know about in order to be useful.   Without a very good reason, these are usually private.

Constants

Constants are values that don't change while the program is running.  They are usually referenced in more than one place.  

Constructor

A function that gets called when a new instance of the class is created.  There is only ever one class definition for Invoice, but there can  be many instances created of that class.  For example, a company might create thousands of invoice instances, each for a different customer.

Method

A function that can be called to access the functionality of the Invoice class.  Static methods don't need an instance created to be able to call them, but non-static methods need an instance of the Invoice class created to be able to call them.

Scope

How long a variable stays active, its lifespan. For example, most variables only exist within the set of curly braces they are defined in, and are then discarded.

Local variable

A short-term variable needed to perform an operation inside a method.

Getters and Setters

A way that a class exposes its private member variables without actually giving up full control over them.

It will be helpful if you understand the above Object Oriented terminology as it is used throughout this book.  For other terms, there is a Glossary following.

blog comments powered by Disqus