Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 -...
Transcript of Visual Studio and C# - University of Calgarypages.cpsc.ucalgary.ca/~kta/481/materials/CPSC 481 -...
CPSC 481 - Tutorial 4Visual Studio and C#
(based on previous tutorials by Alice Thudt, Fateme Rajabiyazdi, David Ledo, Brennan Jones, and Sowmya Somanath)
Today
▷ Intro to Assignment 2▷ Visual Studio ▷ Intro to C#
1.Assignment 2
Details
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
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
Horizontal Prototype Presentations
▷ Tuesday Mar 7 in tutorial (T01)▷ Thursday Mar 9 in tutorial (T02)
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
Final Project Demonstrations
▷ April 10 -14:○ Demos will be STRICTLY run from the submitted
USB/DVD media○ ALL team members must participate
What should we do now?
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)
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
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
Main Project
▷ Heuristic Evaluation:○ Evaluate your FINAL interface using the heuristic
evaluation method○ This is a second evaluation
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
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
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
Main Project Examples
Main Project Examples
Main Project Examples
https://youtu.be/xzGwc0rvAww
Project
▷ Please start working on your redesigns now!
2.Visual Studio
Using Visual Studio
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)
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/
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
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/
Starting a project
Starting a project
Starting a project
Starting a project
Starting a project
Workspace
Workspace
Workspace
Workspace
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
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
3.Intro to C#
Basics
C#
▷ C# compared to Java○ Naming conventions○ Namespace○ Classes○ Properties and Fields○ Methods
▷ Create a more complex console application
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(){ … }
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;
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) */
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
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
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
Properties
class TimePeriod
{
private double seconds;
public double Hours
{
get { return seconds / 3600; }
set { seconds = value * 3600; }
}
}
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);
}
}
Foreach Loop
using System.Collections;
ArrayList list = new ArrayList();
list.Add(1);
list.Add(2);
foreach (int i in list)
{
int j = i;
}
Foreach Loop
▷ If you use generic containers (e.g., ArrayList), casting is implicit○ Unlike Java where you have to explicitly cast
Inheritance
public class ChildClass : InterfaceName
public class ChildClass : ParentClass
public class ChildClass : ParentClass,
IInterface1, IInterface2 …
Inheritance
▷ Base class○ Max 1 inheritance
▷ Interfaces○ One or more interfaces
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
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#
Resources
▷ Programming Guide: https://msdn.microsoft.com/en-us/library/kx37x362.aspx
▷ Tutorials: https://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx
Next week
▷ Intro to WPF (interface building)
Thanks!Any questions?You can find me at: