We are currently using the 5.0 version of C#, in which new programming features have been added to handle some of the new changes added to the .NET platform. We can understand better about the .NET Framework and the different versions of C# launched with it by the following picture, and in this book, we will learn about these features of C#.
As we said earlier that as the needs change, new types of hardware devices are created to meet those needs, and a new type of programming language is created to easily handle and control new types of hardware devices. Or else new features are added to the programming language.
For this reason, when the .NET Framework 1.0 was launched, C# 1.0 was also launched with it, which was a new programming language developed for the .NET Framework, and as new versions of the .NET Framework came. To meet the new requirements, new features were also added to the C# Programming Language. As a result, we are currently using the compiler of C# 5.0 version.
Object-Oriented Programming System Basics
Since C# is a Pure Object Oriented Programming Language, so without understanding the Fundamental Concepts of Object-Oriented Programming System, we can say a simple “Hello! World” program also cannot be created, because even in that program, the syntax which we have to use to get the facility of input and output, they are also completely based on the rules of Object Oriented Programming System.
Object – The Definition
Everything in the world can be called an object, which can be seen physically or logically, can be felt in the context of any visible thing. As we said, that object can be seen; it means that everything which has any color, form, and shape is an Object, such as Keyboard, Employee, Client, etc. Similarly, everything that can be felt in the context of something visible is an object like a bank account that belongs to a physical person, which has a color, form, and shape.
Every object has some characteristics, due to which one object is distinguished from another object. We call these attributes of any object as Attributes of that Object or Properties of that Object. We are changing the value of an object’s attribute changes that object.
For example, a property of a Bank Account Object can be its Account Number. Now, if the value of Account Number Property of any bank account is changed, then that bank account will start referring to the bank account of another person. That is, if the object’s attribute or property value is changed, then the object changes, although the new object also remains a member of the same category or class whose first object was
Just as every object uses some of its Unique Attributes or Properties to be Uniquely Identifiable, similarly, every object works in some way or the other. The tendency of the object to do this work is called the behavior of the object.
Objects – Based on Problem
The way we see any problem in real life, in the same way, we can represent that problem in computer also. The problem can be represented logically in the computer only when the problem is understood properly, and it is known that what are the main objects of the problem.
For example, suppose that the Bio-Data of all its employees in a company is to be computerized by upgrading them from the manual register. So we have to first identify the most important object related to this Real World problem, and because the Bio-Data of various Employees has to be stored on the computer, therefore the most important object related to this problem is the employee itself because We have to manage the information of the Employee through Computerized Application Software.
Abstraction – The Problem Simplifying Process
When we have to represent any Real Life Problem logically on the computer, first of all, we have to decide what are the important things related to the problem, which affect the result of the problem.
Abstraction is the process of separating the important things that affect the solution of the problem from the non-essential things that do not affect the solution of the problem. We try to understand this concept of OOPS with the help of the previous example.
Suppose that the Bio-Data of various Employees of a company is to be stored on the computer. Since a certain sequence has to be followed to complete this work, therefore this work is a kind of problem for the computer, which has to be solved.
Now since the main object of our problem is employee, it can have many Attributes or Properties, which help to uniquely distinguish one employee from another Employee. For example, some of the various properties of the employee may be as follows:
Employee’s First Name
- Address
- City
- District
- State
- Date Of Birth
- Qualification
- Extra Ability
- Degrees
- Designation
- Date Of Company Joining
- Hobbies
- Contact Number
- of His Brothers and Sisters
- His Father’s Date of Birth
- His Father’s Name
- His Friends Contact Number
Similarly, there can be many other properties of an Employee, on the basis of which it can be uniquely identified differently from any other Employee. But there are some Attributes in this list, which have no direct relationship with the Bio-Data of the Employee, i.e., the result of the main problem.
For example, how many siblings an employee has, has nothing to do with the Bio-Data of the Employee. Similarly, there is no direct relationship between the Date of Birth of the employee’s father or the Contact Number of the employee’s friend with the Bio-Data of the Employee.
That is, these three Attributes are such Attributes, which have no relation with the Bio-Data of the Employee. Therefore, by separating these unneeded data from the rest of the essential data, we are left with the following Attributes:
- Employee’s First Name
- Employee’s Last Name
- Address
- City
- District
- State
- Date Of Birth
- Qualification
- Extra Ability
- Degrees
- Designation
- Date Of Company Joining
- Hobbies
- Contact Number
- His Father’s Name
In this way, we separate the essential attributes affecting the outcome of the problem (Bio-Data of Employee) from the essential attributes without being related to the problem. This process is called Abstraction in Object-Oriented Programming Concept, and after Abstraction, the necessary Attributes which affect the result of our problem, those necessary Attributes are called Abstract Attributes.
Abstract Data Type – Logical Representation of Real-World Object
We can see that to get the Attributes related to Bio-Data Problem, we first considered all the Attributes of an Employee and then got the required Attributes by separating the required Attributes from the Unnecessary Attributes.
Now, if the Employee Object of this problem is to be represented logically in the computer, then we have to create an Abstract Data Type based on these Abstract Attributes, which is known only as Type in C#. At the same time, this Abstract Data Type is generally represented as a class in various Object-Oriented Programming Languages.
Class is a new type of User-Defined Data Type, which is created to logically represent any real-world object related to the problem in the computer. That is, a class is just a specification or model, which decides how the various Abstract Attributes of a real-world object related to a problem can be represented in the computer’s memory.
Simply put, by using the concepts of OOPS, a programmer acquires the ability to logically represent a real-world object in the computer in exactly the same way as that object exists in the real world.
Attributes – The Data Members of the Class
When the various attributes of an object related to the result of a problem have to be represented in the computer, then on the basis of the data stored in the attributes of that object in the computer, we decide which attribute of the object, what type of value ( Integer, Character, Float, etc.). The attribute can be represented by the type of value; that attribute is declared with the same type of data type.
On declaring the Object’s Attributes with Data Type, the various Abstract Attributes of the Object are called Data Members of the Class.
If we say the same thing, in other words, depending on what kind of data will be stored in Abstract Attributes obtained from Abstraction, or keeping this in mind, the Basic Data Type of these different Abstract Attributes is decided. And when these Abstract Attributes are specified in the class along with their Data Type, then these Abstract Attributes are called Data Members of the Class.
Behaviors – The Methods of the Class
The work that an object does is called the behavior of that object. But when we want to represent an object in the computer, then we do not see what the object can actually do; rather, we see what the functions of the object, by which the object can do any of its work is. Changes the value of the attribute, which is identified by the process of Abstraction.
The Behaviors of the Object that affect the Abstract Attributes related to a problem are the Behaviors related to that problem. In C#, we have to use Methods to represent these Behaviors by Object’s Class. Methods are those code segments of C#, which change the value of some Abstract Attribute of an object in some way or the other.
That is, those operations that, when performed, change the value of an Abstract Attribute of the Object are called Methods.
Problem Design (OOPS) v/s Problem Implementation (OOPL)
On the basis of both OOPS and OOPL, there are always two definitions of any OOPS concept. One definition only works to represent the concept of OOPS, while the other definition deals with implementing the concepts of OOPS in a programming language based on that first definition.
When we give a definition with respect to OOPS, that definition is in relation to a Real-World Physical Object related to a Real-World Problem.
But when we implement various definitions of OOPS in a programming language, then the main purpose of OOPS is to represent a Real-World Object in the best way logically in a programming language so that a Real-World Object is related to the problem. It can be represented in the computer as a new data type called Abstract Data Type.
We can use two approaches to solve a problem. The first approach is completely based on the concepts of OOPS and is related to designing the solution to the problem.
That is, we can design any software based on the concept of OOPS without even writing a single line of coding. The only difference will be that we will not get any direct result of this design. But if the model we create on the basis of OOPS is implemented in any OOPL language, then we can also get a direct result of our problem.
To put this thing in a simple way, by writing the algorithm of adding two numbers, we will not get the sum of two numbers. But what kind of steps have to be followed to add two numbers? That process is known. While writing computer codes in a programming language on the basis of this algorithm, we will get the actual addition of two numbers.
That is, creating an algorithm is the work related to problem design, while making a program is the work related to implementing that algorithm.
Similarly, applying the concept of OOPS is related to problem design, whereas implementing the design based on the concept of OOPS in a computer language like C# is related to problem-solving.
We can also say that when a problem has to be defined in the real world, then we can identify the different objects of the problem in physical form, but when the same problem has to be defined in the computer in logical form, then the problem Represent as a new data type, which we identify as Abstract Data Type or Class of Object in a Computer Programming Language.
Encapsulation – The Unitizing Process of Attributes and Behaviors
As we said earlier that every OOPS concept has two definitions based on OOPS and OOPL. The same rule also applies with respect to the Encapsulation Concept of OOPS.
When we see in relation to OOPS, making some arrangements to use an object without understanding its internal workings of the complex ways of doing its work, this process is called EncapsulationEncapsulation. Let us see an example to understand this concept.
Suppose we have a computer. When we switch the computer on, without knowing how the computer is turned on, we keep using the computer. Similarly, by pressing the accelerator of a car, a driver keeps driving the car without knowing how and why the speed of the car increases. In both these examples, Computer and Car are two Encapsulated Objects, which are used from them without knowing the way of working, i.e., Internal Working.
If we understand this concept in the context of C# Programming Language, then the definition changes. With respect to Programming Language C#, when we have to define EncapsulationEncapsulation, we define this concept as follows.
By the process of specifying the Abstract Attributes related to the problem with their data type, the data members of that object are obtained, and by performing the operations related to the problem, an object changes the state or value of any of its Abstract Attribute, that operation It is called the Behavior of the Object and the Code Blocks we write to implement these Operations in C# are called Methods.
That is, on implementing the Physical Attributes and Behaviors of the Object related to a problem in C#, the various Abstract Attributes related to the problem of the object are specified as Methods for the Data Members and the Operations that change the various Attributes.
The properties of any object, that is, both its Attributes and its Behaviors, are part of a single Physical Object. Therefore, the process of specifying both the Data Members representing the Attributes of the Object and the Methods representing the Behaviors as a single unit or units is called Encapsulation in OOPL.
After EncapsulationEncapsulation, i.e., after encapsulating as a unit by combining the various Data Members (Attributes) and Methods (Behaviors) of the object related to a problem in the computer, the specification which we get, if give a name to that specification If given, that specification is a representation of the class of an object related to the problem.
For C #, this is a new type of data type or type, which is able to represent a real-world object related to a real-world problem in a computer logically. It can also be called Abstract Data Type because it is formed on the basis of Abstract Attributes obtained from the Abstraction of a problem.
In this post, we learned about various basic concepts related to OOPS (Object Oriented Programming System). In the next post, we will learn about creating a class using these OOPS concepts, which is a type of Abstract Data Type and is made to represent a real-world object logically in the program.