Saturday, June 4, 2011

Introduction to Object-Oriented Concept

Object – an abstraction of the behaviour and attributes of the entity being modeled.Behaviour – > methods
Attributes – > properties
Class – template
Objects – instances of the class
The dot(.) operator to access the methods of the object (e.g. car.getName())
ASP.NET controls are objects, ASP.NET pages are objects and data access is achieved using objects.
Objects

Model of an entity
An abstraction of the relevant properties and behaviour of the entity being modeled.
An object has
State (properties or attributes) that describe the object (e.g. name)
Behaviour (or methods) – functions that can be performed by the objects. (e.g. access the objects attributes to retrieve or change the values, getName())
Classes

A template for creating objects or instances of a class.
Defines the attributes or properties of the class and the methods or behaviours for the class.
Instances

Class definitions can be used to create objects that are instances of that particular class.
Variable

A name associated with memory location(s) in your computer.
Where you can store data or information in your program.
Data types

Attribute of a piece of data that tells the computer something about what kind of data is being handled.
Example: Integer, Character, Boolean, String, a particular class.
Declaring Variables

Dim VariableName As DataType
Example: Dim FirstName As String, Dim Age As Integer
Assigning Variables

variable = value
Example: FirstName=”Donald”, Age=10
Double quotes are required for Strings
Explicit conversion:
1
AgeTextBox.Text = Age.ToString()
Statements

Instructions to tell the computer what to do.
Need to result in the correct output.
Sequence – Executed in sequence (one after another)
Decision – Branch statement (choose only one to be executed)
Loop – One or more statements that are repeated until some pre-determined endpoint is reached.
Methods

Use to get a class to perform a task.
Functions – return a value
Sub – does not return a value
Sub


[Accessor] Sub functionName([parameters])


statements





End Sub

Public Sub DeleteItem(ByVal rowID As Integer)



Items.RemoveAt(rowID)



End Sub
Items – is a collection

rowID – index of the row to be deleted, passed in to the method.

Items.RemoveAt(rowID) – removes the rowIDth row from the items collection.

Function


[Accessor] function functionName([parameters]) As DataType statements



statements



Return value

End Function

No comments:

Post a Comment