Chapter Four Software Basics: The Ghost in the Machine Chapter Outline • Processing with Programs • Application Software: Tools for Users • System Software: The HardwareSoftware Connection • The User Interface: The HumanMachine Connection 1999 Addison Wesley Longman 4.2 Processing with Programs • Software programs: – Are invisible and complex – Must be clear – Must be free of errors – Are a set of instructions that tell a computer what to do 1999 Addison Wesley Longman 4.3 A Fast, Stupid Machine • Computers: – Have limited capabilities – Can only do basic mathematics and logical comparisons – Must be instructed with programs what to do 1999 Addison Wesley Longman 4.4 The Language of Computers • Programmers begin with an algorithm, which is: – A set of step-by-step instructions (written in a natural language, e.g., English) • Algorithms are translated into the vocabulary of a programming language 1999 Addison Wesley Longman 4.5 Flow Chart (I) • • • • • process decision terminal joint flow line 1999 Addison Wesley Longman 4.6 Flow Chart (II) • predefined procedure • input • output • I/O 1999 Addison Wesley Longman 4.7 Control Structures • sequential execution ( concatenation ) • conditional execution ( alternation ) • looping ( iteration ) 1999 Addison Wesley Longman 4.8 Top-Down Structure Design • • • • define the problem design the algorithm as procedures refine the procedures into pseudo code code the program 1999 Addison Wesley Longman 4.9 Programming Languages • Programming languages bridge the gap between the natural language of the human and the numeric codes (zeros and ones) understood by the computer • Examples include: – COBOL, BASIC, and C++ 1999 Addison Wesley Longman 4.10 Programming Languages • low level languages – machine language – assembly language (symbolic language) • high level languages – machine independent – problem oriented – familiar notations 1999 Addison Wesley Longman 4.11 High Level Languages • • • • • 1957 1960 1965 1971 1972 Fortran COBOL BASIC Pascal C 1999 Addison Wesley Longman Z=X+Y ADD X TO Y GIVING Z Z=X+Y z:=x+y; z=x+y; 4.12 High Level Languages • 1980 • 1985 • 1990 Ada C++ Java Sorting ( Ordering ) • internal sort • external sort 1999 Addison Wesley Longman 4.14 Internal Sort • straight – exchange ( bubble sort ) – insertion sort – selection sort • advanced – shell sort – heap sort – quick sort 1999 Addison Wesley Longman 4.15 Bubble Sort • • • • • 44 55 12 42 94 18 06 67 06 44 55 12 42 94 18 67 06 12 44 55 18 42 94 67 06 12 18 44 55 42 67 94 06 12 18 42 44 55 67 94 1999 Addison Wesley Longman 4.16 Bubble Sort • • • • • • • • • • 1000 1010 1020 1030 1040 1050 1060 1070 1080 1090 REM bubblesort subroutine FOR M = 2 to N FOR I=N to M step -1 IF A(I-1) <= A(I) THEN 1070 TEMP = A(I-1) A(I-1) = A(I) A(I) = TEMP NEXT I NEXT M RETURN 1999 Addison Wesley Longman 4.17 Insertion Sort • • • • • • • 44 55 12 42 94 18 06 67 44 55 12 44 55 12 42 44 55 94 12 18 42 44 55 94 06 12 18 42 44 55 94 06 12 18 42 44 55 67 94 1999 Addison Wesley Longman 4.18 Insertion Sort • procedure straightinsertion • var i,j: index; x:integer; • begin • for i := 2 to n do begin • x := a[i]; a[0] := x; j := i-1; • while x< a[j] do • begin a[j+1] := a[j]; j := j-1 end; • a[j+1] := x; • end • end; 1999 Addison Wesley Longman 4.19 Selection Sort • • • • • • 44 55 12 42 94 18 06 67 06 55 12 42 94 18 44 67 06 12 55 42 94 18 44 67 06 12 18 42 94 55 44 67 06 12 18 42 44 55 94 67 06 12 18 42 44 55 67 94 1999 Addison Wesley Longman 4.20 Selection Sort • for (i=1;i<n; i++) { • min = i; • for( j= i+1; j<n; j++) • if (a[j] < a[min]) min= j; • temp= a[i]; • a[i] = a[min]; • a[min] = temp; • }; 1999 Addison Wesley Longman 4.21 Shell sort • • 4 sort • 2 sort • 1 sort 44 55 12 42 94 18 06 67 44 18 06 42 94 55 12 67 06 18 12 42 44 55 94 67 06 12 18 42 44 55 67 94 • each pass profits from previous pass • diminishing increment yields better result 1999 Addison Wesley Longman 4.22 Heap sort • • • • • 44 55 12 42 | 94 44 55 12 | 42 94 44 55 | 06 42 94 44 | 42 06 55 94 | 06 42 12 55 94 • • • 12 42 18 55 94 67 44 | 06 18 42 44 55 94 67 | 12 06 42 55 44 67 94 | 18 12 06 1999 Addison Wesley Longman 18 18 18 18 18 06 06 12 12 44 67 67 67 67 67 4.23 Quick sort • • 44 55 12 42 94 06 18 67 18 06 12 42 94 55 44 67 1999 Addison Wesley Longman 4.24 Application Software: Tools for Users • Software applications include: – Consumer software – Integrated software – Vertical-market and custom software 1999 Addison Wesley Longman 4.25 Consumer Applications • There are thousands of different consumer software titles • Consumer software differs based on: – Documentation – Upgradability – Compatibility – Warranty – Extent of ownership/license 1999 Addison Wesley Longman 4.26 Documentation • Documentation includes: – Printed tutorial and reference manuals that explain how to use the software – On-line manuals and help screens which offer immediate help to the user 1999 Addison Wesley Longman 4.27 Upgrades • Rather than buy the latest version and discard your old one, often you can pay a fee to the software maker and upgrade the old version to the new one • Newer versions of a software company’s product usually have additional features and fewer bugs 1999 Addison Wesley Longman 4.28 Compatibility • Compatibility means the software will function properly with the hardware, operating system, and any peripherals • To date, there is no industry standard that software must follow 1999 Addison Wesley Longman 4.29 Warranty • Buyer beware! • Software manufacturers limit their liability for software problems by selling their software “as is” • Error-free software does not exist 1999 Addison Wesley Longman 4.30 Ownership/Licensing • Three categories: – Purchased software grants you a license to use the software as the software company tells you – Shareware software is free for the trying, but a nominal fee is to be paid to the programmer if you continue to use it – Public domain software is legally free and cannot be owned or licensed 1999 Addison Wesley Longman 4.31 Integrated Applications and Suites: Multipurpose Software • Multipurpose software that includes most of these modules: – Word processing – Database – Spreadsheet – Graphics – Telecommunications 1999 Addison Wesley Longman 4.32 Integrated Software: Advantages • Costs less than buying the applications individually • Data is easily transferred between modules • Commands used in each module are usually the same • Usually there is a seamless integration of the modules 1999 Addison Wesley Longman 4.33 Vertical-Market and Custom Software • Job-specific software: – Medical billings – Library cataloging – Restaurant management – Single-client software needs 1999 Addison Wesley Longman 4.34 System Software: The Hardware-Software Connection • Operating Systems • Language Processors • Utility Programs 1999 Addison Wesley Longman 4.35 Language Processors • Assemblers • Compilers • Interpreters 1999 Addison Wesley Longman 4.36 What the Operating System Does • The operating system controls: – Communication with peripherals – Coordination of concurrent processing – Memory management – Monitoring of resources and security – Management of programs and data – Coordinating network communications 1999 Addison Wesley Longman 4.37 Operating System • to make users comfortable • to make machines efficient • MS-DOS – single user, single-task • WINDOWS – single user, multi-task • Unix – multi user, multi-task 1999 Addison Wesley Longman 4.38 Microsoft O.S. • 1980 MS-DOS – text mode • 1990 MS-Windows 3.0 – graphic mode – multi-tasking • 1995 MS-Windows 95 – native O.S. – plug & play – network management 1999 Addison Wesley Longman 4.39 Microsoft O.S.(II) • 1998 MS-Windows 98 – Web integration – support multi-medium • 2000 MS-Windows Me – more reliable 1999 Addison Wesley Longman 4.40 Utility Programs • Utility software controls tasks such as: – repairing damaged files – making it easy for users to copy files from one storage device to another – translating files so different software can read them – guarding against viruses 1999 Addison Wesley Longman 4.41 The User Interface: The Human-Machine Connection • The user interface is what the user sees on the screen and interacts with • Two major user interface types: – Character-based interface – Graphical user interface 1999 Addison Wesley Longman 4.42 A Character-Based User Interface: MS-DOS • This is a disk operating system in which the user interacts with characters – letters – numbers – symbols 1999 Addison Wesley Longman 4.43 A Character-Based User Interface: MS-DOS • MS-DOS™ is the most widely used general-purpose operating system • Features include: – Command-line interface (commands are typed) – Menu-driven interface (commands are chosen from on-screen lists) 1999 Addison Wesley Longman 4.44 Graphical User Interfaces: Macintosh • This is a disk operating system in which the user interacts with the computer by using a pointing device (e.g. a mouse) • As early as 1984, the Macintosh™ computer was designed with this interface in mind 1999 Addison Wesley Longman 4.45 Graphical User Interfaces: Windows • In 1995, Windows 95™ was released as a graphical user interface for IBM™ computers and their compatibles 1999 Addison Wesley Longman 4.46 Why WIMP Won • Windows, Icons, Menus, and Pointing devices • In this graphical user interface, the cursor of the pointing device (mouse) appears on the screen and can be used to point to icons, work within windows, and select from menus 1999 Addison Wesley Longman 4.47 Tomorrow’s User Interfaces • Future interfaces will probably: – Make individual applications obsolete – Support natural languages (talk to the machine and it talks back) – Include artificial intelligence and agents that fit our needs – Be based on virtual reality (data in three-dimensional physical space) 1999 Addison Wesley Longman 4.48 Rules of Thumb: Computer Consumer Concepts Before you buy, you should consider: • • • • • • Cost Compatibility Capacity Customizability Capability Connectivity 1999 Addison Wesley Longman • Convenience • Company • Purchasing Curve 4.49 Cost • Before you buy: – Determine what you can afford – Allow for “extras” – Join a user group or talk with other computer and software owners 1999 Addison Wesley Longman 4.50 Compatibility • Before you buy, make sure you know: – What is the right computer and software for what you want to do – If the computer and software you will need work well together 1999 Addison Wesley Longman 4.51 Capacity • Before you buy, make sure you know: – How much computer power you are going to need – If the processor will be able to handle your demands – If you will be able to upgrade later on 1999 Addison Wesley Longman 4.52 Customizability • Before you buy, make sure you know: – If your computer can be customized to fit your needs (such as video editing) 1999 Addison Wesley Longman 4.53 Capability • Before you buy, make sure you know: – Which computer is the right tool for you – If the computer and software will be able to meet your demands today and years from now 1999 Addison Wesley Longman 4.54 Connectivity • Before you buy, make sure you: – Have included a high-speed modem or some other network connection – Can take full advantage of the communication capabilities of your computer 1999 Addison Wesley Longman 4.55 Convenience • Before you buy, make sure you determine: – Whether portability or permanent connection of peripherals is important – Which kind of user interface will help you do your work easier – If you should have the same machine as people around you 1999 Addison Wesley Longman 4.56 Company • Before you buy, make sure you know: – if you are buying from a reputable company – if parts and service will be available if needed 1999 Addison Wesley Longman 4.57 Purchasing Curve • Most models of personal computers seem to have a useful life span of just a few years • Before you buy, make sure you know: – how new or old the computer is that you want to buy – not to buy a brand new computer model – not to buy an “obsolete” computer model 1999 Addison Wesley Longman 4.58