Teaching%20Session%204

Teaching%20Session%204 - Engineering 1D04 Teaching Session...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Engineering 1D04 Teaching Session 4
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 1 s Comments are very important in computer programming. s Comments are a plain natural language (English) description attached to a chunk of code to explain what the code does. s Comments are not executed by the computer. They are intended to make code more readable. Why? For whom? Comments
Background image of page 2
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 2 s Comments are very important in computer programming. s Comments are a plain natural language (English) description attached to a chunk of code to explain what the code does. s Comments are not executed by the computer. They are intended to make code more readable. Comments in general, identifiers For ALL users - including the developer(s)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 3 Comments s In visual studio, code that the compiler considers to be a comment is written in an ugly shade of green. s If code that shouldn't be a comment is this colour, there's a problem with your syntax.
Background image of page 4
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 4 //Assign value to textbox TextBox1.Text = "Comment Example"; a = x; //Comment on same line as code!! Comments s There are two syntaxes for comments that can be used in C#. s First - the text between two //'s and the end of a line is a comment.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 5 /* This is my super long comment. "Comment Example" is getting written to TextBox1. TextBox1 is an output textbox that should have been given a better name */ TextBox1.Text = "Comment Example"; Comments s Second - multiple line comments can be written between /* and */
Background image of page 6
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 6 Comments s Visual studio has a tool to make lines into a comment. s Highlighting a section, and clicking the Comment out Selected Lines button turns entire lines into comments.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 7 Comments s Highlighting a section and clicking the Uncomment the selected lines button will remove the comment marks put on by the other button.
Background image of page 8
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 8 Comments s It's important to write a modest amount of comments. s Too many comments clutter the code. s Too few makes it very difficult to understand what code does. s Do not simply restate what is obvious from reading the code - assume the reader can read C#.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 9 double pnAbsSlope(double x1, double y1, double x2, double y2) { double slope = (y2 - y1) / (x2 – x1); if (slope > 0) textBox1.Text = "Positive Slope"; else { textBox1.Text = "Negative Slope"; slope = -slope; } return slope } Recap: If Statements
Background image of page 10
10 The Else-If s There are a few more variations of the if- else statement. s
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 63

Teaching%20Session%204 - Engineering 1D04 Teaching Session...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online