Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction.

Similar presentations


Presentation on theme: "Introduction."— Presentation transcript:

1 Introduction

2 Let’s begin Goal Teach you how to program effectively
Skills and information to be acquired Mental model of computer and network behavior Problem solving Object-oriented design Java

3 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card

4 Computer Organization
Most computers have four major parts—a central processing unit, memory, input devices, and output devices. The central processing unit (CPU) is the brain of the computer. It is where computations are performed and decisions are made. Memory is where the data and software are kept while being processed by the CPU. It is essentially a workspace and scratch pad for the CPU. The CPU both fetches information from and temporarily stores information in the memory. More memory typically means that a computer can run larger software applications and do certain tasks faster. In general, input devices and output devices communicate information between the computer and its users or between itself and other computers. For example, keyboards and mice are input devices that enable a user to issue requests, while monitors and printers are output devices that enable information to be displayed. Intel Pentium 4 microprocessor.

5 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card 3.06 billion operations per second The first line of the advertisement describes the microprocessor in the computer. The computer comes with an Intel Pentium 4® processor running at 3.06 GHz. The advertisement tells us the processor performs 3.06 billion operations per second (i.e., each operation takes about 327 picoseconds). The microprocessor comes with a 512-kilobyte cache. A cache is a very high speed memory used by a microprocessor to store both recently used and soon to be used information and instructions.

6 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card 512 million bytes of memory that can be transferred at double the normal rate A byte is 8 bits A bit is a 0 or a 1 The second line of the ad tells us how much and the type of main memory the machine has. Main memory is where data and software reside when they are being executed by the CPU. This machine has 512 megabytes of main memory, which is a very good amount for running the Windows operating system. More memory is generally better, but having more than 1 GB is not cost effective for the typical user. This particular machine comes with DDR SDRAM memory. The DDR is an acronym for double data rate. What this characteristics means is that data stored in DDR memory can be supplied to the CPU twice as fast as non-DDR memory. The double data rate is achieved in a manner that is analogous to how the jump rope game “double dutch” is played. Instead of a single clock signal (i.e., one rope), there are two clock signals (i.e., two ropes) that double the rate data can be delivered (i.e., the jumper must jump twice as fast).

7 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card Stores 200 billion bytes of data. You want high RPM and low seek time seconds is average The next line of the advertisement gives the specification of the hard disk drive of the machine (see Figure 1.3 for a photograph of a hard disk drive). The hard disk is where data files and software reside. So the larger your hard disk, the more software you can install and the more data you can store (e.g., pictures and music). The advertisement tells us that the capacity of the disk is 200 GB and that the disk is attached to the system using the UATA-100 interface (ultra-advanced technology attachment). This interface defines how fast data can be moved from the disk to the CPU and vice versa. UATA-100 supports transfer rates of 100 MB/second. The internals of a hard disk drive.

8 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card 17” on the diagonal. Resolution up to 1,280 by 1,024 pixels The advertised machine comes with a 17-inch liquid crystal display (LCD). This type of display often is referred to as a flat panel display (see Figure ). These displays show an image using the same technology found in some watches and calculators. The other type of display technology uses a CRT (cathode ray tube). CRT technology is used in most televisions. Compared to CRT displays, LCD panels are very lightweight and take up much less space. LCDs are more expensive currently than CRTs. However, the prices of LCD monitors are dropping as factories convert from production of CRTs to LCDs.  The two most important characteristics of a monitor are the size of its screen and its resolution. The viewing area of a typical monitor ranges in size from 14 inch to 24 inch. The resolution is how many dots per inch can be displayed across and down the screen. A dot in this context often is referred to as a pixel, which stands for “picture element.” The higher the resolution, the sharper the image on the screen. Most monitors support a resolution of 1,024 by 768. High-end monitors may support higher resolutions such as 1,280 by 1,024 and 1,920 by 1,200.

9 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card Microprocessor for displaying images with 64 million bytes of memory. More memory supports more colors and higher resolution The image to display is sent from the computer to the monitor through a device called a graphics card. Because displaying high-resolution images requires significant computation resources, graphics cards contain a microprocessor designed specifically for displaying images. These microprocessors often are referred to as GPUs (graphic processing units) to differentiate them from CPUs. Our advertised machine contains a GPU called the GeForce4 from a company called NVIDIA. Some of the other more popular graphics cards are made by ATI Technologies and Matrox. A key characteristic of a graphics card is how much memory it has. The amount of memory on the graphics card determines the resolution of the image that can be displayed, the number of colors that can be displayed, and the speed at which the monitor can be updated. Low-end graphics cards have 16 to 32 MB of memory, while the high-end graphics cards have 128 MB of memory. The listed graphics card has 64 MB of memory, which should perform well for most applications, including graphics intensive games.

10 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card Reads DVDs 16 times faster than a basic DVD drive. Can hold up to 8 billion bytes of data The advertised machine includes both a DVD drive and a CD-RW drive. A DVD drive enables the playing of DVD movies on the computer. This DVD drive does not support creating DVDs, but such drives are commonly available for the consumer market. A key parameter for DVD and CD-RW drives is the speed at which data can be read or written. Speeds for DVD and CD-RW drives are given in multiples of the speed of the first available drives. The specified DVD drive has a speed rating of 16x, which means it can read at 16 times the speed of the first DVD drives.

11 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card Can read and write CDs. Can hold 650 million bytes of data Reads at 48 times faster and writes 24 times faster than a basic drive The RW in CD-RW indicates the drive can both read and write CDs. These drives are very popular because they enable consumers to create their own music CDs. They are also a good way to back up files. A CD can hold 650 MB of data or several hours of music. The specification for a CD-RW is given in sets of three—the listed drive has the specification 48x/24x/48x. This specification indicates that the drive can write to CD-R media at 48 speed, can write to CD-RW media speed at 24 and can read discs at 48 speed. (CD-R media can be written only once and CD-RW media can be rewritten).

12 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card Can send or receive up to 56 thousand bits per second The machine comes with a 56K modem. A modem (short for modulator/demodulator) enables the computer to connect to the Internet over the telephone line. The 56K indicates the speed at which the modem can send data. A 56K modem can transmit 56 kilobits per second. However, most 56K modems rarely achieve this maximum rate. First, most telephone networks limit the top speed to 53 kilobits per second. Second, the actual rate depends on several factors including the telephone line conditions (e.g., the presence of static or interference) and the distance to the central telephone company equipment.

13 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card Computer operating system using a graphical interface The advertisement also gives the operating system that comes installed on the machine. This machine comes with a version of Microsoft Windows—Windows XP. There are a two major variants of Windows XP: the home edition and the professional edition. The professional edition includes additional features: the ability to encrypt the file system to protect valuable data, a remote desktop so that you can access the machine over the Internet, and offline files and folders, which is useful for a mobile machine that sometimes is connected to a file server. There are other operating systems available for machines. An increasingly popular operating system is Linux. Linux frequently is used by researchers and in computing systems dedicated to high-end applications such as Web servers, network gateways, and file servers. One major reason for Linux’s popularity is that the source code for Linux is available freely. By having access to the source code, Linux can be modified to suit the particular needs of the application. There are several different versions of Linux available with Red Hat Linux being the one used most widely. Before downloading a version of Linux over the Internet, make sure you have a fast connection. Linux is quite large and can take several hours to download over a broadband connection.

14 Computer Organization
Computer advertisement specification Intel® Pentium 4 Processor at 3.06GHz with 512K cache 512MB DDR SDRAM 200GB ATA-100 Hard Drive (7200 RPM, 9.0 ms seek time) 17” LCD Monitor 64MB NVIDIA GeForce4 MX Graphics Card® 16x Max DVD-ROM Drive 48x/24x/48x CD-RW Drive 56K PCI Telephony Modem Windows XP Home Edition SP2 ® 10/100 Fast Ethernet Network Card Can send or receive data at two rates – 10 or 100 million bytes per second The last detail of the advertisement specifies a high-speed network card. A high-speed network card is useful if you want to create your own local area network in your home, or if you have a broadband connection to the Internet. A broadband connection is a high-speed connection via either a cable modem or via digital subscriber line (DSL) service from the telephone company. Unlike the slow speed of a telephone modem connection, cable modems and DSL service offer transmission speeds of several megabytes per second.

15 Home network

16 Backbones

17 Network communication
Communication protocol Set of rules that govern how data is sent and received TCP/IP Exchanging packets of information over the Internet FTP Exchanging files between computes SMTP Exchanging over the Internet POP Exchanging between mail reader and the ISP HTTP Exchanging files over the WWW SSL How information is to be encrypted Think walky-talky over-and-out An important part in the growth of the Internet was the development of efficient protocols. The most important Internet protocol is the TCP/IP (Transmission Control Protocol/ Internet Protocol). It governs how packets of information are sent across the Internet. The TCP specifies both how a message is to be split into the packets and how the packets are to be assembled to reproduce the original message. The IP handles the address part of a packet so that it gets to the right destination. There are other specialized protocols. Most of these protocols are implemented using TCP/IP. Some other common protocols used on the Internet include: The File Transfer Protocol (FTP) specifies how to exchange files between computers. The Simple Mail Transfer Protocol (SMTP) specifies how is moved across the Internet. The Post Office Protocol 3 (POP3) governs how electronic mail ( ) is exchanged between your mail reader (e.g., Outlook and Netscape Communicator) and your Internet Service Provider (ISP). Another protocol for communicating between your local machine and your Internet service provider is IMAP (Internet Message Access Protocol). The Hypertext Transfer Protocol (HTTP) is the set of rules for exchanging files (text, graphic images, sound, video, and other multimedia files) over the World Wide Web (WWW). It specifies the actions that are taken when you click on a link within a document. The Secure Sockets Layer (SSL) is a protocol that specifies how information is encrypted before being sent over the Internet. It is used widely in electronic commerce. You can tell if a Web page is using SSL by noting whether its WWW address begins with https instead of http.

18 Software Program Sequence of instruction that tells a computer what to do Execution Performing the instruction sequence Programming language Language for writing instructions to a computer Major flavors Machine language or object code Assembly language High-level

19 Software Program Sequence of instruction that tells a computer what to do Execution Performing the instruction sequence Programming language Language for writing instructions to a computer Major flavors Machine language or object code Assembly language High-level The instruction set for a machine is a set of binary codes that are unique to its CPU type. Consequently, different computers use different machine languages. The machine language understood by Intel’s Pentium processor is quite different from the machine language understood by IBM’s PowerPC® processor. A major problem with machine language programming is that it is very tedious and error prone to write directly in binary codes. Slightly less tedious is assembly language programming. An assembly language is a symbolic language for coding machine language instructions. Like machine language programmers, assembly language programmers must have a complete understanding of basic operations of the machine. Furthermore, because the corresponding machine operations are so primitive, for even very simple tasks, assembly language programs can be quite long and complicated. Program to which computer can respond directly. Each instruction is a binary code that corresponds to a native instruction

20 Symbolic language for coding machine language instructions
Software Program Sequence of instruction that tells a computer what to do Execution Performing the instruction sequence Programming language Language for writing instructions to a computer Major flavors Machine language or object code Assembly language High-level The instruction set for a machine is a set of binary codes that are unique to its CPU type. Consequently, different computers use different machine languages. The machine language understood by Intel’s Pentium processor is quite different from the machine language understood by IBM’s PowerPC® processor. A major problem with machine language programming is that it is very tedious and error prone to write directly in binary codes. Slightly less tedious is assembly language programming. An assembly language is a symbolic language for coding machine language instructions. Like machine language programmers, assembly language programmers must have a complete understanding of basic operations of the machine. Furthermore, because the corresponding machine operations are so primitive, for even very simple tasks, assembly language programs can be quite long and complicated. Symbolic language for coding machine language instructions

21 Software Program Sequence of instruction that tells a computer what to do Execution Performing the instruction sequence Programming language Language for writing instructions to a computer Major flavors Machine language or object code Assembly language High-level A distinguishing characteristic of a high-level programming language is that detailed knowledge of the machine being programmed is not required. Another characteristic is that a high-level programming language uses a vocabulary and structure that is close to the type of problem being solved. For example, the programming language FORTRAN, which is used to solve scientific and engineering problems, uses a notation that is mathematical. Indeed, the name FORTRAN is derived from the phrase formula translation. Because of the close coupling of a programming language to types of problems, there are literally hundreds of high-level programming languages. The commands in a high-level language program are not executed directly by a computer. A high-level language program has to be translated first. The conversion is accomplished by a specialized program called a translator. A translator accepts a program written in a one language and translates it to an equivalent program in another language. The input to the translator is the source program and the output of the translator is the target program. Most translators convert a high-level language program to a machine language program. For high-level languages, a translator normally is referred to as a compiler. Detailed knowledge of the machine is not required. Uses a vocabulary and structure closer to the problem being solved

22 Java is a high-level programming language
Software Program Sequence of instruction that tells a computer what to do Execution Performing the instruction sequence Programming language Language for writing instructions to a computer Major flavors Machine language or object code Assembly language High-level A distinguishing characteristic of a high-level programming language is that detailed knowledge of the machine being programmed is not required. Another characteristic is that a high-level programming language uses a vocabulary and structure that is close to the type of problem being solved. For example, the programming language FORTRAN, which is used to solve scientific and engineering problems, uses a notation that is mathematical. Indeed, the name FORTRAN is derived from the phrase formula translation. Because of the close coupling of a programming language to types of problems, there are literally hundreds of high-level programming languages. The commands in a high-level language program are not executed directly by a computer. A high-level language program has to be translated first. The conversion is accomplished by a specialized program called a translator. A translator accepts a program written in a one language and translates it to an equivalent program in another language. The input to the translator is the source program and the output of the translator is the target program. Most translators convert a high-level language program to a machine language program. For high-level languages, a translator normally is referred to as a compiler. Java is a high-level programming language

23 For program to be executed it must be translated
Software Program Sequence of instruction that tells a computer what to do Execution Performing the instruction sequence Programming language Language for writing instructions to a computer Major flavors Machine language or object code Assembly language High-level A distinguishing characteristic of a high-level programming language is that detailed knowledge of the machine being programmed is not required. Another characteristic is that a high-level programming language uses a vocabulary and structure that is close to the type of problem being solved. For example, the programming language FORTRAN, which is used to solve scientific and engineering problems, uses a notation that is mathematical. Indeed, the name FORTRAN is derived from the phrase formula translation. Because of the close coupling of a programming language to types of problems, there are literally hundreds of high-level programming languages. The commands in a high-level language program are not executed directly by a computer. A high-level language program has to be translated first. The conversion is accomplished by a specialized program called a translator. A translator accepts a program written in a one language and translates it to an equivalent program in another language. The input to the translator is the source program and the output of the translator is the target program. Most translators convert a high-level language program to a machine language program. For high-level languages, a translator normally is referred to as a compiler. For program to be executed it must be translated

24 Translation Translator
Accepts a program written in a source language and translates it to a program in a target language Compiler Standard name for a translator whose source language is a high-level language Interpreter A translator that both translates and executes a source program The commands in a high-level language program are not executed directly by a computer. A high-level language program has to be translated first. The conversion is accomplished by a specialized program called a translator. A translator accepts a program written in a one language and translates it to an equivalent program in another language. The input to the translator is the source program and the output of the translator is the target program. Most translators convert a high-level language program to a machine language program. For high-level languages, a translator normally is referred to as a compiler. A particular type of translator of interest to Java programmers is an interpreter. An interpreter is a translator that both translates and executes the source program.

25 Java translation Two-step process First step
Translation from Java to bytecodes Bytecodes are architecturally neutral object code Bytecodes are stored in a file with extension .class Second step An interpreter translates the bytecodes into machine instructions and executes them Interpreter is known a Java Virtual Machine or JVM At the beginning of this section, we mentioned that one of the key features of Java is that a Java program can run on a variety of different types of machines. This feature makes Java ideal for developing Internet applications where there are many different types of machines connected to the network. It is the Java interpreter that makes this happen. When we compile a Java program, the Java compiler does not produce a machine language program for a particular computer like the compilers for other programming languages such as C, C++, or FORTRAN do. Rather the Java compiler produces a program for an interpreter called the Java Virtual Machine (JVM). Essentially, the JVM is a program that mimics the operation of a real machine. The JVM reads the program produced by the Java compiler and executes the Java machine language instructions produced by the Java compiler. The Java machine language instructions are called Java bytecodes and can be viewed as architecturally neutral object code. The bytecodes are stored in a file with an extension of .class. For program DisplayForecast.java, a Java compiler produces a bytecode file named DisplayForecast.class.

26 Task Display the forecast
I think there is a world market for maybe five computers. Thomas Watson, IBM, 1943.

27 Sample output

28 DisplayForecast.java // Authors: J. P. Cohoon and J. W. Davidson
// Purpose: display a quotation in a console window public class DisplayForecast { // method main(): application entry point public static void main(String[] args) { System.out.print("I think there is a world market for"); System.out.println(" maybe five computers."); System.out.println(" Thomas Watson, IBM, 1943."); }

29 DisplayForecast.java // Authors: J. P. Cohoon and J. W. Davidson // Purpose: display a quotation in a console window public class DisplayForecast { // method main(): application entry point public static void main(String[] args) { System.out.print("I think there is a world market for"); System.out.println(" maybe five computers."); System.out.println(" Thomas Watson, IBM, 1943."); } Three statements make up the action of method main() Method main() is part of class DisplayForecast

30 DisplayForecast.java // Authors: J. P. Cohoon and J. W. Davidson // Purpose: display a quotation in a console window public class DisplayForecast { // method main(): application entry point public static void main(String[] args) { System.out.print("I think there is a world market for"); System.out.println(" maybe five computers."); System.out.println(" Thomas Watson, IBM, 1943."); } A method is a named piece of code that performs some action or implements a behavior

31 DisplayForecast.java // Authors: J. P. Cohoon and J. W. Davidson // Purpose: display a quotation in a console window public class DisplayForecast { // method main(): application entry point public static void main(String[] args) { System.out.print("I think there is a world market for"); System.out.println(" maybe five computers."); System.out.println(" Thomas Watson, IBM, 1943."); } An application program is required to have a public static void method named main().

32 Java and the Internet Now here’s the key idea—we can execute a Java class file on any machine that has a copy of a JVM on it. Figure 1.9 illustrates this process. Suppose, you want to send the program to some friends so that they can run it on their machine, where your machine is a PC, and your friends have an Apple. You first compile DisplayForecast.java to produce DisplayForecast.class. You then send the file DisplayForecast.class to the friends over the Internet (e.g., via or FTP). Using a JVM that is running on the your friends’s Apple machine, your friends can interpret the program you sent. Java and the Internet. You might wonder what’s the big deal. Why not just send the source program and let your friend compile it and run it? There are several potential problems with this approach. First, application source programs are sometimes quite large. Sending a source program over the network can take significant time—especially if the connection from the Internet to the friend’s home computer is a slow modem connection. The Java bytecodes were designed to be small and compact and thus sending a class file is much more efficient than sending a machine-language program or a Java source program. Second, while you might not care if your friend saw your source program, most companies do not want to send source programs over the Internet as they may contain important information such as formulas that they do not wish to disclose. Sending a class file offers some protection for proprietary information.

33 Engineering software Complexity of software grows as attempts are made to make it easier to use Rise of wizards Several factors account for the increased complexity. First, to do more, the software is larger. It is not unusual for application programs, such as spreadsheets, word processors, and drawing programs, to consist of millions of lines of code. Another factor that increases complexity is the interaction between components. For example, a word processor may contain one component for spell checking and correction, and another component that provides the services of a thesaurus. Let’s consider the spell-checking component. When a possible spelling error is detected, the spelling checker must report the possible error to the user. Thus the spelling checker must interact with the component of the application that creates a window or a dialog box so that the possible error can be displayed and the user queried about what action, if any, to take. If the user agrees it is a spelling error, the checker can correct the misspelling. To make the correction, the checker must interact with the component of the word processor responsible for replacing text in the document. Obviously, as the number of components grows, the number of interactions between components can grow rapidly.

34 Software engineering Goal
Production of software that is effective and reliable, understandable, cost effective, adaptable, and reusable

35 Software engineering Goal
Production of software that is effective and reliable, understandable, cost effective, adaptable, and reusable Work correctly and not fail A software application should be effective and reliable. That is, it should work correctly and not fail. Imagine that you have spent several hours writing an important paper with a word processor. Then while doing a pasting operation, the word processor quits unexpectedly and you lose all your work. This ineffective, unreliable action would undoubtedly make you upset, and rightfully so.

36 Software engineering Goal
Production of software that is effective and reliable, understandable, cost effective, adaptable, and reusable Because of the long lifetime many people will be involved Creation Debugging Maintenance Enhancement Two-thirds of the cost is typically beyond creation Understandability is also important because of the long lifetime of software. A software product usually evolves over time. Software engineers who had nothing to do with its original development often make enhancements and fix bugs (errors). This process is called software maintenance. As a measure of the difficulty of maintaining software, experts estimate that two-thirds of the cost of developing software is devoted to maintenance. This cost can be reduced when the design and operation of a system are comprehensible.

37 Software engineering Goal
Production of software that is effective and reliable, understandable, cost effective, adaptable, and reusable Cost to develop and maintain should not exceed expected benefit A software system should be cost effective. That is, the cost to develop and maintain a software system should not exceed the expected profit from selling the system. Many software companies have gone bankrupt because they have underestimated either the cost of developing a system or the time to design, build, and maintain the software.

38 Software engineering Goal
Production of software that is effective and reliable, understandable, cost effective, adaptable, and reusable Design software so that new features and capabilities can be added Because of its potentially long lifetime, software should be adaptable. It often is difficult to predict which features and capabilities eventually will be added to a software product. By designing software so that additional features and capabilities can be added easily, maintenance costs can be reduced.

39 Software engineering Goal
Production of software that is effective and reliable, understandable, cost effective, adaptable, and reusable Makes sense due to the great costs involved to have flexible components that can be used in other software Because of high development costs, software should be reusable. If many millions of dollars are spent to develop some software, it makes sense to make its components flexible so they can be reused when developing other software. This strategy is common practice in other businesses—the automotive engineer does not design a new car from scratch. Rather, the engineer borrows from the design and components of existing cars.

40 Principles Abstraction Encapsulation Modularity Hierarchy

41 Principles Abstraction Encapsulation Modularity
Hierarchy Determine the relevant properties and features while ignoring nonessential details Abstraction is the process of determining the relevant properties and features of an object while ignoring nonessential details. The relevant properties are defined by how the object is to be used and manipulated. For example, an auto salesperson views a car from the standpoint of its selling features, while a mechanic views the car from the standpoint of the systems that require maintenance. If you are concerned with developing a help system to assist car owners who do their own repairs, you need to be sure that the mechanic’s view is considered. 2001 PT Cruiser Photo/Courtesy of DaimlerChrysler Corporation.

42 Separate components into external and internal aspects
Principles Abstraction Encapsulation Modularity Hierarchy Separate components into external and internal aspects Encapsulation or information hiding is the process of separating the component of an object into external and internal aspects. The external aspects of an object need to be visible to other objects in the system. The internal aspects are details that should not affect other parts of the system. Hiding the internal aspects of an object means that they can be changed without requiring changes to other system parts.

43 Principles Abstraction Encapsulation Modularity
Hierarchy Construct a system from components and packages Most complex systems are modular. They are constructed by combining simpler working components or packages. Proper modularization of a complex system also helps manage complexity. Breaking things down into smaller, easier to understand pieces makes the larger system easier to understand. For example, an automobile can be decomposed into subsystems. Automobile subsystems include a cooling system, an ignition system, and an exhaust system. By thinking about an automobile in terms of its subsystems, we can grasp more readily the car’s overall structure and operation.

44 Ranking or ordering of objects
Principles Abstraction Encapsulation Modularity Hierarchy Ranking or ordering of objects A ranking or ordering of objects based on some relationship between them is a hierarchy. Hierarchies can help us understand complex organizations and systems. Figure contains a partial organizational chart for the management of a company. The chart shows the management hierarchy based on the relationship of who reports to whom. The hierarchy helps employees understand the structure of their company.   A useful way of ordering abstractions is from most general to least general. A hierarchical ordering based on natural relationships is called a taxonomy. Such a hierarchy makes all the abstractions easier to understand because it exposes the relationship of the characteristics and behaviors they have in common. For example, consider a taxonomy of musical instruments that organizes instruments by how they produce their sound. Idiophones: Solid instruments that are intrinsically sonorous, e.g., bell and cymbal. Membranophones: Instruments with taut membranes, e.g., drum and tambourine. Aerophones: Instruments that enclose and free masses of air, e.g., trumpet and saxophone. Chordophones: Instruments with stretched strings, e.g., lyre and violin. Electrophones: Instruments with oscillating electric circuits, e.g., synthesizer and electric piano.

45 Object-oriented design
Purpose Promote thinking about software in a way that models the way we think and interact with the physical word Including specialization Object Properties or attributes Behaviors Now let’s analyze this activity. First, you recognized the need for action—having to get up early and deciding that the clock radio could help meet that need. So you go over to the clock radio, which is a physical object. This object has properties like weight and size, and it also can do something. For one it can play music at an indicated time. It’s not necessary for you to know entirely how the clock radio works. You need to know only which switches and buttons to use. The switches and buttons are the interface to the clock radio. If you understand the interface to an object, you can use it to perform some tasks without understanding how the object works internally. Moving the appropriate switches and pushing the appropriate buttons are signals to the clock radio to modify its behavior. Such interactions are so routine that it is easy to overlook how amazing this activity is. You were able to make an object perform a complex activity without understanding the internal operation of the object. You were able to do so because you had an appropriate abstraction of the object. Indeed your mental abstraction of a clock radio means that when you travel and stay at a hotel room, you are able to set its clock radio even though it is a different clark radio. Similar objects often exhibit similar behavior. This way of dealing with the complex world around us also can be applied to software design and programming. A key step in developing a complex system using object-oriented design is to determine the objects that constitute the system. By carefully creating appropriate abstractions of these objects and separating their internal implementation from their external behavior, we can manage the complexity of a large software system. So what exactly do we mean by an object? Physical things are certainly objects. A ball, a file cabinet, an address book, a tree, and a computer all are objects. What about things like a word, a bank account, or a musical note? These things are not physical objects, but they are objects—in the sense that they have attributes and properties, and we can perform actions on them. A word has a length and meaning, and if we are talking in regard to a word processor, a word can be inserted or deleted from a document. A bank account has a balance to which funds can be deposited or debited. A musical note has pitch, duration, and loudness and can be played. For the most part, something is an object if it has a name, properties associated with it, and behaviors such as message handling. Typically, when an object receives a message, the message causes the object either to take some action or to change one of its properties. Continuing with our clock radio example, when you push the “music on” button, the current broadcast is played. If we are going to take an object-oriented approach to developing software, it makes sense to use a programming language such as Java that supports thinking and implementing solutions in terms of objects. A language with features that support thinking about and implementing solutions in terms of objects is an object-oriented programming language. Using an object-oriented programming language to implement an object-oriented design is called object-oriented programming. Notice we were very careful to include the phrase “implement an object-oriented design.” As you will see later, you can use an object-oriented language, but not think in terms of objects.

46 Programming Class Term for a type of software object Object
An instance of a class with specific properties and attributes Using an object-oriented programming language to implement an object-oriented design is called object-oriented programming. Notice we were very careful to include the phrase “implement an object-oriented design.” As you will see later, you can use an object-oriented language, but not think in terms of objects. Programming languages generally give programmers the ability to specify the types of objects to be used in their programs, where a type is a collection of values and the operations that can be performed on those values. An example of a type would be the set of integers and the arithmetic operations that can be performed on them. Object-oriented languages provide programmers the ability to create a type known as a class for representing the properties and message-handling behaviors of a type of object. Classes normally are organized so that the manipulation of a property is handled via a message to the object. Thus, the class encapsulation process is similar in nature to the process of designing a car radio, which has interfaces for both its user and to the electrical system. Programmers use a class to create instances of it. An instance is an object with a particular value for each property and attribute of the class. In practical terms, a class can be thought of as a model or template for an object. From the class, objects with specific properties can be created, or instantiated. An object is an instance of exactly one class. As another example, consider a star-shaped cookie cutter. When it is pressed into dough, a cookie is formed. The cutter corresponds to a class—it is a cookie mold. An individual cookie is an object—it is constructed using the cookie cutter. The difference between a class and an object is subtle but important. Whereas a class is a concept, an object is a concrete entity, it is a specific instance of a class. For example, the concept of a car corresponds to a class, but the particular SUVs you may see driving down a street are objects. Similarly, the notion of a bank account corresponds to a class, but your savings account is an object. We can use a class type to represent playing cards. The properties of a card would be its rank and suit. Card message handling would include methods that queried an object regarding its rank value and suit value. The queen of clubs and the nine of diamonds would be playing card instances or objects. Another important feature of object-oriented languages is that they let programmers exploit the similarity of objects to derive new types of objects from existing types of objects. In this situation, we call the old type, the superclass and the new class a subclass. The subclass both extends or specializes the functionality of the superclass and inherits the properties and behaviors of the superclass. Specialization is something we see all the time. For example, a poem, novel, biography, and office memo are all types of writing with specialized attributes. An example in Java is the graphical superclass for representing the attributes and behaviors expected of any component that can be placed in a window. The superclass is used as the basis for deriving specialized components such as buttons, menus, scroll bars, labels, and text entry areas. As another example, an aquarium simulation is developed in Chapter 12. The superclass for the simulator is a standard Java class rendering (drawing) images. A snapshot of the application is given in Figure 1.12.

47 Programming Problem solving through the use of a computer system Maxim
You cannot make a computer do something if you do not know how to do it yourself

48 Problem Solving Why do you care? We are all assigned tasks to do
At work At home At school Why not do them Right Efficiently

49 Problem Solving Why care about computer-based problem solving (i.e., programming)? Neat Frontier of science Profitable Necessary Quality of life

50 Problem Solving Remember
The goal is not a clever solution but a correct solution

51 Problem Solving Accept The process is iterative
In solving the problem increased understanding might require restarting

52 Problem Solving Solutions
Often require both concrete and abstract thinking Teamwork

53 Problem Solving Process
What is it?

54 Problem Solving Process
What is it? Analysis Design Implementation Testing

55 Problem Solving Process
What is it? Analysis Design Implementation Testing Determine the inputs, outputs, and other components of the problem Description should be sufficiently specific to allow you to solve the problem

56 Problem Solving Process
What is it? Analysis Design Implementation Testing Describe the components and associated processes for solving the problem Straightforward and flexible Method – process Object – component and associated methods

57 Problem Solving Process
What is it? Analysis Design Implementation Testing Develop solutions for the components and use those components to produce an overall solution Straightforward and flexible

58 Problem Solving Process
What is it? Analysis Design Implementation Testing Test the components individually and collectively

59 Problem Solving Process

60 Problem Solving Methodologies
How to do it? Depends upon your mode of thinking Bricolage approach Planned approach

61 Problem Solving Methodologies
How to do it? Depends upon your mode of thinking Bricolage approach Planned approach Problem features and aspects are repeatedly tried and manipulated according to your personal way of organizing information A mistake is not an error, but a correction waiting to be made in the natural course of solving the problem

62 Problem Solving Methodologies
How to do it? Depends upon your mode of thinking Bricolage approach Planned approach Uses logic, formalism, and engineering coupled with a structured methodology Inherent structure of the planned approach offers makes it easier to show correctness of solution Dominant method in terms of teaching

63 Tips Find out as much as you can Reuse what has been done before
Expect future reuse Break complex problems into subproblems

64 Tips Find out as much as you can Reuse what has been done before
Expect future reuse Break complex problems into subproblems Find out what is known about the problem Talk to the presenter Determine what attempts have succeeded and what attempts have failed

65 Tips Find out as much as you can Reuse what has been done before
Expect future reuse Break complex problems into subproblems Research can require significant time and generate questions The effort is worthwhile because the result is a better understanding True understanding of the problem makes it easier to solve

66 Tips Find out as much as you can Reuse what has been done before
Expect future reuse Break complex problems into subproblems Consider Sketching a solution and then repeatedly refine its components until the entire process is specified

67 Tips Find out as much as you can Reuse what has been done before
Expect future reuse Break complex problems into subproblems Your time is valuable Correctness is probably even more valuable Use existing infrastructure that is known to work

68 Tips Find out as much as you can Reuse what has been done before
Expect future reuse Break complex problems into subproblems Be open to indirect use of existing materials

69 Tips Find out as much as you can Reuse what has been done before
Expect future reuse Break complex problems into subproblems Make as few assumptions as necessary Maximizes the likelihood that your effort can be used in future situations

70 Tips Find out as much as you can Reuse what has been done before
Expect future reuse Break complex problems into subproblems Divide-and-conquer Solve subproblems and combine into an overall solution


Download ppt "Introduction."

Similar presentations


Ads by Google