Class and object are almost synonymous. One needs another. You need a class because you need one or many objects. Objects usually retain the characteristics of class and represent them when they are instantiated. But there is a caveat. Each object with its own set of member variables is destroyed after the execution.
What happens then if you want to retain the member values of an object throughout the program?
You can declare it as a ‘static’ variable or static function.
One of the key pillars on which modular programming stands now is methods. Sometime you may call it functions. In fact ritually in C# it is called methods and PHP is happy about calling it functions. After all, it is something that makes a program move. It is actually full of action. Without a method or function program becomes immovable.
Abstraction and Encapsulation
Abstraction and Encapsulation are important features of any Object Oriented Programming language. Abstraction means presenting the required feature hiding others. Encapsulation means packaging one or more components together. Let us have a detail look into the inside stories of Abstraction and Encapsulation.
What is Fibonacci Series?
The Fibonacci sequence is named after Fibonacci. His 1202 book Liber Abaci introduced the sequence to Western European mathematics, although the sequence had been described earlier in Indian mathematics. By modern convention, the sequence begins either with F0 = 0 or with F1 = 1. The Liber Abaci began the sequence with F1 = 1, without an initial 0.
The first statement in a typical C# program is
By declaring this statement we are including namespaces in the program. It means now we can refer to the classes defined in the namespace ‘System’. What does it actually mean?
I take out the definition from the page of PHP Manual directly.
Usually vocabulary and grammar build a language. Programming language also follow almost the same pattern as it has a set of keywords which may compared to vocabulary and syntax that can be categorised as grammar.
Through vocabulary and grammar people interpret and understand language. Now the question is, can computer directly interpret and understand the instructions written in any programming language?
No, they can not.
A computer needs a translator to translate those set of instructions and thereby execute them. So something comes between programming language and machine language that computer understands. A special program called ‘compiler’ is needed to do that job. It follows the input-process-output (IPO) procedure to get the job done.
This process of conversion is called compilation. At the end of the day each programming language needs a compiler, like C# needs ‘csc’ compiler.
Introducing C# and PHP
Computer languages have come up a long way since 1940s. It develops, rebuilds itself making path for the new languages to appear and thereby has changed the whole gamut of the computer science.
In the 1940s, scientists punch the instructions into a room sized computer and those instructions were a series of one and zeros. It was complicated and called machine language. You may also call it First Generation of Computer Language.
Flexibility of Classes
The concept of classes is inexorably flexible. One may want to extend an old class adding few new characters. In doing so one must not abandon the old class. Suppose 12reach.in is a web site that stores information about various programming language. Now one would like to add a different kind of topic into it like literature. As language is sequential, you can say it is a spitting image of any procedural programming language as it runs sequentially. They both share some common traits, tendency and over all logic.
You can sense an object. So an object shows some tangible behaviour or you may call it as an tangible entity that you can feel, see or smell. Suppose a tennis ball has some characters like
1) it has a visual boundary
2) it has a well defined purpose (like bouncing)
3) it involves an action that you can direct to it (like hitting or tossing)
4) you can see, feel or even smell it