Presentation is loading. Please wait.

Presentation is loading. Please wait.

Based on Deitel How To Program slides 1.  Computer use is increasing in almost every field  Computing costs have been decreasing dramatically due to.

Similar presentations


Presentation on theme: "Based on Deitel How To Program slides 1.  Computer use is increasing in almost every field  Computing costs have been decreasing dramatically due to."— Presentation transcript:

1 Based on Deitel How To Program slides 1

2  Computer use is increasing in almost every field  Computing costs have been decreasing dramatically due to rapid developments in hardware, software and communications technologies  Computing has become so economical that billions of computers are in use worldwide 2

3  Computers process data, using sets of instructions called computer programs  These programs guide computers through orderly sets of calculations and other actions that are specified by people known as computer programmers  Today’s personal computers can perform billions of these calculations and actions per second. A person operating a desk calculator might require a lifetime to complete the same amount of work!  Today’s fastest supercomputers work so quickly that they can perform the equivalent of 150,000 actions and calculations per second for every person on the planet! 3

4  A computer consists of various devices referred to as hardware ◦ (for example, the keyboard, screen, mouse, hard drive, memory, DVD drives and processing units)  The programs that run on a computer are referred to as software ◦ (for example, applications such as word processors, payroll systems, spreadsheets, e-mail systems, games, etc.)  Object-oriented programming (which models real-world objects with software counterparts), available in C# and other major programming languages (Java, C++, SmallTalk etc.), can greatly enhance productivity 4

5  Instructions for the hardware  A collection of instructions is called a program 5

6  Well-known computer architecture: Von Neumann  Imperative languages, most dominant, because of von Neumann computers  Data and programs stored in memory  Memory is separate from CPU  Instructions and data are piped from memory to CPU  Basis for imperative languages  Variables model memory cells  Assignment statements model piping  Iteration is efficient (not recursion, though more natural) Instructions are in adjacent cells 6

7  1957 FORTRAN  1958 ALGOL  1960 LISP  1960 COBOL  1962 APL  1962 SIMULA  1964 BASIC  1964 PL/I  1966 ISWIM  1970 Prolog  1972 C  1975 Pascal  1975 Scheme  1977 OPS5  1978 CSP  1978 FP  1980 dBASE II  1980 Python  1983 Smalltalk-80  1983 Ada  1983 Prolog  1984 Standard ML  1986 C++  1986 CLP(R)  1986 Eiffel  1988 CLOS  1988 Mathematica  1988 Oberon  1989 HTML  1990 Haskell  1991 VisualBasic 1.0  1994 Ruby  1995 Java  2000 C#  2000 Python 2.0  2001 VB.NET  2001 Scala 7

8 8

9 9 Normalized Comparison 2015 (from http://www.langpop.com/) google, craigslist, powell’s, freshmeat, del.icio.us, ohloh,.etc.http://www.langpop.com/ 2012

10 Mar 2015 Mar 2014ChangeProgramming LanguageRatingsChange 11C16.642%-0.89% 22Java15.580%-0.83% 33Objective-C6.688%-5.45% 44C++6.636%+0.32% 55C#4.923%-0.65% 66PHP3.997%+0.30% 79JavaScript3.629%+1.73% 88Python2.614%+0.59% 910Visual Basic.NET2.326%+0.46% 10-Visual Basic1.949%+1.95% 1112F#1.510%+0.29% 1213Perl1.332%+0.18% 1315Delphi/Object Pascal1.154%+0.27% 1411Transact-SQL1.149%-0.33% 1521Pascal1.092%+0.41% 1631ABAP1.080%+0.70% 1719PL/SQL1.032%+0.32% 1814Ruby1.030%+0.06% 1920MATLAB0.998%+0.31% 2045R0.951%+0.72%

11 http://www.scribd.com/doc/1363822/Complete-MAP-of-programming-languages- Treerelational-2006 http://www.digibarn.com/collections/posters/tongues/tongues.jpg Click me 11

12 12

13  1950s and early 1960s: Simple applications; worry about machine efficiency  equations  Late 1960s: People efficiency became important; readability, better control structures  Shift from h/w to s/w  Structured programming  Satellites, airlines, complex  Late 1970s: Process-oriented to data-oriented  Data abstraction  Top-down design and step-wise refinement  Middle 1980s and beyond: Object-oriented programming  Data abstraction (SIMULA) + inheritance (Smalltalk, helped C++ and Java, C# ) + polymorphism  Procedure-oriented (good for concurrency) and data-oriented coexists 13

14  Computer Architecture  Languages are developed around the prevalent computer architecture, known as the von Neumann architecture  Programming Methodologies  New software development methodologies (e.g., object-oriented software development) led to new programming paradigms and by extension, new programming languages 14

15 15

16  Fetch-execute-cycle (on a von Neumann architecture computer)  Program resides in memory, but executes in CPU initialize the program counter repeat forever fetch the instruction pointed by the counter increment the counter decode the instruction (what actions needed) execute the instruction end repeat Stop is rare, usually execution back to OS Functional languages not as efficient as imperative on von Neumann architecture because they are not based on vars 16

17 Virtually every computer can be envisioned as divided into various logical units or sections:  Input unit. ◦ “Receiving” section  obtains information (data and computer programs) from input devices and places it at the disposal of the other units so that it can be processed. ◦ Keyboards and mouse devices ◦ Others:  touchscreen  speaking to your computer  scanning images and barcodes  reading from secondary storage devices: hard drives, CD/DVD/Blu- RAY drives, USB drives (thumb drives), flash drives or memory sticks  and having your computer receive information from the Internet (such as when you download videos from YouTube™, e-books from Amazon etc.). 17

18 ◦ This rapid-access, relatively low-capacity “warehouse” section retains information that has been entered through the input unit, making it immediately available for processing when needed. ◦ The memory unit also retains processed information until it can be placed on output devices by the output unit. Information in the memory unit is volatile - it’s typically lost when the computer’s power is turned off. The memory unit is often called either memory or primary memory. 18

19 ◦ Central processing unit (CPU). This “administrative” section coordinates and supervises the operation of the other sections. ◦ The CPU tells the input unit when information should be read into the memory unit, tells the ALU when information from the memory unit should be used in calculations and tells the output unit when to send information from the memory unit to certain output devices. ◦ Can be multiple CPUs and, hence, can perform many operations simultaneously - such computers are called multiprocessors. ◦ A multi-core processor implements multiprocessing on a single integrated circuit chip - for example, a dual-core processor has two CPUs and a quad-core processor has four CPUs. 19

20 ◦ Arithmetic and logic unit (ALU). This “manufacturing” section performs calculations, such as addition, subtraction, multiplication and division. It also contains the decision mechanisms that allow the computer, for example, to compare two items from the memory unit to determine whether they’re equal. ◦ In today’s systems, the ALU is usually implemented as part of the next logical unit, the CPU. 20

21 ◦ Output unit. This “shipping” section takes information that the computer has processed and places it on various output devices to make it available for use outside the computer. ◦ Most information that is output from computers today is displayed on screens, printed on paper, played on audio players, iPads or used to control other devices. Computers also can output their information to networks, such as the Internet. 21

22 ◦ Secondary storage unit. This is the long-term, high-capacity “warehousing” section. Programs or data not actively being used by the other units normally are placed on secondary storage devices (ex., hard drive) until they’re needed again, possibly hours, days, months or even years later. ◦ Therefore, information on secondary storage devices is said to be persistent - it is preserved even when the computer’s power is turned off. Secondary storage information takes much longer to access than information in primary memory, but the cost per unit of secondary storage is much less than that of primary memory.  Examples of secondary storage devices include CDs, DVDs and USB drives, which can hold hundreds of millions to billions of characters. 22

23 The operating system and language implementation are layered over machine interface of a computer 23

24 1. Analyze: define the problem 2. Design: plan the solution to the problem (epics, user and engineering stories) 3. Interface development: select the objects 4. Code: translate the algorithm into a programming language 5. Debug and Test: locate and remove any errors in the program ( http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks) http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks 6. Documentation: organize all the materials that describe the program 24

25 25

26  Flowchart/sequence diagram  Diagram that visually represents the steps that the program performs to arrive at a solution  A popular logic tool used for showing an algorithm in graphical form  Petstore example: https://wiki.sei.cmu.edu/sad/index.php/Petstore_Application https://wiki.sei.cmu.edu/sad/index.php/Petstore_Application  Pseudocode  An algorithm design technique that uses a combination of English words and a la Visual Basic statements  Used to create a rough sketch of the steps required to complete a task  Hierarchy Chart (Structure chart)  Shows the overall program structure  Describes what each part, module, or component of the program does  Also, shows how each module relates to other modules in the program 26

27  Most common flowchart symbols:  Flowline  Terminal  Input/Output  Processing  Decision 27

28 Initialize counter and sum to 0 Are there more data? Get next grade Increment counter Add grade to sum Yes No Stop Start 28

29  An algorithm design technique that uses a combination of English words and Visual Basic-like statements  Used to create a rough sketch of the steps required to complete a task Initialize Counter and Sum to 0 Do While there are more data Get the next Grade Add the Grade to the Sum Increment the Counter Loop Compute Average = Sum / Counter Display Average 29

30  Shows the overall program structure  Describes what each part, or module, of the program does  Also, shows how each module relates to other modules in the program Class average Program Get Grade Calculate Average Compute Sum and Number of Grades Display Average 30

31  Scientific applications (number crunching)  40 th - 50 th  Large numbers of floating point computations; use of arrays and matrices; loops, selections.  Efficiency #1. Compete with Assembly  Fortran (very efficient, still around), ALGOL 60 (broader scope, but was not accepted, seemed complex)  Business applications  50 th  Produce reports, use decimal numbers and characters  COBOL (1960, still around)  Artificial intelligence (AI)  Symbols rather than numbers manipulated; use of linked lists vs arrays  LISP (1965)  Later Prolog, C, Scheme, F#, Scala 31

32  Systems Programming  60 th - 70 th  Need efficiency because of continuous use ( PL/S, ALGOL )  IBM, Digital, UNISYS  C (UNIX written in C)  Low level, execution, efficient, no safety restrictions – SYSTEM Programming  Dangerous for APPLICATION  Web Software  Eclectic collection of languages: markup (e.g., XHTML ), scripting (e.g., JavaScript, PHP, Perl ), general-purpose (e.g., Java ), C# 32

33  Mobile Software (hottest)  http://en.wikipedia.org/wiki/Mobile_application_development http://en.wikipedia.org/wiki/Mobile_application_development  Java Me (Nokia, Sony Ericsson …),  Android (34+ members include Google, HTC, Motorola, T-Mobile)  Objective-C iOS/Apple  C/C++/Pascal palm OS  C#/VB.Net - Windows Phone 33

34  Overall advancement of computing  Commercial languages (most widely used, not always the best)  ALGOL 60 (blocks, recursion, controls) was better than FORTRAN (lacking them)  Was not supported well  C. A. R. Hoare Programming: Sorcery or Science? (1981!)  Software, he looks forward to a move from the Dark Ages into the Enlightenment. He states that ‘the programmer of today shares many attributes with the craftsmen of yesterday’ through apprenticeship and experiential learning, and ‘shares many attributes with the high priest’ with software manuals taking the role of sacred works.  Hoare then considers ‘the rise of engineering’ and, moving from third person to first person, looks forward: ‘we would like to claim that computer programming has transcended its origins as a craft, has avoided the temptation to form itself into a priesthood, and can now be regarded as a fully fledged engineering profession’ 34

35  In 1977, Apple Computer—creator of today’s popular Mac personal computers, iPod digital music players and iPhones—popularized personal computing.  In 1981, IBM, then the world’s largest computer vendor, introduced the IBM Personal Computer, legitimizing personal computing in business, industry and government organizations.  These machines could be linked together in computer networks, sometimes over telephone lines and sometimes in local area networks (LANs) within an organization. 35

36  This led to the phenomenon of distributed computing, in which an organization’s computing, instead of being performed only at some central computer installation, is distributed over networks to the geographically dispersed sites where the organization’s work is performed.  Information is shared easily across computer networks, where computers called servers offer a common data store and various services that may be used by client computers distributed throughout the network, hence the term client/server computing.  Web App Development with ASP.NET, Java JSP, JavaScript, CSS 36

37  Every year or two, the computing power of computers has approximately doubled without any increase in price.  This often is called Moore’s Law, ◦ (named after the person who first identified and explained the trend, Gordon Moore, co-founder of Intel)  Moore’s Law is especially true in relation to the amount of memory that computers have for programs and data, the amount of secondary storage (such as disk storage) they have, and their processor speeds—the speeds at which computers execute their programs (that is, do their work). 37

38  Similar growth has occurred in the communications field, in which costs have plummeted as enormous demand for communications bandwidth has attracted intense competition.   Such phenomenal improvement in the computing and communications fields is truly fostering the so-called Information Revolution. 38

39 (Reminder) Two's complement From Wikipedia of a binary number is defined as the value obtained by subtracting the number from a large power of two (specifically, from 2N for an N-bit two's complement). The two's complement of the number then behaves like the negative of the original number in most arithmetic, and it can coexist with positive numbers in a natural way. http://www.youtube.com/watch?v=0qjEkh3P9RE http://www.rapidtables.com/math/number/Numeral_system.htm 8-bit two's-complement integers 39

40 Ex: number 28 in 8 bit quantities Step 1. 28 in binary form. 00011100 Step 2. Inversion. 0 ->1, 1 -> 0. 11100011 Step 3. Add 1 1110010 Ex: binary 11111111 00001001 to decimal Step 1. This is a negative number (1 is first) Step 2. Complement 00000000 11110110 Step 3. Add 1 00000000 11110111 = 247 Step 4. Decimal is -247. 40

41  Data items processed by computers form a data hierarchy that becomes larger and more complex in structure as we progress from the simplest data items (called “bits”) to richer data items, such as characters, fields, and so on. 41

42 Bits  The smallest data item in a computer can assume the value 0 or the value 1.  Such a data item is called a bit (short for “binary digit”—a digit that can assume either of two values).  simplest manipulations of 0s and 1s—examining a bit’s value, setting a bit’s value and reversing a bit’s value (from 1 to 0 or from 0 to 1). Characters  We prefer to work with decimal digits (0–9), uppercase letters (A–Z), lowercase letters (a–z), and special symbols (e.g., $, @, %, &, *, (, ), –, +, ", :, ? and / ).  Digits, letters and special symbols are known as characters. The computer’s character set is the set of all the characters used to write programs and represent data items on that device.  Computers process only 1s and 0s, so every character is represented as a pattern of 1s and 0s.  The Unicode character set contains characters for many of the world’s languages. 42

43  C# supports several character sets, including 16-bit Unicode ® characters that are composed of two bytes – each byte is composed of eight bits. ◦ See Appendix B (book)for more information on the ASCII (American Standard Code for Information Interchange) character set—the popular subset of Unicode that represents uppercase and lowercase letters in the English alphabet, digits and some common special characters. 43

44 ASCII letter D is 68 10 or 44 16 4 16 is 0100 2 D is 0100 0100 2 44

45 Extended ASCII Yen sign (¥) is 9D 16 9 16 = 9 10 = 1001 2 D 16 = 13 10 = 1101 2 ¥ in binary is: 1001 1101 2 45

46 Fields  Just as characters are composed of bits, fields are composed of characters or bytes.  A field is a group of characters or bytes that conveys meaning. ◦ For example, a field consisting of uppercase and lowercase letters could be used to represent a person’s name, and a field consisting of decimal digits could represent a person’s age. Records  Several related fields can be used to compose a record.  In a payroll system, for example, the record for an employee might consist of the following fields (possible types for these fields are shown in parentheses): ◦ Employee identification number (a whole number) ◦ Name (a string of characters) ◦ Address (a string of characters) ◦ Hourly pay rate (a number with a decimal point) ◦ Year-to-date earnings (a number with a decimal point) ◦ Amount of taxes withheld (a number with a decimal point)  Thus, a record is a group of related fields. 46

47 Files  A file is a group of related records. ◦ More generally, a file contains arbitrary data in arbitrary formats.  In some operating systems, a file is viewed simply as a sequence of bytes - any organization of the bytes in a file, such as organizing the data into records. Database  A database is a collection of data that’s organized for easy access and manipulation.  The most popular database model is the relational database in which data is stored in simple tables.  A table includes records composed of fields. ◦ For example, a table of students might include first name, last name, major, year, student ID number and grade point average fields. ◦ The data for each student is a record, and the individual pieces of information in each record are the fields.  You can search, sort and otherwise manipulate the data based on its relationship to multiple tables or databases.  noSQL database (Big Data) 47

48 Big Data  The amount of data being produced worldwide is enormous and growing explosively.  According to IBM, approximately 2.5 quintillion bytes (2.5 exabytes) of data are created daily and 90% of the world’s data was created in just the past two years! ( www-01.ibm.com/software/data/bigdata/ ) ◦ Mongo Db ◦ Cassandra ◦ HBase 48

49 49

50  In the mid-1980s, Microsoft developed the Windows operating system.  These operating systems, which borrowed from many concepts (such as icons, menus and windows) popularized by early Apple Macintosh operating systems, enabled users to work with multiple applications simultaneously.  Windows XP, Windows Vista and Windows 7, 8 users. Windows is by far the world’s most widely used operating system. 50

51  Although hundreds of computer languages are in use today, they can be divided into three general types: ◦ Machine languages ◦ Assembly languages ◦ High-level languages 51

52  Machine Languages  A computer can directly understand only its own machine language, which is defined by the computer’s hardware design.  Machine languages generally consist of streams of numbers (ultimately represented in the computer as combinations of 1s and 0s) that instruct computers how to perform their most elementary operations.  The number system with only 1s and 0s is called the binary number system.  Machine languages are machine dependent—a particular machine language can be used on only one type of computer.  Ex.: adds overtime pay to base pay and stores the result in gross pay, demonstrates the incomprehensibility of machine language to humans  +1300042774 +1400593419 +1200274027 52

53  Assembly Languages ◦ Instead of using the strings of numbers that computers could directly understand, programmers began using English-like abbreviations (called mnemonics) to represent the computer’s basic operations. ◦ These abbreviations formed the basis of assembly languages. ◦ Translator programs called assemblers convert assembly-language programs to machine language at computer speeds. ◦ Ex.: assembly-language program also adds overtime pay to base pay and stores the result in gross pay, but the steps are clearer to humans than in the machine- language example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY 53

54  High-Level Languages ◦ To speed up the programming process, high-level languages (in which single program statements accomplish more substantial tasks) were developed. ◦ Translator programs called compilers convert high-level-language programs into machine language. ◦ A payroll application written in a high-level language might contain a statement such as grossPay = basePay + overTimePay ◦ From these examples, it’s clear why programmers prefer high-level languages. ◦ C# is one of the world’s most popular high-level programming languages. 54

55  Visual Basic evolved from BASIC, developed in the mid-1960s at Dartmouth College for introducing novices to fundamental programming techniques.  In the late 1980s and the early 1990s, Microsoft developed the Microsoft Windows graphical user interface (GUI)—the visual part of the operating system with which users interact.  With the creation of the Windows GUI, the natural evolution of BASIC was to Visual Basic, introduced by Microsoft in 1991 to make programming Windows applications easier.  Visual Basic and C# programs are created with the use of Microsoft’s Visual Studio—a collection of software tools called an Integrated Development Environment (IDE).  With the Visual Studio 2012 IDE can write, run, test and debug Visual Basic and C# programs 55

56  C first gained widespread recognition as the development language of the UNIX operating system in the early 1970s.  C++, developed in the early 1980s, provides several features that “spruce up” the C language, and, more importantly, capabilities for object-oriented programming (OOP).  Objects are reusable software components that model items in the real world.  A modular, object-oriented approach to design and implementation can make software development groups much more productive than is possible using earlier programming techniques. 56

57  The Objective-C programming language, also developed in the early 1980s, added capabilities for object-oriented programming (OOP) to the C programming language.  It eventually became the software development language for Apple’s Macintosh.  Its use has exploded as the app development language for Apple’s wildly popular iPod, iPhone and iPad consumer devices. 57

58  Sun Microsystems in 1991 funded an internal corporate research project that resulted in the development of a C++-based language, which Sun eventually called Java. As the World Wide Web exploded in popularity in 1993, Sun saw the possibility of using Java to add dynamic content (for example, interactivity, animations and the like) to web pages.  Java is now used to develop large-scale enterprise applications, to enhance the functionality of web servers (the computers that provide the content we see in our web browsers), to provide applications for consumer devices (such as cell phones, pagers and smartphones) and for many other purposes. 58

59  In 2000, Microsoft announced the C# (pronounced “C-Sharp”) programming language—created specifically for the.NET platform.  C# has similar capabilities to Java and is appropriate for the most demanding application development tasks, especially for building today’s enterprise applications, and web-based and mobile applications. 59

60  Part of the.NET development platform (2000)  Based on C++, Java, and Delphi  Provides a language for component-based software development  All.NET languages  (C#, Visual BASIC.NET, Managed C++, J#.NET, and Jscript.NET, F# 2010 functional use Common Type System (CTS), which provides a common class library Compiled into intermediate ByteCode and use a Just-In-Time compiler immediately prior to execution 60

61  Started as a similar language to Java  Keep and improved C++  enum safer than in C++ (implicitly converted to int )  Better struct  switch – every non empty must end with an unconditional branch  Delegates instead of pointers for event handlers and callbacks  In java callback are interfaces; C++ pointers  Methods can take a variable number of param  Java start using it too in 1.5+  Autoboxing  Java took it too  Foreach  Java took it too 61

62  C# is object oriented  C# is event driven— ◦ programs respond to user-initiated events such as mouse clicks, keystrokes and timer expirations.  Microsoft’s Visual C# is a visual programming language—in addition to writing program statements to build portions of your applications, you can use Visual Studio’s graphical user interface to conveniently drag and drop predefined objects like buttons and textboxes into place on your screen, and label and resize them. 62

63  In the late 1960s, ARPA implemented the ARPAnet, the grandparent of today’s Internet.  ARPAnet’s main benefit proved to be the capability for quick and easy communication via what came to be known as electronic mail (e-mail).  This is true even on today’s Internet, with e-mail, instant messaging and file transfer allowing billions of people worldwide to communicate with each other.  Companies started spending large amounts of money to develop and enhance their Internet presence. 63

64  Bandwidth— the information-carrying capacity of communications lines—on the Internet has increased tremendously, while hardware costs have plummeted.  In 1989, Tim Berners-Lee of began to develop a technology for sharing information over the Internet via “hyperlinked” text documents.  He called his invention the HyperText Markup Language (HTML). He also wrote the communication protocol HyperText Transfer Protocol (HTTP) to form the backbone of his new hypertext information system, which he referred to as the World Wide Web or simply “the web.” 64

65  The web is a collection of hardware and software associated with the Internet that allows computer users to locate and view multimedia-based documents (documents with various combinations of text, graphics, animations, audios and videos) on almost any subject.  In 1994, Berners-Lee founded an organization, called the World Wide Web Consortium, devoted to developing technologies for the World Wide Web.  Today’s applications can be written with the aim of communicating among the world’s computers via the Internet and the web.  This is the focus of Microsoft’s.NET strategy. 65

66  In most programming today, each task in a program must finish executing before the next task can begin.  This is called synchronous programming and is the style we use for most of this book.  C# also allows asynchronous programming in which multiple tasks can be performed at the same time.  Asynchronous programming can help you make your apps more responsive to user interactions, such as mouse clicks and keystrokes, among many other uses.  Visual C# 2012’s new async and await capabilities simplify asynchronous programming, because the compiler hides much of the associated complexity from the developer. 66

67  As the popularity of the web exploded, HTML’s limitations became apparent. HTML’s lack of extensibility (the ability to change or add features) frustrated developers, and its ambiguous definition allowed erroneous HTML to proliferate.  The need for a standardized, fully extensible and structurally strict language was apparent. As a result, XML was developed by the W3C.  Data independence, the separation of content from its presentation, is the essential characteristic of XML. 67

68  Because XML documents describe data, any application conceivably can process them. XML is increasingly used in databases.  Microsoft’s.NET technologies use XML to mark up and transfer data over the Internet, to enable software components to interoperate and to describe graphical user interfaces. 68

69  In 2000, Microsoft announced its.NET initiative, a broad vision for using the Internet and the web in the development, engineering, distribution and use of software.  Developers can create.NET applications in any.NET-compatible language (such as C#, Visual Basic, and others).  Part of the initiative includes Microsoft’s ASP.NET technology, allowing developers to create web applications.  Visual programming has become popular because it enables developers to create Windows and web applications easily, using such prepackaged controls as buttons, textboxes and scrollbars.  The.NET Framework executes applications, includes the.NET Framework Class Library and so on. 69

70  The details of the.NET Framework are found in the Common Language Infrastructure (CLI), which contains information about the storage of data types (that is, data that has predefined characteristics such as a date, percentage or currency amount), objects and so on.  The Common Language Runtime (CLR) is the central part of the.NET Framework — it executes.NET programs.  Programs are compiled into machine-specific instructions in two steps. 70

71 71

72 72

73  The Common Language Runtime (CLR) ◦ executes.NET programs and provides functionality to make them easier to develop and debug.  The CLR is a virtual machine (VM) – ◦ software that manages the execution of programs and hides from them the underlying operating system and hardware.  The source code for programs that are executed and managed by the CLR is called managed code. 73

74  First, the program is compiled into Microsoft Intermediate Language (MSIL), which defines instructions for the CLR.  Code converted into MSIL from other languages and sources can be woven together by the CLR.  The MSIL for an application’s components is placed into the application’s executable file.  When the application executes, another compiler (known as the just-in-time compiler or JIT compiler) in the CLR translates the MSIL in the executable file into machine-language code (for a particular platform), then the machine-language code executes on that platform. 74

75  The.NET Framework also provides a high level of language interoperability.  Programs written in different languages (for example, C# and Visual Basic) are all compiled into MSIL—the different parts can be combined to create a single unified program. MSIL allows the.NET  Framework to be language independent, because.NET programs are not tied to a particular programming language. 75

76  If the.NET Framework exists and is installed for a platform, that platform can run any.NET program.  The ability of a program to run without modification across multiple platforms is known as platform independence.  Code written once can be used on another type of computer without modification, saving time and money.  Previously, companies had to decide whether converting their programs to different platforms—a process called porting -was worth the cost.  With.NET, porting programs is no longer an issue, at least once.NET itself has been made available on the platforms. 76

77  The.NET Framework provides a high level of language interoperability.  Because software components written in different.NET languages (such as C# and VB.NET) are all compiled into MSIL, the components can be combined to create a single unified program.  Thus, MSIL allows the.NET Framework to be language independent. .NET 4.5 features.NET for Windows Store Apps—a subset of.NET that’s used to create Windows 8 UI (user interface) style apps. 77

78  Self study… 78

79 ◦ Running the Advanced Painter application. ◦ Double click the file name AdvancedPainter.exe (Fig. 1.1) to run the application (Fig. 1.2). ◦ Figure 1.2 labels several graphical elements—called controls. These include GroupBoxes, RadioButtons, a Panel and Buttons. The application allows you to draw with a red, blue, green or black brush of small, medium or large size. ◦ The brush’s properties, selected in the RadioButtons labeled Black and Medium, are default settings—the initial settings you see when you first run the application. Default settings also provide visual cues for users to choose their own settings. 79

80  The Advanced Painter application allows developers to draw with different brush sizes and colors.  Open a Windows Explorer window and navigate to the C:\examples\ch01 directory (Fig. 1.6)— assuming you placed the examples in the C:\examples folder. 80

81 81

82 82

83 Step 4: Changing the Brush Color  Click the RadioButton labeled Red to change the brush color, then click the RadioButton labeled Small to change the brush size.  Position the mouse over the white Panel, then drag the mouse to draw with the brush.  Draw flower petals, as shown in Fig. 1.9. 83

84 84

85 Step 5: Changing the Brush Color and Size  Click the Green RadioButton to change the brush color. Then, click the Large RadioButton to change the brush size.  Draw grass and a flower stem, as shown in Fig. 1.10. 85

86 ◦ Changing the brush size. ◦ Click the RadioButton labeled Green to change the color of the brush again. Then, click the RadioButton labeled Large to change the size of the brush. Draw grass and a flower stem, as shown in Fig. 1.4. 86

87 Step 6: Finishing the Drawing  Click the Blue and Medium RadioButtons.  Draw raindrops, as shown in Fig. 1.11, to complete the drawing. 87

88 Step 7: Stopping the App  When you run an app from Visual Studio, you can terminate it by clicking the stop button on the Visual Studio toolbar or by clicking the close box on the running app’s window. 88

89  Object technology is a packaging scheme for creating meaningful software units.  There are date objects, time objects, paycheck objects, invoice objects, automobile objects, people objects, audio objects, video objects, file objects, record objects and so on. ◦ button objects, textbox objects, menu objects and many more.  Almost any noun can be reasonably represented as a software object. 89

90  Objects have attributes (also called properties), such as color, size, weight and speed; and perform actions (also called methods or behaviors), such as moving, sleeping or drawing.  Classes are types of related objects.  For example, all cars belong to the “car” class, even though individual cars vary in make, model, color and options packages.  A class specifies the general format of its objects, and the attributes and actions available to an object depend on its class. 90

91  An object is related to its class in much the same way as a building is related to the blueprint from which the building is constructed.  Contractors can build many buildings from the same blueprint; programmers can instantiate (create) many objects from the same class.  With object technology, properly designed classes can be reused on future projects. 91

92 92

93  Focus on the behaviors and interactions of objects.  In the same way, an application that’s divided into objects is easy to understand, modify and update because it hides much of the detail.  C# is one of the world’s most widely used object-oriented languages, especially in the Microsoft software development community. 93

94  Basic Object-Technology Concepts  Object-oriented design ( OOD ) models software in terms similar to those that people use to describe real-world objects.  It takes advantage of class relationships, where objects of a certain class, such as a class of vehicles, have the same characteristics— cars, trucks, little red wagons and roller skates have much in common. 94

95  OOD takes advantage of inheritance relationships, where new classes of objects are derived by absorbing characteristics of existing classes and adding unique characteristics of their own.  An object of class “convertible” certainly has the characteristics of the more general class “automobile,” but more specifically, the roof goes up and down.  Object-oriented design provides a natural and intuitive way to view the software design process—namely, modeling objects by their attributes, behaviors and interrelationships, just as we describe real-world objects. 95

96  OOD also models communication between objects.  Just as people send messages to one another (for example, a sergeant commands a soldier to stand at attention), objects also communicate via messages.  A bank-account object may receive a message to decrease its balance by a certain amount because the customer is withdrawing that amount of money.  OOD encapsulates (that is, wraps) attributes and operations (behaviors) into objects—an object’s attributes and operations are intimately tied together. 96

97  Objects have the property of information hiding–objects may know how to communicate with one another across well-defined interfaces, although they’re not allowed to know how other objects are implemented—implementation details are hidden within the objects themselves.  You can drive a car effectively, for example, without knowing the details of how engines, transmissions, brakes and exhaust systems work internally—as long as you know how to use the accelerator pedal, the brake pedal, the steering wheel and so on. 97

98 Classes, Fields and Methods  Each class contains data as well as the set of methods that manipulate that data and provide services to clients (that is, other classes that use the class).  The data components of a class are called attributes or fields.  For example, a bank account class might include an account number and a balance. The operation components of a class are called methods.  A bank-account class might include methods to make a deposit (increase the balance), make a withdrawal (decrease the balance) and inquire what the current balance is. 98

99  Classes are to objects as blueprints are to houses—a class is a “plan” for building objects of the class. Just as we can build many houses from one blueprint, we can instantiate (create) many objects from one class.  Each class has a potential to become a valuable software asset that you and other programmers can reuse to speed future software development efforts. 99

100  Introduction to Object-Oriented Analysis and Design (OOAD)  This approach may work for small programs, but what if you were asked to create a software system to control thousands of automated teller machines for a major bank?  For a project so large an complex, you could not simply sit down and start writing programs.  To create the best solutions, you should follow a detailed process for determining your project’s requirements (that is, what your system is supposed to do) and developing a design that satisfies them (that is, deciding how your system should do it).  Ideally, you would go through this process and carefully review the design (and have your design reviewed by other software professionals) before writing any code.  If this process involves analyzing and designing your system from an object-oriented point of view, it’s called object-oriented analysis and design (OOAD). 100

101  Although many different OOAD processes exist, a single graphical language known as the UML (Unified Modeling Language) for communicating the results of any OOAD process has come into wide use. 101


Download ppt "Based on Deitel How To Program slides 1.  Computer use is increasing in almost every field  Computing costs have been decreasing dramatically due to."

Similar presentations


Ads by Google