Teaching%20Session%204

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

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

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

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

View Full Document Right Arrow Icon
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 1 square4 Comments are very important in computer programming. square4 Comments are a plain natural language (English) description attached to a chunk of code to explain what the code does. square4 Comments are not executed by the computer. They are intended to make code more readable. Why? For whom? Comments
Image of page 2
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 2 square4 Comments are very important in computer programming. square4 Comments are a plain natural language (English) description attached to a chunk of code to explain what the code does. square4 Comments are not executed by the computer. They are intended to make code more readable. Comments To document rationale/intent & highlight difficulties: document inputs/outputs & in general, identifiers For ALL users - including the developer(s)
Image of page 3

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

View Full Document Right Arrow Icon
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 3 Comments square4 In visual studio, code that the compiler considers to be a comment is written in an ugly shade of green. square4 If code that shouldn't be a comment is this colour, there's a problem with your syntax.
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 square4 There are two syntaxes for comments that can be used in C#. square4 First - the text between two //'s and the end of a line is a comment.
Image of page 5

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

View Full Document Right 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 square4 Second - multiple line comments can be written between /* and */
Image of page 6
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 6 Comments square4 Visual studio has a tool to make lines into a comment. square4 Highlighting a section, and clicking the Comment out Selected Lines button turns entire lines into comments.
Image of page 7

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

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

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

View Full Document Right 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
Image of page 10
© Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 10 The Else-If square4 There are a few more variations of the if- else statement.
Image of page 11

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern