Vous êtes sur la page 1sur 21

m   

{Lecturer, Computer Engineering Department }


Ú ut shows names of objects and related properties ,
methods and events.
Ú To open object browser click on ³object browser´
on toolbar or follow ±
View - > object browser
Ú a new window will open up called ³object browser
³.
Ú To view objects of visual basics , select library as
VB,
Ú =rogramming languages ::
[1] =rocedural
[2] Object oriented

Ú =O= ::
A procedural Oriented programming language emphases
on procedures, functions used in writing a program!
ut concentrates on functions rather then the data being
used!
Ú Object oriented =rogramming language ::
0 OO= is a programming language that concentrates on
objects and methods to design different applications.
0 OO= has many interesting features such as«
Encapsulation
=olymorphism
unheritance
Data abstraction

0 Difference between =O= and OO=s«


1) Encapsulation ::
Ú Encapsulation in OO=-terminology means that an
object has something like a shell around it protecting
the attributes or status variables from being accessed
from outside of the object .
Ú Only the methods of the object have access to them,
can read and modify their values.
Ú The methods, providing the services of the object, are
the interface to the outside world.
¢  
Ú =olymorphism in OO=-Terminology means that a certain
message may be implemented by different objects in different
ways.
Ú Example ::
Ú hape ± circle, square, triangle«
Ú For all we can have area calculated!
Ú "=oly" means "many" and "morph" means "form".
Ú =olymorphism is the ability of an object (or reference) to
assume (be replaced by) or become many different forms of
object.
Ú example: function overloading, function overriding, virtual
functions.
Ú ou drive an automobile, which has properties like wheel
size, engine size, gas tank size, and other properties.
Ú The automobile you drive is a concrete implementation
of the automobile interface.
Ú ut has additional features, like sliding doors, logo type, cd
changer slot count, moon roof lever location, or other
various properties that are specific to the make/model of
the car.
Ú un addition, automobile may have certain behaviors like
open/close door, open trunk, turn wheel, and other
behaviors that would be specific to an automobile.
Ú unheritance is the process by which new classes
called R  R classes are created from existing
classes called  classes.
Ú The derived classes have all the features of the
base class and the programmer can choose to
add new features specific to the newly created
derived class.
Ú Example ::
Ú =arrot is child class [derived class] of parent class
BuD [ base class] .
Ú - 

unheritance helps the code to be reused in many situations.


Using the concept of inheritance, the programmer can create as
many derived classes from the base class as needed while
adding specific features to each derived class as needed.

Ú Õ
   

The above concept of reusability achieved by inheritance saves


the programmer time and effort. ince the main code written can
be reused in various situations as needed.
Ú
Ú This property helps removing complexity!
Ú The complex part of the object is hidden from the
user by this property!
Ú For example«
Ú Latest mobile handset :
we use it for call, sms, mms, voise
massages , images, videos, internet and so on «
But we don¶t go in technical details of how
this facilities are implemented!
Ú o what is an object?
Ú An object is a component of a program that knows how to
perform certain actions and to interact with other pieces of
the program.
Ú Objects can be thought of as "smart" black boxes.
Ú That is, objects can know how to do more than one specific
task, and they can store their own set of data.
Ú Designing a program with objects allows a programmer to
model the program after the real world.
Ú
Ú =erson as object ::
attributes [ properties] ± name, age, height, salary
etc..
methods ± display details of person, calculate salary
etc..

Ú For example ::
Text box as an object has different prosperities and
different methods!
1) Object :: all the tools we use from tool box like
label, command button, check box etc are
objects.
2) =roperties :: properties are the attributes of the
objects«
3) Methods ::actions associated with objects are
called methods«
e.g. Text1.setfocus
Ú All code is written in procedures in VB.
Ú Each of the procedure is one of the sub procedure
which starts with =rivate sub and ends with END
sub
Ú ub procedures are also referred as sub
programs.
Ú Name of it will be given as objectname
_eventname
Example::
Command1_Click()
1) User interaction:: As user clicks mouse button or presses
any key on keyboard an event can be triggered. For
example:: clicking a command button or typing in a text
box etc..
2) Object event:: objects can trigger their own events.. For
example :: timer triggers its own TuME event after a
specified time interval.
3) Operating ystem :: our application may also handle
events triggered by O . For example when a part of
window is hidden by another window event is triggered
by O , and our application can handle it!
4) =rogramming events ::By writing codes even we can
trigger event! For example :: code can be written to click
a command button on specific condition without even
using a mouse!
1) =lanning
1) Design user interface
2) =lan properties
3) =lan basic code [pseudocode]
2) Coding / =rogramming
1) Design user interface
2) et properties
3) Write basic code
åOOD DA !!

Vous aimerez peut-être aussi