Using Expressions Effectively
|
|
- Karen York
- 5 years ago
- Views:
Transcription
1 Using Expressions Effectively By Kevin Hazzard and Jason Bock, author of Metaprogramming in.net Writing code in IL can easily lead to incorrect implementations and requires a mental model of code execution in.net that s not as intuitive as the one a high-level language provides. Fortunately, there s another API in.net that lets you create code without having to know anything about IL. This is the Expression API that exists within the LINQ world. In this article, based on chapter 6 of Metaprogramming in.net, the authors show you how to use expressions effectively. Now that you ve seen how expressions are created, let s get into areas that will make your expression life easier with debugging, emitting, and mutating. Learning these techniques is important so that you know your expressions do what you think they should do. Let s begin by looking at how to add debug information to your expression. Debugging expressions Using the Expression API is a simpler, cleaner experience than trying to work with IL. That said, any time a developer writes a piece of code, something can go wrong. Fortunately, there are a couple of techniques you can use to debug your expressions. Let s start with the first one: visualizing your expression in the debugger. Visualizing an expression in Visual Studio Whenever you create an expression of any type, you can get a visualization of that node in Visual Studio when you run your code under the debugger. You move your mouse pointer over the variable in code, drill down to the Debug View option, and select Text Visualizer. Figure 1 shows what an expression looks like in this visualizer. You may wonder why the language used in the visualizer doesn t use C# or VB. Expressions can support options that a language may not be able to express (like a fault block), so the designers of the visualizer came up with a different language to show the expression. It s not that hard to follow, and it s a quick and easy way to get a good idea for what your expression looks like at a particular point in its construction.
2 2 Figure 1 Visualizing an expression in Visual Studio. The language may not look like anything you ve seen before, but the intent is clear. NOTE For more information on the visualizer, see In the next section, you ll see how you can step into an expression at runtime. Using Reflection.Emit to debug expressions Although a visual representation of an expression is a nice tool to have, sometimes you want to have the debugger dive right into the code. Unfortunately, an expression is a tree that represents your code structure. Or is it? When you compile your method, it s emitting IL for you. Surprisingly, there s a connection between expressions and Reflection.Emit that lets you create debug information for an expression. Let s see how you can get it to work. Similar to the exception handler example, you re going to start with a simple add two numbers together code snippet. The first thing you need to do is create a bunch of dynamic members from the Reflection.Emit API. Don t worry, you won t need to write any IL for debugging purposes; these members act as a host to your expression, as you ll see in a moment: var name = Guid.NewGuid().ToString("N"); var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly( new AssemblyName(name), AssemblyBuilderAccess.Run); var module = assembly.definedynamicmodule(name, true); var type = module.definetype( Guid.NewGuid().ToString("N"), TypeAttributes.Public); var methodname = Guid.NewGuid().ToString("N"); var method = type.definemethod(methodname, MethodAttributes.Public MethodAttributes.Static, typeof(int), new Type[] { typeof(int), typeof(int) }); All this code is doing is getting an in-memory dynamic assembly set up along with dynamic type and method. As you can see, the names of these members don t matter in this case what does matter is the debugging support. For that, you need a DebugInfoGenerator: var generator = DebugInfoGenerator.CreatePdbGenerator(); var document = Expression.SymbolDocument("AddDebug.txt"); The generator created from CreatePdbGenerator() will be used when the expression is compiled. You also need to create a symbol document based on a text file. The AddDebug.txt file in this example is the expression
3 3 expressed in the language used in the expression visualizer demonstrated in the previous section. We won t show the code here, but you ll see what some of it looks like in a figure near the end of this section. To create debug symbols for sections of the code, you need to wrap a specific node in the expression tree with a DebugInfoExpression: var adddebuginfo = Expression.DebugInfo(document, 6, 9, 6, 22); var add = Expression.Add(x, y); var addblock = Expression.Block(addDebugInfo, add); The section in the document that maps to the expression node being wrapped is defined in the DebugInfo() call. This DebugInfoExpression object is used in a Block() call to wrap the BinaryExpression that represents the addition functionality of this expression. Once you re done defining your expression, save the expression s implementation into the dynamic assembly: var lambda = Expression.Lambda(addBlock, x, y); lambda.compiletomethod(method, generator); var bakedtype = type.createtype(); return (int)bakedtype.getmethod(methodname).invoke(null, new object[] { a, b }); In this case, you use CompileToMethod() to specify which method you re implementing in the dynamic assembly along with the debug information related to this method. At this point, when you step into the Invoke() call in a debugger, you ll get into the file specified in the SymbolDocumentInfo object. Figure 2 shows what this looks like when you step into the expression language copied to the text file. Figure 2 Debugging an expression. Even though the language may look a little odd, it s clear that you ve stopped at the point where addition occurs in the method. CAVEAT Using expressions to implement your methods in Reflection.Emit is a nice alternative to IL. But there s one major limitation to this approach: you can only use expressions to define static methods. You can t use an expression for an instance method. For more information on why this is the case, see You now know how you can debug your expression. Let s move on to another topic: immutability. It will definitely affect your design, and that s what the next section is all about. Mutating expression trees We ll now look at expressions, immutability, and how you can create new expressions based on existing ones via the ExpressionVisitor class. Let s start by looking at the reasoning behind having immutable trees. Immutability of expression trees To frame the conversation on immutable expressions, let s look at an expression that adds two integers together: Expression<Func<int, int, int>> add = (x, y) => x + y; Let s say someone wanted to change that expression to make it subtract the two arguments rather than add them. Because Expression<T> is a reference type, the expression you were referencing will now perform a
4 4 subtraction, not an addition. That s not at all what you want! Immutable data structures are easier to reason about because you know that once the structure is created, it won t change. This also has benefits from a concurrency perspective because these structures are automatically thread-safe. NOTE For more information on the benefits (and some shortcomings) of programming using immutable values see Immutability and Being able to use a structure as the basis for future changes isn t a bad thing. In the next section, you ll see how you can create a new expression based on an existing one. Creating variations of expressions You now know that expressions are immutable. Let s see how to create a new expression from the contents of an existing expression. The key class you need is ExpressionVisitor. As the name implies, this class is based on the visitor pattern, which is designed to allow you to traverse complex object structures in a simplistic way by visiting specific methods that you care about. NOTE For more on the visitor pattern, see You feed a subclass of ExpressionVisitor the expression that s your baseline and then you overwrite the VisitXYZ() methods you re interested in to create a new expression. Let s create a custom visitor that will change an add operation to a subtract operation. The following code listing demonstrates what it takes to write such a visitor. Listing 1 Creating an expression visitor internal sealed class AddToSubtractExpressionVisitor : ExpressionVisitor { internal Expression Change(Expression expression) { return this.visit(expression); } } protected override Expression VisitBinary(BinaryExpression node) { return node.nodetype == ExpressionType.Add? Expression.Subtract( this.visit(node.left), this.visit(node.right)) : node; } As you can see, it doesn t take that much code to change an expression. In this case, you override VisitBinary() because you re trying to find the mathematical expression node Add. If you find one, then you create a new node that subtracts the child nodes. Note that you need to keep visiting the Left and Right nodes from the given node because they may also contain addition operations. For example, if you didn t do that, an expression like this (x, y) => ((((32 * x) / 4) + y) + (x + 4)) would turn into this: (x, y) => ((((32 * x) / 4) + y) (x + 4)) That s not what you want, because there are still two addition operations in the expression. Visiting the child nodes gives you the right result: (x, y) => ((((32 * x) / 4) y) (x 4)) NOTE Before.NET 4.0, there wasn t a way in the.net Framework to visit an expression. The ExpressionVisitor class existed in System.Linq.Expressions, but it was marked as internal, so you couldn t use it. There are a couple of ways to support this technique in.net 3.5 see and for details on these approaches.
5 5 You now know how to debug and change expressions in.net.
6 6 Here are some other Manning titles you might be interested in: Windows 8 Apps with HTML5 and JavaScript Dan Shultz, Joel Cochran, and James Bender Fast ASP.NET Websites Dean Alan Hume Windows Store App Development: C# and XAML Pete Brown Last updated: 8/2/13
Kevin Hazzard Jason Bock
S AMPLE CHAPTER in.net Kevin Hazzard Jason Bock FOREWORD BY Rockford Lhotka MANNING Metaprogramming in.net by Kevin Hazzard Jason Bock Chapter 6 Copyright 2013 Manning Publications brief contents PART
More informationGetting Started. 1 by Conner Irwin
If you are a fan of the.net family of languages C#, Visual Basic, and so forth and you own a copy of AGK, then you ve got a new toy to play with. The AGK Wrapper for.net is an open source project that
More informationCS354 gdb Tutorial Written by Chris Feilbach
CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that
More informationRuntime code generation techniques in real life scenarios
Runtime code generation techniques in real life scenarios Raffaele Rialdi Senior Software Architect Microsoft MVP @raffaeler https://github.com/raffaeler http://iamraf.net Abstract The runtime code generation
More informationThe NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software.
Introduction to Netbeans This document is a brief introduction to writing and compiling a program using the NetBeans Integrated Development Environment (IDE). An IDE is a program that automates and makes
More informationCSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch
CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed
More informationSoftware Design and Analysis for Engineers
Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 9 Date:
More informationFor your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to
For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Author...
More informationLecture 4 CSE July 1992
Lecture 4 CSE 110 6 July 1992 1 More Operators C has many operators. Some of them, like +, are binary, which means that they require two operands, as in 4 + 5. Others are unary, which means they require
More informationGDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial
A Walkthrough with Examples CMSC 212 - Spring 2009 Last modified March 22, 2009 What is gdb? GNU Debugger A debugger for several languages, including C and C++ It allows you to inspect what the program
More information1.7 Limit of a Function
1.7 Limit of a Function We will discuss the following in this section: 1. Limit Notation 2. Finding a it numerically 3. Right and Left Hand Limits 4. Infinite Limits Consider the following graph Notation:
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 4 Introduction to C (pt 2) 2014-09-08!!!Senior Lecturer SOE Dan Garcia!!!www.cs.berkeley.edu/~ddgarcia! C most popular! TIOBE programming
More informationint $0x32 // call interrupt number 50
Kernel Programming: Process isolation, goal to make programs run fast and reliably o Processes should not affect others, unless there s a specific and allowed communication channel o Each process can act
More informationEXAMINING THE CODE. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist:
EXAMINING THE CODE CONTENTS I. Static White Box Testing II. 1. Examining the Design and Code 2. Formal Review: 3. Coding Standards and Guidelines: 4. Generic Code Review Checklist: Dynamic White Box Testing
More informationSoftware Engineering /48
Software Engineering 1 /48 Topics 1. The Compilation Process and You 2. Polymorphism and Composition 3. Small Functions 4. Comments 2 /48 The Compilation Process and You 3 / 48 1. Intro - How do you turn
More informationCS125 : Introduction to Computer Science. Lecture Notes #11 Procedural Composition and Abstraction. c 2005, 2004 Jason Zych
CS125 : Introduction to Computer Science Lecture Notes #11 Procedural Composition and Abstraction c 2005, 2004 Jason Zych 1 Lecture 11 : Procedural Composition and Abstraction Solving a problem...with
More informationIntroduction. A Brief Description of Our Journey
Introduction If you still write RPG code as you did 20 years ago, or if you have ILE RPG on your resume but don t actually use or understand it, this book is for you. It will help you transition from the
More informationCS125 : Introduction to Computer Science. Lecture Notes #38 and #39 Quicksort. c 2005, 2003, 2002, 2000 Jason Zych
CS125 : Introduction to Computer Science Lecture Notes #38 and #39 Quicksort c 2005, 2003, 2002, 2000 Jason Zych 1 Lectures 38 and 39 : Quicksort Quicksort is the best sorting algorithm known which is
More informationIntroducing C# and the.net Framework
1 Introducing C# and the.net Framework C# is a general-purpose, type-safe, object-oriented programming language. The goal of the language is programmer productivity. To this end, the language balances
More informationThink like an Elm developer
Think like an Elm developer Piper Niehaus Denver, CO, USA Backpacker / skier Nonprofit board chair Software Engineer at Pivotal Pivotal Tracker team Elm in Production since 2016 Internal Products and Services
More informationImproved Web Development using HTML-Kit
Improved Web Development using HTML-Kit by Peter Lavin April 21, 2004 Overview HTML-Kit is a free text editor that will allow you to have complete control over the code you create and will also help speed
More informationImplementing an Algorithm for Boomerang Fraction Sequences in Python
Introduction Implementing an Algorithm for Boomerang Fraction Sequences in Python We ve all encountered maze problems, where the challenge is to find a path through a labyrinth from a starting point to
More information9 R1 Get another piece of paper. We re going to have fun keeping track of (inaudible). Um How much time do you have? Are you getting tired?
Page: 1 of 14 1 R1 And this is tell me what this is? 2 Stephanie x times y plus x times y or hm? 3 R1 What are you thinking? 4 Stephanie I don t know. 5 R1 Tell me what you re thinking. 6 Stephanie Well.
More informationUNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING
UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE13/L: INTRODUCTION TO PROGRAMMING IN C SPRING 2012 Lab 3 Matrix Math Introduction Reading In this lab you will write a
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationCS Introduction to Data Structures How to Parse Arithmetic Expressions
CS3901 - Introduction to Data Structures How to Parse Arithmetic Expressions Lt Col Joel Young One of the common task required in implementing programming languages, calculators, simulation systems, and
More informationVisual Basic 2008 Anne Boehm
TRAINING & REFERENCE murach s Visual Basic 2008 Anne Boehm (Chapter 3) Thanks for downloading this chapter from Murach s Visual Basic 2008. We hope it will show you how easy it is to learn from any Murach
More informationUpcoming Features in C# Mads Torgersen, MSFT
Upcoming Features in C# Mads Torgersen, MSFT This document describes language features currently planned for C# 6, the next version of C#. All of these are implemented and available in VS 2015 Preview.
More informationThe C# Programming Language. Overview
The C# Programming Language Overview Microsoft's.NET Framework presents developers with unprecedented opportunities. From web applications to desktop and mobile platform applications - all can be built
More informationChapter 1 Getting Started
Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different
More informationPatterns Of Enterprise Application Architecture
Patterns Of Enterprise Application Architecture Lecture 11-12 - Outlines Overview of patterns Web Presentation Patterns Base Patterns Putting It All Together References Domain Logic Patterns Domain Model
More informationCISC220 Lab 2: Due Wed, Sep 26 at Midnight (110 pts)
CISC220 Lab 2: Due Wed, Sep 26 at Midnight (110 pts) For this lab you may work with a partner, or you may choose to work alone. If you choose to work with a partner, you are still responsible for the lab
More informationNESTED IF STATEMENTS AND STRING/INTEGER CONVERSION
LESSON 15 NESTED IF STATEMENTS AND STRING/INTEGER CONVERSION OBJECTIVE Learn to work with multiple criteria if statements in decision making programs as well as how to specify strings versus integers in
More informationHow Rust views tradeoffs. Steve Klabnik
How Rust views tradeoffs Steve Klabnik 03.04.2019 What is a tradeoff? Bending the Curve Overview Design is about values Case Studies BDFL vs Design By Committee Stability Without Stagnation Acceptable
More informationJoseph Hernandez 7/31/2011 Project Paper for CS 6910
Joseph Hernandez 7/31/2011 Project Paper for CS 6910 For my project this semester I chose to try and implement the Voting System created by Brett Wilson for his Masters Project, IMPLEMENTING A PAILLIER
More informationMEAP Edition Manning Early Access Program WebAssembly in Action Version 1
MEAP Edition Manning Early Access Program WebAssembly in Action Version 1 Copyright 2018 Manning Publications For more information on this and other Manning titles go to www.manning.com welcome Thank you
More informationInteractive Tourist Map
Adobe Edge Animate Tutorial Mouse Events Interactive Tourist Map Lesson 2 Make click events In the last lesson you learned how to set up you stage and get your project ready for some interactivity. You
More informationDeveloping Desktop Apps for Ultrabook Devices in Windows 8*: Getting Started
Developing Desktop Apps for Ultrabook Devices in Windows 8*: Getting Started By Paul Ferrill The Ultrabook provides a rich set of sensor capabilities to enhance a wide range of applications. It also includes
More informationPart I. Integrated Development Environment. Chapter 2: The Solution Explorer, Toolbox, and Properties. Chapter 3: Options and Customizations
Part I Integrated Development Environment Chapter 1: A Quick Tour Chapter 2: The Solution Explorer, Toolbox, and Properties Chapter 3: Options and Customizations Chapter 4: Workspace Control Chapter 5:
More informationSafety SPL/2010 SPL/20 1
Safety 1 system designing for concurrent execution environments system: collection of objects and their interactions system properties: Safety - nothing bad ever happens Liveness - anything ever happens
More informationI m sure you have been annoyed at least once by having to type out types like this:
Type Inference The first thing I m going to talk about is type inference. C++11 provides mechanisms which make the compiler deduce the types of expressions. These features allow you to make your code more
More informationIntroduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#)
Introduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#) Course Number: 6367A Course Length: 3 Days Course Overview This three-day course will enable students to start designing
More informationSPRITES Moving Two At the Same Using Game State
If you recall our collision detection lesson, you ll likely remember that you couldn t move both sprites at the same time unless you hit a movement key for each at exactly the same time. Why was that?
More informationAzure Developer Immersions Application Insights
Azure Developer Immersions Application Insights Application Insights provides live monitoring of your applications. You can detect and diagnose faults and performance issues, as well as discover how users
More informationChapter 9: Dealing with Errors
Chapter 9: Dealing with Errors What we will learn: How to identify errors Categorising different types of error How to fix different errors Example of errors What you need to know before: Writing simple
More informationLecture Notes on Advanced Garbage Collection
Lecture Notes on Advanced Garbage Collection 15-411: Compiler Design André Platzer Lecture 21 November 4, 2010 1 Introduction More information on garbage collection can be found in [App98, Ch 13.5-13.7]
More informationOur Hall of Fame or Shame candidate for today is the command ribbon, which was introduced in Microsoft Office The ribbon is a radically
1 Our Hall of Fame or Shame candidate for today is the command ribbon, which was introduced in Microsoft Office 2007. The ribbon is a radically different user interface for Office, merging the menubar
More informationThe name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.
Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that
More informationLecture 1: Overview
15-150 Lecture 1: Overview Lecture by Stefan Muller May 21, 2018 Welcome to 15-150! Today s lecture was an overview that showed the highlights of everything you re learning this semester, which also meant
More informationType Checking and Type Equality
Type Checking and Type Equality Type systems are the biggest point of variation across programming languages. Even languages that look similar are often greatly different when it comes to their type systems.
More informationSection Notes - Week 1 (9/17)
Section Notes - Week 1 (9/17) Why do we need to learn bits and bitwise arithmetic? Since this class is about learning about how computers work. For most of the rest of the semester, you do not have to
More informationProgramming Robots with ROS, Morgan Quigley, Brian Gerkey & William D. Smart
Programming Robots with ROS, Morgan Quigley, Brian Gerkey & William D. Smart O Reilly December 2015 CHAPTER 23 Using C++ in ROS We chose to use Python for this book for a number of reasons. First, it s
More informationNCAA Instructions Nerdy for Sports
Home Page / Login 2 Registration 3 Main Menu 4 Making your Picks 5 Editing your Picks 7 View your Picks 8 Double Check your Picks 9 Actual Results 11 Payouts 12 Reports 12 League History 16 Contact Us
More informationLesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014
Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class
More informationTA hours and labs start today. First lab is out and due next Wednesday, 1/31. Getting started lab is also out
Announcements TA hours and labs start today. First lab is out and due next Wednesday, 1/31. Getting started lab is also out Get you setup for project/lab work. We ll check it with the first lab. Stars
More informationLecture 21: The Many Hats of Scala: OOP 10:00 AM, Mar 14, 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 21: The Many Hats of Scala: OOP 10:00 AM, Mar 14, 2018 Contents 1 Mutation in the Doghouse 1 1.1 Aside: Access Modifiers..................................
More informationLinks Menu (Blogroll) Contents: Links Widget
45 Links Menu (Blogroll) Contents: Links Widget As bloggers we link to our friends, interesting stories, and popular web sites. Links make the Internet what it is. Without them it would be very hard to
More informationRepetition Through Recursion
Fundamentals of Computer Science I (CS151.02 2007S) Repetition Through Recursion Summary: In many algorithms, you want to do things again and again and again. For example, you might want to do something
More informationWPF and MVVM Study Guides
1. Introduction to WPF WPF and MVVM Study Guides https://msdn.microsoft.com/en-us/library/mt149842.aspx 2. Walkthrough: My First WPF Desktop Application https://msdn.microsoft.com/en-us/library/ms752299(v=vs.110).aspx
More informationCS1102: What is a Programming Language?
CS1102: What is a Programming Language? Kathi Fisler, WPI September 13, 2007 1 The Design and Programming Perspectives To start to understand what comprises a programming language, let s consider sample
More informationPortable Class Libraries ---
Portable Class Libraries --- Overview In this lab, you ll learn about Portable Class Libraries (PCLs). PCLs enable you to create managed assemblies that work on more than one.net Framework platform. Within
More informationHCA Tech Note 103. Expressions. Example: Conversion
Expressions This technical note provides several examples on some of the common uses of expressions and the Compute element. The Compute element opens a lower level of HCA than available from the Visual
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 4 C Pointers 2004-09-08 Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia Cal flies over Air Force We re ranked 13 th in the US and
More informationSDK Programming for Web Developers
1 SDK Programming for Web Developers Excerpted from iphone in Action Introduction to Web and SDK Development Christopher Allen and Shannon Appelcline MEAP Release: May 2008 Softbound print: December 2008
More informationUnderstanding Recursion
Understanding Recursion sk, rob and dbtucker (modified for CS 536 by kfisler) 2002-09-20 Writing a Recursive Function Can we write the factorial function in AFunExp? Well, we currently don t have multiplication,
More informationLab #0 Getting Started Due In Your Lab, August 25, 2004
Lab #0 Getting Started Due In Your Lab, August 25, 2004 Name: Lab Time: Grade: /10 Man UNIX systems contain on-line manuals called man pages that are accessed through the program man. To find out how to
More informationLab 4. Out: Friday, February 25th, 2005
CS034 Intro to Systems Programming Doeppner & Van Hentenryck Lab 4 Out: Friday, February 25th, 2005 What you ll learn. In this lab, you ll learn to use function pointers in a variety of applications. You
More informationThe Dynamic Typing Interlude
CHAPTER 6 The Dynamic Typing Interlude In the prior chapter, we began exploring Python s core object types in depth with a look at Python numbers. We ll resume our object type tour in the next chapter,
More information5.5 Completing the Square for the Vertex
5.5 Completing the Square for the Vertex Having the zeros is great, but the other key piece of a quadratic function is the vertex. We can find the vertex in a couple of ways, but one method we ll explore
More informationIntroduction to Mobile Development
Introduction to Mobile Development Building mobile applications can be as easy as opening up the IDE, throwing something together, doing a quick bit of testing, and submitting to an App Store all done
More informationComputer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs. Lexical addressing
Computer Science 21b (Spring Term, 2015) Structure and Interpretation of Computer Programs Lexical addressing The difference between a interpreter and a compiler is really two points on a spectrum of possible
More informationFundamental C# Programming
Part 1 Fundamental C# Programming In this section you will find: Chapter 1: Introduction to C# Chapter 2: Basic C# Programming Chapter 3: Expressions and Operators Chapter 4: Decisions, Loops, and Preprocessor
More information4. Java Project Design, Input Methods
4-1 4. Java Project Design, Input Methods Review and Preview You should now be fairly comfortable with creating, compiling and running simple Java projects. In this class, we continue learning new Java
More informationFirst-Order Translation Checklist
CS103 Winter 2019 First-Order Translation Checklist Cynthia Lee Keith Schwarz In this handout, we ve distilled five specific points that you should check in your first-order logic statements before submitting
More informationLINQ Language-Integrated Query Introduction
LINQ Language-Integrated Query Introduction Contents Introduction... 1 The var Keyword... 2 IEnumerable... 2 Anonymous Classes... 3 Extension Methods Part I... 3 The this Parameter... 4 Extension Methods
More informationDownload Free Pictures & Wallpaper from the Internet
Download Free Pictures & Wallpaper from the Internet D 600 / 1 Millions of Free Graphics and Images at Your Fingertips! Discover How To Get Your Hands on Them Almost any type of document you create can
More informationPart I: Programming Access Applications. Chapter 1: Overview of Programming for Access. Chapter 2: Extending Applications Using the Windows API
74029c01.qxd:WroxPro 9/27/07 1:43 PM Page 1 Part I: Programming Access Applications Chapter 1: Overview of Programming for Access Chapter 2: Extending Applications Using the Windows API Chapter 3: Programming
More information/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17
01.433/33 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/2/1.1 Introduction In this lecture we ll talk about a useful abstraction, priority queues, which are
More informationASYNCHRONOUS PROGRAMMING IN C# 5 WITHOUT USE OF MULTIPLE THREADS
ASYNCHRONOUS PROGRAMMING IN C# 5 WITHOUT USE OF MULTIPLE THREADS Aleš Keprt Department of Informatics, Moravian College Olomouc ales.keprt@mvso.cz ABSTRACT: Asynchrony is a situation when multiple things
More informationProgramming in Visual Basic with Microsoft Visual Studio 2010
Programming in Visual Basic with Microsoft Visual Studio 2010 Course 10550; 5 Days, Instructor-led Course Description This course teaches you Visual Basic language syntax, program structure, and implementation
More informationPart 6 - Constructing Railroad Bridges
Part 6 - Constructing Railroad Bridges Bridges are a vital part of every railroad, and in Train Simulator we are fortunate to have a large variety of them, both in the game itself and available through
More informationIn fact, as your program grows, you might imagine it organized by class and superclass, creating a kind of giant tree structure. At the base is the
6 Method Lookup and Constant Lookup As we saw in Chapter 5, classes play an important role in Ruby, holding method definitions and constant values, among other things. We also learned how Ruby implements
More informationCSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)
CSE 413 Languages & Implementation Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1 Goals Representing programs as data Racket structs as a better way to represent
More informationThe Language INtegrated Query (LINQ) feature of Visual Studio 2008 provides
In This Chapter Chapter 1 Getting to Know LINQ Defining LINQ uses, benefits, and design goals Considering the real world uses of LINQ Defining declarative programming languages Understanding the LINQ namespaces
More informationCS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/
CS61C Machine Structures Lecture 4 C Pointers and Arrays 1/25/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L04 C Pointers (1) Common C Error There is a difference
More informationText Input and Conditionals
Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()
More informationCMSC 433 Programming Language Technologies and Paradigms. Spring 2013
CMSC 433 Programming Language Technologies and Paradigms Spring 2013 Encapsulation, Publication, Escape Data Encapsulation One of the approaches in object-oriented programming is to use data encapsulation
More informationMr G s Java Jive. #11: Formatting Numbers
Mr G s Java Jive #11: Formatting Numbers Now that we ve started using double values, we re bound to run into the question of just how many decimal places we want to show. This where we get to deal with
More informationFunctions and Decomposition
Unit 4 Functions and Decomposition Learning Outcomes Design and implement functions to carry out a particular task. Begin to evaluate when it is necessary to split some work into functions. Locate the
More informationWe aren t getting enough orders on our Web site, storms the CEO.
In This Chapter Introducing how Ajax works Chapter 1 Ajax 101 Seeing Ajax at work in live searches, chat, shopping carts, and more We aren t getting enough orders on our Web site, storms the CEO. People
More informationStatistics Case Study 2000 M. J. Clancy and M. C. Linn
Statistics Case Study 2000 M. J. Clancy and M. C. Linn Problem Write and test functions to compute the following statistics for a nonempty list of numeric values: The mean, or average value, is computed
More informationCS 103 Lab - Party Like A Char Star
1 Introduction In this lab you will implement a "hangman" game where the user is shown blanks representing letter of a word and then tries to guess and fill in the letters with a limited number of guesses.
More informationPROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led
CENTER OF KNOWLEDGE, PATH TO SUCCESS Website: PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO 2010 Course: 10550A; Duration: 5 Days; Instructor-led WHAT YOU WILL LEARN This course teaches you
More informationSKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)
SKILL AREA 304: Review Programming Language Concept Computer Programming (YPG) 304.1 Demonstrate an Understanding of Basic of Programming Language 304.1.1 Explain the purpose of computer program 304.1.2
More informationCOMP Lecture Notes Iterative and Recursive Procedures for Strings
COMP 161 - Lecture Notes - 11 - Iterative and Recursive Procedures for Strings Spring 2016 In these notes we look at developing iterative and recursive implementations of procedures for Strings. These
More informationThread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections
Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent
More informationMemory Usage. Chapter 23
C23621721.fm Page 280 Wednesday, January 12, 2005 10:52 PM Chapter 23 Memory Usage The garbage collector is one of the most sophisticated pieces of the Microsoft.NET Framework architecture. Each time an
More informationLecture 19 CSE August You taught me Language, and my profit on t is I know how to curse. William Shakspere, The Tempest, I, ii.
Lecture 19 CSE 110 5 August 1992 You taught me Language, and my profit on t is I know how to curse. William Shakspere, The Tempest, I, ii. 1 Left-Over Language Features Today was the day we saw the last
More informationExcel Basics: Working with Spreadsheets
Excel Basics: Working with Spreadsheets E 890 / 1 Unravel the Mysteries of Cells, Rows, Ranges, Formulas and More Spreadsheets are all about numbers: they help us keep track of figures and make calculations.
More informationPreventing and Finding Bugs in Parallel Programs
Preventing and Finding Bugs in Parallel Programs Charlie Peck Earlham College BW/UPEP Institute @ NCSA May, 2011 1 How Did We Get Here? Debugging serial programs can be hard; debugging parallel programs
More information