Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 -...

59
CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials by Alice Thudt, Fateme Rajabiyazdi, David Ledo, Brennan Jones, and Sowmya Somanath)

Transcript of Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 -...

Page 1: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

CPSC 481 - Tutorial 4Visual Studio and C#

(based on previous tutorials by Alice Thudt, Fateme Rajabiyazdi, David Ledo, Brennan Jones, and Sowmya Somanath)

Page 2: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Today

▷ Intro to Assignment 2▷ Visual Studio ▷ Intro to C#

Page 3: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

1.Assignment 2

Details

Page 4: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Assignment 2

▷ Continuation of the interface your team started designing (ideally).

▷ Two more design evolutions:1. Horizontal medium-fidelity prototype (20%)2. Moderately robust system that implements

vertical functionality (80%)

▷ Prototype using C#▷ Perform a heuristic evaluation

Page 5: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Horizontal Prototype

▷ Deadline: Mar. 7-9 in class:1. Write-up – including redesign rational (i.e.,

changes from the first prototype), screen snapshots, and a grading sheet (from assignment handout)

2. Horizontal prototype presentation freeze

▷ Submission either:○ Email to me ([email protected])○ Submit on a USB along with your write-up

Page 6: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Horizontal Prototype Presentations

▷ Tuesday Mar 7 in tutorial (T01)▷ Thursday Mar 9 in tutorial (T02)

Page 7: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Main Project Deadlines

▷ Friday Apr. 7 in class:1. Complete portfolio (Assignment 1 + new stuff)2. Redesign rational3. Implementation freeze—no more changing code

after this point4. Latest screen snapshots5. Heuristic evaluation of final system6. Final discussion7. USB/DVD:

■ All source code (project)■ Required data files■ README file

Page 8: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Final Project Demonstrations

▷ April 10 -14:○ Demos will be STRICTLY run from the submitted

USB/DVD media○ ALL team members must participate

Page 9: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

What should we do now?

Page 10: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Horizontal Prototype

▷ Write-up:○ Two-page redesign rational (main reasons for

change)○ Screen snapshots of your screens (but not

counted towards the two-page count)

Page 11: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Horizontal Prototype

▷ Presentation slide deck + writeup:○ MUST be submitted on Monday Mar 6 in lecture

(with your write-up)○ Present screen snapshots of your medium-fi

prototype

Page 12: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Main Project

▷ Redesign your interface (again):○ Evaluate your interface using any of the following:

■ Heuristic evaluation■ Walkthrough■ Or others you learnt in class

○ Implement a substantial part of the vertical functionality (screens, error messages, input handling, etc)■ Anything that you think is interesting should

be functional and demo-able

Page 13: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Main Project

▷ Heuristic Evaluation:○ Evaluate your FINAL interface using the heuristic

evaluation method○ This is a second evaluation

Page 14: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Main Project

▷ Electronic submission (USB/DVD):○ All source code and data files for the final version

of your working project○ README file – your names, instructions on how to

use the system, what cases/functions were implemented, what kind of data needs to be input, etc.

○ Test your code on the lab machine before you submit

Page 15: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Main Project

▷ Final demonstration:○ You will demo to me and Ehud (a timetable will be

posted by me)○ Test your demo on the lab computer and using the

projector before the final demo

Page 16: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

TimelineDate Deliverable

(refer to assignment 2 specifications)

March 6thIn Lecture

⊳ Horizontal Prototype Redesign writeup⊳ Horizontal Prototype Presentations freeze

March 7-9In Tutorial

⊳ Horizontal Prototype presentations in tutorial (20% of mark)⊳ Bring your grading sheets!

April 7In Lecture

⊳ Final Project submission (portfolio, implementation freeze, evaluation, screenshots, etc)

April 10-14Finals

⊳ Project Demonstrations

Page 17: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Main Project Examples

Page 18: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Main Project Examples

Page 19: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Main Project Examples

https://youtu.be/xzGwc0rvAww

Page 20: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Project

▷ Please start working on your redesigns now!

Page 21: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

2.Visual Studio

Using Visual Studio

Page 22: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Visual Studio

▷ Visual Studio 2015 Professional is installed on the lab machines

▷ You may download Visual Studio 2015 onto your machine for free here○ Select Visual Studio Community 2015○ It is a big download (> 5GB)

Page 23: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Optional: Version Control

▷ BitBucket (git/mercurial):○ Free private repositories for up to 5 collaborators○ Optional, it might help you collaborate

▷ Github (git):○ Popular, but private repos are paid○ Desktop app: https://desktop.github.com/ ○ Guide to Git:

http://rogerdudler.github.io/git-guide/

Page 24: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Optional: SVN Accounts

▷ For those who want an SVN account, go to the CPSC help desk and ask for one

▷ OR email CPSC Help Desk: [email protected]○ Request for an SVN account○ Include members’ IT account usernames or all

usernames you wish to have access to it○ State it is for your CPSC 481 group project

Page 25: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Optional: SVN Accounts

▷ We won’t go over this in tutorial, but here are some resources that can help you:○ AnkhSVN:

http://grouplab.cpsc.ucalgary.ca/cookbook/index.php/VisualStudio/Subversion

○ VisualSVN: https://www.visualsvn.com/ ○ TortoiseSVN:

http://tortoisesvn.net/visualstudio.html ○ Guide to Git:

http://rogerdudler.github.io/git-guide/

Page 26: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Starting a project

Page 27: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Starting a project

Page 28: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Starting a project

Page 29: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Starting a project

Page 30: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Starting a project

Page 31: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Workspace

Page 32: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Workspace

Page 33: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Workspace

Page 34: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Workspace

Page 35: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Hello World!

Page 36: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Hello World!

Page 37: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Hello World!

Page 38: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Hello World!

Page 39: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Hello World!

Page 40: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Workspace

▷ Where to download and how to install Visual Studio

▷ How to get SVN accounts▷ How to create a new project in Visual

Studio▷ Basic features of the workspace▷ How to make a console application▷ How to use the debugger

Page 41: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

3.Intro to C#

Basics

Page 42: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

C#

▷ C# compared to Java○ Naming conventions○ Namespace○ Classes○ Properties and Fields○ Methods

▷ Create a more complex console application

Page 43: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Naming Conventions

▷ Every language has its own naming conventions○ E.g., Java uses camelCasing, while C# uses

camelCasing for variables and PascalCasing for methods

int myInteger;

public void ReturnResults(){ … }

Page 44: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Naming Conventions

▷ A lot of people like to call instance variables (or fields) starting with an underscore:

○ Interfaces always start with an I (e.g. ICloneable)

int _instanceVar;

Page 45: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Comments

// This is a single-line comment

/* This is a multi-line comment */

/// This is how you describe methods

/** (This is how you describe methods in Java) */

Page 46: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Access Modifiers

▷ public – accessible anywhere▷ private – only accessible within the class or struct▷ protected – only accessible within the same hierarchy▷ internal – only accessible by the same assembly

Page 47: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Access Modifiers

▷ A property is a member that provides a flexible mechanism to read, write, or compute the value of a private field

▷ Also called accessor methods▷ Properties are public methods▷ Properties enable a class to expose a

public way of getting and setting values, while hiding implementation or verification code

Page 48: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Properties

▷ A get property accessor is used to return the property value

▷ A set accessor is used to assign a new value▷ The value keyword is used to define the

value being assigned by the set accessor▷ Properties that do not implement a set

accessor are read only

Page 49: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Properties

class TimePeriod

{

private double seconds;

public double Hours

{

get { return seconds / 3600; }

set { seconds = value * 3600; }

}

}

Page 50: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Using Properties

class Program

{

static void Main()

{

TimePeriod t = new TimePeriod();

// Assigning the Hours property calls the 'set' accessor

t.Hours = 24;

// Evaluating the Hours property calls the 'get' accessor

System.Console.WriteLine("Time in hours: " + t.Hours);

}

}

Page 51: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Foreach Loop

using System.Collections;

ArrayList list = new ArrayList();

list.Add(1);

list.Add(2);

foreach (int i in list)

{

int j = i;

}

Page 52: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Foreach Loop

▷ If you use generic containers (e.g., ArrayList), casting is implicit○ Unlike Java where you have to explicitly cast

Page 53: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Inheritance

public class ChildClass : InterfaceName

public class ChildClass : ParentClass

public class ChildClass : ParentClass,

IInterface1, IInterface2 …

Page 54: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Inheritance

▷ Base class○ Max 1 inheritance

▷ Interfaces○ One or more interfaces

Page 55: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Other Differences

▷ If a class, property, or field does not have an access modifier, it is private by default

▷ So every time you create a class, add the word public at the beginning

▷ Console applications have the console close at the very end of the program

Page 56: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Other Differences

▷ In C#○ Strings can be primitives○ Booleans are denoted bool○ Java’s ArrayList<type> is List<type> in C#○ Java’s list.Length is list.Count in C#

Page 58: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Next week

▷ Intro to WPF (interface building)

Page 59: Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 - Week 4.pdf · CPSC 481 - Tutorial 4 Visual Studio and C# (based on previous tutorials

Thanks!Any questions?You can find me at:

[email protected]