Chapter 1B: Introduction to Visual Basic .NET: Background and Perspective

plumponionchipsSoftware and s/w Development

Nov 18, 2013 (3 years and 6 months ago)

58 views

CSIT 108

Fall 2007

Page
1

of
4

Chapter 1
B
: Introduction to Visual Basic .NET:

Background and Perspective


1.

Solving Problems and Developing Algorithms



Computer programming is problem solving



Problems solved by programs



Require inputs



Produce outputs



Algorithm



Sequence of steps used to t
ransform input(s) into desired output(s)



Critical that programmers embrace problem
-
solving approach



Before writing code, programmer must:



Understand problem at hand



Properly identify inputs and outputs



Develop transformation algorithm



Pseudo code



a short h
and way of describing a computer program. Rather than using the
specific syntax of a computer language, more general wording is used.
I
t is
easier for a non
-
programmer to unders
tand the general workings of a

program

by reading pseudo code instead of the ac
tual programming language
.


Example 1
-
1: Creating a GPA Algorithm



(Credit Hours
: The amount of credit

that

students receive for completing a specific course)



Pseudo code:

Set TotalPoints,

TotalHours, and GPA equal to 0

For each course


Get Grade and CreditHours


Add CreditHours to TotalHours


If Grade is an ‘A’, multiply CreditHours by 4 and add result to TotalPoints


If Grade is a ‘B’, multiply CreditHours by 3 and add result to TotalPoints

If Grade is a ‘C’, multiply
CreditHours by 2 and add result to TotalPoints


If Grade is a ‘D’, multiply CreditHours by 1 and add result to TotalPoints

When no more courses


If TotalHours is not 0, calculate GPA = TotalPoints/TotalHours




Desk
-
checking:



Draw columns by hand that corres
pond to items in algorithm



Create set of test data

CSIT 108

Fall 2007

Page
2

of
4



Step through algorithm



Record changing values for each item





2.

Identifying Basic Object
-
oriented Programming Concepts



Procedural programming



Defining set of steps to transform

inputs into outputs



Translating steps into code



Object
-
oriented programming



Defining collection of objects that work together to solve problem



Object
-
oriented programming languages:



Becoming more popular



Examples:



Java



VB .NET



Object




Thing that has char
acteristics and behaviors



Attributes



Characteristics of an object



Methods



Behaviors of an object



Problem domain objects



Objects specific to problem being solved




Message



Asks object to invoke one of its methods



Encapsulation



Attributes and methods of obje
ct are packaged into single unit



Do not need to know internal structure of object to send messages to it



Class



Defines what all objects of group have in common



Instance



Specific member of group



Example:



Cheeseburger is an instance of food class


CSIT 108

Fall 2007

Page
3

of
4





Inheritance



Class of objects takes on characteristics of another class



Extends them as necessary



Subclasses



Superclass






Polymorphism



Different objects can respond in own way to same message



Related to inh
eritance of methods


CSIT 108

Fall 2007

Page
4

of
4

3.

Examining the Benefits of the Object
-
oriented Approach



Advantages:



Naturalness



Reusability



OO approach still requires algorithm design:



To define methods of object


Summary



Computers consists of:



Hardware



Software



Programming languag
es:



Machine language



Assembly language



High
-
level languages



Writing a program:



Understand problem



Develop algorithm



Desk
-
check



Write code



Object
-
oriented programming



Defines a collection of objects that work together to solve a problem