Migration from C++ to C# – Mini Course

This mini-course was taught by me last in 2009-10, if I recall correctly, for IInd M.Sc. (Maths) students in a deemed university in Andhra Pradesh, India, as part of a course on ASP.Net Web programming.

Pre-requisites for the course: It so happened that students of this course had studied C and C++ languages. So C++ is a pre-requisite for this course.

Migration from C++ to C#

[Note example C# source files referred in the Powerpoint presentations below as not (given) in the C# specification document are available here.]

1) Powerpoint presentation: CPPtoCsharp1. This covers: Course introduction, Course material for C++ to C# migration – Chapter 1, Introduction, of the document ‘C# Language Specification Version 1.2’ from Microsoft: http://download.microsoft.com/download/5/e/5/5e58be0a-b02b-41ac-a4a3-7a22286214ff/csharp%20language%20specification%20v1.2.doc (later versions of C# Language specification were available then itself but Chapter 1, Introduction, of this document was felt more suitable as a tutorial), C# features, Hello world app., Value and Reference types, comparison between Reference in C++ and C#, string class, boxing and unboxing, and program structure.

2) Powerpoint presentation: CPPtoCsharp2. This covers: List class – constructor, properties, read-only and read-write properties and indexer.

3) Powerpoint presentation: CPPtoCsharp3. This covers: event-driven programming, events, quick understanding of delegate, publisher-subscriber relationship, delegate type, event-delegate and event example.

4) Powerpoint presentation: CPPtoCsharp4. This covers: operators, destructors, struct, arrays, interface, IControl interface, class implements interface, interface knowledge reuse, interface – contract, interface variables/types, interface inheritance, interface – multiple inheritance, class – multiple interfaces, interface – methods, properties, events & indexers.

5) Powerpoint presentation: CPPtoCsharp5. This covers: enums, delegate, delegate vs. function pointers, delegate example, multi-cast delegate, event vs. delegate and attributes.

ASP.Net (Web) Programming in C# – Course Report

This course was last taught by me in 2009-10, if I recall correctly, for IInd M.Sc. (Maths) students in a deemed university in Andhra Pradesh, India.

Pre-requisites for the course: It so happened that students of this course had studied C and C++ languages. Students also had studied a database theory course and an SQL lab. course. So C++, relational database theory and SQL are pre-requisites for this course.

The first part of this course was/is a migration from C++ to C# which is available here.

Then ASP.NET Web programming was taught using the tutorial book, “Murach’s ASP.NET 3.5 web programming with C# 2008” (referred to as Murach course book). [The current edition of this book seems to be Murach’s ASP.NET 4.5 Web Programming with C# 2012. I guess that most of the course report given below would apply to the current edition too.] As the tutorial book has detailed instructions for students I had to prepare very little teaching material of my own. This document is a report on the course. The following are the topics that were covered in the course.

1) Introduction to Visual Studio 2008 and MSDN Library – Teaching notes

2) Chapter 1 of Murach course book, “An introduction to ASP.NET web programming”. This covers quick exposure to user interface of pages of shopping cart ASP.NET application, hardware and software components of web apps, how static and dynamic web pages work, ASP.NET state handling, intro to ASP.NET application development, preview of .aspx and .cs source code & design mode view of shopping cart application, compilation of an ASP.NET application.

3) Chapter 2 of Murach course book, “How to develop a one-page web application”. This covers creating a new web application (website) with Visual Studio 2008, sample Future Value program, using Design view to build a web form, flow layout, adding tables and server controls to a form, source and split views, aspx code for Future Value form, adding validation controls to a form, adding code to a form, using page and control events, testing the web application (Future Value app).

4) Chapter 3 of Murach course book, “How to develop a multi-page web application”. This covers shopping cart application, design of order page and cart page, adding (business) classes Product and CartItem to the application, redirecting or transferring to another page, cross-page posting, coding absolute and relative URLs, creating and using Access data source, binding a drop-down list to a data source, using C# code to get data from a data source, using session state, aspx and C# code of the entire shopping cart application.

5) Chapter 4 of Murach course book, “How to test and debug an ASP.NET application”. This covers creating a local IIS web site, creating a remote IIS web site, testing an ASP.NET application with default browser, testing an ASP.NET application with other than default browser, testing an application outside of Visual Studio, using the Exception Assistant, using the debugger, setting breakpoints, using tracepoints, working in break mode, controlling execution of the application (from the debugger), using Autos, Locals and Watch windows to monitor variables, using the Immediate window to work with values, using the Trace feature, creating custom Trace messages, writing information directly to HTTP output stream. Here are some teaching notes for this chapter.

6) For the HTML part of the course, due to time pressure, I specified Chapter 5, “A crash course in HTML” of the Murach course book as a reading assignment. Perhaps the thinking was that they would primarily use Design mode of ASP.NET and could fiddle with the HTML stuff on their own as they got more familiar with ASP.NET web programming. Please note that a suitable selection of topics from the MCLI HTML tutorial is available here: https://raviiyerteaches.wordpress.com/2014/04/12/html/ which was used for the Java Web Programming course (in 2005).

7) Chapter 6 & 7 of Murach course book, “How to work with server controls” & “How to use the validation controls”. These cover types of server controls (Label, TextBox, Button, LinkButton, ImageButton, HyperLink, DropDownList, ListBox, CheckBox, CheckBoxList, RadioButton, RadioButtonList, Image, ImageMap, Calendar, Fileupload), button controls, handling control events (OnClick, OnCommand, OnSelectedIndexChanged, OnTextChanged …), using e argument, using the Command event, text boxes, labels check boxes and radio buttons – aspx code, attributes, events and C# code, list controls – properties (Items, Rows, SelectedItem, SelectedIndex …), list item object properties – Text, Value, Selected, List item collection member functions – Add, Insert, Remove, FindByValue, FindByText …, hyperlink control, file upload control, image map control, calendar control, Validation controls (RequiredFieldValidator, CompareValidator, RangeValidator, RegularExpressionValidator, CustomValidator, ValidationSummary), Common validator properties (Display, ErrorMessage, Text …), typical code for processing page that contains validation controls (Page.IsValid), using required field validator, using compare validator, using range validator, using validation summary control, using validation groups, using a custom validator.

8) Chapter 8 of Murach course book, “How to manage state”. This covers using view state, StateBag class, using session state, HttpSessionState class, when to save and retrieve session state items, using application state, HttpApplicationState class, working with application events, global.asax file, using cookies and URL encoding, HttpCookie class.

9) The database connectivity classes and ADO.NET concepts were also covered (if I recall correctly). Chapters 12 (“An introduction to database programming”) & 13 (“How to use SQL data sources”) cover it. The topics I would have or ideally should be covered are SqlConnection class, SqlCommand class, ProductList application that uses two SQL data sources, creating a SqlDataSource control, defining a connection (Configure Data Source dialog), saving connection string in web.config file, configuring the Select statement, creating a Where clause, how select parameters work, using DataList control, formatting a data list, data binding, how to bind a list control to a data source, Data Source Configuration wizard, Eval and Bind methods, aspx file for ProductList application, creating a data source that can update the database

10) Chapter 14 of Murach course book, “How to use the GridView Control”. Some part of this chapter was covered if I recall correctly. Ideally these topics should be covered: GridView control, attributes, defining fields, sorting, paging, list application that uses GridView control, how to update GridView data, command fields, events raised by GridView control (RowDeleted, RowDeleting, RowEditing, RowUpdating, RowUpdated …), insert a row in a GridView control, Category Maintenance application – aspx file and code-behind (.cs) file, template fields (EditItemTemplate),

11) A Hostel Store web project was given to students who were divided into teams of around four members each. I had given liberty to each team to define the functionality and user interface of their hostel store web app. Later they implemented their proposed functionality at least to some decent extent. The Student teams gave a talk-cum-demo at the end of the project work and at least some students were very happy that they now knew how to create small shopping centre type of applications using ASP.NET and SQLServer/Access database.