Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Oops

0 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Oops

  1. 1. Focused more for interview Perspective and Easy Understanding
  2. 2. <ul><li>Object-Oriented Programming (OOP) is a software development paradigm that suggests developers to split a program in building blocks known as objects. </li></ul><ul><li>The OOP paradigm allows developers to define the object's data, functions, and its relationship with other objects. </li></ul>
  3. 3. <ul><li>Code Reusability </li></ul><ul><li>Enables to model real world object </li></ul><ul><li>Easy Modification </li></ul><ul><li>Easy Maintenance </li></ul><ul><li>More Flexible </li></ul>
  4. 4. <ul><li>Defines an Abstract thing of a thing (i.e. Object) </li></ul><ul><li>Explaining its Behavior </li></ul><ul><li>A user-defined data structure that groups properties and methods. </li></ul><ul><li>Class doesn’t occupies memory. </li></ul><ul><li>Class is a definition </li></ul><ul><li>Abstract classes are classes that can have no instances </li></ul>
  5. 5. <ul><li>A Single entity Which holds Data and Method. </li></ul><ul><li>It’s Structure. </li></ul><ul><li>Should be understandable by a non- Programmer </li></ul>DOG (Class) Color, Shape ( Characteristic ) Bark, Pee, Run ( Behaviors ) Members Abstract characteristics of a thing Fields - _Color Properties - Color Fields - _Color Properties - Color
  6. 6. <ul><li>Specify Class Name </li></ul><ul><li>Declare Data members </li></ul><ul><li>Declare Methods </li></ul><ul><li>Define the Processing </li></ul>
  7. 7. <ul><li>Program them in the following order: </li></ul><ul><li>Namespace: The namespace is a keyword that defines a distinctive name or last name for the class. A namespace categorizes and organizes the library (assembly) where the class belongs and avoids collisions with classes that share the same name. </li></ul><ul><li>Class declaration: Line of code where the class name and type are defined. </li></ul><ul><li>Fields: Set of variables declared in a class block. </li></ul>
  8. 8. <ul><li>Constants: Set of constants declared in a class block. </li></ul><ul><li>Constructors: A method or group of methods that contains code to initialize the class. </li></ul><ul><li>Properties: The set of descriptive data of an object. </li></ul><ul><li>Events: Program responses that get fired after a user or application action. </li></ul><ul><li>Methods: Set of functions of the class. </li></ul>
  9. 9. <ul><li>Destructor: A method that is called when the class is destroyed. </li></ul><ul><li>In managed code, the Garbage Collector is in charge of destroying objects; however, in some cases developers need to take extra actions when objects are being released, such as freeing handles or de-allocating unmanaged objects. </li></ul><ul><li>In .NET, there is no concept of deterministic destructors. The Garbage Collector will call the Finalize() method at a non-deterministic time while reclaiming memory for the application. </li></ul>
  10. 11. <ul><li>Access keywords </li></ul><ul><li>Access keywords define the access to class members from the same class and from other classes. The most common access keywords are: </li></ul><ul><li>Public: Allows access to the class member from any other class. </li></ul><ul><li>Private: Allows access to the class member only in the same class. </li></ul><ul><li>Protected: Allows access to the class member only within the same class and from inherited classes. </li></ul>
  11. 12. <ul><li>Internal: Allows access to the class member only in the same assembly. </li></ul><ul><li>Protected internal: Allows access to the class member only within the same class, from inherited classes, and other classes in the same assembly. Static: Indicates that the member can be called without first instantiating the class. </li></ul>
  12. 13. <ul><li>A particular Instance of a Class </li></ul><ul><li>Objects are the building blocks of OOP </li></ul><ul><li>Represent real world things in an abstract way </li></ul><ul><li>Commonly defined as variables or data structures that encapsulate behavior and data in a programmed unit </li></ul><ul><li>The objects will all act as independent units in their own right, and they will be responsible for carrying out a certain process </li></ul>
  13. 14. <ul><li>Object identity: </li></ul><ul><ul><li>Every object is unique and can be differentiated from other objects. Each time and object is created (instantiated) the object identity is defined. </li></ul></ul><ul><li>Object behavior: </li></ul><ul><ul><li>What the object can do. In OOP, methods work as functions that define the set of actions that the object can do. </li></ul></ul><ul><li>Objec t state: </li></ul><ul><ul><li>The data stored within the object at any given moment. In OOP, fields, constants, and properties define the state of an object. </li></ul></ul>
  14. 15. <ul><li>Inheritance </li></ul><ul><li>Abstraction </li></ul><ul><li>Polymorphism </li></ul><ul><li>Encapsulation </li></ul><ul><li>Event </li></ul>
  15. 16. <ul><li>Is like inheriting the abstract characteristics from other class - It is a kind of hierarchy </li></ul><ul><li>Base Class will be inherited to derived class </li></ul><ul><li>is a way to form new classes using classes that have already been defined </li></ul><ul><li>is-a relationships represent a hierarchy between classes of objects </li></ul><ul><li>Use: </li></ul><ul><ul><li>Reuse of Code – uses the attributes of the base class </li></ul></ul><ul><ul><li>Extensibility – Has it’s own Attributes </li></ul></ul>
  16. 17. <ul><li>Simple / Single </li></ul><ul><li>Multilevel </li></ul><ul><li>Hierarchical </li></ul><ul><li>Multiple </li></ul><ul><li>Hybrid </li></ul>
  17. 18. <ul><li>Superclass: Parent class </li></ul><ul><li>Subclass: Child class </li></ul><ul><li>Base class: Parent class </li></ul><ul><li>Derived class: Child class </li></ul>
  18. 19. <ul><li>Is like inheriting from more than one base class. </li></ul><ul><li>.Net do not allow. But using Multiple interface inheritance this can be achieved. </li></ul>
  19. 20. <ul><li>Information Hiding </li></ul><ul><li>Visibility to the methods and not to the fields </li></ul><ul><li>E.g. A Report designer for a programmer </li></ul><ul><li>Packs the data and Method and protects from external tampering </li></ul><ul><li>Exposing only the details that are relevant: the public interface </li></ul><ul><li>Improves Security </li></ul>
  20. 21. <ul><li>Protected cName as string Protected Function ChangeName(NewName)     Me.cName = NewName End Function </li></ul>
  21. 22. <ul><li>As we cannot hide entire object we give access to some specific part of data. </li></ul><ul><li>Conceptual boundaries of an object </li></ul><ul><li>Focuses on the essential characteristics of an object </li></ul><ul><li>a named entity made up of selected attributes and behavior specific to a particular usage of the originating entity </li></ul><ul><li>Improves Security </li></ul><ul><li>For example see notes below </li></ul>
  22. 23. <ul><li>One entity existing in multiple forms </li></ul><ul><li>Behavior depends on the type of data </li></ul><ul><li>Same message to diff objects results in different behavior </li></ul><ul><li>Linked to inheritance and assures that derived class to override the implementation of parents methods. </li></ul>
  23. 24. <ul><li>Class Employee     Function PayEmployee()        PayEmployee = Hours * HourlyRate     End Function </li></ul><ul><li>Class CommissionedEmployee     Inherits Employee     Overrides Function PayEmployee()        PayEmployee = BasePay + Commissions     End Function </li></ul>
  24. 25. <ul><li>Upcasting </li></ul><ul><li>Casting an object of any type to another type which is above it in the inheritance hierarchy. </li></ul><ul><li>Downcasting </li></ul><ul><li>Casting an object of any type to another type which is below it in the inheritance hierarchy. </li></ul><ul><li>Example </li></ul><ul><li>Sealed Class </li></ul><ul><li>When applied to a class, the sealed modifier prevents other classes from inheriting from it. </li></ul>
  25. 26. <ul><li>static classes and static methods are used to create data and functions that can be accessed without creating an instance of the class. </li></ul><ul><li>class CompanyInfo {     public string GetCompanyName() { return &quot;CompanyName&quot;; }     public string GetComAddress() { return &quot;ComAddress&quot;; }   </li></ul><ul><li>These methods do not need to be attached to a specific instance of the class. Therefore, instead of creating unnecessary instances of this class, you can declare it as a static class, like this: </li></ul><ul><li>static class CompanyInfo {   public static string GetCompanyName() {return &quot;CompanyName&quot;;}   public static string GetComAddress() {return &quot;ComAddress&quot;;} </li></ul>
  26. 27. <ul><li>www.c-sharpcorner.com </li></ul><ul><li>www.csharpcorner.com 2 </li></ul><ul><li>www.kuro5hin.org </li></ul><ul><li>www.informit.com </li></ul><ul><li>www.forums.asp.net </li></ul><ul><li>www.developerfusion.com </li></ul><ul><li>www.msdn.microsoft.com </li></ul>

×