Web Development

iBasic : Object Oriented Programming

Object Oriented Programming

OOP: Object oriented programming as an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand.

Striking features of object-oriented programming are :

  • Emphasis is on data rather than procedure.
  • Programs are divided into what are known as objects.
  • Data is hidden and cannot be accessed by external functions.
  • Objects may communicate with each other through functions.
  • New data and functions can be easily added whenever necessary.
  • Follows bottom-up approach in program design

Basic concepts of object-oriented programming:

  • Objects
  • Classes
  • Data abstraction and encapsulation
  • Inheritance
  • Polymorphism
  • Dynamic binding
  • Message passing

Objects: An object is considered to be a partitioned area of computer memory that stores data and set of operation that can be access the data. Object are the basic run-time entities in an object-oriented system. It represents s physical/real entity.

Classes: Classes are user-defined data types and behave like the built-in types of a programming language. Class is concrete representation of an entity. It represents a group objects, which hold similar attributes and behavior. It provides abstraction and encapsulation.

Encapsulation: The wrapping up of data and functions into a single unit(called class) in known as encapsulation. Encapsulation is binding of attributes and behaviors. Hiding the actual implementation and exposing the functionality of any object. Its main aim is to protect the data from outside world.

Abstraction: Abstraction refers to the act of representing essential features without including the background details or explanations. Hiding the complexity.

Polymorphism: Means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends upon the types of data used in the operation. Ability to provide different implementation based on different number/type of parameters.

Pure-Polymorphism: When a method is declared as abstract/virtual method in a base class and which is overridden in a base class. If we create a variable of a type of a base class and assign an object of a derived class to it. It will be decided at a run time, which implementation of a method is to be called. This is known as Pure-Polymorphism or Late-Binding.

Overloading: Adding a new method with the same name in same/derived class but with different number/types of parameters. It implements polymorphism.

Overriding: A process of creating different implementation of a method having a same name as base class, in a derived class. It implements Inheritance.

Shadowing: When the method is defined as Final/sealed in base class and not override able and we need to provide different implementation for the same. This process is known as shadowing, uses shadows/new keywords.

Dynamic binding: Means that the code associated with a given procedure call is not known until the time of the call at run-time. It is associated with polymorphism and inheritance.

Inheritance: It is a process of acquiring attributes and behaviors from another object(normally a class or interface).

Abstract class: An abstract class is a special kind of class that cannot be instantiated. It normally contains one or more abstract methods or abstract properties. It provides body to a class.

Interface: An interface has no implementation. It only has the signature or in other words, just the definition of the methods without the body.

Constructor: A special function always called whenever an instance of the class is created.

  • Same name as class name
  • No return type
  • Automatically call when object of class is created
  • Used to initilize the members of class

Copy Construction: Constructor which initializes it’s object member variables (by shallow copying) with another object of the same clas

Test t1(10); // calling Test constructor

Test t2(t1); // calling Test copy constructor

Test t2=t1; // calling Test copy constructor

Destructor: A special method called by GC. Just before object is being reclaimed by GC.

Method Overloading: Method overloading is having methods with same name but carrying different signature, this is useful when you want a method to behave differently depending upon a data passed to it.

Static assembly: Static assemblies can include .NET Framework types (interfaces and classes) as well as resources for the assembly (bitmaps, JPEG files, resource files, and so forth). Static assemblies are stored on disk.

Dynamic assembly: Dynamic assemblies run directly from memory and are not saved to disk before execution.

Functionality of an assembly:

  • It is the smallest unit that has version control.
  • All types and resources in the same assembly are versioned as a unit and support side by side execution.
  • Assemblies contain the metadata and other identities which allow the common language runtime to execute.
  • They are the unit where security permissions are requested and granted.

Serialization: Serialization is the process of converting an object into a stream of bytes.

De-serialization: De-Serialization is the opposite process of creating an object from a stream of bytes.

Serialization/De-serialization is mostly used to transport objects (during remoting), or to persist objects (e.g. to a file or database).

  • XmlSerializer [for webservices]
  • SoapFormatter/BinaryFormatter [for remoting

Advantages of Inheritance:

  • It permits code re-usability.
  • Re-usability saves time in program development.
  • It encourages the reuse of proven and debugged high-quality software, thus reducing problem after a system becomes functional.
OOP: Object oriented programming as an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s