Decisions, repetition, Code Snippets, Comments, and Intellisense

Slides:



Advertisements
Similar presentations
Chapter 8 Improving the User Interface
Advertisements

1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
A First Program Using C#
Prepared by Uzma Hashmi Instructor Information Uzma Hashmi Office: B# 7/ R# address: Group Addresses Post message:
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Program documentation Using the Doxygen tool Program documentation1.
Doing Snippets in.NET Tuc Goodwin February Agenda What is a “snippet”? Where do I find Snippets? How do I use snippets? Demo How do I create a snippet?
ECE Application Programming Instructors: Dr. Michael Geiger & Nasibeh Nasiri Fall 2015 Lecture 2: Basic C program structure Data in C: Data types,
Variables and Functions. Open your Encoder program Let’s begin by opening the “Labyrinth Auto Straight” code. Save this file as Labyrinth with variables.
Introduction to programming in the Java programming language.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Page 1 – Autumn 2009Steffen Vissing Andersen SDJ I1, Autumn 2009 Agenda: Java API Documentation Code Documenting (in javadoc format) Debugging.
Microsoft Visual Basic 2012 CHAPTER FIVE Decision Structures.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Java Programming: From Problem Analysis to Program Design, 4e Chapter 5 Control Structures II: Repetition.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Presentation By :- Nikhil R. Anande ( ) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER.
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Mail Merge Introduction to Word Processing ITSW 1401 Instructor: Glenda H. Easter Introduction to Word Processing ITSW 1401 Instructor: Glenda H. Easter.
Welcome to Computer Programming II! Computer Programming II Summer 2015.
C++ LANGUAGE MULTIPLE CHOICE QUESTION
Data Virtualization Tutorial: Custom Functions
More Sophisticated Behavior
Working with Java.
Miscellaneous Excel Combining Excel and Access.
Overview of c# Programming
Microsoft Outlook By: Phuong Nguyen.
CSC 221: Computer Programming I Spring 2010
CSC 221: Computer Programming I Fall 2005
Java Coding 3 – part2 David Davenport Computer Eng. Dept.,
3.01 Apply Controls Associated With Visual Studio Form
Revision Lecture
Computer Programming I
Quick Test What do you mean by pre-test and post-test loops in C?
CHAPTER FIVE Decision Structures.
Scripts & Functions Scripts and functions are contained in .m-files
C# Programming: From Problem Analysis to Program Design
Chapter 8: Control Structures
Using Procedures and Exception Handling
Using Visual Studio with C#
Chapter 5: Control Structures II
© Paradigm Publishing, Inc.
CHAPTER FIVE Decision Structures.
Introduction to javadoc
Variables and Arithmetic Operations
Code Snippets, Intellisense, Comments, Type Conversion
Chapter 7: Strings and Characters
Topics Introduction to File Input and Output
Conditional Statements
Introduction to Python
CISC101 Reminders Quiz 1 grading underway Assn 1 due Today, 9pm.
From Debugging to Data Conversion Operations
Fall 2018 CISC124 12/1/2018 CISC124 Note that the next assignment, on encapsulation, is due next Wednesday at 7pm – not Friday. The next Quiz is not until.
Chapter 1: Computer Systems
Fundamental Error Handling
Documentation Comments in C#.
Program Documentation
Introduction to Problem Solving and Control Statements
Introduction C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell.
CISC124 Labs start this week in JEFF 155. Fall 2018
The Java switch Statement
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Introduction to javadoc
CISC101 Reminders All assignments are now posted.
EECE.2160 ECE Application Programming
Variables in C Topics Naming Variables Declaring Variables
Topics Introduction to File Input and Output
Correct document structure Easy for authors and accessible to readers
Presentation transcript:

Decisions, repetition, Code Snippets, Comments, and Intellisense Additional C# Information Decisions, repetition, Code Snippets, Comments, and Intellisense Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Topics Decisions and Repetition Using Code Snippets Comments and Intellisense Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Decisions and Repetition Similar to Java and C++ Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Decisions and Repetition if, switch, while, for Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

if – else, while, for The if-else, while, for constructs in C# is almost identical to counterparts in Java Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

May initialize and increment/decrement more than one counter Counting Loop - For May initialize and increment/decrement more than one counter Program Output Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

switch-case The switch statement is similar to Java Each case MUST end in a break, return, or throw May not “fall through” to the next case Exception: empty cases are allowed, and they fall through to the next non-empty case The exceptions noted above allow for several cases to have same action switch expression and case labels must be integer, char, enum, or string type Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

switch-case Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Surround with … and Snippets Visual Studio tools to help get the construct correct and do it more easily Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Surround With … If one has existing code and discovers that some of it should be in a loop, an if-else statement, a try block, or some similar construct, VS can help convert to the desired state Select the code to embed, and right-click on it From the resulting menu, choose Surround With… Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Surround With …, continued From the dropdown list, choose the desired structure Variable names are highlighted and selected, making it easy to change the names to suit your needs Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Code Snippets Using code snippets saves both time and keystrokes Code snippets are customizable segments of code that are easily inserted when needed They relieve the programmer from typing the skeleton code in common situations such as for and while loops, try-catch-finally, foreach, class, enum, and so forth Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

If you cannot remember … If the exact format for the construct you need eludes you at the moment you need it, use VS’s Insert Snippet tool Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Snippet A snippet is a tailorable set of lines of code to do a common task Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Using Snippets The names of common code snippets are closely related to the keywords involved If one types the name of a snippet at the beginning of a line and then presses the tab key twice, the snippet is inserted as shown on the next slide Names of some snippets Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Using Snippets Continued If one types a snippet name such as for … Note: Intellisense helps … after pressing TAB twice, this code is inserted The variables are highlighted and selected for easy modification if desired Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Overriding an Inherited Method To override an inherited method, one may type override and press space key to get a list of all methods one may override from the current base class These are from System.Object, but the list depends on where the current class is in an inheritance hierarchy Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Email selected snippet More on Snippets One may also save a piece of code as a snippet, for later, repeated use Use the Snippet Manager from the Tools menu Can also drag/drop code to Toolbox for later use One may also easily e-mail a selected snippet to a colleague or team member Email selected snippet Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Similar to Using Snippets … Intellisense is a great help when typing If one types the first few characters of a keyword or identifier name, Intellisense shows a list of all such words beginning with those characters and you can select the one you want (highlight it and press TAB) In VS2010, Intellisense uses regular expressions to find what you want using a “contains” approach Typing “mem” gives all choices containing mem such as OutOfMemoryException and MissingMemberException Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Using Pascal Casing with Intellisense In addition to the “contains” approach Intellisense uses, it also takes advantage of the Pascal Casing C# uses in names Only type the UPPER CASE characters from the name To insert the class name OutOfMemoryException in code, one only needs to type OOM and press TAB, for example Type OOM to get this Intellisense Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Comments in C# Documentation and Intellisense Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Ordinary Comments in C# Ordinary comments in C# have the same formats as in Java A single or partial line comment begins with // A multiline block of comments may consist of Several lines of single line comments Comments that begin with /* … and end at some later point with … */ Used for same purposes as in other languages Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Examples: Ordinary Comments in C# Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

XML Comments XML comments are used in C# for two primary purposes Build documentation in a standard way that can be extracted to an XML file that may be formatted into a user’s manual or programmer’s guide, somewhat similar to Javadoc Generate documentation to be used by Intellisense within any program that uses the class Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

XML Comments XML comments have a common format Begin with three forward slashes: /// Use specific XML tags such as <summary></summary> <param name=“parameter_name"></param> <returns></returns> Designate specific items used by Intellisense VS can auto-generate a skeleton of XML comments for you Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Example Type /// here Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

This skeleton of XML comments is generated instantly Example, continued This skeleton of XML comments is generated instantly Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Fill in details as shown Example, cont. Fill in details as shown Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Example, cont. Hover the cursor over the name of the constructor when it is used in code to see Intellisense Note that the second line is exactly the <summary> provided in the XML comment Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

From the XML <param> comment we wrote Example, cont. When writing code that uses this constructor, Intellisense updates as we type to show what is next, using the XML comments we wrote Where we are in typing From the XML <param> comment we wrote Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018

Another Example Another tag; there are several other standard tags one may use Two places after the decimal in this output Decisions, Repetition, Code Snippets, Comments, and Intellisense November 16, 2018