November 21, 2017
There are literally thousands of computer languages, each with a different purpose. Some, such as COBOL are well known as design mistakes amongst programmers, while Pascal, my personal favorite is considered a joke among many. While surfing the Internet last night looking for potential story ideas, I came across a new programming language calling itself Ruby. The designers claim that it should be familiar to the users of many common programming languages. That may be the case but none of the computer languages it emulates looked familiar to me.
I do not know if its claim of being open source is unique among programming languages is unique or not. I thought Sun’s Java made that claim a long time ago as it needed to be so the language could be implemented on every platform. It seems to me that such an attempt would only be useful if the standards and how they were implemented were open to everyone.
The initial documentation itself is refreshing and actually easy to follow, which you won’t get if you pick up the manuals that come with Microsoft’s Visual Basic or Inprise’s Delphi. I have not yet had much of a chance to play around with it but you can either try it out online or download several compilers for the language.
Although the syntax did not seem very familiar to me as I do most of my programming in Pascal and only an occasional bit in C, Ruby claims to have a syntax similar to many popular languages. Since object oriented programming looks the same regardless of which language you choose to do it in.
Another thing the documentation does not make clear is what exactly they intend the language to be used for. I may have missed it, but it would be nice to know if it’s designed to be use for teaching, scripting, cross-platform programming, education, or just general applications. Best is to buy research paper to know about the language. Despite it being fairly new, versions exist on several operating systems including Windows. It may be that much like Sun Microsystem’s Java language, Ruby will show why you should not let programmers simplify anything. Java remains a complex mess to everyone but the language of the designers, and form what I’ve seen so far Ruby did a better job, but looks like it could use a little more development. At least from a cursory glance it is much easier to learn than Java.
June 9, 2017
Object-Oriented Programming (OOP) is used to build OOPS. Objects are the basic building block of Object-Oriented Programming System (OOPS). The real world objects have two characteristics: state and behavior. For example, human beings have state, such as name, color, age, and height and behavior such as walking, dancing, and sleeping. All the objects in OOPS are based on real world having a specific state and behavior.
OOPS consists of the following features:
Encapsulation implies that the non-essential details of an object are hidden from the user and an access is provided to its essential details. Therefore, encapsulation is also called information hiding. For example, when you plug in the cord of a vacuum cleaner and switch it on, the vacuum cleaner starts functioning. An end-user need not know the working principle of a vacuum cleaner to convert electricity into suction power. The switch of th6 vacuum cleaner encapsulates the complex process of conversion of electricity into suction power. The complexity of an object is hidden as a result of encapsulation.
Computer games also use the feature of encapsulation. The user only needs to know how to play the game. However, the complex working of game is hidden from the user.
In object-oriented methodology, need of encapsulation arises because the emphasis is on designing classes in such a manner that the classes share data and methods among themselves. Encapsulation is the feature that provides security to the data and the methods of a class.
An Anytime money (ATM) that you use to withdraw money also has an encapsulated function. You insert an ATM card in the machine and provide the pin code. The only access that you have to the ATM is to provide the pin code for your account and not to the process of validating the password. If the pin code is correct, you can make the desired transaction. The backend transaction process is encapsulated. In addition, if you try to access another account, access is denied, as you are not authorized to access any account other than your account.
Abstraction refers to the attributes of an object that clearly demarcates it from other objects. For example, while developing an online shopping site for books, you use objects of various items, such as books, compact disks (CDs), and cassettes. All these objects have a well-defined set of attributes that distinguish these objects from each other. For example, a book has page numbers, type of binding, and subject. However, a CD has type of media, such as audio or visual, duration, and storage capacity of the CD.
The concept of abstraction is implemented in object-oriented programming by creating classes. All the attributes of the objects of the classes are defined in the class. However, you cannot store any data in a class because creating a class does not allocate any memory space to the class. To store data, you need to create objects of the class, which have memory allocated as soon as it is created. Classes form the templates for creating objects.
In addition to the well-defined characteristics of an object, abstraction enables you to provide a restricted access to data. You come across hundreds of advertising messages every day through magazines or newspapers. You do not read, understand, and respond to all of these because these are not of your interest. Instead, you concentrate only on messages that are of your specific interest. For example, if you want to buy a refrigerator, you will concentrate on the advertisements featuring refrigerators. You will not concentrate on the advertisements of other products, such as vacuum cleaner, washing machine, and air conditioner.
In object-oriented programming, abstraction means ignoring the non-essential details of an object and concentrating on its essential details. As discussed earlier, in an ATM, the user is not required to know the entire process of a transaction and how the data is stored. However, the program provides a restricted access to the user’s account.
Similarly, when you want to send e-mail messages, you should know the processes of writing e-mail messages and sending it to the receiver. However, it is not necessary for you to know the entire process of sending the e-mail messages across the network.
To implement abstraction, you also use the encapsulation feature. Encapsulation hides the irrelevant details of an object and abstraction makes only the relevant details of an object visible. For example, the operation of a washing machine is hidden or encapsulated from the user. The details, like switching on and off the washing machine are the only details relevant for the user to know. This is implemented by abstraction. Rest of the working of the washing machine is encapsulated from the user.
In object-oriented methodology, inheritance enables you to extend the functionality of an existing class. You create a class that inherits the attributes and behavior of another class. In addition, the new class can consist of a few new attributes and behaviors that are specific to the class. In terms of classes and objects, attributes refer to the data and behavior refers to the methods.
For example, you might have the Student class that consists of the basic characteristics of students, such as name, date of birth, and gender. You can extend the functions of the student class to a day scholar, who in addition to characteristics of the Student class contains its own features, such as locker number and residential address.
Inheritance enables you to add new features and functionality to an existing class without modifying the existing class. Inheritance also enables you to share data and methods among multiple classes.
Polymorphism is derived from two Latin words-Poly, which means many, and morph, which means forms. Anything that exists in more than one form is known as a polymorph. You might have noticed that a person assumes different roles in different scenarios. For example, a person assumes various roles when he interacts with the members of his family. He is a father to his children, child to his parents, and husband to his wife. Although, the person is same, he behaves differently with the family members as per his relation with the member.
In object-oriented methodology, polymorphism is the feature that enables you to assign a different meaning or usage to an entity in different contexts. The entity can be a variable, method, or an object. In other words, Polymorphism allows a programmer to make use of an entity in several different forms without affecting the original identity of the entity.