chapter 1: introduction to visual basic.net: background and perspective visual basic.net...
TRANSCRIPT
![Page 1: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/1.jpg)
Chapter 1: Introduction to Visual Basic .NET:
Background and Perspective
Visual Basic .NET Programming:
From Problem Analysis to Program Design
![Page 2: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/2.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 2
Objectives
• Learn basic computer terminology and component architecture
• Explore the history of programming languages
• Recognize the similarities between programming languages and spoken languages
• Solve problems and develop algorithms
![Page 3: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/3.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 3
Objectives (continued)
• Identify basic object-oriented programming concepts
• Examine the benefits of the object-oriented approach
![Page 4: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/4.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 4
Understanding Basic Computer Terminology And Component
Architecture
• Understand basic computer terms
• Fundamentals of how computer works
• Computer requires:
• Hardware
• Software
![Page 5: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/5.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 5
Understanding Basic Computer Terminology And Component
Architecture (continued)• Hardware
– Physical components of computer
• Architecture
– Arrangement of hardware components within computer
![Page 6: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/6.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 6
![Page 7: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/7.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 7
Understanding Basic Computer Terminology And Component
Architecture (continued)• Primary computer components:
– Input/output devices
– Memory
• Read-only memory (ROM)
• Random access memory (RAM)
![Page 8: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/8.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 8
Understanding Basic Computer Terminology And Component
Architecture (continued)
• Primary computer components (continued):
– Central processing unit
• Registers
• Arithmetic logic unit (ALU)
• Control unit
• Software
– Computer programs that are executed by hardware
![Page 9: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/9.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 9
Exploring the History of Programming Languages
• Modern programming languages
– Very powerful
– Enable you to develop sophisticated applications with relative ease
– Bear little resemblance to early counterparts
• HOWEVER, principal underpinnings remain unchanged
![Page 10: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/10.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 10
Machine Language
• Earliest programming languages• Consist of only 0’s and 1’s• Bit
– Binary digit of either 0 or 1– At machine level, computers only truly understand
bits
• Bit patterns– Used to represent other pieces of information
• Example: characters
![Page 11: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/11.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 11
Machine Language (continued)
• Memory location
– Can be represented as binary number using combination of bits
![Page 12: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/12.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 12
![Page 13: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/13.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 13
Assembly Language
• Provides one-to-one correspondence between each machine language instruction and a mnemonic
• Mnemonic
– Word or character string that represents an instruction
• Requires writing set of single-step instructions
• Easier for people to read and write
![Page 14: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/14.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 14
Assembly Language (continued)
• Sample instructions:
– CLR Clear the accumulator
– ADD A Add the contents of memory location A to the accumulator
– SUB G Subtract the contents of memory location G from the accumulator
– STO E Store the contents of the accumulator in memory location E
![Page 15: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/15.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 15
Assembly Language (continued)
• Assembler
– Translates mnemonics and memory location names into underlying machine code
• Program written for one computer architecture
– Usually will not run on different computer architecture
– Drawback of assembly language
![Page 16: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/16.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 16
High-level Languages
• Evolved due to needs for:
– Portability
– More expressive languages
• Easier to read, write, and maintain
• Less efficient in terms of:
– CPU time
– Memory
![Page 17: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/17.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 17
High-level Languages (continued)
• Compiler
– Translate program to machine code
• Linker
– Combines object code with other programs in class libraries
• Loader
– Loads object code into memory
– Executes program
![Page 18: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/18.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 18
High-level Languages (continued)
• Source code
– Program written by programmer
• Class library
– Collection of object files
– Support features and functions of a high-level language
![Page 19: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/19.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 19
![Page 20: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/20.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 20
Learning a Programming Language
• Understand basic vocabulary• Keywords
– Words built into language– Also called reserved words
• Statements– Consist of:
• Keywords
• Identifiers
• Symbols
![Page 21: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/21.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 21
Learning a Programming Language (continued)
• Procedures
– One or more related statements
– Work together to perform specific task
• Modules
– Self-sufficient group of related procedures
– Can combine with other modules to create applications
![Page 22: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/22.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 22
Learning a Programming Language (continued)
• Syntax
– Rules of language
– Includes:
• Spelling
• Punctuation
• Grammar
– Each programming language has own unique syntax and structure
![Page 23: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/23.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 23
Learning a Programming Language (continued)
• Syntax error
– Mistake in program
• Violates language rules
– Compiler checks for syntax errors
![Page 24: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/24.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 24
Learning a Programming Language
• Logic error
– Mistake in program
• Executes and produces incorrect result
– Also known as bugs
– Not checked by compiler
![Page 25: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/25.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 25
Solving Problems and Developing Algorithms
• Computer programming is problem solving
• Problems solved by programs
– Require inputs
– Produce outputs
• Algorithm
– Sequence of steps used to transform input(s) into desired output(s)
![Page 26: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/26.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 26
![Page 27: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/27.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 27
Solving Problems and Developing Algorithms
(continued)
• Critical that programmers embrace problem-solving approach
• Before writing code, programmer must:
– Understand problem at hand
– Properly identify inputs and outputs
– Develop transformation algorithm
![Page 28: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/28.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 28
Example 1-1: Creating a GPA Algorithm
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
![Page 29: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/29.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 29
Example 1-1: Creating a GPA Algorithm (continued)
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
![Page 30: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/30.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 30
Solving Problems and Developing Algorithms
(continued)
• Desk-checking:
– Draw columns by hand that correspond to items in algorithm
– Create set of test data
– Step through algorithm
– Record changing values for each item
![Page 31: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/31.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 31
Example 1-2: Desk-Checking the Algorithm
![Page 32: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/32.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 32
Example 1-2: Desk-Checking the Algorithm (continued)
![Page 33: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/33.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 33
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
![Page 34: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/34.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 34
Identifying Basic Object-oriented Programming
Concepts (continued)
• Object-oriented programming languages:– Becoming more popular
– Examples:• Java
• VB .NET
• Object – Thing that has characteristics and behaviors
![Page 35: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/35.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 35
Identifying Basic Object-oriented Programming
Concepts (continued)
• Attributes
– Characteristics of an object
• Methods
– Behaviors of an object
• Problem domain objects
– Objects specific to problem being solved
![Page 36: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/36.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 36
![Page 37: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/37.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 37
Identifying Basic Object-oriented Programming
Concepts (continued)
• Message
– Asks object to invoke one of its methods
• Encapsulation
– Attributes and methods of object are packaged into single unit
– Do not need to know internal structure of object to send messages to it
![Page 38: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/38.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 38
Identifying Basic Object-oriented Programming
Concepts (continued)
• Class
– Defines what all objects of group have in common
• Instance
– Specific member of group
– Example:
• Cheeseburger is an instance of food class
![Page 39: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/39.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 39
Identifying Basic Object-oriented Programming
Concepts (continued)
• Inheritance
– Class of objects takes on characteristics of another class
• Extends them as necessary
– Subclasses
– Superclass
![Page 40: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/40.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 40
![Page 41: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/41.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 41
Identifying Basic Object-oriented Programming
Concepts (continued)
• Polymorphism
– Different objects can respond in own way to same message
– Related to inheritance of methods
![Page 42: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/42.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 42
Examining the Benefits of the Object-oriented Approach
• Advantages:
– Naturalness
– Reusability
• OO approach still requires algorithm design:
– To define methods of object
![Page 43: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/43.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 43
Summary
• Computer consists of:
– Hardware
– Software
• Programming languages:
– Machine language
– Assembly language
– High-level languages
![Page 44: Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design](https://reader034.vdocument.in/reader034/viewer/2022051018/56649e045503460f94aefc18/html5/thumbnails/44.jpg)
Visual Basic .NET Programming: From Problem Analysis to Program Design 44
Summary (continued)
• 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