Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2005

Slides:



Advertisements
Similar presentations
Optional Static Typing Guido van Rossum (with Paul Prescod, Greg Stein, and the types-SIG)
Advertisements

Generics Programming in C# Generics CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 12 th -13 th Lecture Pavel Ježek.
Copyright © 2012 Pearson Education, Inc. Chapter 9 Delegates and Events.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
1 Generics and Using a Collection Generics / Parameterized Classes Using a Collection Customizing a Collection using Inheritance Inner Classes Use of Exceptions.
C# Programming: From Problem Analysis to Program Design1 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
McGraw-Hill© 2007 The McGraw-Hill Companies, Inc. All rights reserved. 1-1.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Taken from slides of Starting Out with C++ Early Objects Seventh Edition.
Eric Vogel Software Developer A.J. Boggs & Company.
CSC 142 B 1 CSC 142 Java objects: a first view [Reading: chapters 1 & 2]
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Programming Languages and Paradigms Object-Oriented Programming (Part II)
Introduction to C# C# is - elegant, type-safe, object oriented language enabling to build applications that run on the.NET framework - types of applications.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Hoang Anh Viet Hà Nội University of Technology Chapter 1. Introduction to C# Programming.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
C# 2.0 and Future Directions Anders Hejlsberg Technical Fellow Microsoft Corporation.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Advanced C# Types Tom Roeder CS fa. From last time out parameters difference is that the callee is required to assign it before returning not the.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Introduction to Object-Oriented Programming Lesson 2.
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
IS 350 Course Introduction. Slide 2 Objectives Identify the steps performed in the software development life cycle Describe selected tools used to design.
C# Programming: From Problem Analysis to Program Design
Building Enterprise Applications Using Visual Studio®
Part 1: Overview of LINQ Intro to LINQ Presenter: PhuongNQK.
Constructors and Destructors
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Introduction to Windows Programming
Chapter 2: The Visual Studio .NET Development Environment
Jim Fawcett CSE775 – Distributed Objects Spring 2017
Abstract Factory Pattern
Programming with ANSI C ++
/* LIFE RUNS ON CODE*/ Konstantinos Pantos Microsoft MVP ASP.NET
Jim Fawcett CSE681 – SW Modeling & Analysis Fall 2014
Jim Fawcett CSE775 – Distributed Objects Spring 2009
Jim Fawcett CSE687 – Object Oriented Design Spring 2015
Using Application Domains Effectively
Ch 10- Advanced Object-Oriented Programming Features
Introduction to Visual Basic 2008 Programming
Methods Attributes Method Modifiers ‘static’
Review: Two Programming Paradigms
Chapter Eleven Handling Events.
Object-Oriented Programming & Design Lecture 14 Martin van Bommel
Abstract Factory Pattern
CompSci 230 Software Construction
Intent (Thanks to Jim Fawcett for the slides)
Eclipse 20-Sep-18.
Lecture 23 Polymorphism Richard Gesick.
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
.NET and .NET Core 9. Towards Higher Order Pan Wuming 2017.
Code Snippets, Intellisense, Comments, Type Conversion
VISUAL BASIC.
6 Delegate and Lambda Expressions
Overview of Memory Layout in C++
Using JDeveloper.
Constructors and Destructors
Creating Your First C Program Using Visual Studio 2010
Creating Your First C Program Using Visual Studio 2010
Fundaments of Game Design
How to organize and document your classes
Abstract Classes and Interfaces
5. 3 Coding with Denotations
Jim Fawcett CSE681 – SW Modeling & Analysis Fall 2018
Jim Fawcett CSE775 – Distributed Objects Spring 2006
Binding 10: Binding Programming C# © 2003 DevelopMentor, Inc.
Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2006
Presentation transcript:

Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2005 Visual Studio 2005 Jim Fawcett CSE681 – Software Modeling and Analysis Fall 2005

References C# Programming Language, Anders Hejlsberg, et. al., Addison-Wesley, 2004 Pro C# 2005, and the .Net 2.0 Platform, Andrew Troelsen, Apress 2005 Visual C#, A Developer’s Notebook, Jesse Liberty, OReilly, 2005 ASP.NET 2.0, Core Reference, Dino Exposito, Microsoft Press, 2005

Additions to C# Generics Iterators Anonymous Methods Partial Types Static Classes Nullable Type Delegate Covariance and Contravariance

C# Generics C++ Class Template Syntax: template <class T> class stack { … }; stack<widget> wStack; C# Generics Syntax public class stack<T> { … } stack<widget> wStack = new stack<widget>();

Comparison C++ Templates CLR Generics Type safe Bind at compile time Has specializations Supports template methods Supports partial template specialization Does not need constraints Calls on methods of a parameter type can be checked because the parameter type is known then. Does not share implementations for any type CLR Generics Type safe Bind at run-time No specializations Supports Generic methods Uses constraints Supports compile-time verification that methods called on a parameter type are correct Shares implementation among all instances for reference types Does not share implementations for value types

Second Look at Generics The “shares implementation for reference types” is important. It says that generics are essentially cosmetic. We don’t have to explicitly cast items extracted from a generic container, but the underlying representation is still object. The explicit cast we had to do is now done by the generic machinery, but we still pay the performance hit for the cast.

Constraints on Generics Constraints are an optional list of type requirements declared with the where keyword: Public class Dictionary<k,v> where k : IComparable { public void Add( k key, v value ) { … // constraint tells compiler that object key has // CompareTo() method if ( key.CompareTo(x) < 0 ) { … } … } }

Iterators An iterator block is a block that yields an ordered sequence of values. An iterator block is distinguished by the presence of one or more yield statements. A function that contains this block may not have out or ref parameters or a return statement. See example on next slide.

Iterator Example Class stack<T> : IEnumerable<T> { T[ ] items; int count; : public IEnumerator<T> GetEnumerator() { for(int i = count-1; i>=0; --i) yield return items[i]; } } Note that the operation of this function is NOT what its code advertises.

Anonymous Methods Anonymous methods support creation of an inline delegate: public delegate void aDelType(string); public event aDelType aDel; : aDel += delegate(string str) { // code }; The delegate arguments may be omitted if the code does not use them.

Method Group Conversions An implicit conversion exists from a method group to a compatible delegate: public delegate void aDelType(string); public event aDelType aDel; : void myHandler(string str) { … } : aDel += myHandler; Here, aDelType(string) is a method group.

Partial Types A C# class can now be split across two or more files. The visual studio wizards now place designer code in a separate file, so you don’t have to print that when you want a hard copy of the class. Syntax: public partial class my class { // code } public partial class my class { // more code } Now we can print out all the developer’s code without having to display the designer code.

Static Classes A class can be declared as static: All class members are static. You can not use new to instantiate an instance. They may not define instance constructors. They are sealed.

Nullable Type Represents a value of type T that may be null: Nullable<int> x = null; Nullable<string> y = null; Can be used to represent: nullable columns in a database optional attributes in an XML element

Delegate Covariance and Contravariance Covariance permits a delegate typed to invoke a method with base return type to bind to a function returning a class derived from base. Contravariance permits a delegate typed to invoke a method with base parameters to bind to a function passing derived parameters, supporting polymorphism.

Visual Studio IDE Changes to the IDE Can save several IDE configuration settings to suit specific tasks UML diagrammer / code generator Code Refactoring Tool Code Snippets Improved Object Viewer in Debugger Debugging Visualizers

Support for Cleaning up and Documenting Code Create UML diagrams from classes and classes from UML diagrams. Refactor Code Change method or parameter name everywhere Factor out method by selecting lines

Create UML Class Diagrams with Code and Vice Versa

Refactor Code

Code Snippets Select code, right-click, and select code snippet: Get context menu with choices like if, for, while, … Wraps code with the selected construct in an intelligent, easy-to-use way.

Debugging Visualizers

WinForms Many New Controls: Asynchronous Tasks One-click Deployment Tools strips Validation Window splitter Asynchronous Tasks One-click Deployment

New Controls, Better Object View

Asynchronous Tasks Uses BackgroundWorker class RunWorkerAsync raises a DoWork event That causes a Designer wired delegate to call backgroundWorker1_DoWork(sender,args);

Asynchronous Tasks

WebForms No longer need IIS for development Built-in Forms-based security Roles Master pages Themes Personalization support Easier data access

Samples and Help, C#

Samples and Help, C++

Samples and Help, ASP.Net