61
1 Yun Zhang Chapter 4 Application Software Readings: 4.1 Software Basics 4.2 Using Software Systems 4.3 Batch Script Files 4.4 Databases 4.5 Software Engineering Assessments: Exercise 4

Yun Zhang 1 Chapter 4 Application Software Readings: 4.1 Software Basics 4.2 Using Software Systems 4.3 Batch Script Files 4.4 Databases 4.5 Software Engineering

Embed Size (px)

Citation preview

1

Yun Zhang

Chapter 4 Application Software Readings:

4.1 Software Basics 4.2 Using Software Systems 4.3 Batch Script Files 4.4 Databases 4.5 Software Engineering

Assessments: Exercise 4

2

Yun Zhang

4.1 Software Basics • Exactly what is software?

Software consists of computer programs, support modules, and data modules that work together to provide a computer with the instructions and data necessary for carrying out a specific type of task, such as document production, video editing, or Web browsing.

3

Yun Zhang

• When you purchase a piece of software, you own the physical medium on which it is distributed, typically a diskette or CD. However, the software itself is owned by the author or copyright holder, and what you may legally do with it is determined by the license that was granted at the time of purchase.

4

Yun Zhang

4.2 Using Software Systems

• Software systems usually provide input and control methods that can help users accomplish their tasks quickly and efficiently.

4.2.1 Lab: DOS Commands

DIR , TYPE , TREE , EXIT ……

path : \windows\system32

5

Yun Zhang

4.2 Using Software Systems

• 4.2.2 Lab: Macros–宏定义与宏操作(例:WORD中定义宏和运行宏)

– 利用简单的语法,把常用的动作写成宏,当在工作时,就可以直接利用事先编好的宏自动运行,去完成某项特定的任务,而不必再重复相同的动作

– 宏病毒:某种特殊功能的宏,感染 WORD 的通用模板,使其带有某种自动功能,从而可能具有某种破坏能力

6

Yun Zhang

– It can reduce the amount of time required to create a document.

– It can reduce the chance of entering erroneous data.

– It can simplify a complicated set of interactions, so that other people can perform the operation without understanding all of the details involved with the application interface. You can even place the name of the macro on the application's menu or toolbar, as if you have created a function that was not provided by the application's developers

7

Yun Zhang

4.2 Using Software Systems

• 4.2.3 Lab: Embedding Application Objects – Object Linking and Embedding (OLE) is a

facility provided by more sophisticated applications, and it requires operating system support. The OLE facility allows data (typically graphics or spreadsheets) that has been created by any of a number of different applications to be combined into a single document file.

8

Yun Zhang

4.3 Batch Script Files

• 4.3.1 Advanced Command-Line Functions

• DOS Command Syntax

• Review of File System Commands

• Wildcard Characters

• Redirection and Piping

9

Yun Zhang

DOS Command Syntax• Each line begins with a command name or pro

gram name. • After the command name may come one or mor

e switches. – A switch is written as a slash(/ 斜线 ) followed by a lett

er. – Switches can also take parameters, which are separat

ed from the switch by a colon(: 冒号 ).

• Commands can also take arguments, such as filenames or paths.

10

Yun Zhang

DOS Command Syntax

• The /? switch tells a command to display its Help entry.

• Typing del /? on the Windows Me command line causes the following to display:

11

Yun Zhang

Examples

• C:\>dir

• C:\>dir /w

• C:\>dir /o:n

• C:\>dir c:\windows

• C:\>dir /?

12

Yun Zhang

Review of File System Commandscd Change the working directory.

md Make a new directory.

rd Remove an existing empty directory.

deltree Remove an existing directory and its contents.

attrib Change a file's attributes

copy Make a copy of a file.

xcopy Make a copy of files and sub-directories.

ren Rename a file within a directory.

move Move a file from one drive/directory to another.

del Delete files.

dir List files in a directory.

type Display the contents of a text file.

13

Yun Zhang

Wildcard Characters• Certain commands accept a list of file

names. Rather than typing in an actual list, it is often easier to use an asterisk ( * ) within a file name specification to get the command processor to generate a list of file names for us. An asterisk ( * ) acts as a wildcard character that can match any number of characters in a file name. Here are some examples of an asterisk used as a wildcard character with the dir command:

14

Yun Zhang

Wildcard Characters• List only those files and folders in the root folder

whose names start with "n":dir c:\n*

• List only those files and folders in the root folder whose names end with "n":dir c:\*n

• List only those files and folders in the root folder whose names contain an "n" anywhere:dir c:\*n *

15

Yun Zhang

Wildcard Characters

• List only those files in the root folder that are of type DOC:dir c:\*.doc

• List all files and folders in the root folder.dir c:\* In this last example the wildcard character can be omitted; dir c:\ works just as well.

16

Yun Zhang

Wildcard Characters• There is another wildcard character that is

more specific—the question mark ( ? ) wildcard. The question mark wildcard represents any one character. This means that a character must exist in the spot designated by a question mark wildcard. Consider the following two commands:

• del c:\*.*del c:\????????.???

17

Yun Zhang

Redirection– On a PC, the command processor

coordinates with the operating system to redirect all data from the keyboard driver to the Standard Input virtual device and all data from the Standard Output virtual device to the display driver. Redirection allows the user to change this.

– The left angle bracket ( < ) is used to redirect standard input, and the right angle bracket ( > ) is used to redirect standard output.

18

Yun Zhang

Some examples of the use of redirection• List all files in the root folder to the printer i

nstead of the display:

dir c:\*.* >lpt: • Create a new text file called "temp.txt" con

taining a list of files in the root folder. (Note: Nothing will appear on the display.):

dir c:\*.* >c:\temp.txt

19

Yun Zhang

Some examples of the use of redirection• Run "program.exe" and have it get data from the

text file INPUT.DAT rather than the keyboard:

c:\program.exe <c:\input.dat • Run "program.exe", have it get data from the tex

t file "input.dat" rather than the keyboard, and display the output on the printer:

c:\program.exe <c:\input.dat >lpt:

20

Yun Zhang

Some examples of the use of redirection

– Another bit of syntax allows you to append output to the end of a file—or else create the file if it does not already exist

– dir c:\*.* >>c:\temp.txt

21

Yun Zhang

Piping• Piping is a function of the command

processor that links two commands together via redirection: the output of the first command becomes the input to the second.

22

Yun Zhang

Piping

• To pipe data from one command to another as described above, the user separates the two commands on the command line with a vertical bar character ( | ).

• Display all the options of the dir command: dir /? | more

23

Yun Zhang

4.3.2 Batch File Commands

• Batch Files

• Commands

• Like Macros, which were discussed in 4.2.2 Lab: Macros, batch files automate tasks.

24

Yun Zhang

• Review of File System Commands cd Change the working directory.

md Make a new directory.

rd Remove an existing empty directory.

deltree Remove an existing directory and its contents. (Use rd /s in Windows NT/2000.)

attrib Change a file's attributes (for example, read-only file, system file, hidden file)

copy Make a copy of a file.

xcopy Make a copy of files and sub-directories.

ren Rename a file within a directory.

move Move a file from one drive/directory to another.

del Delete files. Warning: Files that are deleted in DOS or from the Command Window cannot be restored.

dir List files in a directory.

type Display the contents of a text file.

25

Yun Zhang

4.3 Batch Script Files

4.3.2 Batch File Commands

• Create a new Batch file

• Commands

• Rem , echo , echo. , @echo off , pause , :label , goto label , if exist filename

4.3.3 Lab: Creating a Batch File

26

Yun Zhang

• Example---- swap.bat

REM Here is the source to SWAP file1 file2@ECHO OFFREM Remember that / precedes a switch.REM Use HELP DEL or DEL /? to find out about /QDEL/Q TEMPMOVE %1 TEMPMOVE %2 %1MOVE TEMP %2

27

Yun Zhang

4.3.2 Batch File Commands• The following is a list of command-line features c

ommonly used in batch files:• rem remark

This designates anything that follows the rem command on the line (remark in our example) as a comment.

• echo message This command displays message to Standard Output. The echo command can also be used with output redirection to send a message to a file. For example, echo starting stage three.

28

Yun Zhang

4.3.2 Batch File Commands

• echo. Notice the period ( . ) at the end of the echo command. This is a special variation of the echo command, which displays a blank line to Standard Output.

• @echo off This stops commands in the batch file from being displayed to Standard Output.

29

Yun Zhang

4.3.2 Batch File Commands• pause

This command interrupts the execution of the batch file and displays the message "Press any key to continue...." Execution resumes when a single keyboard key is pressed.

• : label Any line in the batch file that starts with a colon ( : ) is considered a label 标签 .Labels are used by certain flow control commands to repeat or skip over certain lines in the file.

30

Yun Zhang

4.3.2 Batch File Commands• goto label

This command causes the command processor to execute the first command line after the label referenced by the command.

• if exist filename command If the statement is true, then the command is executed. E.g.: if exist index.html del index.html

31

Yun Zhang

4.3.3 Lab: Creating a Batch File

• Example of a Batch File

• Example of a Batch File with Arguments

• Try to follow each example and determine what actions are being performed by the commands in the batch file.

32

Yun Zhang

Example of a Batch File• Batch file: COPYWP.BAT

REM Batch file created by John Smith@ ECHO OFFECHO Copying Word and PPT files to a floppy:LOOPECHO Please insert a floppy into drive A:PAUSECOPY C:\data\smith\*.doc a:\COPY C:\data\smith\*.ppt a:\GOTO LOOP

33

Yun Zhang

Example of a Batch File with Arguments• Batch file: COPYWP.BAT

REM Batch file created by John Smith@ ECHO OFFECHO Copying Word and PPT files:LOOPECHO Please insert floppy into drive A:PAUSECOPY C:\data\%1\*.doc a:\COPY C:\data\%1\*.ppt a:\GOTO LOOP

34

Yun Zhang

Example of a Batch File with Arguments• Batch file: COPYWP.BAT

REM Batch file created by John Smith@ ECHO OFFECHO Copying files:LOOPECHO Please insert floppy into drive A:PAUSECOPY C:\data\%1\*.%2 a:\

GOTO LOOP

35

Yun Zhang

4.4 Databases

• Databases are one of the most common business applications of computers

• Example: Every company has an employee database for keeping track of its personnel, and schools have databases to keep track of their students.

• Database , table , record , field , data type

36

Yun Zhang

4.4 DatabasesReading Sequence: • Parsons/Oja, Database Software in Section 3C.

Page 174-176 Learning Goal: Knowledge of the components of a databas

e: fields, records, files and database management software. In Addition: After completing this reading, go to the online phone directory people.yahoo.com and look up the phone number of someone you know. Based on the listing you get back, what fields do you think are present in the database?

Assessments:• Multiple-Choice Quiz 15

37

Yun Zhang

Data management software

• What is data management software?

• Data management software helps you to store, find, organize, update, and report information. Several types of data management software exist, including file management software and database management software.

38

Yun Zhang

File Management Software • File: 1. a named collection of data that is stored

on some storage medium.• 2. a structured file, a collection of records, each

with the same set of fields that can hold data.• Each record记录 holds data for a single entity实体— a person, place, thing or event. A field字段 holds one item of data relevant 相应的 to a record, contains the smallest unit of meaningful data in a data file.

39

Yun Zhang

Basic Concepts

• Data( 数据 )

• Database( 数据库 )

• DBMS( 数据库管理系统 )

• DBS( 数据库系统 )

40

Yun Zhang

SQL

• Structured Query Language (SQL) is a popular query language used by numerous data management software packages.

• SQL 语言的动词SQL 功能 动词数据定义 CREATE,DROP,ALTER

数据查询 SELECT

数据操纵 INSERT,UPDATE,DELETE

数据控制 GRANT,REVOKE

41

Yun Zhang

SQL Example

[ 例 1] 查询全体学生的学号与姓名。SELECT Sno , Sname

FROM Student ;  

[ 例 2] 查询全体学生的姓名、学号、所在系。SELECT Sname , Sno , Sdept

FROM Student ;

42

Yun Zhang

SQL Example[ 例 3] 查询全体学生的详细记录。

SELECT Sno , Sname , Ssex , Sage ,Sdept

FROM Student ; 或SELECT *

FROM Student ;

43

Yun Zhang

SQL Example[ 例 4] 查全体学生的姓名及其出生年份。

SELECT Sname , 2007-SageFROM Student ; 输出结果:

Sname 2007-Sage --------- ------------- 李勇 1976 刘晨 1977 王名 1978 张立 1978

44

Yun Zhang

4.5 Software Engineering

4.5.1 Issues in Large-Scale Software Development

• The Software Development Process

1.Define or redefine the problem. 2.Plan a solution to the problem. 3.Code the solution. 4.Evaluate and test everything.

45

Yun Zhang

• In very large systems, such as the software that controls a major e-commerce Web site, there may be hundreds of people working together to create the desired software system. As the size of the development team increases, the need for a shared understanding of the goals for the system becomes increasingly important.

46

Yun Zhang

• Define or Redefine the Problem – 对需求的共识– 形成规范的文档– 可能需要一个反复的过程

• Plan a Solution to the Problem – 列举可能的解决方案– 设计系统方案,并进行测试验证

47

Yun Zhang

• Code the Solution – Programmers code a system in the chosen lang

uage or languages – Programmer testing of solution – System acceptance

• Evaluate and Test Everything – 性能评估– 功能测试– 如需要,重新设计与处理

48

Yun Zhang

4.5 Software Engineering

4.5.2 Open Source Model

• Unless you work for Microsoft, you will not be allowed to read the source code for the Windows operating system. But, you can read the source code for the Linux operating system, make copies of it, even give it away for free. Linux is an example of an open source software project.

49

Yun Zhang

• Enjoy programming and have a need for that particular piece of software, so it is in their interest to help improve it by adding new features or fixing bugs.

• It is still possible to make money with open source software, by selling support services, printed manuals, or proprietary add-ons that enhance an open source product

• Free Software , the software is protected by a license

50

Yun Zhang

Open Source Model• Open source advocates argue that when

code is available for anyone to read, "All bugs are shallow," meaning they will be tracked down quickly by somebody.

• In addition, some users place a greater degree of trust in open-source systems because it is harder to hide malicious features, such as built-in security holes or mechanisms that violate privacy.

51

Yun Zhang

Open Source Model• Most software today is still produced using a

closed-source model. Companies must invest substantial funds to create a successful software product. Giving the code away would rob them of the chance to recoup those costs through sales. The code may also contain what a company regards as proprietary technology, or trade secrets, such as tricks for improving the performance of a database system, that it does not want to reveal to competitors.

52

Yun Zhang

Open Source Model• It is still possible to make money with open

source software, by selling support services, printed manuals, or proprietary add-ons that enhance an open source product. Several companies now market Linux distributions this way. Another famous open source software system is the Netscape browser. Originally developed as a closed source product, Netscape decided to turn the browser into an open source system and give it away for free. The company makes money by selling server software and other services.

53

Yun Zhang

Software License • Free software 自由软件 may be used for any p

urpose, copied, modified, and redistributed at will. In order to ensure that these freedoms are preserved in all copies and derivative versions, the software is protected by a license. A variety of free software licenses have been proposed. One is called copyleft, a pun on "copyright."– GPL license ( GNU General Public License)– BSD license ( Berkeley Software Distribution license,)

• Shareware• Public Domain Software

54

Yun Zhang

4.5 Software Engineering

4.5.3 Tools for Software Creation and Management

• Editors – 纯文本的编辑– 支持对特定语言格式的识别和语法检查

• Compilers – Compilers take program source code written by

people as input and produce object code suitable for machine execution

– 语法错误的识别和错误报告

55

Yun Zhang

• Debuggers – The most popular of debugging tools are the vis

ual debuggers, which provide a graphical representation of the program's execution

• Integrated Development Environments (IDEs)– IDEs have become increasingly popular – IDEs like Microsoft Visual Studio, IBM Visual Ag

e, and Symantec Cafe are software suites consisting of editors, compilers, debuggers, and software engineering tools for program documentation and maintenance.

56

Yun Zhang

Exercise 4• Question 1. DOS Commands• In this section, you will interface with the operati

ng system using DOS commands.

For each of the following tasks, list the correct DOS command. Note: While it is not necessary to perform these tasks on a computer, the assignment is structured for each task to be completed in sequence; that is to say, a task may depend on the state created by previous tasks.

57

Yun Zhang

• Display the syntax and switches for the command dir. • List all directories and files in C:\, pausing if the informati

on scrolls off the display. • List all directories and files in C:\ with a three-character fi

le name beginning with W. • List all files in C:\ whose extension contains X and sort th

e results by size. • List all directories and files in C:\, redirecting the output t

o a file named "ssd2.txt" in directory C:\. • List all directories and files in C:\, appending the output t

o ssd2.txt. • In directory C:\, create a subdirectory called "SSD2". • Copy ssd2.txt to directory SSD2. • Rename ssd2.txt in directory SSD2 as "ssd2.bak". • Delete ssd2.txt. • Remove directory SSD2.

58

Yun Zhang

Exercise 4• Question 2. Batch File Creation• In this section, you will interface with the operati

ng system using DOS commands.

For each of the following tasks, list the correct DOS command. Note: While it is not necessary to perform these tasks on a computer, the assignment is structured for each task to be completed in sequence; that is to say, a task may depend on the state created by previous tasks.

59

Yun Zhang

Exercise 4• Name the batch file EXDIR.BAT. • Include your name as a remark in EXDIR.BAT. • Include the creation date as a remark in EXDIR.

BAT. • Include the function of EXDIR.BAT as a remark i

n EXDIR.BAT- redirects the output of dir C:\ to a file named by the user.

• The filename provided by the user is the first argument.

60

Yun Zhang

Exercise 4• A valid switch for the command dir is the optiona

l second argument. • If the file named by the user already exists, EXDI

R.BAT immediately generates an error message and then exits without executing dir.

• The error message generated by EXDIR.BAT must display, "filename already exists, aborting EXDIR."

• Please upload and submit your batch file (EXDIR.BAT) when you are done.

61

Yun Zhang

Exercise 4• Question 3. Database Specification• Consider creating a database on an e-commerce Web

server.• The three tables in the database are Customer Inform

ation, Supplier Information, and Warehouse Information. For each table, do the following:

• List the fields required to capture all of the information necessary and their corresponding data types. Your answer should be in the following format:[table name][field name]: [data type]Possible data types for the fields are Text, Numeric, Integer, Date, and Currency.

• Indicate which of the fields in a table is the primary key for the table.