Advanced Object- Oriented Programming Programming Right from the Start with Visual Basic.NET 1/e 14.

Slides:



Advertisements
Similar presentations
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
Advertisements

ITEC200 – Week03 Inheritance and Class Hierarchies.
Creating Classes from Other Classes Chapter 2 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Classes, Encapsulation, Methods and Constructors
Using Visual Basic.NET in Web Pages ASP.NET. Object-Oriented Programming (Page 1) Classes and Objects – Create objects based upon a class An object is.
ASP.NET Programming with C# and SQL Server First Edition
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
BACS 287 Basics of Object-Oriented Programming 1.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Object Based Programming. Summary Slide  Instantiating An Object  Encapsulation  Inheritance  Polymorphism –Overriding Methods –Overloading vs. Overriding.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Microsoft Visual Basic 2005: Reloaded Second Edition
Module 7: Object-Oriented Programming in Visual Basic .NET
An Object-Oriented Approach to Programming Logic and Design
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Chapter 10: Writing Class Definitions Visual Basic.NET Programming: From Problem Analysis to Program Design.
CHAPTER ONE Problem Solving and the Object- Oriented Paradigm.
Programming Pillars Introduction to Object- Oriented Programming.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
Creating Classes and Objects Chapter Microsoft Visual Basic.NET: Reloaded 1.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Object-Oriented Application Development Using VB.NET 1 Chapter 6 Writing a Problem Domain Class Definition.
Chapter Eleven Classes and Objects Programming with Microsoft Visual Basic th Edition.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Programming with Microsoft Visual Basic 2012 Chapter 11: Classes and Objects.
1.
Microsoft Visual Basic 2012 CHAPTER ELEVEN Multiple Classes and Inheritance.
Object-Oriented Programming. Objectives Distinguish between object-oriented and procedure-oriented design. Define the terms class and object. Distinguish.
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
Introduction to Object-Oriented Programming Lesson 2.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 27 I Love this Class.
CITA 342 Section 1 Object Oriented Programming (OOP)
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Object-Oriented Programming: Inheritance and Polymorphism.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Object-Oriented Programming: Classes and Objects Chapter 1 1.
Object-Oriented Programming: Classes and Objects.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Copyright © 2012 Pearson Education, Inc. Chapter 4 Writing Classes : Review Java Software Solutions Foundations of Program Design Seventh Edition John.
Section 2.1: Programming paradigms
Object-Oriented Programming: Classes and Objects
Multiple Classes and Inheritance
Microsoft Visual Basic 2005: Reloaded Second Edition
Table of Contents Class Objects.
Section 2.1: Programming paradigms
Object-Oriented Programming: Inheritance
Chapter 11 – Object-Oriented Programming
Programming with Microsoft Visual Basic 2008 Fourth Edition
Object-Oriented Programming: Classes and Objects
Object-Oriented Programming: Inheritance and Polymorphism
Object-Oriented Programming: Inheritance
CIS16 Application Development and Programming using Visual Basic.net
Object-Oriented PHP (1)
Object-Oriented Programming: Inheritance
C++ Object Oriented 1.
Creating and Using Classes
Presentation transcript:

Advanced Object- Oriented Programming Programming Right from the Start with Visual Basic.NET 1/e 14

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 2 Objectives Understand the differences between classes and objects Understand object terminology, including encapsulation, inheritance, and polymorphism Know how to create your own classes

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 3 Objectives (cont.) Know how to write constructors with multiple parameter lists Develop applications that use classes and objects

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall Writing Objects VB.NET is an object-oriented language. Forms are objects. Controls are objects. Controls are objects that have GUI properties and methods.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall Object-Oriented Terminology A language is considered to be object- oriented if it supports three main features: –Encapsulation –Inheritance –Polymorphism

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 12 Inheritance (cont.)

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall Creating Your Own 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall Creating Your Own 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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()

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall The Complete TMilitaryTime Class Definition

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall The Complete TPerson and TStudent Class Definitions

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Crews/Murphy – Programming Right From the Start with Visual Basic.NET 1/e – ©2004 Prentice Hall 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.

Advanced Object- Oriented Programming Programming Right from the Start with Visual Basic.NET 1/e 14