39
T U T O R I A L 2009 Pearson Education, Inc. All rights rese 1 1 Advanced Painter Application Introducing Computers, the Internet and Visual Basic

T U T O R I A L 2009 Pearson Education, Inc. All rights reserved. 1 1 Advanced Painter Application Introducing Computers, the Internet and Visual Basic

Embed Size (px)

Citation preview

T U T O R I A L

2009 Pearson Education, Inc. All rights reserved.

1

1Advanced Painter

ApplicationIntroducing Computers, theInternet and Visual Basic

2009 Pearson Education, Inc. All rights reserved.

2

Outline

1.1 What Is a Computer?

1.2 Computer Organization

1.3 Machine Languages, Assembly Languagesand High-Level Languages

1.4 Visual Basic

1.5 Other High-Level Languages

1.6 Structured Programming

2009 Pearson Education, Inc. All rights reserved.

3

Outline

1.7 Key Software Trend: Object Technology

1.8 The Internet and the World Wide Web

1.9 Introduction to Microsoft .NET

1.10 Test-Driving the Visual Basic Advanced Painter Application

2009 Pearson Education, Inc. All rights reserved.

4

In this tutorial you will learn: ■ Identify the characteristics of low-level and

high-level programming languages.■ Apply the basics of object-oriented programming.■ Run your first Visual Basic application.■ Locate additional .NET and Visual Basic

information.

Objectives

2009 Pearson Education, Inc. All rights reserved.

5

■ Computer use is increasing in almost every field. ■ In an era of rising costs, computing costs are

actually decreasing dramatically because of rapid developments in both hardware and software technology.

■ Silicon-chip technology has made computing economical and popular in business, industry, government and our personal lives.

Introduction

2009 Pearson Education, Inc. All rights reserved.

6

1.1 What Is a Computer?

■ A computer is a device that can perform calculations and make logical decisions much faster than humans can.

■ Computers process data, using sets of instructions called computer programs.

– These programs guide computers through orderly sets of actions that are specified by people known as computer programmers.

2009 Pearson Education, Inc. All rights reserved.

7

1.1 What Is a Computer? (Cont.)

■ A computer is composed of various devicesknown as hardware:

– keyboard

– screen

– mouse

– hard drives

– memory

– DVD drives

– printer

– processing units

■ The programs that run on a computer are referred to as software.

2009 Pearson Education, Inc. All rights reserved.

8

1.2 Computer Organization

Computers can be thought of as being dividedinto six units:■ Input unit: This “receiving” section of the computer obtains information from input devices.

– Input can come from devices such as the keyboard and the mouse.

■ Output unit: This “shipping” section of the computer takes information that the computer has

processed and places it on various output devices.– Output can be displayed on screens, printed on paper,

played on audio/video devices, and transmitted over the Internet.

2009 Pearson Education, Inc. All rights reserved.

9

1.2 Computer Organization (Cont.)

■ Memory unit: This “warehouse” section of the computer stores data while an application is running. Its information is immediately available for processing.

– To be executed, computer programs must be in memory.

– The memory unit retains information until it can be sent to output devices.

– Often, the memory unit is called either memory or primary memory.

– Random-access memory (RAM) is an example of primary memory.

– Primary memory is usually volatile, which means that it is erased when the machine is powered off.

2009 Pearson Education, Inc. All rights reserved.

10

1.2 Computer Organization (Cont.)

■ Central processing unit (CPU): The CPU supervises the operation of the other sections.

■ Arithmetic and logic unit (ALU): The ALU (a part of the CPU) performs calculations and makes decisions.

■ Secondary storage unit: This unit is the “warehousing” section of the computer.

– Devices such as hard drives, CD-ROM drives, DVD drives, and USB memory sticks are secondary storage units.

– These normally hold programs or data that other units are not actively being used.

– The computer can retrieve this information when it is needed later in time. Secondary storage is nonvolatile.

– Information in secondary storage takes much longer to access than information in primary memory.

2009 Pearson Education, Inc. All rights reserved.

11

1.3 Machine Languages, Assembly Languagesand High-Level Languages

■ Programmers write instructions in programming languages. Some of these are directlyunderstandable by computers, and others require intermediate translation steps.

■ Computer languages that are in use today can be divided into three general types:

– machine languages

– assembly languages

– high-level languages

2009 Pearson Education, Inc. All rights reserved.

12

1.3 Machine Languages, Assembly Languagesand High-Level Languages (Cont.)

■ A computer can directly understand only its own machine language.

■ As the “natural language” of a particular computer, machine language is defined by the computer’s hardware design. Machine languages are machine dependent.

■ Machine languages generally consist of streams of numbers (ultimately reduced to 1s and 0s in the binary number system).

2009 Pearson Education, Inc. All rights reserved.

13

1.3 Machine Languages, Assembly Languagesand High-Level Languages (Cont.)

■ The following section of a machine-language program demonstrates the incomprehensibility of machine language to humans:+1300042774+1400593419+1200274027

■ Machine-language programming proved to be slow and error prone.

2009 Pearson Education, Inc. All rights reserved.

14

1.3 Machine Languages, Assembly Languagesand High-Level Languages (Cont.)

■ Programmers began using English-like abbreviations to represent the computer’s basic operations.

■ These abbreviations formed the basis of assembly languages.LOAD BASEPAYADD OVERPAYSTORE GROSSPAY

2009 Pearson Education, Inc. All rights reserved.

15

1.3 Machine Languages, Assembly Languagesand High-Level Languages (Cont.)

■ Translator programs called assemblers convert assembly-language programs to machine language.

■ Although it is clearer to humans, computers cannot understand assembly-language code until it is translated into machine language.

■ Assembly languages still require many instructions to accomplish even the simplest tasks.

2009 Pearson Education, Inc. All rights reserved.

16

1.3 Machine Languages, Assembly Languagesand High-Level Languages (Cont.)

■ To speed up the programming process,high-level languages were developed.

■ Programs called compilers convert high-level-language programs into machine language.

■ High-level languages look almost like everyday English and contain common mathematical notations.grossPay = basePay + overTimePay

■ Visual Basic is one of the world’s most popularhigh-level programming languages.

2009 Pearson Education, Inc. All rights reserved.

17

1.4 Visual Basic

■ Visual Basic evolved from BASIC (Beginner’s All-purpose Symbolic Instruction Code), which was developed as a language for writing simple programs quickly and easily.

■ When Bill Gates founded Microsoft Corporation in the 1970s, he implemented BASIC on several early personal computers.

2009 Pearson Education, Inc. All rights reserved.

18

1.4 Visual Basic (Cont.)

■ In the late 1980s and the early 1990s, Microsoft developed the Microsoft® Windows® graphical user interface (GUI).

■ Visual Basic was introduced by Microsoft in 1991 to make programming Windows applications easier.

2009 Pearson Education, Inc. All rights reserved.

19

1.4 Visual Basic (Cont.)

■ Visual Basic is a so-called object-oriented,event-driven visual programming language.

■ Programs are created with the use of a softwaretool called an Integrated Development Environment (IDE).

■ The latest versions of Visual Basic are fully object oriented and respond to user-initiated events such as mouse clicks, keystrokes and timers.

■ In Visual Studio, it is convenient to make programs by dragging and dropping predefined objects like buttons and textboxes.

2009 Pearson Education, Inc. All rights reserved.

20

1.4 Visual Basic (Cont.)

■ Microsoft introduced its .NET strategy in 2000.■ The .NET platform allows applications to be

distributed to a variety of devices.■ Software components created in different .NET

programming languages can communicate with one another.

2009 Pearson Education, Inc. All rights reserved.

21

1.5 Other High-Level Languages

■ Although hundreds of high-level languages have been developed, only a few have achieved broad acceptance.

■ IBM Corporation developed Fortran in themid-1950s to create scientific and engineering applications.

■ COBOL was developed in the late 1950s by a group of computer manufacturers. COBOL is used primarily for business applications that require the manipulation of large amounts of data.

2009 Pearson Education, Inc. All rights reserved.

22

1.5 Other High-Level Languages (Cont.)

■ The C language gained widespread recognition asa development language for the UNIX operating system.

■ C++ was developed by Bjarne Stroustrup in the early 1980s at Bell Laboratories. C++ provides capabilities for object-oriented programming (OOP).

– Objects are reusable software components thatmodel items in the real world.

– Object-oriented programs are easier to understand, correct and modify.

2009 Pearson Education, Inc. All rights reserved.

23

1.5 Other High-Level Languages (Cont.)

■ Developers use Java to create web pages with dynamic content, to build large-scale enterprise applications, to enhance the functionality of web servers, and to provide applications for consumer devices.

■ In 2000, Microsoft announced C#. The C# programming language was designed specifically for the .NET platform. Like Visual Basic, C# is object oriented and has access to .NET’s library.

2009 Pearson Education, Inc. All rights reserved.

24

1.6 Structured Programming

■ During the 1960s, software-development efforts often ran behind schedule, costs greatly exceeded budgets and the finished products were unreliable.

■ Research activity intended to address these issues resulted in the evolution of structured programming.

■ Pascal was designed for teaching structured programming, but lacks many features needed to make it useful in commercial, industrial and government applications.

■ The Ada programming language, based on Pascal, was developed under the sponsorship of the U.S. Department of Defense (DOD) during the 1970s and early 1980s.

2009 Pearson Education, Inc. All rights reserved.

25

1.7 Key Software Trend: Object Technology

■ Object technology is a packaging scheme for creating meaningful software units.

■ Almost any noun can be reasonably represented as a software object.

■ Objects:– have properties such as color, size and weight

– perform actions such as moving, sleeping or drawing

■ A class specifies the general format of its objects, and the properties and actions available to an object depend on its class.

2009 Pearson Education, Inc. All rights reserved.

26

1.7 Key Software Trend: Object Technology (Cont.)

■ Procedural programming languages focused on actions (verbs) rather than objects (nouns).

■ Object-oriented languages more naturally reflects the way in which we perceive the world.

■ This has resulted in significant productivity gains.– Properly designed classes can be reused on future

projects

– Using libraries of classes reduces the amount of effort required to implement new systems

– The production of software is more understandable because it is better organized and has fewer

maintenance requirements.

2009 Pearson Education, Inc. All rights reserved.

27

1.7 Key Software Trend: Object Technology (Cont.)

■ Instead of worrying about the details of how objects are implemented, you can focus on the behaviors and interactions of objects.

■ Visual Basic is one of the world’s most widely used object-oriented languages.

2009 Pearson Education, Inc. All rights reserved.

28

1.8 The Internet and the World Wide Web

■ In the late 1960s, ARPA rolled out plans to network the main computer systems of ARPA-funded universities and research institutions.

■ This became known as the ARPAnet, the grandparent of today’s Internet.

■ Its main benefit proved to be the capability for quick and easy communication via what came to be known as electronic mail (e-mail).

2009 Pearson Education, Inc. All rights reserved.

29

1.8 The Internet and the World Wide Web (Cont.)

■ The protocol for communicating over the ARPAnet became known as the Transmission Control Protocol (TCP).

■ TCP ensured that messages, consisting of pieces called “packets,” were properly routed from sender to receiver, arrived intact and were assembled in the correct order.

■ One challenge was to enable different networks to communicate with each other.

– ARPA accomplished this by developing the Internet Protocol (IP), which created the current architecture of the Internet.

■ The combined set of protocols is now called TCP/IP.

2009 Pearson Education, Inc. All rights reserved.

30

1.8 The Internet and the World Wide Web (Cont.)

■ Companies started to develop and enhance their Internet presence.

■ This generated fierce competition among communications carriers and hardware and software suppliers.

■ As a result, bandwidth has increased tremendously, while hardware costs have plummeted.

2009 Pearson Education, Inc. All rights reserved.

31

1.8 The Internet and the World Wide Web (Cont.)

■ The World Wide Web is a collection of hardware and software associated with the Internet.

■ In 1989, Tim Berners-Lee of CERN began to develop a technology for sharing information via “hyperlinked” text documents called HyperText Markup Language (HTML).

■ He also wrote communication protocols such as HyperText Transfer Protocol (HTTP).

■ In October 1994, Berners-Lee founded the World Wide Web Consortium, devoted to developing technologies for the World Wide Web.

2009 Pearson Education, Inc. All rights reserved.

32

1.8 The Internet and the World Wide Web (Cont.)

■ The Internet and the web will surely be listed among the most important creations of humankind.

■ Today’s applications can be written to communicate among the world’s computers. This is the focus of Microsoft’s .NET strategy.

■ The Internet and the World Wide Web:– make information instantly and conveniently accessible,

– and allow individuals and small businesses to achieve worldwide exposure.

2009 Pearson Education, Inc. All rights reserved.

33

1.9 Introduction to Microsoft .NET

■ In June 2000, Microsoft announced its .NET initiative

– The .NET initiative permits developers to create applications in any .NET-compatible language.

– Part of the initiative includes Microsoft’s ASP.NET.

■ The .NET strategy extends the idea of software reuse to the Internet.

■ Visual programming enables .NET programmers to create applications using prepackaged graphical components.

2009 Pearson Education, Inc. All rights reserved.

34

1.9 Introduction to Microsoft .NET (Cont.)

■ The Microsoft .NET Framework:– executes applications and web services

– contains a class library (called the Framework Class Library)

– and provides many other programming capabilities.

2009 Pearson Education, Inc. All rights reserved.

35

■ Open a Windows Explorer window and navigate to the C:\Examples\Tutorial01 directory (Fig. 1.1).

Figure 1.1 | Contents of C:\Examples\Tutorial01.

Double click this file torun the application

Test-Driving the AdvancedPainter Application

2009 Pearson Education, Inc. All rights reserved.

36

■ Double-click the file name AdvancedPainter.exe to run the application (Fig. 1.2).

Figure 1.2 | Visual Basic Advanced Painter application.

RadioButtons

Test-Driving the Advanced Painter Application (Cont.)

GroupBoxes

Panel

Buttons

2009 Pearson Education, Inc. All rights reserved.

37

■ Select a small red brush, and begin to draw a flower (Fig. 1.3).

Figure 1.3 | Drawing with a new brush color.

Test-Driving the Advanced Painter Application (Cont.)

2009 Pearson Education, Inc. All rights reserved.

38

■ Select a large green brush and continue drawing (Fig. 1.4).

Figure 1.4 | Drawing with a new brush size.

Test-Driving the Advanced Painter Application (Cont.)

2009 Pearson Education, Inc. All rights reserved.

39

■ Select a medium blue brush and draw rain drops (Fig. 1.5).

Figure 1.5 | Finishing the drawing.

Test-Driving the Advanced Painter Application (Cont.)

Close box