Thursday, April 15, 2010

Class inheritance in haXe

Yes, we can inherit properties of one class to another in haXe. Inheritance helps us to reuse existing code with little or no modification. In haXe we can extend one class and implements many interfaces. So, we can inherit several types at same time. The new class is said as derived class and the inherited class is called as super class. Inheritance is different from subtype-polymorphism. To declare a subtype we need to define a new class.
This syntax can be shown like this:
Class super-class extends subclass1, implements subclass2, implements subclass3
{
}
Here super-class inherits properties from subclasses.
When we wish to add a single function or more to an existing class without changing the class itself, we can simple extend the class and then create our function in our new class. Let’s see an example of it.
Class brain{}
Interface eye{}
Interface hand{}
Class human extends brain, implements eye, implements hand
{
}
Here class human has its own types and also uses types of brain, eye, and hand as required. The difference with other languages is that it uses the ‘implements’ keyword for every implementations. Other languages implements interfaces like ‘implements eye, head, brain’, uses the ‘implements’ keyword only single time.




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

No comments: