html5-img
1 / 100

Programming Fundamentals (with C#)

Programming Fundamentals (with C#). Based on Deitel How To program slides. Introduction. Computer use is increasing in almost every field Computing costs have been decreasing dramatically due to rapid developments in hardware, software and communications technologies

aspen
Télécharger la présentation

Programming Fundamentals (with C#)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Fundamentals(with C#) Based on Deitel How To program slides

  2. Introduction • 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

  3. Introduction (cont.) • 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 supercomputerswork so quickly that they can perform the equivalent of 150,000 actions and calculations per second for every person on the planet!

  4. Introduction (cont.) • 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, can greatly enhance productivity

  5. What is Software? • Instructions for the hardware • A collection of instructions is called a program

  6. Computer Architecture Influence • 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

  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 Famous Languages

  8. Genealogy of Common Languages

  9. Popularity of Programming Languages 2012 2011 2010 Normalized Comparison 2012 (from http://www.langpop.com/) yahoo, google, craigslist, powell’s, freshmeat, del.icio.us, ohloh

  10. http://www.tiobe.com/index.php/content/paperinfo/tpci/index.htmlhttp://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

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

  12. Developers

  13. Programming Methodologies Influences • 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

  14. Computer Architecture • 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

  15. The von Neumann Architecture

  16. The von Neumann Architecture • 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

  17. Computer Organization • Virtually every computer can be envisioned as divided into various logical units or sections: • Input unit. This “receiving” section obtains information (data and computer programs) from input devicesand places it at the disposal of the other units so that it can be processed. • Most information is entered into computers through keyboards and mouse devices. • Information also can be entered in many other ways, including by speaking to your computer, scanning images and barcodes, reading from secondary storage devices (like hard drives, CD drives, DVD drives and USB drives—also called 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, and the like).

  18. Computer Organization (cont.) • Memory unit. 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 memoryorprimary memory.

  19.   Computer Organization (cont.) • 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. • Many of today’s computers have 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.

  20.   Computer Organization (cont.) • 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.

  21.  Computer Organization (cont) • 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 (such as Apple’s popular iPods), or used to control other devices. Computers also can output their information to networks, such as the Internet.

  22.   Computer Organization (cont.) • 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.

  23. Layered (onion) View of Computer The operating system and language implementation are layered over machine interface of a computer

  24. Program Development Cycle 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) 6. Documentation: organize all the materials that describe the program

  25. Some Programming Tools • 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 • 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. Flowchart • Most common flowchart symbols: • Flowline • Terminal • Input/Output • Processing • Decision

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

  28. Pseudocode • 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. Hierarchy Chart • 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 Compute Sum and Number of Grades Calculate Average Display Average

  30. Programming Domains • Scientific applications (number crunching) • 40th - 50th • 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 • 50th • 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. Programming Domains cont. • Systems Programming • 60th - 70th • 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 • WebSoftware • Eclectic collection of languages: markup (e.g., XHTML), scripting (e.g., JavaScript, PHP, Perl), general-purpose (e.g., Java), C#

  32. Programming Domains cont. • Mobile Software (hottest) • http://en.wikipedia.org/wiki/Mobile_application_development • JavaMe (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. Main Reasons for Studying Different Programming Languages • 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. Personal Computing, Distributed Computing and Client/Server Computing • 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. Personal Computing, Distributed Computing and Client/Server Computing (cont.) • 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 etc, JavaScript, CSS

  36. Hardware Trends • 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—the company that manufactures the vast majority of the processors in today’s personal computers. • 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.   Hardware Trends (cont.) • 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. (Reminder) Two's complementFrom 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. Two's complement Examples 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. DataHierarchy • 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.  Data Hierarchy (Cont.) 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). • It’s remarkable that the impressive functions performed by computers involve only the 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. Data Hierarchy (Cont.) • 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. ASCII • letter D is 6810 or 4416 • 416 is 01002 • D is 0100 0100 2

  44. Extended ASCII • Yen sign (¥) is 9D 16 • 916 = 910 = 10012 • D16 = 1310 = 11012 • ¥ in binary is: • 1001 11012

  45. Data Hierarchy (Cont.) 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. • In the preceding example, all the fields belong to the same employee.

  46. Data Hierarchy (Cont.) 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, is a view created by the programmer. 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.

  47. Data Hierarchy (Cont.) 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/)

  48. Microsoft’s Windows Operating System • 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.

  49. Machine Languages, Assembly Languages and High-Level Languages • Although hundreds of computer languages are in use today, they can be divided into three general types: • Machine languages • Assembly languages • High-level languages

More Related