H (Hybrid) Language
∟Classes and Objects
This chapter provides notes on classes and objects in H language.
What Is Class
What Is Object
$class Statement - Create New Classes
Class Variables and Functions
Execution of $class Definition Body
__new() - Object Constructor Function
$instance Statement - Define Instance Template
Execution of $instance Definition Body
Access Object Properties
$method Statement - Define Object Method
Access Object Methods
_first() Method - Object Initialization
Access Class Variables from Object Methods
__delete() - Object Destructor Method
$delete Statement - Delete Objects
_last() Method - Object Cleanup
Takeaways:
- A class is a data type that defines a group of data objects with
the same list of properties and methods
- An object, also called instance, is a data object of a specific class.
It has the same list of properties and methods as all other objects
created by the same class.
- $class statement is for creating new classes.
- A class can have class variables and functions
to support object properties and methods.
- The $class definition body is executed, when the $class statement is executed.
- Object constructor function, __new(), is a built-in special class function
to create new objects.
- class_name() is shorthand version of class_name.__new().
- The $instance statement is for defining instance (or object) properties and
methods within the class definition body.
- The $instance definition body is executed, each time when the
__new() function is called.
- The $method statement is for defining object (or instance) methods
within the instance template definition body.
- Once an object is created, you can use the dot (.) expression to
access its properties and methods.
- The _first() method is for object initialization during the new object construction process.
- Object destructor method, __delete(), is a built-in special object method
to delete an object.
- The $delete statement is equivalent of calling the __delete method.
- The _last() method is for object cleanup during the object destruction process.
Table of Contents
About This Book
Introduction of H Language
Syntax
Data Types
Variables
Expressions
Statements
"boolean" Data Type
"integer" Data Type
"string" Data Type
"real" Data Type
"array" Data Type
Source Code Packages
►Classes and Objects
Object Oriented Programming
Inheritance - Object Attachments
Encapsulation - Private Members
References
Full Version in PDF/ePUB