Teaching with C Sharp Rob Miles. Overview  Introduction >My perspective  C# and Java >Broad overview of the languages  Significant C# Features >C#

Slides:



Advertisements
Similar presentations
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Advertisements

Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Introduction to Java Programming, 4E
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++
Introduction to the C# Programming Language for the VB Programmer.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
Advanced Object-Oriented Programming Features
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
C# Programming: From Problem Analysis to Program Design1 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 1 Program Design
Templates. Objectives At the conclusion of this lesson, students should be able to Explain how function templates are used Correctly create a function.
Tahir Nawaz Visual Programming C# Week 2. What is C#? C# (pronounced "C sharp") is an object- oriented language that is used to build applications for.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
Object Oriented Software Development 1. Introduction to C# and Visual Studio.
From C++ to C#. Web programming The course is on web programming using ASP.Net and C# The course is on web programming using ASP.Net and C# ASP.Net is.
A Free sample background from © 2001 By Default!Slide 1.NET Overview BY: Pinkesh Desai.
Introducing Java.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
A First Program Using C#
M1G Introduction to Programming 2 4. Enhancing a class:Room.
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
Developing Workflows with SharePoint Designer David Coe Application Development Consultant Microsoft Corporation.
Chapter 3 Introduction to Collections – Stacks Modified
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Lecture 1 Programming in C# Introducing C# Writing a C# Program.
11 A First Game Program Session Session Overview  Begin the creation of an arcade game  Learn software design techniques that apply to any form.
C# Programming Fundamentals of Object-Oriented Programming Fundamentals of Object-Oriented Programming Introducing Microsoft.NET Introducing Microsoft.NET.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Lecture Set 2 Part B – Configuring Visual Studio; Configuration Options and The Help System (scan quickly for future reference)
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Introduction to C# C# is - elegant, type-safe, object oriented language enabling to build applications that run on the.NET framework - types of applications.
May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004.
Introduction to Java Programming with Forte Y. Daniel Liang.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Java SE 8 for Programmers, Third Edition
Java 5 Part 1 CSE301 University of Sunderland Harry Erwin, PhD.
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
Introduction to C#. Why C#? Develop on the Following Platforms ASP.NET Native Windows Windows 8 / 8.1 Windows Phone WPF Android (Xamarin) iOS (Xamarin)
Object Oriented Software Development
Aug 9, CMSC 202 ArrayList. Aug 9, What’s an Array List ArrayList is  a class in the standard Java libraries that can hold any type of object.
Chapter 4 Introduction to Classes, Objects, Methods and strings
M1G Introduction to Programming 2 5. Completing the program.
Getting Started with.NET Getting Started with.NET/Lesson 1/Slide 1 of 31 Objectives In this lesson, you will learn to: *Identify the components of the.NET.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
CSE 1201 Object Oriented Programming ArrayList 1.
04 |Sharing Code Between Windows 8 and Windows Phone 8 in Visual Studio Ben Riga
11 Computers, C#, XNA, and You Session 1.1. Session Overview  Find out what computers are all about ...and what makes a great programmer  Discover.
Computer Science Reaching Wider Summer School 2012.
Review of the numeration systems The hardware/software representation of the computer and the coverage of that representation by this course. What is the.
Visual Programming Borland Delphi. Developing Applications Borland Delphi is an object-oriented, visual programming environment to develop 32-bit applications.
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
Lecture 8: Collections, Comparisons and Conversions. Svetla Boytcheva AUBG, Spring COS 240 Object-Oriented Languages.
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
Teaching with C Sharp Rob Miles.
C# for C++ Programmers 1.
INF230 Basics in C# Programming
Object-Oriented Analysis and Design
Introduction to .NET Framework Ch2 – Deitel’s Book
CS360 Windows Programming
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Object Oriented Practices
(Computer fundamental Lab)
Java Programming Language
Presentation transcript:

Teaching with C Sharp Rob Miles

Overview  Introduction >My perspective  C# and Java >Broad overview of the languages  Significant C# Features >C# features from a teaching perspective  Conclusion >..and possibly a sing song?

Introduction  The material is based on my experience teaching C# to two student cohorts  It is necessarily coloured by my teaching philosophy  It has been presented in targeted sections so that you can use those components which suit your purpose  There are number of sample projects for each section which form the basis of the lab work

Presentation Notes  A full set of notes is provided for this presentation  The notes are broken down in the same sequence as the items given here  Each section is followed by a number of practical examples along with some ideas for investigation

Bonus Materials  As this is the “collectors edition” of the course >Just like every other edition…  It is supplied with bonus materials in the form of a copy of “C# from Java”  This provides an FAQ for a number of conversion issues

Teaching Philosophy  At Hull we teach an “algorithms first” course  This concentrates on program construction in semester one and introduces objects in semester two  Everything is placed in the strongest possible “real world” context and I make heavy use of analogies

Objects  Objects are presented as a solution to structure and design  I try to make a logical transition from structures to components: >Encapsulation >Business Objects >Test driven development >Component based design >Hierarchies for code reuse

Teaching and C#  I have found that C# matches with our teaching philosophy  It would also match with an objects first approach, at least as well as Java does  The points made later are applicable to both teaching approaches

C# and Java  C# is heavily based on Java  Conversion from C# to Java (or back) is not difficult  C# programs seem to run faster on the PC platform  C# is not being positioned as Microsoft proprietary >But the language development is Microsoft driven, in the same way that Java development is Sun driven

C# Versions  There are now two versions of C#  Version 2 adds a number of features: >Partial classes >Generics  There are few breaking changes moving from C# Version 1 to Version 2  This presentation is Version 1 compliant

Development Tools  A command line compiler kit is available >Directly analogous to the JDK  Visual Studio 2005 is available under the Academic Alliance  Visual Studio 2005 Express Edition is available for free >David will give more details of these later

C# Language Features  We can consider some specific C# features: >User input/Output >Value Types and Structures >Exception Handling >Reference Parameters >Event Handling/Delegates >Program Linking and Deployment >Properties >Generics  They will be placed into a teaching context

User input/output  The System.Console object provides a range of input/output actions  There is no need to create a stream object  There is also no need to trap exceptions

demo demo  Simple Input/Output >Text Read and Write and colour manipulation  Console Power >Moving dot game

Value Types  In Java a type is either primitive or reference:  Primitive >Managed by value >Primitive types do not support methods or properties  Reference >Managed by reference >Support methods and properties >Slower to manipulate

Java Primitive Problems  For a student learning to program the primitive-reference distinction is hard to grasp  It also brings a need to describe the use of wrapper classes >Students do not like to have to learn the difference between int and Integer  This knowledge is not that relevant to other languages

C# value types  C# uses a different approach: >All types are objects >Some types are “value” types, i.e. manipulated by value not reference >But they all support methods and properties >The “box” operation performs conversion from value to reference as required  The C# student need not be aware of any distinction at the start of the course

demo demo  Value type behaviour in.NET 1.1 and.NET 2.0 >Using ildasm to look at the IL

Boxing in Action static void Main(string[] args) { int a, b; a = 99; b = a; b = 100; Console.WriteLine("a is {0} b is {1}", a, b); }

Boxing Assembler

Structures as value types  C# supports a struct type  This type is directly analogous to the struct in C  A struct is manipulated as a value type  This allows data to be grouped together without a need to cover objects and references  It also allows for more complex exercises

C# Structs  A struct in C# is managed by value.  However, they do behave a lot like objects >They can support methods and properties >They can have constructors >They can even implement an interface  But they do not support inheritance

demo demo  Structures in C# >Simple structures >Structure “housekeeping” >Arrays of structures

Exception Handling  In Java you have to handle some exceptions (the checked ones) >These are thrown by lots of library methods, including input/output  In C# all exceptions are unchecked >If you don’t catch them the run time system will pick them up >This makes things like simple input/output much simpler

demo demo  Exceptions in C# >Simple exception handling >Creating your own exceptions

Reference Parameters  Unlike Java, where parameters are always passed by value, in C# reference parameters are allowed  This makes programming more efficient  It also allows discussion of the meaning of references without the need to consider objects

demo demo  Reference Parameters >ref parameters >in parameters

Event handling and delegates  C# provides a delegate type which can be used to create a typesafe reference to a method in an instance of a class  There is no need to create an instance of a class to receive events  Delegates are used to manage system events and the user interface

demo demo  Event handling with delegates >Simple form creation and event management >Using the Visual Studio 2005 Forms Designer

Delegates and Design  Delegates bring function pointers back into programming  However, they can be deployed in a typesafe manner in a properly managed environment  However, he biggest advantage over Java is that they make interacting with Forms components much easier

Program Linking and Deployment  In Java a program is built at run time >The classpath is used to locate the required components as the program runs >There is little attention paid at build time to linking issues  In C# the.exe file is an assembly which may make use of.dll library files >There is a distinct difference between an executable file and a library one >An exe file will refer to a specific version of a dll when it is built

C# Programs  Only one class in a C# program may contain a Main method to provide the entry point  During the build process the particular libraries to be used must be specifically identified and located >If you are using Visual Studio the metadata from the assembly can be used in interactive help

C# Linking and Teaching  I place great emphasis on Business Objects and Test Driven Development  The C# linking process fits well with this approach  The students are initially introduced to the process by means of compiler directives  Later they move on to use Visual Studio 2005

demo demo  Using Business Objects >Single workspace containing a number of Visual Studio Projects

The naming of components  Java provides a package mechanism by which a system can be broken down into components >this is linked to the physical position of the file in a directory hierarchy >only one public class can placed in each file, and the filename must match the class name  C# does not do this >A class is placed in a “namespace” which is not physically mapped to storage

C# Namespace  Namespaces are hierarchical  A single source file can contain components from a number of namespaces  A namespace can span multiple source files  Visual Studio 2005 provides a view of all the components in a namespace

Partial Classes  These are available in C# Version 2.0  A class can be made to span a number of source files  This allows the developer to partition the behaviours of a class into a number of separate source files >Hide the scary bits?  Visual Studio 2005 does this with forms

demo demo  Using Business Objects and Namespaces >Advanced multi-project workspace with business and control objects

Properties  Properties are “syntactic sugar”  They provide a convenient wrapper for get and set behaviour in objects  There is no need to use them >But all of the system library classes do  They are best explained in the context of “making life easier”

demo demo  Simple Properties >A book title class which uses properties to manage the name of the book

Properties and Assembler

Generics  Generics are new in Version 2.0  They let you create classes which work on classes  You don’t have to give the types of the classes when you write the code  Instead you use placeholders which are “filled in” at runtime in a typesafe manner

Generics and teaching  I would not teach about generics in the first part of a programming course  The fact that they are now present in C# means that we can use this language in later years

Generic Collections  The major advantage that generics brings for learner programmers is a better way to deploy collection classes  They remove the need to cast items read from the collection >Although I must admit I think that covering casting at this point is a good idea

demo demo  Using the List collection class >A typesafe list collection is created using the new System.Generics.List collection class

Using Generics  Generics do make it possible to talk about data structures without dwelling on the type of the data being manipulated  This can be rolled into discussions about generalisation which can take place in the latter parts of a first year course

demo demo  Creating and using a generic linked list class >A linked list generic which is deployed for both integers and string types

Conclusion  Students like C# >We have seen improved performance in both coursework and examinations  It is a more productive programming environment than Java >All of the language changes are soundly pragmatic >The toolset is very effective and now handles important issues like test driven development  C# will do very nicely. For now……

Questions  I can take any quick questions now  For more detailed ones please catch me in the break or during the labs