Download presentation
Presentation is loading. Please wait.
1
2009 Pearson Education, Inc. All rights reserved. 1 Part I: Compilers Part II: Pair Programming Most slides courtesy of Ms. Stephany Coffman-Wolph Many slides modified by Prof. L. Lilien (even many without explicit message). Slides added by L.Lilien are © 2006-2010 Leszek T. Lilien. Permision to use for non-commercial purposes slides added by L.Lilien’s will be gladly granted upon a written (e.g., emailed) request.
2
2009 Pearson Education, Inc. All rights reserved. 2 Part I: Compilers From Chapter 1 of the textbook (ed.3) Plus many slides courtesy of Ms. Stephany Coffman-Wolph Plus slides modified and added by Dr. Lilien
3
2009 Pearson Education, Inc. All rights reserved. 3 1.1 Introduction 1.2 What Is a Computer? 1.3 Computer Organization 1.4 Personal Computing, Distributed Computing and Client/Server Computing 1.5 Hardware Trends 1.6 Microsoft’s Windows Operating System 1.7 Machine Languages, Assembly Languages and High-Level Languages 1.8 Visual Basic 1.9 C, C++ and Java 1.10 Visual C#
4
2009 Pearson Education, Inc. All rights reserved. 4 1.11 Other High-Level Languages 1.12 Structured Programming 1.13 Key Software Trend: Object Technology 1.14 The Internet and the World Wide Web 1.15 Extensible Markup Language (XML) 1.16 Introduction to Microsoft.NET 1.17 The.NET Framework and the Common Language Runtime 1.18 Test-Driving a C# Advanced Painter Application 1.19 Software Engineering Case Study: Introduction to Object Technology and the UML
5
2009 Pearson Education, Inc. All rights reserved. 5 1.7 Machine Languages, Assembly Languages and High-Level Languages Programmers write instructions in various programming languages Three general types of computer languages : – Machine languages – Assembly languages – High-level languages
6
2009 Pearson Education, Inc. All rights reserved. 6 Fig. 1.1 | Comparing machine, assembly and high-level languages. 1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.)
7
2009 Pearson Education, Inc. All rights reserved. 7 ++READ LATER++ 1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.) A computer can directly understand only its own machine language – It consists of streams of numbers - Ultimately reduced to binary 1s and 0s Machine-language programs - nearly incomprehensible to humans – Example machine-language program snippet: +1300042774 +1400593419 +1200274027
8
2009 Pearson Education, Inc. All rights reserved. 8 Machine-language programming is slow and error prone English-like abbreviations form the basis of assembly languages – Easier to program in them – Easier to understand them A computer does not understand assembly languages – Until they are translated into computer’s machine language – Translation done by assemblers Assemblers convert assembly-language programs to machine- language programs – Example assembly-language program snippet: LOAD BASEPAY or: LD BASEPAY ADD OVERPAY STORE GROSSPAY or ++READ LATER++ 1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.)
9
2009 Pearson Education, Inc. All rights reserved. 9 Example: Assembly code and its machine code [ http://en.wikipedia.org/wiki/Assembly_language#Assembler [ http://en.wikipedia.org/wiki/Assembly_language#Assembler ] ++READ LATER++ 1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.) NOTE: The “object code” of the assembler is the machine code Slide added by L.Lilien
10
2009 Pearson Education, Inc. All rights reserved. 10 To facilitate programming, high-level languages were developed Keywords in English form the basis of high-level languages – Much easier to program in them – Much easier to understand them – Look almost like everyday English with math expressions: grossPay = basePay + overTimePay A computer does not understand high-level languages – Until they are translated into computer’s machine languages – Translation done by compilers Compilers convert high-level-language programs to machine- language programs ++READ LATER++ 1.7 Machine Languages, Assembly Languages and High-Level Languages (Cont.)
11
2009 Pearson Education, Inc. All rights reserved. 11 A typical compilation process [ Fig. from: http://en.wikipedia.org/wiki/Compiler ] http://en.wikipedia.org/wiki/Compiler – With more detail that you need to know ++OPTIONAL++ 1.7 Machine, Assembly and High- Level Languages (Cont.) Slide added by L.Lilien
12
2009 Pearson Education, Inc. All rights reserved. 12 ++READ LATER++ 1.16 Introduction to Microsoft.NET Microsoft’s.NET initiative uses the Internet and the web in the development, engineering, distribution and use of software. Applications in any.NET-compatible language can interact with each other Microsoft’s ASP.NET technology allows you to create web applications The.NET strategy allows programmers to concentrate on their specialties without having to implement every component of every application
13
2009 Pearson Education, Inc. All rights reserved. 13 ++OPTIONAL++ 1.17 The.NET Framework and the Common Language Runtime The Microsoft.NET Framework: – manages and executes applications and web services – contains a class library: - the.NET Framework Class Library (FCL) – provides security and other programming capabilities Notice different.NET Framework releases in the figure – 2.0 / 3.0 / 3.5 / 4.0 Fig. from: http://en.wikipedia.org/wiki/.NET_Framework Slide modified by L.Lilien
14
2009 Pearson Education, Inc. All rights reserved. 14 1.17 The.NET Framework and the Common Language Runtime (Cont.) 2-step compilation using Common Language Infrastructure (CLI) 1) C# compiler – Input: C# code – Output: CIL code – CIL = Common Intermediate Language – CIL = MSIL (Microsoft Intermediate Language) – CIL code is machine-independent code – CIL code is stored in an executable file 2) CLR compiler (CLR = Common Language Runtime) – Input: CIL code – Output: Machine-language code - Machine-dependent code - I.e. not machine-independent code - Specific to the platform running CLR Fig. from: http://en.wikipedia.org/wiki/.NET_Framework Slide added by L.Lilien C#
15
2009 Pearson Education, Inc. All rights reserved. 15 Purpose of the Common Language Infrastructure (CLI) – Provide a language-neutral platform for application development and execution, - Includes functions for exception handling, garbage collection, security, interoperability – The core aspects of the.NET Framework implemented within the scope of the CLI - So,.NET Framework is not tied to a single language -Instead, it is available for many languages supported by the framework Microsoft's implementation of the CLI is called the Common Language Runtime (CLR) ++READ LATER++ 1.17 The.NET Framework and the Common Language Runtime (Cont.) Slide modified by L.Lilien
16
2009 Pearson Education, Inc. All rights reserved. 16 ++READ LATER++ 1.10 Visual C# C# was designed specifically for the.NET platform – As a language that would enable programmers to migrate easily to.NET C# is object oriented – With access to a powerful class library of prebuilt components – It has roots in C, C++ and Java - Adapting the best features of each
17
2009 Pearson Education, Inc. All rights reserved. 17 Visual C# is an event-driven, visual programming language C# allows to write programs that respond to events such as mouse clicks and keystrokes Visual Studio’s graphical user interface allows to design GUIs by dragging and dropping predefined objects (like buttons and textboxes) into place ++READ LATER++ 1.10 Visual C#
18
2009 Pearson Education, Inc. All rights reserved. 18 Microsoft introduced C# along with its.NET strategy in 2000 The.NET platform allows applications to be distributed to a variety of devices The original C# programming language was standardized by ECMA International in December 2002 Since then, Microsoft proposed several language extensions – Adopted as part of the revised ECMA C# standard ++READ LATER++ 1.10 Visual C# (Cont.)
19
2009 Pearson Education, Inc. All rights reserved. The Complete Compilation Process Complete compilation process I/O: – Input: high-level language (HLL) code – source code – Output: machine-code – object code 19 Slide added by L.Lilien
20
2009 Pearson Education, Inc. All rights reserved. The Complete Compilation Process (Cont.) Four basic steps performed by a typical compiler: 1) Preprocessing (a part of the compiler!) - To expand macros (details later) 2) Compilation (in the narrow sense) - Translates from high-level source code to assembly code - Not to CIL/MSIL code 3) Assembly (a part of the compiler!) - Translates from assembly code to machine code - When there are calls to external functions in the assembly source file, the assembler leaves the addresses of the external functions undefined, to be filled in later by the linker 4) Linking (a part of the compiler!) - Takes one or more objects and combines them into a single executable -An executable requires many external functions from system and run-time libraries - Creates the final executable (.exe in Windows) 20 Slide modifieds by L.Lilien This and next 9 slides courtesy of S. Coffman-Wolph, a few modified (slightly) by L. Lilien
21
2009 Pearson Education, Inc. All rights reserved. 1) Preprocessing First stage of the overall compilation process Preprocessor processes compiler directives – ++OPTIONAL++ Technically, C# does not have a separate Preprocessing process (it is actually done at the same time as the lexical analysis ). Directives – Allow for conditional compilations - To conditionally skip sections of source files, - To report errors and warning conditions - To have distinct regions of source code – Always placed on their own line and begin with #
22
2009 Pearson Education, Inc. All rights reserved. ++READ LATER++ 1) Preprocessing (Cont.) Directives – Directives in C# - #if, #else, #elif, and #endif - #define and #undef - #warning and #error - #line - #region and #endregion
23
2009 Pearson Education, Inc. All rights reserved. 1) Preprocessing (Cont.) Example of Code w/Preprocessor Directives (lines starting with #) #define Debug // Debugging on #undef Trace // Tracing off class PurchaseTransaction { void Commit() { #if Debug CheckConsistency(); #if Trace WriteToLog(this.ToString()); #endif CommitHelper(); }
24
2009 Pearson Education, Inc. All rights reserved. 2) Compilation The actual compilation — in the narrow sense Input: preprocessed source code Output: assembly language (for a specific processor) – ++OPTIONAL++ Major phases: - Scanner “Break up” the text/code into tokens Done via Regular Expressions - Parser Insures that the source code follows all the rules - Code generator Creates assembly language code
25
2009 Pearson Education, Inc. All rights reserved. ++READ LATER++ 2) Compilation (Cont.) Regular Expressions Regular expressions are from the theoretical side of computer science – Automata theory – Formal language theory – These fields study models of computation (automata) and ways to describe and classify formal languages Regular expressions are used mainly for pattern matching
26
2009 Pearson Education, Inc. All rights reserved. ++READ LATER++ 2) Compilation (Cont.) Regular Expression Basic Examples Match any digit – \d or [0-9] Match any non-digit – \D Match exactly three digits – \d{3} or \d\d\d or [0-9][0-9][0-9] or [0-9]{3} Match any sequence of letters in upper or lower case, but there must be at least 1 letter – [a-zA-Z]+ Match any sequence of at least one word character – \w+
27
2009 Pearson Education, Inc. All rights reserved. 3) Assembly Converts assembly language code into machine code – Input (source file):assembly language code – Output (object file):machine code Processes calls to external functions – They can be present in the source file (assembly language file) – Assembler leaves addresses of external functions undefined - To be filled in later by the linker (next overall compilation phase)
28
2009 Pearson Education, Inc. All rights reserved. 4) Linking The final stage of compilation is the linking of object files to create an executable – Takes multiple object files and creates one executable file. – Among these object files are many external functions taken from system and run-time libraries Linker complains if it can not link proper methods/functions – Earlier in compilation, if a method/function did not exist, it was assumed that it was in another file (to be linked later) – You can think of this phase as the one trying to fill-in any remaining “blanks” and “ties” it all together
29
2009 Pearson Education, Inc. All rights reserved. The Complete Compilation Process (Cont.) Summary: Four basic compiler steps: 1) Preprocessing (a part of the compiler!) 2) Compilation (in the narrow sense) 3) Assembly (a part of the compiler!) 4) Linking (a part of the compiler!) 29 Slide modifieds by L.Lilien
30
2009 Pearson Education, Inc. All rights reserved. ++READ LATER++ Suggested Additional Reading Talks about C/C++ but the basic theory is the same: http://www.network- theory.co.uk/docs/gccintro/gccintro_83.html C# article: http://msdn.microsoft.com/en- us/magazine/cc136756.aspx
31
2009 Pearson Education, Inc. All rights reserved. 31 Part II: Pair Programming Slides courtesy of Ms. Coffman-Wolph Plus minor modifications by Dr. Lilien
32
2009 Pearson Education, Inc. All rights reserved. Pair Programming Pair Programming = Two People, One Computer – A mechanism for real-time problem solving and real-time quality assurance – Helps developers to focus on the problem at hand Two people work together at one computer to create code – Not simply dividing up the project… … and working on them independently – The “pair” should be in the same room - Or in this day and age, communicating in real-time - E.g., via Video Chat, Shared Desktop, etc. 32
33
2009 Pearson Education, Inc. All rights reserved. Tasks for Driver and Navigator One person is a driver – Controls the keyboard and mouse - types the actual code – Leads the conversation and discussions through the process One person is a navigator – P ays attention to the driver – Monitors code and design – Makes relevant suggestions, – Corrects errors - Stop holes in logic, provide debugging assistance, etc. Communication between driver and navigator is the most important part of Pair Programming! – Without good communication, Pair Programming teams are ineffective Switch the roles throughout the entire project – Nobody should always be the driver or navigator 33
34
2009 Pearson Education, Inc. All rights reserved. Things to Avoid Things you should avoid: Interrupting every time your partner starts doing something in a way other than how you'd do it Once you wrestle the keyboard away, deleting your partner's last edit immediately Then doing what you were thinking of instead If your partner objects, ignoring it and talking over it Speaking non-stop, so your partner never has a moment of silence in which to speak, read code, or have a thought For further (humorous) reading: http://www.c2.com/cgi/wiki?HowToPissOffYourPair 34
35
2009 Pearson Education, Inc. All rights reserved. But I Like Working By Myself… Things to think about: – Writing software is a team activity - Large software is extremely rarely written by one person alone – You can learn from your partner’s feedback - To benefit from both your successful and less successful activities, techniques and habits – Pair programming studies have shown: - Pair programmers have greater productivity than solo programmers (most studies show double productivity) - Pair programming significantly improves design correctness - Pair programmers’ code has overall higher correctness - Pair programming decreases overall time required
36
2009 Pearson Education, Inc. All rights reserved. ++READ LATER++ More Benefits of Pair Programming Studies have shown the following benefits: – Better brainstorms – Better and higher quality code – Increased morale – Increased teamwork – Enhanced learning – Increased courage – Better and more effective debugging – Increased knowledge – Better time management 36
37
2009 Pearson Education, Inc. All rights reserved. ++READ LATER++ Selecting your partner… Suggestions: – Find a partner that is in your lecture and/or your lab - Makes things a little easier… – Find a partner who’s schedule can work with your schedule - Start by comparing schedules, if both of you only have 1 hour that you can meet up - this really will not work – Make sure you and your partner can easily meet in the same location - Schedule your first meeting to be very soon after the assignment comes out – Exchange contact information (names, email, phone numbers, etc) when you agree to be partners – Start your assignment early! - Things go smoother if you are not starting at 2 am the day before it is due…(trust me on this one)
38
2009 Pearson Education, Inc. All rights reserved. ++READ LATER++ How to they “pick” partners in “real” world? Alternatives: – People paired by managers - Mixing novice programmers with experts - Mixing “new” programmers with “older” programmers – People select their partners themselves – People pick tasks they want to work on, and the pairs result from task selections - Pair forming is especially easy if a large project is broken into very small tasks - People pair with lots of partners throughout the project
39
2009 Pearson Education, Inc. All rights reserved. ++READ LATER++ Can I… … work on the project without my partner? – Track down an error in between meetings, read the specs, ask the instructor clarification questions, think through the logic/design - yes – You should wait to do major design/coding only when you and your partner can meet … not have a partner? – It is a requirement for CS1120. (Sorry) – If you feel you have a special case - see me … change partners between assignment 6 and 7? – Absolutely … come to you if I am having problems with my partner? – Absolutely
40
2009 Pearson Education, Inc. All rights reserved. Good Reading Material on Pair Programming “All I Really Need to Know about Pair Programming I Learned In Kindergarten” – http://collaboration.csc.ncsu.edu/laurie/Papers/Kindergarten.PDF “Software Reviews and Pair Programming” – http://agile.csc.ncsu.edu/SEMaterials/ReviewsandPairProgramm ing.pdf http://agile.csc.ncsu.edu/SEMaterials/ReviewsandPairProgramm ing.pdf Many more – you can google it up 40
41
2009 Pearson Education, Inc. All rights reserved. In-class Pair Programming Exercise Get problem from our class web page 41
42
2009 Pearson Education, Inc. All rights reserved. 42 The End
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.