Thursday, November 18, 2010

OOP (Object-Oriented Programming) for beginners

OOP stands for Object -Oriented Programming. It is a programming technic making programming easier and efficient. Programmers can re-use codes, "encapsulate" data to prevent accidental changes and secure applications in various ways.

History
In 1960s, as hardware and software became increasingly complex, manageability often became a concern. Researchers studied ways to maintain software quality and developed object-oriented programming. Object-oriented programming (OOP) is a computer science term used to characterize a programming language. The term ‘object-oriented programming’ was coined by Xerox PARC to designate a computer application that describes the methodology of using objects as the foundation for computation. Currently Java, J2EE, C++, C#, Visual Basic.NET, ActionScript are some of the popular OOP programming languages. The first programming language to use objects was Simula 67.


Understanding OOP
To begin life with OOP, terms such as objects, class, methods, inheritance, polymorphism,encapsulation are some terms to be remembered.
  • Objects: An object is the primary entity of OOP. Anything to be dealt with (like in real life) are objects. Say you are developing an applications for a school. The stdents, the teachers, the clarks can be treated as objects.
  • Class: Class is a blueprint of an object which consists of the properties, behaviour and functions (called "methods" in OOP). Let's take the school application for example. Let there be a class called "school". A teacher Mr. XYZ is an object of class schools. We can call it as "Mr. XYZ is a member variable of class school".
  • Method: Every useful objects have methods. Mr. XYZ, the teacher, and the member variable of class "school", takes classes in school, does his lunch at recess, attends meetings, and other works. In programming point of view, to make use of Mr. XYZ, we can create methods like TakeClass( ), HaveLunch( ), AttendMeeting( ) etc.
  • Property: Do you have any specific property that distinguishes you besides being a human? Well, in OOP, properties are set to give a distinction to class.
OOP Fundamentals
So, let's see what OOP can do for you!
  • Inheritance: To be precise, inheritance is a speciality of a class which maintains hierarchy, thus giving you the strength of code reusability, more productivity and efficiency.
    Mr. XYZ is a teacher, a teacher is a human, a human is a living thing. So if we create three classes, Teacher( ), Human( ), LivingThing( ), we can say Teacher( ) class is derived from Human( ) class, the Human( ) class is again derived from LivingThing( ) class. For Teacher( ) class, Human( ) class is considered as "Base Class".The Teacher( ) class " inherits" all methods and properties and also its own methods and properties. Neat, isn't it?
    There are two kinds of relationships in inheritance technique- "is-a" relationship and "has-a" relationship.
  • Polymorphism: Polymorphism is an useful feature in OOP. It allows re-using methods. Like Mr. XYZ, Mr.PQR, another teacher who also takes classes. For Polymorphism, we don't have to create another TakeClass( ) method for Mr. PQR. One is good enough! Neat again, isn't it? And oh yes, this kind of polymorphism is called "Method Overloading".
  • Encapsulation: Say you are working with a class which is derived from a class called,say, "root". Now since any damage in root( ) class can affect the class you're working with, you might be interested to "encapsulate" the root( ) class, means hiding it from outer world to prevent accidental damage.
This is a basic concept of OOP. There are lots more to know for the next level of OOP knowledge. Keep an eye here for the next post about OOP.

Sunday, November 7, 2010

Civic Sense- the "Desi" way


Civic sense is nothing but social ethics. It is consideration by the people for the unspoken norms of society. A lot of people assume that civic sense is just about keeping the roads, streets and public property clean. But civic sense is more than that; it has to do with law-abiding, respect for fellow men. [Source] .In other word, it's an important identity of the entities of a society.
Okay, but who cares?

That's right, so what's so special about it?

I think you know, but just in case.

Take a look around, will you please?

Spit marks, urine, vulgar graffiti, random garbage and overflowing sewers at every nook and corner of India.People must first question themselves and their own civic sense. Roads are not dirty because nobody cleaned it, but because somebody dirtied it in the first place. Walls of public toilets, movie houses, railway stations are "colored" with spits, making them as well as the whole society, the whole nation, the whole country ugly. Who have did these? Was it YOU? No? Good, but how many times YOU have asked someone to stop dirtying your place, your city, your country? So what say, do YOU have adequate civic sense?
Using 'everybody does it' is an excuse and only an excuse. In India, even prominent personalities indulge in proud displays of lack of civic sense. Take for example, ministers who delay planes with complete disregard for other passengers or companies that freely pollute rivers and lakes. It is difficult for a country to change its mindset when its leaders themselves are setting bad examples, round the clock, all the time. [Source]
To be continued.. check over time

Wednesday, November 3, 2010

To Worry, or not to worry

[cigarette]
Smoking on health are serious and deadly. Out of approximately 4000 chemicals in cigarettes, most are toxic. Cigarettes affect everything from the internal functioning of organs to the efficiency of the body's immune system.
Smoking effects on human body
• Nicotine reaches the brain within 10 seconds after smoke is inhaled. It has been found in every part of the body and in breast milk.
• Carbon monoxide binds to hemoglobin in red blood cells, preventing affected cells from carrying oxygen.
• Carcinogens damage important genes that control the growth of cells, causing them to grow abnormally or to reproduce rapidly.
• Smoking affects the function of the immune system and increases the risk for respiratory infections.
• Oxidative stress mutates DNA and leads to chronic lung injury. Oxidative stress is the general mechanism behind the aging process, contributing to the development of cancer and cardiovascular disease.
• The body produces antioxidants to help repair damaged cells. Smokers have lower levels of antioxidants in their blood than do nonsmokers.
Carcinogens in cigarettes
A carcinogen is defined as any substance that can cause cancer. Many chemicals in cigarettes are known to cause cancer.
TSNAs
Tobacco-specific N-nitrosamines (TSNAs) are known to be some of the most potent carcinogens present in smokeless tobacco, snuff and tobacco smoke.
Benzene
Benzene can be found in pesticides and gasoline. It is present in high levels in cigarette smoke and accounts for half of all human exposure to this hazardous chemical.
Pesticides
Pesticides are inhaled into our lungs via cigarette smoke.
Toxic Metals in cigarettes
Toxic / heavy metals are metals and metal compounds that have the potential to harm our health when absorbed or inhaled. In very small amounts, some of these metals support life, but when taken in large amounts, can become toxic.
Arsenic
Commonly used in rat poison, arsenic finds its way into cigarette smoke through some of the pesticides that are used in tobacco farming.
Cadmium
Cadmium is a toxic heavy metal that is used in batteries. Smokers typically have twice as much cadmium in their bodies as nonsmokers.
Poisons in cigarettes
Poison is any substance that causes severe physical distress or death. Approximately 200 poisonous gases have been discovered in cigarette smoke.
Ammonia
Ammonia compounds are used in cleaning products and fertilizers. Ammonia is also used to boost the impact of nicotine in manufactured cigarettes.
Carbon Monoxide
Carbon monoxide is present in car exhaust and is lethal in very large amounts. Cigarette smoke contain high levels of carbon monoxide.
Hydrogen Cyanide
Hydrogen cyanide was used to kill people in the gas chambers in Nazi Germany during World War II. It can be found in cigarette smoke.
Nicotine
Nicotine is a poison used in pesticides and is the major addictive element in cigarettes.

Sunday, August 15, 2010

Happy "Independence" Day- why it sounds funny to me

Well,  HAPPY INDEPENDENCE DAY to all of you.
______________________________________________________________
It's a Sunday, and most of the human beings have their weekend. So it is an Independence Day, isn't it?

As of August 15th, the "Independence Day" of our country, India, flags are being hoisted, colorful functions and patriotic songs have surrounded the environment. Our Capital has a great show there, like every year.
What is "Independence" by the way? I mean, the two words "Independence" and "Freedom" are vastly used on this special day.

Are you Independent? Are you Free?


WE, THE PEOPLE OF INDIA, having solemnly resolved to
constitute India into a SOVEREIGN SOCIALIST SECULAR DEMOCRATIC
REPUBLIC and to secure to all its citizens:
JUSTICE, social, economic and political;
LIBERTY of thought, expression, belief, faith and worship;
EQUALITY of status and of opportunity;
and to promote among them all
FRATERNITY assuring the dignity of the individual and the unity and
integrity of the Nation;
IN OUR CONSTITUENT ASSEMBLY this twenty-sixth day of November, 1949,
do
HEREBY ADOPT, ENACT AND GIVE TO OURSELVES THIS CONSTITUTION.