Sunday, August 8, 2010

Perception for Progammers: Inheritance

Overview
We were asked to do do a project on perception as it relates to our course. Well, that is a 
rather vague request; thus, I decided to narrow down things by first answering the question, "What is perception?
Perception - process by which organisms interpret and organize sensation to produce a meaningful experience of the world. 

Then that leads us to another question on what sensation is.

Sensation - a process  wherein sense organs receive stimulation and relay the messages to the brain.

A Rebuttal
Contrary to what the rest of the world thinks, software engineers actually make software based on objects
modeled from the real world. If we face it, the real world is what actually uses these software, so it only makes sense that real world processes are mimiced and automated in software created by --surprise surprise! -- programmers. In some ways, we actually create another world where objects live and interact among each other in their own realm. For example, look at an attendance system. Isn't that automating/imitating a real world process? Thus, we actually make systems based on how we perceive the real world. How we see it, hear it, feel it. But that discussion deserves its own post in itself..so instead, I will elaborate on a more specific way wherein a principle of perception affects what we do as programmers - the Law of Similarity.

The Law of Similarity
According to this Gestalt Law of Perception, items that are similar or alike tend to be grouped together. Programmer Peeps, sounds familiar? Doesn't it sound like INHERITANCE? A common start in finding if inheritance is possible is by...

Inheritance
But wait! What is inheritance again?
Inheritance: Object-oriented programming allows classes to inherit commonly used state and behavior from other classes.
Inheritance lets us group together similar attributes and functionality in a more general class, whether it be abstract or not.We can even lump those up into an interface so that all other classes, which are more specific, will just inherit the general functionality of the more general or parent(super)class. Therefore, from our example above, this is what programmers do. The classes in this UML-like diagram will look like; all the similar functionality are grouped in the parent class Animal and all the other species inherit from it.


Another Example
Look at the example below. Stop and think. Don't books, CD's, and travel guides all have a price? Don't all products have an name and a description? This is a perfect example of inheritance. Instead of repeating the same code over and over, we group the similar things together, such as id, name, description, and price, and put them in a more general class. That way, the more specific classes can inherit from them, instead of res re-specifying them in their own respective classes.





Conclusion
Thus, we have related a principle of perception to the course of Software Engineering. Just because we deal with high technology, codes, programs, and software doesn't mean that we do not participate in the real world around us.









Definitions and Images:
Sensation and Perception : Rizalee Rowan D.
Head First Java

No comments:

Post a Comment