Fundamentals of oops in .Net


Published on

This presentation is very useful for the Beginners who want to know the BASE on which OOPS work on .

Published in: Education, Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Fundamentals of oops in .Net

  1. 1. Fundamentals of OOPS in .NET<br />By Harman<br />
  2. 2. Introduction<br />OOPS<br />OOP is a design philosophy. It stands for Object Oriented Programming. Object-Oriented Programming (OOP) uses a different set of programming languages than old procedural programming languages (C, Pascal, etc.). Everything in OOP is grouped as self sustainable "objects". Hence, you gain re-usability by means of four main object-oriented programming concepts. <br />Classification: Confidential 2011-10-04<br />2<br />
  3. 3. Objects<br />An object can be considered a "thing" that can perform a set of related activities. The set of activities that the object performs defines the object's behavior. For example, the hand can grip something or a Student (object) can give the name or address. In pure OOP terms an object is an instance of a class. <br />Classification: Confidential 2011-10-04<br />3<br />
  4. 4. Class<br />A class is simply a representation of a type of object. It is the blueprint/ plan/ template that describe the details of an object. A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations. <br />public class Student<br /> {<br /> } <br />According to the sample given below we can say that the student object, named objectStudent, has created out of the Student class. <br />Student objectStudent = new Student(); <br />Classification: Confidential 2011-10-04<br />4<br />
  5. 5. Continues<br />As an example, there may be thousands of other bicycles in existence, all of the same make and model. Each bicycle has built from the same blueprint. In object-oriented terms, we say that the bicycle is an instance of the class of objects known as bicycles.<br />Classification: Confidential 2011-10-04<br />5<br />
  6. 6. Encapsulation (or information hiding)<br />The encapsulation is the inclusion within a program object of all the resources need for the object to function - basically, the methods and the data. In OOP the encapsulation is mainly achieved by creating classes, the classes expose public methods and properties.<br />encapsulation also allows a class to change its internal implementation without hurting the overall functioning of the system.<br />Classification: Confidential 2011-10-04<br />6<br />
  7. 7. Association<br />Association is a (*a*) relationship between two classes. It allows one object instance to cause another to perform an action on its behalf. Association is the more general term that define the relationship between two classes, where as the aggregation and composition are relatively special. <br />Example next slide -><br />Classification: Confidential 2011-10-04<br />7<br />
  8. 8. Example of Association<br />public class StudentRegistrar<br /> { <br />public StudentRegistrar (); <br />{ <br />new RecordManager().Initialize()<br />}}<br />we can say that there is an association between StudentRegistrar and RecordManager<br />Classification: Confidential 2011-10-04<br />8<br />
  9. 9. Abstraction<br />Abstraction is another good feature of OOPS. Abstraction means to show only the necessary details to the client of the object.<br />For Ex:- <br />We don’t know the inner details of monitor ? What happen when you switch ON Monitor? Does this matter to you what is happening inside the Monitor? No Right, Important thing for you is weather Monitor is ON or NOT. <br />When you change the gear of your vehicle are you really concern about the inner details of your vehicle engine? No but what matter to you is that Gear must get changed that’s it!! <br />This is abstraction; show only the details which matter to the user. <br />abstraction says expose only the details which are concern with the user (client) of your object. So the client who is using your class need not to be aware of the inner details like how you class do the operations? He needs to know just few details. <br />Classification: Confidential 2011-10-04<br />9<br />
  10. 10. Abstract Class<br />If a class is to serve the purpose of providing common fields and members to all subclasses, we create an Abstract class. For creating an abstract class, we make use of the abstract keyword. Such a class cannot be instantiated. <br />abstract public class Vehicle { } <br />Above, an abstract class named Vehicle has been defined. We may use the fields, properties and member functions defined within this abstract class to create child classes like Car, Truck, Bike etc. that inherit the features defined within the abstract class.<br />We can also have virtual methods defined in an abstract class. The virtual method may have its default implementation, where a subclass can override it when required. <br />Classification: Confidential 2011-10-04<br />10<br />
  11. 11. Interface<br />An interface is a collection of semantically related abstract members. An interface expresses through the members it defines, the behaviors that a class needs to support. An interface is defined using the keyword interface. The members defined in an interface contain only definition, no implementation. The members of an interface are all public by default, <br />Classification: Confidential 2011-10-04<br />11<br />
  12. 12. Diff b/w Abstract class & Interface <br />A class may inherit only one abstract class, but may implement multiple number of Interfaces. Say a class named Car needs to inherit some basic features of a vehicle, it may inherit from an Abstracts class named Vehicle. <br />Members of an abstract class may have any access modifier, but members of an interface are public by default, and cant have any other access modifier.<br />Abstract class methods may OR may not have an implementation, while methods in an Interface only have a definition, no implementation. <br />Classification: Confidential 2011-10-04<br />12<br />
  13. 13. Continue Abstract Class<br />Interface definition begins with a keyword interface so it is of type interface <br />Abstract classes are declared with the abstract keyword so it is of type class <br />Interface has no implementation, but they have to be implemented. <br />Abstract class’s methods can have implementations and they have to be extended. <br />Classification: Confidential 2011-10-04<br />13<br />
  14. 14. Implicit/Explicit IMP-<br />.Net support multiple implementations, the concept of implicit and explicit implementation provide safe way to implement methods of multiple interfaces by hiding, exposing or preserving identities of each of interface methods, even when the method signatures are the same.<br />Just an interface<br />interface IDisposable<br />{<br /> void Dispose();<br />} <br />Classification: Confidential 2011-10-04<br />14<br />
  15. 15. Ex- Implicit & Explicit<br />class Student : IDisposable<br />{<br /> public void Dispose()<br /> {<br /> Console.WriteLine("Student.Dispose");<br /> }<br /> void IDisposable.Dispose()<br /> {<br /> Console.WriteLine("IDisposable.Dispose");<br /> }<br />} <br />Implicit<br />Explicit<br />Classification: Confidential 2011-10-04<br />15<br />
  16. 16. What is Inheritance?<br />Ability of a new class to be created, from an existing class by extending it, is called inheritance. <br />public class Exception<br />{<br />}<br />public class IOException : Exception<br />{<br />}<br />According to the previous example the new class (IOException), which is called the derived class or subclass, inherits the members of an existing class (Exception), which is called the base class or super-class. <br />The class IOException can extend the functionality of the class Exception by adding new types and methods and by overriding existing ones. <br />Classification: Confidential 2011-10-04<br />16<br />
  17. 17. What is Polymorphism?<br />Polymorphisms is a generic term that means 'many shapes'. More precisely Polymorphisms means the ability to request that the same operations be performed by a wide range of different types of things. <br />In OOP the polymorphisms is achieved by using many different techniques named method overloading, operator overloading and method overriding, <br />Method Overloading<br />The method overloading is the ability to define several methods all with the same name. <br />What is Operator Overloading?<br />Operator overloading is the most evident example of Polymorphism. In operator overloading, an operator is ‘overloaded’ or made to perform additional functions in addition to what it actually does. For e.g. we can overload the “+” operator to add two complex numbers or two imaginary numbers.<br />X= a + b //+ is overloaded to add two integers, float etcFew operators like :: cannot be overloaded.<br />Classification: Confidential 2011-10-04<br />17<br />
  18. 18. Continue:-<br />Method overriding is a language feature that allows a subclass to override a specific implementation of a method that is already provided by one of its super-classes. A subclass can give its own definition of methods but need to have the same signature as the method in its super-class.<br />Classification: Confidential 2011-10-04<br />18<br />
  19. 19. Class diagrams<br />A class diagrams are widely used to describe the types of objects in a system and their relationships. Class diagrams model class structure and contents using design elements such as classes, packages and objects. <br />Classification: Confidential 2011-10-04<br />19<br />
  20. 20. What is MVC architecture?<br />The Model-View-Controller (MVC) architecture separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes. <br />Model: specified DataSet and typed DataSet are the most common use of the model. <br />View: The ASPX and ASCX files generally handle the responsibilities of the view. <br />Controllers: The handling of events or the controlling is usually done in the code-behind class. <br />Classification: Confidential 2011-10-04<br />20<br />
  21. 21. Data Access Layer<br />Used while retrieving the information to and from the database .<br />The data access layer (DAL), which is a key part of every n-tier system, is mainly consist of a simple set of code that does basic interactions with the database or any other storage device. <br />These functionalities are often referred to as CRUD (Create, Retrieve, Update, and Delete). <br />The data access layer need to be generic, simple, quick and efficient as much as possible. It should not include complex application/ business logics. <br />Classification: Confidential 2011-10-04<br />21<br />
  22. 22. Business Logic Layer/Presentation Layer<br />Business Logic Layer include the Business logic example classes , methods permanents to be passed to execute it using Special procedures to the database.<br />Presentation layer represents the USER INTERFACE which will be presented to the User , it uses browsers like Internet explorer to convert the business logic to human readable form .<br />Classification: Confidential 2011-10-04<br />22<br />
  23. 23. <ul><li>Thanks</li></ul>Harman<br />Application Developer<br />Fundamentals of OOPS<br />