IS437: Fall 2004 Instructor: Dr. Boris Jukic - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

IS437: Fall 2004 Instructor: Dr. Boris Jukic

Description:

Millie Buddy Snoopy. Dog Cashier A Tax Return. Each Object Has A Name (External Identifier) ... Snoopy.Talk 'Bark Bark' Parent class and child class may have ... – PowerPoint PPT presentation

Number of Views:70
Avg rating:3.0/5.0
Slides: 29
Provided by: fishe65
Category:

less

Transcript and Presenter's Notes

Title: IS437: Fall 2004 Instructor: Dr. Boris Jukic


1
IS437 Fall 2004Instructor Dr. Boris Jukic
  • Object Oriented Programming

2
Learning Objectives
  • Object-oriented concepts
  • Implementation of object-oriented concepts in
  • Visual Basic .Net

3
Limitations Of Conventional Languages
  • Small Vocabulary
  • Highly Procedural
  • Logic Buried In Long Lines Of Code
  • Difficult To Re-Use Code
  • Costly To Build And Modify
  • Allow Only Simple Data Structures

4
Object-Oriented Approach PROGRAMMING
LANGUAGES SMALLTALK, C, Java, Visual Basic
.Net
5
Goals
To Achieve Greater Semantic Expressiveness
- Complex Structure - A Variety Of
Relationships - Natural Representation
To Reduce Use of Procedural Blocks of Code To
Enhance Re-Usability
6
Objects Correspond to Real World Constructs
student
university
cashier
car
ATM
radio
sales report
.
7
Key OO Concepts
Object Encapsulation Class Class Hierarchy And
Inheritance Message And Polymorphism
8
Object Encapsulation
Everything Is Modeled As Object Millie
Buddy Snoopy Dog Cashier A
Tax Return Each Object Has A Name (External
Identifier) An Object Has Two Components
- Properties (To Store Information)
Can Take On Complex Structure E.G.
Widget_A (Acquisition_Date, Quantity On Hand)
(( 3/10/92 100) ( 3/20/92 150)
( 3/25/92 200)) - Methods (Behavior
Encapsulation)
9
Record structure in COBOL
Name Social Security
Hobby
John Smith 445-09-2049
Swimming Mary Scott 670-37-4095
Bridge Bill Shoemaker 888-92-9104
Dancing John Smith 123-87-3094
Painting
Records have no common external
identifiers. Attributes are single-valued.
10
Class Example
DOG(COLOR, SPEED)
instance-of relationship
SNOOPY
MILLE
PUPPY
11
Class Hierarchy Example
IS-A-Kind of relationship
ANIMAL
BIRD
DOG
FISH
instance-of relationship
POLLY
MILLIE
MOBY
GENERALIZATION-SPECIALIZATION RELATIONSHIP
12
Class Hierarchy Another Example
IS-A-Kind of relationship
STUDENT
UNDER-GRADUATE STUDENT
MBA STUDENT
PH.D. STUDENT
13
Inheritance
(COLOR, SPEED)
ANIMAL
(Beak, Fly)
(Bark, Ears)
DOG
BIRD
FISH
POLLY
MOBY
MILLIE
14
Polymorphism
  • Ability to take on many shapes and forms
  • Many classes can provide the same property or
    method, without having to worry what type of
    class it is
  • Dog class (eat() method)
  • Mosquito class (eat() method)
  • Of course, same method would be implemented in a
    very different way
  • Same class can have multiple versions of the
    method
  • Overloaded methods

15
Benefits Of OO Approach
- Greater Semantic Expressiveness Can
Represent Is_A Relationships Support Complex
Data Structure - Behavior Encapsulation
Facilitates The Modeling Of Real-World
Objects - Object Library (Re-Use)
- Reduce Procedurality Through An
Enlarged Vocabulary
16
Difficulties
  • Different Programming Paradigm
  • Resistance, Requires a shift in thinking)
  • Increased Complexity
  • Takes time to become acquainted with the library
    of objects

17
Implementation of OO in Visual Basic .Net
  • Object
  • Encapsulation (property and method)
  • Classes over 6,000 in number
  • Class hierarchy and inheritance
  • Polymorphism

Visual Basic .Net supports all of the key OO
concepts. It is a full-fledged OO system.
18
Object, Class, Encapsulation in VB .Net
New keyword creates a new instance of an object
class
19
New Method in VB .Net
  • Also called constructor
  • It is the method that classes use to
    instantiating
  • objects.

Dim label1 as Label Label1 New Label
Dim label1 as New Label
or
20
Add a control to a form
Me.controls.add(label1)
The control to be added
Represents this form
Add to the collection
Collections of controls on a form
21
A Simplified View of Class Hierarchy in VB .Net
Object
IS-A-Kind of relationship
Component
Control
Data Adapter
Label
DateTimePicker
PictureBox
22
Polymorphism in VB .Net
  • Functionally equivalent methods can have the
  • same name
  • VB .Net implements polymorphism in various
  • ways
  • - overloading
  • - overriding
  • - method hiding

23
Polymorphism in VB .Net Overloading
Messagebox.Show(Enter numeric data.) Messagebox.
Show(Enter numeric data., Data entry
error) Messagebox.Show(This is a message.,
This is a title bar, MessageBoxButtons.OK)
Overloading methods sharing the same name, for
the same object, but with different signatures
(argument lists)
24
MessageBox General Form
Messagebox.Show(TextMessage) Messagebox.Show(TextM
essage, TitlebarText) Messagebox.Show(TextMessage,
TitlebarText, MessageBoxButtons) Messagebox.Show(
TextMessage, TitlebarText, MessageBoxButtons,
MessageBoxIcons)
25
Polymorphism in VB .Net Overriding
Talk methodI cannot talk
Animal
Parent class and child class may have methods
with the same name. The method in child class can
override the method in parent class.
Dog
Talk method Bark Bark
Snoopy.Talk Bark Bark
Snoopy
26
Polymorphism method hiding
Button1.Click CustomerForm.Click Checkbox1.Click
27
Namespaces
  • Namespaces are file cabinets for classes, similar
    to the concept of folders.
  • Namespaces can contain classes, other namespaces,
    etc.
  • Namespaces help organize the vast number of
    classes into a neat structure.
  • To make use of a class, we need to reference or
    import the namespace that contains the class.

28
Namespace Hierarchy
System namespace System
Windows.Forms namespace System.Windows.Forms
Data namespace System.Data
Drawing namespace System.Drawing
Button
OleDb namespace System.Data.OleDb
Label
OleDb provides interaction with MS Access.
TextBox
Write a Comment
User Comments (0)
About PowerShow.com