Kĩ thuật lập trình - Introduction to computers, the internet and the world wide web
Object-oriented design (OOD)
Models software in terms similar to those used to describe real-world objects
Class relationships
Inheritance relationships
Models communication among objects
Encapsulates attributes and operations (behaviors)
Information hiding
Communication through well-defined interfaces
Object-oriented language
Programming in object-oriented languages is called object-oriented programming (OOP)
Java
60 trang |
Chia sẻ: huyhoang44 | Lượt xem: 707 | Lượt tải: 0
Bạn đang xem trước 20 trang tài liệu Kĩ thuật lập trình - Introduction to computers, the internet and the world wide web, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
1Introduction to Computers, the Internet and the World Wide Web1 Our life is frittered away by detail. Simplify, simplify.Henry David ThoreauThe chief merit of language is clearness.GalenMy object all sublime I shall achieve in time.W. S. GilbertHe had a wonderful talent for packing thought close, and rendering it portable.Thomas B. Macaulay“Egad, I think the interpreter is the hardest to be understood of the two!” Richard Brinsley SheridanMan is still the most extraordinary computer of all.John F. Kennedy2OBJECTIVESIn this chapter you will learn: Basic computer hardware and software concepts.Basic object technology concepts, such as classes, objects, attributes, behaviors, encapsulation, inheritance and polymorphism.The different types of programming languages.Which programming languages are most widely used.A typical Java development environment.Java's role in developing distributed client/server applications for the Internet and the web.The history of the UML—the industry-standard object-oriented design language.The history of the Internet and the World Wide Web.To test-drive Java applications.31.1 Introduction1.2 What Is a Computer?1.3 Computer Organization1.4 Early Operating Systems1.5 Personal, Distributed and Client/Server Computing1.6 The Internet and the World Wide Web1.7 Machine Languages, Assembly Languages and High-Level Languages1.8 History of C and C++1.9 History of Java1.10 Java Class Libraries41.11 Fortran, COBOL, Pascal and Ada1.12 BASIC, Visual Basic, Visual C++, C# and .NET1.13 Typical Java Development Environment1.14 Notes about Java and Java How to Program, Seventh Edition1.15 Test-Driving a Java Application1.16 Software Engineering Case Study: Introduction to Object Technology and the UML1.17 Web 2.01.18 Software Technologies1.19 Wrap-Up1.20 Web Resources51.1 IntroductionJava Standard Edition (Java SE) 6 Sun’s implementation called the Java Development Kit (JDK)Object-Oriented ProgrammingJava is language of choice for networked applicationsJava Enterprise Edition (Java EE) geared toward large-scale distributed applications and web applicationsJava Micro Edition (Java ME) geared toward applications for small, memory constrained devices61.2 What Is a Computer?ComputerPerforms computations and makes logical decisionsMillions or billions of times faster than human beingsComputer programsSets of instructions for which computer processes dataHardwarePhysical devices of computer systemSoftwarePrograms that run on computers71.3 Computer Organization Six logical units of computer systemInput unitMouse, keyboardOutput unitPrinter, monitor, audio speakersMemory unitRetains input and processed informationArithmetic and logic unit (ALU)Performs calculationsCentral processing unit (CPU)Supervises operation of other devicesSecondary storage unitHard drives, floppy drives81.4 Early Operating SystemsBatch processingOne job (task) at a timeOperating systemsDeveloped to make computers more convenient to useMade transitions between jobs easierMore throughputMultiprogramming“Simultaneous” jobsTimesharing operating systems91.5 Personal, Distributed and Client/Server ComputingPersonal computingComputers for personal useDistributed computingNetworked computersComputing performed among several computersClient/server computingServers offer common store of programs and dataClients access programs and data from server101.6 The Internet and the World Wide WebInternetDeveloped more than four decades ago with DOD fundingOriginally for connecting few main computer systemsNow accessible by over a billion computersWorld Wide Web (WWW)Allows for locating/viewing multimedia-based documents111.7 Machine Languages, Assembly Languages and High-Level LanguagesMachine language“Natural language” of computer componentMachine dependentAssembly languageEnglish-like abbreviations represent computer operationsTranslator programs (assemblers) convert to machine languageHigh-level languageAllows for writing more “English-like” instructionsContains commonly used mathematical operationsCompiler converts to machine languageInterpreterExecute high-level language programs without compilation121.8 History of C and C++C++ evolved from C, which evolved from BCPL and BCDeveloped at Bell LabsPopularized as the language of the UNIX operating systemC++ Deveoped by Bjarne StroustrupProvides object-oriented programming capabilitiesHybrid languageObjectsReusable software components that model real-world itemsAttributes and behaviors131.9 History of JavaJavaOriginally for intelligent consumer-electronic devicesThen used for creating web pages with dynamic contentNow also used to:Develop large-scale enterprise applicationsEnhance web server functionalityProvide applications for consumer devices (cell phones, etc.)141.10 Java Class LibrariesJava programs consist of classesInclude methods that perform tasksReturn information after task completionJava provides class librariesKnown as Java APIs (Application Programming Interfaces)To use Java effectively, you must knowJava programming languageExtensive class libraries 15Software Engineering Observation 1.1Use a building-block approach to create programs. Avoid reinventing the wheel—use existing pieces wherever possible. Called software reuse, this practice is central to object-oriented programming.16Software Engineering Observation 1.2When programming in Java, you will typically use the following building blocks: Classes and methods from class libraries, classes and methods you create yourself and classes and methods that others create and make available to you.17Performance Tip 1.1Using Java API classes and methods instead of writing your own versions can improve program performance, because they are carefully written to perform efficiently. This technique also shortens program development time.18Portability Tip 1.1Using classes and methods from the Java API instead of writing your own improves program portability, because they are included in every Java implementation.19Software Engineering Observation 1.3Extensive class libraries of reusable software components are available over the Internet and the web, many at no charge.201.11 FORTRAN, COBOL, Pascal and AdaFortranFORmula TRANslatorDeveloped by IBM for scientific and engineering applicationsCOBOLCOmmon Business Oriented LanguageUsed for commercial applications requiring precise/efficient manipulation of large amounts of dataPascalDeveloped by Prof. Niklaus WirthDesigned to teach structured programmingAdaDeveloped under the sponsorship of the U.S. Department of DefenseNeeded a single language to fill most of its needsProvided multitasking so programmers could specify parallel tasks211.12 BASIC, Visual Basic, Visual C++, C# and .NETBASICBeginner’s All-Purpose Symbolic Instruction CodeDeveloped at Dartmouth College to familiarize novices with programming techniquesVisual Basic introduced by Microsoft in the early 1990s.NET platformPart of Microsoft’s corporate-wide strategy to incorporate the Internet and web into computer applicationsThree primary .NET programming languagesVisual Basic .NET (based on BASIC)Visual C++ .NET (based on C++)C# (based on C++ and Java)221.13 Typical Java Development EnvironmentJava programs go through five phasesEditProgrammer writes program using an editor; stores program on disk with the .java file name extensionCompileUse javac (the Java compiler) to create bytecodes from source code program; bytecodes stored in .class filesLoadClass loader reads bytecodes from .class files into memoryVerifyBytecode verifier examines bytecodes to ensure that they are valid and do not violate security restrictionsExecuteJava Virtual Machine (JVM) uses a combination of interpretation and just-in-time compilation to translate bytecodes into machine language23Fig. 1.1 | Typical Java development environment.24Common Programming Error 1.1Errors like division by zero occur as a program runs, so they are called runtime errors or execution-time errors. Fatal runtime errors cause programs to terminate immediately without having successfully performed their jobs. Nonfatal runtime errors allow programs to run to completion, often producing incorrect results.251.14 Notes about Java and Java How to Program, Seventh EditionStresses clarityPortabilityAn elusive goal due to differences between compilers, JVMs and computersAlways test programs on all systems on which the programs should run26Good Programming Practice 1.1Write your Java programs in a simple and straightforward manner. This is sometimes referred to as KIS (“keep it simple”). Do not “stretch” the language by trying bizarre usages.27Portability Tip 1.2Although it is easier to write portable programs in Java than in other programming languages, differences between compilers, JVMs and computers can make portability difficult to achieve. Simply writing programs in Java does not guarantee portability.28Error-Prevention Tip 1.1Always test your Java programs on all systems on which you intend to run them, to ensure that they will work correctly for their intended audiences.29Good Programming Practice 1.2Read the documentation for the version of Java you are using. Refer to it frequently to be sure you are aware of the rich collection of Java features and are using them correctly.30Good Programming Practice 1.3Your computer and compiler are good teachers. If, after carefully reading your Java documentation manual, you are not sure how a feature of Java works, experiment and see what happens. Study each error or warning message you get when you compile your programs (called compile-time errors or compilation errors), and correct the programs to eliminate these messages.31Software Engineering Observation 1.4Some programmers like to read the source code for the Java API classes to determine how the classes work and to learn additional programming techniques.321.15 Test-Driving a Java ApplicationTest-driving the ATM applicationCheck system setupLocate the ATM application (Fig. 1.2)Run the ATM application (Fig. 1.3)Enter an account number (Fig. 1.4)Enter a PIN (Fig. 1.5)View the account balance (Fig. 1.6)Withdraw money from the account (Fig. 1.7)Confirm that the account information has been updated (Fig. 1.8)End the transaction (Fig. 1.9)Exit the ATM applicationAdditional applications (Fig. 1.10)33Fig. 1.2 | Opening a Windows XP Command Prompt and changing directories.Using the cd command tochange directoriesFile location of the ATM application34Fig. 1.3 | Using the java command to execute the ATM application.35Fig. 1.4 | Prompting the user for an account number.ATM welcome messageEnter account number prompt36Fig. 1.5 | Entering a valid PIN number and displaying the ATM application's main menu.Enter valid PINATM main menu37Fig. 1.6 | ATM application displaying user account balance information.Account balance information38Fig. 1.7 | Withdrawing money from the account and returning to the main menu.ATM withdrawal menu39Fig. 1.8 | Checking new balance.Confirming updated account balance information after withdrawal transaction40Fig. 1.9 | Ending an ATM transaction session.ATM goodbye messageAccount number prompt for next user41Fig. 1.10 | Examples of additional Java applications found in Java How to Program, 6/e.421.16 Software Engineering Case Study: Introduction to Object Technology and the UML (Required)Object orientationUnified Modeling Language (UML)Graphical language that uses common notationAllows developers to represent object-oriented designs431.16 Software Engineering Case Study (Cont.)ObjectsReusable software components that model real-world itemsLook all around youPeople, animals, plants, cars, etc.AttributesSize, shape, color, weight, etc.BehaviorsBabies cry, crawl, sleep, etc.441.16 Software Engineering Case Study (Cont.)Object-oriented design (OOD)Models software in terms similar to those used to describe real-world objectsClass relationshipsInheritance relationshipsModels communication among objectsEncapsulates attributes and operations (behaviors)Information hidingCommunication through well-defined interfacesObject-oriented languageProgramming in object-oriented languages is called object-oriented programming (OOP)Java451.16 Software Engineering Case Study (Cont.)Classes are to objects as blueprints are to housesAssociationsRelationships between classesPackaging software in classes facilitates reuse461.16 Software Engineering Case Study (Cont.)Object-Oriented Analysis and Design (OOA/D)Essential for large programsAnalyze program requirements, then develop a designUMLUnified Modeling LanguageStandard for designing object-oriented systems471.16 Software Engineering Case Study (Cont.)History of the UMLNeed developed for process with which to approach OOA/DBrainchild of Booch, Rumbaugh and JacobsonObject Management Group (OMG) supervisedVersion 2 is current version481.16 Software Engineering Case Study (Cont.)UMLGraphical representation schemeEnables developers to model object-oriented systemsFlexible and extensible491.17 Web 2.0Web use exploded in mid-to-late 1990sDot com economic bust hit in the early 2000sResurgence in 2004 with Web 2.0First Web 2.0 conferenceGoogle widely regarded as signature company of Web 2.0Web services enable Web 2.0501.17 Web 2.0 (cont.)AjaxTerm popularized in 2005Group of technologies and programming techniques in use since the late 1990sHelps Internet-based applications perform like desktop application511.17 Web 2.0 (cont.)BlogsWebsites that are like online diariesAbout 60 million of them at the time of this writingBlogosphere—Collection of all blogs and the blogging communityTechnorati—a leading blog search engineRSS feedsEnable sites to push information to subscribersCommonly used to deliver blog postings521.17 Web 2.0 (cont.)Web 3.0Next generation webAlso known as the semantic webWeb 1.0 mostly HTML basedWeb 2.0 making increasing use of XML (e.g., RSS feeds)Web 3.0 will make extensive use of XML to add meaning to content531.18 Software TechnologiesAgile Software DevelopmentMethodologies for developing software quickly with fewer resourcesExtreme Programming (XP)One of many agile development methodologiesRelease software frequently in small increments to encourage user feedbackProgrammers work in pairs at one computerImmediate code reviewAll team programmers able to work on any part of code541.18 Software Technologies (cont.)RefactoringReworking code to make cleaner/easier to maintainWidely used in agile development methodologiesMany tools availableDesign patternsProven architectures for constructing flexible/maintainable object-oriented software551.18 Software Technologies (cont.)Game programmingGame business is larger than first run movie businessCollege courses and majors now devoted to sophisticated game-programming techniques561.18 Software Technologies (cont.)Open source softwareIndividuals and companies contribute to developing, maintaining and evolving software in exchange for the right to use that software for their own purposes, typically at no chargeCode typically scrutinized by much larger audiences, so bugs get removed fasterJava now open sourceSome open source organizationsEclipse Foundation, Mozilla Foundation, Apache Software Foundation, SourceForge571.18 Software Technologies (cont.)LinuxOpen source operating systemOne of the greatest successes of the open source movementMySQLan open source database management systemPHP most popular open source server-side Internet “scripting” language for developing Internet-based applicationsLAMP—Linux, Apache, MySQL and PHP (or Perl or Python)An acronym for the set of open source technologies that many developers used to build web applications581.18 Software Technologies (cont.)Ruby on RailsCombines the scripting language Ruby with the Rails web application framework developed by 37SignalsMany Ruby on Rails developers report significant productivity gains over using other languages when developing database-intensive web applicationsGetting Real (gettingreal.37signals.com/toc.php)a must read for today’s web application developers591.18 Software Technologies (cont.)Software generally viewed as a productYou buy a software package from a software vendor, then install that software on your computer and run it as neededUpgrade process cumbersome and expensiveSoftware as a service (SAAS)Software runs on servers elsewhere on the InternetWhen server is updated, all clients worldwide see the new capabilitiesAccess the software through a browserSalesforce.com, Google and Microsoft’s Office Live and Windows Live all offer SAAS.60
Các file đính kèm theo tài liệu này:
- javahtp7e_01_0426_4327.ppt