Chapter 1

Chapter 1
An Introduction to
Programming and
VB.NET
1-1
Learning Objectives





1-2
Understand importance of information systems in
organizations
List and discuss the six computer operations
Discuss the role of computer programs and
programming languages
Understand concepts of object-oriented
programming in Windows and in VB .NET
List and discuss the steps in developping an
application in VB .NET
Information System

1-3
The combination of technology (computers)
and people that enables an organization to
collect data, store them, and transform them
in useful information
Software



1-4
List of instructions: Programs
Creation of those instructions: Programming
Programming is part of :System
Development
Development




1-5
Identify the problem
Analyze the system
Design the system
Implementation (construction)
Computer Operations






1-6
Input data
Store data in internal memory
Perform arithmetic on data
Compare two values and select an action
accordingly
Repeat a group of actions a number of times
Output the results of precessing
The Six Computer Operations
1-7
Input Data





1-8
From a keyboard
From a mouse
From barcode reader
From data files
From sensors
Store Data in Memory



1-9
Memory location are called Variables
Having data in memory allows rapid access
Data in memory is not static, it is allowed to
be changed by the program
Perform Arithmetic on Data

Includes
–
–
–
–

1-10
Addition
Subtraction
Division
Multiplication
Most manipulation on data in memory can be
seen as arithmetic manipulation
Compare and Select Action

Compare two numerical values
–

Compare textual values
–
1-11
If A>B then do something …
If Name1 = Name2 then …
Repeat Actions a Number of Times



1-12
Keep checking if the next name in a list is the
same as that of the user
Keep adding item prices in a grocery list to
return the total
The computer is king of repetitions!
Output Results

To be useful, the result must be made
accessible
–
–
–
1-13
On a monitor
Printed on paper
Saved in a file on disk
Programs and Programming



1-14
Solution must be a list of steps, this is the
algorithm
The algorithm is not bound to a programming
language, see it as the “English” version of
the program
The algorithm is more important than the
language
Control Structures
1-15

Sequence : ordered list of operations

Decision : control the flow of operation

Repetition : repeat operations until a
certain exit condition is met
Programming in Windows

Windows is based on events
–
–
–
–
1-16
A key being pressed is an event
The mouse moving is an event
Clicking the mouse is an event
Double clicking is an event
VB .NET Language


It allows event-driven programming
It is object-oriented
–
–
–
–
–
1-17
Everything revolves around objects
Each object has properties and methods
Properties are characteristics
Methods are actions the object can take
Some objects can raise events, i.e. notify other
objects that something happened
Characteristics of OOP

Encapsulation
–
–

Inheritance
–

black box view of an object
what is accessible is key, not how it is made accessible
allows for specialization of classes
Polymorphism
–
Different classes (objects) being allowed to be accessed the
same way


1-18
Dog.Run()
Cat.Run()
Programming in VB .NET






1-19
Define problem
Create interface
Develop logic for action objects
Write and test code for action objects
Test overall project
Document project in writing
Case Study: Vintage DVDs

1-20
Want to calculate the taxes and total amount
due on a DVD rental
Step 1: Definition of Problem

Identify input
–

Identify output
–
–

Taxes
Amount due
Identify actions to take
–
–
1-21
Price of DVD
Calculate
Quit the program
Step 2: Creation of Interface


Make a sketch by hand
Decide on the objects required
–


Drag and drop the objects on the form
The layout should be logical
–

Group related objects together
The layout should be eye pleasing
–
1-22
TextBoxes, Buttons, Labels, etc
Avoid to many fonts and loud colors
Step 3: Logic for Action Objects

IPO (Input/Processing/Output) Table
–

Pseudo code
–
–
1-23
For each object, it shows the input, the output,
and what processing needs to be done to get
from one to the other
Step by step instructions in the English language
rather than in a given programming language.
Pseudo code is more natural to the human and is
easy to translate to programming language
Step 4: Write and Test Code

Translate pseudocode or IPO tables into the
syntax of the programming language

Test the code by “running” it in the MSDE
–
–
Test often, every few lines of code written
Make use of test data


1-24
Test ideal conditions
Test problematic conditions
Step 5: Test Overall Project


1-25
Test communication between objects
Make sure the program meets requirements
Step 6: Document Project

Documentation
–

Internal documentation
–
–
–
–
1-26
The written description of the software that aid
users and other programmers
Comments in program to explain the purpose and
logic of the code
Comments are as important as the code
Comments allow for maintenance of the code
Comments start with an apostrophe ( ‘ )
Final Remarks


The development process should be seen as
iterative, you will not get the final solution on the first
try
You should
–
–
–
–

1-27
Design a little
Code a little
Test a little
Document a little
And then repeat the process again and again
Copyright 2004 John Wiley & Sons, Inc.
All rights reserved. Reproduction or translation of this
work beyond that permitted in section 117 of the
1976 United States Copyright Act without express
permission of the copyright owner is unlawful.
Request for further information should be addressed
to the Permissions Department, John Wiley & Sons,
Inc. The purchaser may make back-up copies for
his/her own use only and not for distribution or
resale. The Publisher assumes no responsibility for
errors, omissions, or damages caused by the use of
these programs or from the use of the information
herein
1-28