Org Comp Refs Typ vro Prop Deleg Attrib Version Part. Introduction Part I. Radu Nicolescu Department of Computer Science University of Auckland
|
|
- Arabella Cook
- 6 years ago
- Views:
Transcription
1 Introduction Part I Radu Nicolescu Department of Computer Science University of Auckland 1 August / 50
2 1 Organisation and Contents 2 Compiling C# 3 References 4 Types 5 var, ref and out 6 Properties and Indexers 7 Delegates 8 Attributes 9 Versioning explicit overriding 10 Partial classes 2 / 50
3 Course materials All course materials in this part lectures, assignments, links,... are available in one single location: compsci335s2c/lectures/radu/ Of course, also linked from Canvas / Modules: (next slide) slides are for online study only handouts are recommended for printing 4 / 50
4 Course materials 5 / 50
5 Organisation Three lectures per week: handouts, slides, samples, additional readings requires homework Three tutorials per week, repeating the same topics: optional, but recommended immediately after the lectures Assignments: 20% of total course marks Test: 20% of total course marks likely MCQ Exam: 60% of total course marks likely MCQ Office hours: by appointment or immediately after the teaching? 6 / 50
6 Contents two parts Part R (weeks 3-8): Introduction to functional programming (FP) and applications such as XML and Web Services using REST Part I uses C# primarily, but also other languages, such as F#, Java, Javascript... Assignment requires a command-line C#, F# application Part M (weeks 1-2, 9-12): Web application security,... 7 / 50
7 Why functional programming? Functional programming (FP) is a programming style (paradigm) which often: leads to more concise and bug-free programs enables a better separation of concerns allows a uniform integration of data from heterogeneous sources (e.g. objects, SQL, XML, REST/ODATA) provides better support for concurrency (parallel programming) will make you a better programmer 8 / 50
8 Why functional programming? Tzu-li and Tzu-ssu were boasting about the size of their latest programs. Two-hundred thousand lines, said Tzu-li, not counting comments! Tzu-ssu responded, Pssh, mine is almost a million lines already. Master Yuan-Ma said, My best program has five hundred lines. Hearing this, Tzu-li and Tzu-ssu were enlightened. Master Yuan-Ma: The Book of Programming (Marijn Haverbeke: Eloquent Javascript) 9 / 50
9 Why functional programming? There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, And the other way is to make it so complicated that there are no obvious deficiencies. C.A.R. Hoare, 1980 ACM Turing Award Lecture (Marijn Haverbeke: Eloquent Javascript) 10 / 50
10 What about object-oriented programming? The problem with object-oriented languages is they ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle. Joe Armstrong, interviewed in Coders at Work (Marijn Haverbeke: Eloquent Javascript) 11 / 50
11 Why C#? C# and most modern imperative/oo languages (C++, Java) are becoming multi-paradigm languages In this direction, C#,.NET and related tools are years ahead of other imperative languages We ll also have short introduction to F# s basics We further use F# in a grad course (734), to study advanced functional topics, including modern parallel programming 12 / 50
12 Why C#? For example, a critical ingredient of functional programming lambda expressions C#: 2007 (!) C++: 2011 (C++11 Why Lambdas Rock) lambda-closures.html Java: 2014 (Java 8 is Revolutionary, Java is back) everything-about-java-8/ 13 / 50
13 Why C#? Another critical ingredient, true generics, i.e. generic types which are kept at runtime C#: 2006 (!) Current Java: generic types are processed by the compiler and then erased thus not present at runtime Java: 201? Project Valhalla http: // 14 / 50
14 Why C#? The functional concepts and skills that we learn using C# are or will be, sooner or later, available in other languages (Java) C# is cross-platfrom, free and open source C# is supported by powerful tools Linqpad a lightweight interactive editor, excellent for learning and developing small snippets (free version) Visual Studio (2015) a complex tool for large projects (free community version; also, other tools freely available to compsci students) technical-facilities/software.html 15 / 50
15 Compiling C#.CS C# source file Hello.cs 1 using System ; 2 3 p u b l i c c l a s s H e l l o { 4 p u b l i c s t a t i c void Main ( s t r i n g [ ] a r g s ) { 5 Console. W r i t e L i n e ( H e l l o! ) ; 6 Console. ReadLine ( ) ; 7 } 8 } Line 5 is the only real business line, hmm / 50
16 Compiling C# CSC cf PATH env variable Compiler output:.dll library;.exe program; collectively known as assemblies CSC C# compiler (VS 2015) C:\Program Files (x86)\msbuild\14.0\bin CSC C# compiler (VS 2017) C:\Program Files (x86)\microsoft Visual Studio\ 2017\Enterprise\MSBuild\15.0\Bin\Roslyn 1 CSC H e l l o. cs 1 CSC / t a r g e t : exe /out : H e l l o. exe H e l l o. cs language-reference/compiler-options/ command-line-building-with-csc-exe 18 / 50
17 Compiling C# Linqpad.LINQ C# snippet for Linqpad (also: F#, VB, SQL) Linqpad automatically references most frequently used libraries Linqpad automatically wraps your code into full classes Linqpad can easily create and maintain DB and Web REST connections 19 / 50
18 Compiling C# VS.SLN VS solution files (i.e. a group of related projects).csproj VS project file (i.e. a group of sources complied together) Many other files and folders... Has great tools and is excellent for large team projects Hides too much of the complexity, so it is not so great for small learning compsci projects VS is a good way to INSTALL a compatible complete set of compilers, tools and libraries But DO NOT USE VS IN 335, unless specifically advised! 20 / 50
19 C# references Required: familiarity with Chapter 1, Introduction, of C# Language Specification, version 5.0 for VS language-reference/language-specification/ Complete reference and programming guide https: //docs.microsoft.com/en-us/dotnet/csharp/csharp In the sequel, we briefly overview a few of the C# basic features that we use and are different from Java 22 / 50
20 Type system unification Java: (1) reference types (objects) and (2) primitive types (e.g. int) C#: (1) reference types one balloon two handles semantics C#: (2) value types (e.g. int or structures) copy semantics C#: conceptually, both types derive from the root class object and can be fully treated as objects! 1 s t r i n g s = 7. ToString ( ) ; 2 3 s t a c k. Push ( 1 2 ) ; 24 / 50
21 Classes vs Structures Let s contrast class and struct semantics First, consider class PointC reference semantics (one balloon, two handles) 1 c l a s s PointC { 2 p u b l i c i n t X { get ; set ; } 3 p u b l i c i n t Y { get ; set ; } 4 } 1 var pc = new PointC { X = 10, Y = 20, } ; 2 v ar qc = pc ; // ref semantics 3 qc. X += 1 ; // qc. X == pc. X == 11 pc and qc are two handles to the same object, which was changed! 25 / 50
22 Classes vs Structures Next, consider struct PointS copy semantics 1 s t r u c t PointS { 2 p u b l i c i n t X { get ; set ; } 3 p u b l i c i n t Y { get ; set ; } 4 } 1 var ps = new PointS { X = 10, Y = 20, } ; 2 v ar qs = ps ; // copy semantics 3 qs. X += 1 ; // qc. X == 11 && pc. X == 10 ps and qs are two distinct objects, initially identical, but then only one was changed! 26 / 50
23 Type-safe casting This casting raises an exception: 1 object o = abc ; 2 3 Point p = ( Point ) o ; This type-safe casting returns null (no exception) 1 object o = abc ; 2 3 Point p = o as Point ; // p = n u l l 27 / 50
24 The implicit type var The type of local variables can be statically determined by the compiler, if they are immediately initialised Instead of this redundant line 1 D i c t i o n a r y <s t r i n g, s t r i n g > t r a n s l a t e = 2 new D i c t i o n a r y <s t r i n g, s t r i n g >(); You can write a crisper one 1 var t r a n s l a t e = new D i c t i o n a r y <s t r i n g, s t r i n g >(); The compiler replaces this var by the expected type Dictionary <string, string> 29 / 50
25 The implicit type var This is still static typing; do not confuse it with more dynamic features var keyword dotnet/csharp/language-reference/keywords/var Implicitly Typed Local Variables programming-guide/classes-and-structs/ implicitly-typed-local-variables 30 / 50
26 Ref parameters Parameters that may change back (even value types): 1 s t a t i c void Swap ( r e f i n t a, r e f i n t b ) { 2 i n t t = a ; 3 a = b ; 4 b = t ; 5 } 1 i n t x = 1 ; i n t y = 2 ; 2 Console. W r i t e L i n e ( p re : x ={0}, y={1}, x, y ) ; 3 // pre : x=1, y=2 4 5 Swap ( r e f x, r e f y ) ; 6 7 Console. W r i t e L i n e ( p o s t : x ={0}, y={1}, x, y ) ; 8 // p o s t : x=2, y=1 31 / 50
27 The out parameters Ref parameters must be initialised before calling the method (recall Swap) Out parameters need not they get values from the called method In fact, out parameters are additional return values (sometimes we need more than one) programming-guide/arrays/ passing-arrays-using-ref-and-out 32 / 50
28 The out parameters Example a method with two out parameters 1 // divisor, dividend, quotient, remainder 2 void D i v i d e ( i n t a, i n t b, out i n t q, out i n t r ) { 3 q = a / b ; 4 r = a % b ; 5 } Example usage 1 i n t q, r ; 2 D i v i d e ( 7, 3, out q, out r ) ; 3 Console. W r i t e L i n e ( q={0}, r ={1}., q, r ) ; 4 // q=2, r =1. 33 / 50
29 Properties A handy structured way to define Java like accessors (i.e. a getter and setter pair) 1 p u b l i c c l a s s Button { // simplified 2 p r i v a t e s t r i n g c a p t i o n ; 1 p u b l i c s t r i n g Caption { 2 get { return c a p t i o n ; } // getter 3 set { // setter 4 c a p t i o n = v a l u e ; // v a l u e is setter param 5 Console. W r i t e L i n e ( r e p a i n t :{0}, c a p t i o n ) ; 6 } 7 } 8 } 35 / 50
30 Properties Properties can used in an uniform manner from outside look like fields! 1 var b = new Button ( ) ; 2 b. Caption = ABC ; // set; causes repaint 3 s t r i n g s = b. Caption ; // get 1 b. Caption += DEF ; // get & set; causes repaint The last line in Java style: 1 b. s e t C a p t i o n ( b. g e t C a p t i o n ( ) + DEF ) ; 36 / 50
31 Indexers associative arrays In a nutshell, an indexer is anonymous property with additional parameters, which formally look like array indices parameters/indices can have any type (int, string, etc) 1 var t r a n s l a t e = 2 new D i c t i o n a r y <s t r i n g, s t r i n g >(); 3 4 t r a n s l a t e [ one ] = un ; 5 // t r a n s l a t e. s e t ( one, un ) 6 t r a n s l a t e [ two ] = deux ; 7 t r a n s l a t e [ t h r e e ] = t r o i s ; 8 9 Console. W r i t e L i n e ( t r a n s l a t e [ two ] ) ; 10 // t r a n s l a t e. g e t ( two ) 11 // deux 37 / 50
32 Delegates type-safe pointers to methods Consider the following class defining two methods with excepting the names identical signatures (int string void) 1 c l a s s Test { 2 p u b l i c s t a t i c void S ( i n t a, s t r i n g b ) {... } 3 p u b l i c void I ( i n t x, s t r i n g y ) {... } 4 } Their common signature can be abstracted by the following delegate type (pointer-to-function type): 1 delegate void D( i n t p, s t r i n g q ) ; D matches any method with the same parameter and return types (here int string void) 39 / 50
33 Delegates type-safe pointers to methods The two methods can now be processed in an uniform way 1 D d = Test. S ; 2 d ( 3, a l p h a ) ; // Test. S ( 3, a l p h a ) 3 4 Test t = new Test ( ) ; 5 d = t. I ; 6 d ( 7, beta ) ; // t. I ( 7, beta ) In most practical cases, we do not really need to define our own delegate types There are many predefined delegate types (generic, to fit as many types as possible) 40 / 50
34 Delegates type-safe pointers to methods Action<...> (0 to 16 parameters) 1 T 1 T 2 void 2 3 p u b l i c delegate void 4 Action <i n T1, i n T2> ( 5 T1 arg1, 6 T2 arg2 7 ) Instead of our previous delegate type D, we could have used the predefined Action<int, string> 1 Action <int, s t r i n g > d = Test. S ; / 50
35 Delegates type-safe pointers to methods Func<...> (0 to 16 parameters) 1 T 1 T 2 TResult 2 3 p u b l i c delegate TResult 4 Func<i n T1, i n T2, out TResult> ( 5 T1 arg1, 6 T2 arg2 7 ) 42 / 50
36 Delegates type-safe pointers to methods Predicate<T> 1 T bool 2 3 p u b l i c delegate bool 4 P r e d i c a t e <i n T> ( 5 T o b j 6 ) Predicate<T> is a handy alternative to Func<T, bool> 43 / 50
37 Attributes similar to Java annotations Here, the WebMethod attribute specifies a cache duration 1 p u b l i c c l a s s S e r v i c e 1 : WebService { 2 [ WebMethod ( CacheDuration =60)] 3 p u b l i c double ConvertTemperature ( double f a h r ) { 4 return ( ( f a h r 32) 5) / 9 ; 5 } 6 } Line 2 decorates method ConvertTemperature with an instance of class WebMethodAttribute and sets its property CacheDuration The semantics of attributes is not defined by language itself, but by various tools and frameworks that run attribute decorated code 45 / 50
38 Versioning similar to annotations In C#, versioning is strictly enforced at the language level, while in Java annotations are recommended but still optional programming-guide/classes-and-structs/ versioning-with-the-override-and-new-keywords 1 p u b l i c c l a s s Base { 2 p u b l i c v i r t u a l void f ( ) {... } 3 } 1 p u b l i c c l a s s D e r i v e d : Base { 2 p u b l i c o v e r r i d e void f ( ) {... } 3 } This helps to avoid the (in)famous fragile base problem 47 / 50
39 Partial classes The same class can defined by separate chunks, even in different files programming-guide/classes-and-structs/ partial-classes-and-methods Very helpful if one part is automatically created by a tool which could be automatically regenerated (thus overwritten) while the other is developed by a programmer (and must be controlled) 49 / 50
40 Partial classes Example 1 p a r t i a l c l a s s X { 2 p u b l i c void f ( ) {... } 3 } 1 p a r t i a l c l a s s X { 2 p u b l i c void g ( ) {... } 3 } It works! 1 var x = new X ( ) ; 2 x. f ( ) ; 3 x. g ( ) ; 50 / 50
Object Oriented Paradigm
Object Oriented Paradigm History Simula 67 A Simulation Language 1967 (Algol 60 based) Smalltalk OO Language 1972 (1 st version) 1980 (standard) Background Ideas Record + code OBJECT (attributes + methods)
More informationTopics Covered Thus Far CMSC 330: Organization of Programming Languages
Topics Covered Thus Far CMSC 330: Organization of Programming Languages Names & Binding, Type Systems Programming languages Ruby Ocaml Lambda calculus Syntax specification Regular expressions Context free
More informationWhidbey Enhancements to C# Jeff Vaughan MSBuild Team July 21, 2004
Whidbey Enhancements to C# Jeff Vaughan MSBuild Team July 21, 2004 Outline Practical Partial types Static classes Extern and the namespace alias qualifier Cool (and practical too) Generics Nullable Types
More informationDo Languages Matter? Lecture 1: Overview. Why Article. Do Languages Matter? Why choose C vs C++ vs Java vs Python...!
Do Languages Matter? Why choose C vs C++ vs Java vs Python... Lecture 1: Overview CSC 131 Fall, 2014 Kim Bruce What criteria to decide? Scenarios: - ios app - Android App - Web App - Mac App - Windows
More informationJavaScript V. Higher Order Functions
JavaScript V Higher Order Functions Tzu-li and Tzu-ssu were boasting about the size of their latest programs. Two-hundred thousand lines, said Tzu-li, not counting comments! Tzu-ssu responded, Pssh, mine
More informationClosures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming
Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Summary 1. Predictive Parsing 2. Large Step Operational Semantics (Natural) 3. Small Step Operational Semantics
More informationAP Computer Science A: Java Programming
AP Computer Science A: Java Programming Zheng-Liang Lu Department of Computer Science & Information Engineering National Taiwan University APcomSci 297 Spring 2018 Class Information Instructor: Zheng-Liang
More informationProject Compiler. CS031 TA Help Session November 28, 2011
Project Compiler CS031 TA Help Session November 28, 2011 Motivation Generally, it s easier to program in higher-level languages than in assembly. Our goal is to automate the conversion from a higher-level
More informationCSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures
CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures Dan Grossman Fall 2014 Hi! I m not Hal J I love this stuff and have taught
More informationIntroduce C# as Object Oriented programming language. Explain, tokens,
Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 4a Andrew Tolmach Portland State University 1994-2017 Semantics and Erroneous Programs Important part of language specification is distinguishing valid from
More informationJava Programming. Zheng-Liang Lu. Java 308 Spring Department of Computer Science & Information Engineering National Taiwan University
Java Programming Zheng-Liang Lu Department of Computer Science & Information Engineering National Taiwan University Java 308 Spring 2019 Class Information Instructor: Zheng-Liang Lu Email: d00922011@ntu.edu.tw
More informationWeeks 6&7: Procedures and Parameter Passing
CS320 Principles of Programming Languages Weeks 6&7: Procedures and Parameter Passing Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Weeks 6&7: Procedures and Parameter Passing 1 / 45
More informationSixth lecture; classes, objects, reference operator.
Sixth lecture; classes, objects, reference operator. 1 Some notes on the administration of the class: From here on out, homework assignments should be a bit shorter, and labs a bit longer. My office hours
More informationMCSA Universal Windows Platform. A Success Guide to Prepare- Programming in C# edusum.com
70-483 MCSA Universal Windows Platform A Success Guide to Prepare- Programming in C# edusum.com Table of Contents Introduction to 70-483 Exam on Programming in C#... 2 Microsoft 70-483 Certification Details:...
More informationCS112 Lecture: Defining Instantiable Classes
CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:
More informationCourse Syllabus C # Course Title. Who should attend? Course Description
Course Title C # Course Description C # is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the.net Framework.
More informationCS 314 Principles of Programming Languages
CS 314 Principles of Programming Languages Lecture 15: Review and Functional Programming Zheng (Eddy) Zhang Rutgers University March 19, 2018 Class Information Midterm exam forum open in Sakai. HW4 and
More informationCSE 341, Autumn 2015, Ruby Introduction Summary
CSE 341, Autumn 2015, Ruby Introduction Summary Disclaimer: This lecture summary is not necessarily a complete substitute for atting class, reading the associated code, etc. It is designed to be a useful
More informationCS 360 Programming Languages Interpreters
CS 360 Programming Languages Interpreters Implementing PLs Most of the course is learning fundamental concepts for using and understanding PLs. Syntax vs. semantics vs. idioms. Powerful constructs like
More information15-122: Principles of Imperative Computation, Fall 2015
15-122 Programming 5 Page 1 of 10 15-122: Principles of Imperative Computation, Fall 2015 Homework 5 Programming: Clac Due: Thursday, October 15, 2015 by 22:00 In this assignment, you will implement a
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 informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 7a Andrew Tolmach Portland State University 1994-2016 Values and Types We divide the universe of values according to types A type is a set of values and a
More informationClosures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming
Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming t ::= x x. t t t Call-by-value big-step Operational Semantics terms variable v ::= values abstraction x.
More informationCPS 506 Comparative Programming Languages. Programming Language
CPS 506 Comparative Programming Languages Object-Oriented Oriented Programming Language Paradigm Introduction Topics Object-Oriented Programming Design Issues for Object-Oriented Oriented Languages Support
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Type Systems, Names and Binding CMSC 330 - Spring 2013 1 Topics Covered Thus Far! Programming languages Ruby OCaml! Syntax specification Regular expressions
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 3a Andrew Tolmach Portland State University 1994-2016 Formal Semantics Goal: rigorous and unambiguous definition in terms of a wellunderstood formalism (e.g.
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2017 Lecture 3a Andrew Tolmach Portland State University 1994-2017 Binding, Scope, Storage Part of being a high-level language is letting the programmer name things: variables
More informationPolymorphism. Contents. Assignment to Derived Class Object. Assignment to Base Class Object
Polymorphism C++ Object Oriented Programming Pei-yih Ting NTOU CS 26-1 Contents Assignment to base / derived types of objects Assignment to base / derived types of pointers Heterogeneous container and
More informationJava Programming. Zheng-Liang Lu. Java 301 Summer Department of Computer Science & Information Engineering National Taiwan University
Java Programming Zheng-Liang Lu Department of Computer Science & Information Engineering National Taiwan University Java 301 Summer 2018 Class Information Instructor: Zheng-Liang Lu Email: d00922011@csie.ntu.edu.tw
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 4a Andrew Tolmach Portland State University 1994-2016 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.
More informationProgramming Languages: Lecture 11
1 Programming Languages: Lecture 11 Chapter 9: Subprograms Jinwoo Kim jwkim@jjay.cuny.edu Chapter 9 Topics 2 Introduction Fundamentals of Subprograms Design Issues for Subprograms Local Referencing Environments
More informationTopics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited
CMSC 330: Organization of Programming Languages Type Systems, Names & Binding Topics Covered Thus Far Programming languages Syntax specification Regular expressions Context free grammars Implementation
More informationG Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 6 Robert Grimm, New York University 1 Review Last week Function Languages Lambda Calculus SCHEME review 2 Outline Promises, promises, promises Types,
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 informationCS-202 Introduction to Object Oriented Programming
CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction
More informationC#: framework overview and in-the-small features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer C#: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer
More informationLecture 10 Notes Linked Lists
Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to
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 informationCMSC330. Objects, Functional Programming, and lambda calculus
CMSC330 Objects, Functional Programming, and lambda calculus 1 OOP vs. FP Object-oriented programming (OOP) Computation as interactions between objects Objects encapsulate mutable data (state) Accessed
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University August 21, 2017 Chapter 2: Data and Expressions CS 121 1 / 51 Chapter 1 Terminology Review
More informationCPS122 Lecture: From Python to Java
Objectives: CPS122 Lecture: From Python to Java last revised January 7, 2013 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.
More informationC++ for Java Programmers
Basics all Finished! Everything we have covered so far: Lecture 5 Operators Variables Arrays Null Terminated Strings Structs Functions 1 2 45 mins of pure fun Introduction Today: Pointers Pointers Even
More informationCSCE 156 Computer Science II
CSCE 156 Computer Science II Lab 04 - Classes & Constructors Dr. Chris Bourke Prior to Lab 1. Review this laboratory handout prior to lab. 2. Read Object Creation tutorial: http://download.oracle.com/javase/tutorial/java/javaoo/objectcreation.
More informationSlide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto
CS 170 Java Programming 1 Expressions Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 What is an expression? Expression Vocabulary Any combination of operators and operands which, when
More informationPOLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors
POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors CSC 330 OO Software Design 1 Abstract Base Classes class B { // base class virtual void m( ) =0; // pure virtual
More informationPOLYMORPHISM 2 PART. Shared Interface. Discussions. Abstract Base Classes. Abstract Base Classes and Pure Virtual Methods EXAMPLE
Abstract Base Classes POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors class B { // base class virtual void m( ) =0; // pure virtual function class D1 : public
More informationCSE341: Programming Languages Lecture 17 Implementing Languages Including Closures. Dan Grossman Autumn 2018
CSE341: Programming Languages Lecture 17 Implementing Languages Including Closures Dan Grossman Autumn 2018 Typical workflow concrete syntax (string) "(fn x => x + x) 4" Parsing Possible errors / warnings
More informationObject-Oriented Programming in C# (VS 2015)
Object-Oriented Programming in C# (VS 2015) This thorough and comprehensive 5-day course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes
More informationClasses Classes 2 / 35
Classes 1 / 35 Classes Classes 2 / 35 Anatomy of a Class By the end of next lecture, you ll understand everything in this class definition. package edu. gatech. cs1331. card ; import java. util. Arrays
More informationEI326 ENGINEERING PRACTICE & TECHNICAL INNOVATION (III-G) Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University
EI326 ENGINEERING PRACTICE & TECHNICAL INNOVATION (III-G) Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University KENNY ZHU Research Interests: Programming Languages Data processing Coordination
More informationCS558 Programming Languages Winter 2013 Lecture 8
OBJECT-ORIENTED PROGRAMMING CS558 Programming Languages Winter 2013 Lecture 8 Object-oriented programs are structured in terms of objects: collections of variables ( fields ) and functions ( methods ).
More informationQUIZ. Source:
QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Ch. 4: Data Abstraction The only way to get massive increases in productivity is to leverage off other people s code. That
More informationPieter van den Hombergh Thijs Dorssers Stefan Sobek. February 10, 2017
Inheritance and Inheritance and Pieter van den Hombergh Thijs Dorssers Stefan Sobek Fontys Hogeschool voor Techniek en Logistiek February 10, 2017 /FHTenL Inheritance and February 10, 2017 1/45 Topics
More informationProcessor. Lecture #2 Number Rep & Intro to C classic components of all computers Control Datapath Memory Input Output }
CS61C L2 Number Representation & Introduction to C (1) insteecsberkeleyedu/~cs61c CS61C : Machine Structures Lecture #2 Number Rep & Intro to C 2005-08-31 There is one handout today at the front and back
More informationBasics of Java Programming CS129 LTPC:
Basics of Java Programming CS9 LTPC: -0-4-3 Instructor: Gauravkumarsingh Gaharwar Program: Masters of Science(IT) Class-Semester: FYMSc(IT) (Sem-II) Email: gauravsinghg@nuv.ac.in Phone Number: 065-30000(0)
More informationCS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University
CS558 Programming Languages Winter 2018 Lecture 4a Andrew Tolmach Portland State University 1994-2018 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.
More informationIntroduction to Computation and Problem Solving
Class 3: The Eclipse IDE Introduction to Computation and Problem Solving Prof. Steven R. Lerman and Dr. V. Judson Harward What is an IDE? An integrated development environment (IDE) is an environment in
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 informationSymbol Tables Symbol Table: In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier in a program's source code is
More informationB16 Object Oriented Programming
B16 Object Oriented Programming Michael A. Osborne mosb@robots.ox.ac.uk http://www.robots.ox.ac.uk/~mosb/teaching.html#b16 Hilary 2013 This course will introduce object-oriented programming (OOP). It will
More informationFinal CSE 131B Spring 2004
Login name Signature Name Student ID Final CSE 131B Spring 2004 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 (25 points) (24 points) (32 points) (24 points) (28 points) (26 points) (22 points)
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and
More informationProgram Analysis And Its Support in Software Development
Program Analysis And Its Support in Software Development Qing Yi class web site: www.cs.utsa.edu/~qingyi/cs6463 cs6463 1 A little about myself Qing Yi B.S. Shandong University, China. Ph.D. Rice University,
More informationLecture 14: Exceptions 10:00 AM, Feb 26, 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 14: Exceptions 10:00 AM, Feb 26, 2018 Contents 1 Exceptions and How They Work 1 1.1 Update to the Banking Example.............................
More informationObject-Oriented Design Lecture 3 CSU 370 Fall 2007 (Pucella) Friday, Sep 14, 2007
Object-Oriented Design Lecture 3 CSU 370 Fall 2007 (Pucella) Friday, Sep 14, 2007 Java We will be programming in Java in this course. Partly because it is a reasonable language, and partly because you
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #2 Number Rep & Intro to C 2005-08-31 There is one handout today at the front and back of the room! Lecturer PSOE, new dad Dan Garcia www.cs.berkeley.edu/~ddgarcia
More informationEquivalent Notations. Higher-Order Functions. (define (f x y) ( body )) = (define f (lambda (x y) ) ) Anonymous Functions.
Equivalent Notations Higher-Order Functions cs480 (Prasad L156HOF 1 (define (f x y ( body = (define f (lambda (x y ( body cs480 (Prasad L156HOF 2 Function Values (define tag (lambda (t l (cons t l (tag
More informationCOSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26
COSC 2P95 Procedural Abstraction Week 3 Brock University Brock University (Week 3) Procedural Abstraction 1 / 26 Procedural Abstraction We ve already discussed how to arrange complex sets of actions (e.g.
More informationCS 251 Intermediate Programming Java Basics
CS 251 Intermediate Programming Java Basics Brooke Chenoweth University of New Mexico Spring 2018 Prerequisites These are the topics that I assume that you have already seen: Variables Boolean expressions
More informationCOMP 250 Winter 2011 Reading: Java background January 5, 2011
Almost all of you have taken COMP 202 or equivalent, so I am assuming that you are familiar with the basic techniques and definitions of Java covered in that course. Those of you who have not taken a COMP
More informationLecture 16: Static Semantics Overview 1
Lecture 16: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis
More informationKey components of a lang. Deconstructing OCaml. In OCaml. Units of computation. In Java/Python. In OCaml. Units of computation.
Key components of a lang Deconstructing OCaml What makes up a language Units of computation Types Memory model In OCaml Units of computation In OCaml In Java/Python Expressions that evaluate to values
More informationC#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations
, 1 C#.Net VT 2009 Course Contents C# 6 hp approx. BizTalk 1,5 hp approx. No exam, but laborations Course contents Architecture Visual Studio Syntax Classes Forms Class Libraries Inheritance Other C# essentials
More informationRuby: Introduction, Basics
Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie
More informationCIS192: Python Programming
CIS192: Python Programming Introduction Harry Smith University of Pennsylvania January 18, 2017 Harry Smith (University of Pennsylvania) CIS 192 Lecture 1 January 18, 2017 1 / 34 Outline 1 Logistics Rooms
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 informationContents. LINQ for Visual C# 2008 i
Contents Chapter 1: LINQ to Objects...1 Introduction...1 A Simple C# 3.0 LINQ to Objects Program...1 Extension Methods...3 Lambda Expressions...5 Expression Trees...6 Object Initialization Expressions...7
More informationCSCC24 Functional Programming Scheme Part 2
CSCC24 Functional Programming Scheme Part 2 Carolyn MacLeod 1 winter 2012 1 Based on slides from Anya Tafliovich, and with many thanks to Gerald Penn and Prabhakar Ragde. 1 The Spirit of Lisp-like Languages
More informationRuby: Introduction, Basics
Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie
More informationSubclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented
Table of Contents L01 - Introduction L02 - Strings Some Examples Reserved Characters Operations Immutability Equality Wrappers and Primitives Boxing/Unboxing Boxing Unboxing Formatting L03 - Input and
More informationCS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output
CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output Last revised January 12, 2006 Objectives: 1. To introduce arithmetic operators and expressions 2. To introduce variables
More informationCase Study: Undefined Variables
Case Study: Undefined Variables CS 5010 Program Design Paradigms Bootcamp Lesson 7.4 Mitchell Wand, 2012-2017 This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International
More informationCS 242. Fundamentals. Reading: See last slide
CS 242 Fundamentals Reading: See last slide Syntax and Semantics of Programs Syntax The symbols used to write a program Semantics The actions that occur when a program is executed Programming language
More informationObject-Oriented Programming in C# (VS 2012)
Object-Oriented Programming in C# (VS 2012) This thorough and comprehensive course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes the C#
More informationPIC 10A Objects/Classes
PIC 10A Objects/Classes Ernest Ryu UCLA Mathematics Last edited: November 13, 2017 User-defined types In C++, we can define our own custom types. Object is synonymous to variable, and class is synonymous
More informationHW1 due Monday by 9:30am Assignment online, submission details to come
inst.eecs.berkeley.edu/~cs61c CS61CL : Machine Structures Lecture #2 - C Pointers and Arrays Administrivia Buggy Start Lab schedule, lab machines, HW0 due tomorrow in lab 2009-06-24 HW1 due Monday by 9:30am
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
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 informationTypes and Type Inference
Types and Type Inference Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on the course homepage Outline General discussion
More informationCS 536. Class Meets. Introduction to Programming Languages and Compilers. Instructor. Key Dates. Teaching Assistant. Charles N. Fischer.
CS 536 Class Meets Introduction to Programming Languages and Compilers Mondays, Wednesdays & Fridays, 11:00 11:50 204 Educational Sciences Charles N. Fischer Instructor Fall 2012 http://www.cs.wisc.edu/~fischer/cs536.html
More informationMEAP Edition Manning Early Access Program Get Programming with Java Version 1
MEAP Edition Manning Early Access Program Get Programming with Java Version 1 Copyright 2018 Manning Publications For more information on this and other Manning titles go to www.manning.com welcome First,
More informationProgramming. Dr Ben Dudson University of York
Programming Dr Ben Dudson University of York Outline Last lecture covered the basics of programming and IDL This lecture will cover More advanced IDL and plotting Fortran and C++ Programming techniques
More information10266 Programming in C Sharp with Microsoft Visual Studio 2010
10266 Programming in C Sharp with Microsoft Visual Studio 2010 Course Number: 10266A Category: Visual Studio 2010 Duration: 5 days Course Description The course focuses on C# program structure, language
More informationLecture 10 Notes Linked Lists
Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Summer 1 2015) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to
More informationProgramming in C# (20483)
Programming in C# (20483) Overview This training course teaches developers the programming skills that are required for developers to create Windows applications using the C# language. During their five
More informationCSE 431S Type Checking. Washington University Spring 2013
CSE 431S Type Checking Washington University Spring 2013 Type Checking When are types checked? Statically at compile time Compiler does type checking during compilation Ideally eliminate runtime checks
More informationProgramming Languages FILS Andrei Vasilateanu
Programming Languages FILS 2014-2015 Andrei Vasilateanu Course Master: Administration Andrei Vasilateanu, andraevs@gmail.com Teaching Assistants: Radu Serban Grading: Final exam 40% Laboratory 60% 2 Tests
More informationPrerequisites: The student should have programming experience in a high-level language. ITCourseware, LLC Page 1. Object-Oriented Programming in C#
Microsoft s.net is a revolutionary advance in programming technology that greatly simplifies application development and is a good match for the emerging paradigm of Web-based services, as opposed to proprietary
More informationPieter van den Hombergh Thijs Dorssers Stefan Sobek. January 11, 2018
Inheritance and Inheritance and Pieter van den Hombergh Thijs Dorssers Stefan Sobek Java Inheritance Example I Visibility peekabo Constructors Fontys Hogeschool voor Techniek en Logistiek January 11, 2018
More information