Goldlilys Media

San Diego Web Design and Development Company

What Is The True Asset of Inheritance?

What Is The True Asset of Inheritance?

“The artist is the person who invents the means to bridge between biological inheritance and the environments created by technological innovation.” - Marshall McLuhan

Before humans or any living things are born, their genetic makeup and outer appearance is already predetermined. How? Everyone comes from a combination of genes from their predecessors especially their parents. Humans cannot control their genes because everyone inherits traits from both of their parents.

Such traits might be the color of your hair, eyes, skin, height and the shape of your face. Any living organism does not have much control over those traits unless an individual prefers to change that to look like someone else. I much prefer a real “imperfect” person rather than a fake “perfect” person. Who determines what perfection is anyway?

While heredity cannot be controlled, behaviors are traits that are inherited and changed by the surrounding environment. According to Profile Performance Systems, our personality determines our behavior. How? Our personality affects the way we behave through our emotions and thoughts. From that article, our personality rarely changes, but our behaviors can be adjusted by learning from new patterns.

An example of behavioral change is learning a new language. Particularly, I learned English as a second language and my first is Tagalog. There are even some people called polyglots who can speak many languages. This emphasizes that behavior or our inner thoughts control what we do, what we listen to and eventually who we become. The only one who can control our thought is us and what we choose to do.

In computer science, inheritance is when “an object or class is based on another object or class, using the same implementation”. Like the biological definition of inheritance, the subclass (children) borrows or inherits traits and behaviors from its superclass (parents). In theory, this allows a better way to maintain the program using code reuse.

Code reuse is useful in programming because it simplifies the need to add traits to its subclasses when it is already part of the superclass. The subclass only needs to extend its parent class and it automatically gets all the variables and values assigned to it. However, the purpose of subclasses is having the ability to override some of the values for those variables that were inherited.

Overriding allows subclasses or the children to differentiate from their superclass or the parents so they behave in a different way. A common example while learning programming is this pseudo code:

public class Animal { String name; public Animal (String name) { // default constructor this.name = name; // assign the name to an animal } } public class Dog extends Animal { String breed; /* Constructor for class Dog without parameters or conditions */ public Dog () { super (); // call default constructor to inherit the variables and values this.breed = null; } /* Constructor for class Dog with parameters or conditions */ public Dog (String name, String breed) { super (name); // assign the name of the dog using the default constructor this.breed = breed; // assign the breed parameter of Dog } }

 

This example shows that the Dog is a subclass of Animal and Animal is the superclass of Dog because Dog inherited traits from Animal. The relationship can be summed up that all Dog is an Animal. But not all Animal is a Dog. Why? From the decision tree, the parents cannot inherit from its children, only vice versa. Realistically and logically speaking, is it not weird for parents to inherit from their children?

Inheritance in Web Development

To portray a real world example, we may have a website for a school. An object class called Person is created. A Person has subclasses called Anonymous, Students, Teachers, Principal and Staff. Each person has a name and a role. The role determines what they have access to on the website and what they can update or do.

Anonymous visitors can only read contents. Students has access to their profiles (name, age, etc) and their class schedule. Teachers has access to their own profiles (name, age, etc), all their students (names, grades, etc) and add syllabus, assignments to their page and classes they are teaching. Principal has access to their own profile, all Teachers and Students, but they can only update their own profile. The Staff is the manager of the website and has access to everything.

From that hierarchy, the more you have access, the more you can see, control and do. The superclass Person has variables that have something in common with all the subclasses: name, age, etc. Every role overrides those common variables as well as have their own unique features (ex: class schedule for students, add syllabus, etc for teachers).

Not all roles are created equal. Why? Every person is learning something different and some have more knowledge than others. However, the commonalities among all of them are what make inheritance efficient and simple to organize the flow of your website. What are the common traits and behaviors for your business? What can one role do and not the other? What makes every user role of your website unique?

Blog Category: Web Tools: Services:

Contact

619.265.6389
Address:

Hera Hub Mission Valley
8885 Rio San Diego Drive, Suite 237
San Diego, CA 92108

Hera Hub Sorrento Valley
4010 Sorrento Valley Blvd, Suite 400
San Diego, CA 92121

Office Hours:

Monday - Friday 10am - 5pm

For a consultation, schedule an appointment.