Object oriented programming in vb.net ppt

Object oriented programming in vb.net ppt
Download

Object oriented programming in vb.net ppt

Skip this Video

Loading SlideShow in 5 Seconds..

Advanced Object- Oriented Programming PowerPoint Presentation

Object oriented programming in vb.net ppt
Object oriented programming in vb.net ppt

Download Presentation

Object oriented programming in vb.net ppt

Advanced Object- Oriented Programming

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

  1. 14 AdvancedObject-OrientedProgramming Programming Right from the Start with Visual Basic .NET 1/e

  2. Objectives • Understand the differences between classes and objects • Understand object terminology, including encapsulation, inheritance, and polymorphism • Know how to create your own classes

  3. Objectives (cont.) • Know how to write constructors with multiple parameter lists • Develop applications that use classes and objects

  4. 14-1 Writing Objects • VB .NET is an object-oriented language. • Forms are objects. • Controls are objects. • Controls are objects that have GUI properties and methods.

  5. Classes and Objects • An object is a combination of data and actions that can be treated as a unit. • A class is the structure of an object, a blueprint that describes the properties (data) and methods (actions) of an object. • An object is created from a class.

  6. 14-2 Object-Oriented Terminology • A language is considered to be object-oriented if it supports three main features: • Encapsulation • Inheritance • Polymorphism

  7. Encapsulation • Encapsulation refers to grouping related properties and methods so they can be treated as a single unit or object. • Encapsulation also refers to protecting the inner contents of an object from being damaged or incorrectly referenced by external code.

  8. Encapsulation (cont.) • One of the basic rules of encapsulation is that class data should be modified or retrieved only through property procedures. • Limiting how external code interacts with the object allows for later modification without risk of compatibility problems.

  9. Encapsulation (cont.) • Encapsulation allows you to control how the data and procedures are used. • You should declare internal details of a class as Private to prevent them from being used outside your class; this technique is called data hiding.

  10. Inheritance • Inheritance describes the ability to create new classes based on an existing class. • The existing class is called the base class, and the new class derived from the base class is called the derived class.

  11. Inheritance (cont.) • The derived class inherits all the properties, methods, and events of the base class and can be customized with additional properties and methods. • Inheritance takes code reuse to a whole new level.

  12. Inheritance (cont.)

  13. Polymorphism • Polymorphism is the ability for objects from different classes to respond appropriately to identical method names or operators. • Polymorphism is essential to object-oriented programming because it allows you to use shared names, and the system will apply the appropriate code for the particular object.

  14. 14-3 Creating YourOwn Classes • A class definition consists of fields, properties, and methods. • A field is a variable in the class and is usually private. • A property is a programming construct that typically provides the interface to a field in a class.

  15. 14-3 Creating YourOwn Classes (cont.) • A method is a function or a sub procedure within a class. • The class definition also may contain constructor methods that are called when a new object is instantiated from the class.

  16. Fields • Fields provide storage for the data in an object and are treated just like variables. • For this text, all field values will be declared Private and all field names will begin with “F”. • [Public|Private] fieldname As datatype

  17. Properties • Private fields of a class cannot be accessed by external code. • If you want an object’s field data to be read or changed, you should include property procedures in the class definition. • The Get property procedure typically retrieves a Private field.

  18. Properties (cont.) • The Set property procedure typically assigns a new value to a Private field. • Some fields are intended to be read-only, meaning external code can view the value of the field, but cannot change its value.

  19. Methods • Methods are procedures defined within a class. • Methods have access to all data within the object – even Private data. [Private|Public] Sub procedurename([parameters]) [statements] End Sub

  20. Constructors • A constructor is a special method that executes during the creation of an object. • All constructor methods are procedures named New. • Sub New ([parameters]) [Statements] End Sub

  21. Constructors (cont.) • When you define a class derived from another class, the first line of a constructor is typically a call to the constructor of the base class. • The base class is referenced by using the keyword MyBase. • MyBase.New()

  22. 14-4 The Complete TMilitaryTime Class Definition

  23. 14-5 The Complete TPerson and TStudent Class Definitions

  24. Chapter Summary • VB. NET is an object-oriented language that supports encapsulation, inheritance, and polymorphism. • Encapsulation refers to grouping related properties and methods so they can be treated as a single unit or object. • Inheritance describes the ability to create new classes based on an existing class.

  25. Chapter Summary (cont.) • Polymorphism is the ability for objects from different classes to respond appropriately to identical method names or operators. • A class definition consists of fields, properties, and methods. • A constructor is a special method that executes during the creation of an object.

  26. 14 AdvancedObject-OrientedProgramming Programming Right from the Start with Visual Basic .NET 1/e

What is VB.NET object

VB.NET is an object-oriented programming language. This means that it supports the features of object-oriented programming which include encapsulation, polymorphism, abstraction, and inheritance. Visual Basic . ASP NET runs on the . NET framework, which means that it has full access to the .

Why VB is object

Visual Basic provides full support for object-oriented programming including encapsulation, inheritance, and polymorphism. Encapsulation means that a group of related properties, methods, and other members are treated as a single unit or object.

What is OOPs concept in .NET with example?

The main ideas behind Object-Oriented Programming (OOPs) concepts include abstraction, encapsulation, inheritance, and polymorphism. Basically, various OOPs concepts let us create working methods and variables, they can be re-used all or part of them without compromising the security concerns of the application.

What is an object in Visual Basic programming?

An object is a combination of code and data that can be treated as a unit. An object can be a piece of an application, like a control or a form. An entire application can also be an object. When you create an application in Visual Basic, you constantly work with objects.