C# Programming: From Problem Analysis to Program Design

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Objectives You should be able to describe: Introduction to Programming
Lecture 2 Introduction to C Programming
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
 2005 Pearson Education, Inc. All rights reserved Introduction.
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program C# Programming: From Problem Analysis to Program Design 2 nd Edition.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
Introduction to Computing and Programming
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
C# Programming: From Problem Analysis to Program Design
Introduction to C Programming
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
A First Program Using C#
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Module 1: Introduction to C# Module 2: Variables and Data Types
Chapter 1: Creating Java Programs
C# B 1 CSC 298 Writing a C# application. C# B 2 A first C# application // Display Hello, world on the screen public class HelloWorld { public static void.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
Computing with C# and the.NET Framework Chapter 1 An Introduction to Computing with C# ©2003, 2011 Art Gittleman.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Chapter 3 Introduction To Java. OBJECTIVES Packages & Libraries Statements Comments Bytecode, compiler, interpreter Outputting print() & println() Formatting.
Creating a Java Application and Applet
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
A First Book of C++ Chapter 1 Getting Started. Objectives In this chapter, you will learn about: –Introduction to Programming –Function and Class Names.
C# Programming: From Problem Analysis to Program Design1 4 th Edition Introduction to Computing and Programming 1.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
IS 350 Course Introduction. Slide 2 Objectives Identify the steps performed in the software development life cycle Describe selected tools used to design.
C# Programming: From Problem Analysis to Program Design
Computer Programming Your First Java Program: HelloWorld.java.
C++ First Steps.
Great way to learn is by example so fire up Visual Studios C (at home make sure you custom install with C++ - no longer default) by Deborah R. Fowler.
C# Programming: From Problem Analysis to Program Design
Chapter 6 JavaScript: Introduction to Scripting
CSC201: Computer Programming
Completing the Problem-Solving Process
Chapter 2 - Introduction to C Programming
Chapter 2, Part I Introduction to C Programming
Introduction to C# Applications
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
C# and the .NET Framework
Introduction to C Topics Compilation Using the gcc Compiler
Chapter 2 - Introduction to C Programming
Introduction Java Chapter 3.
Social Media And Global Computing Introduction to Visual Studio
Advanced Programming Lecture 02: Introduction to C# Apps
Understanding the Visual IDE
CIS16 Application Development Programming with Visual Basic
Chapter 3 Classes and Objects
An Introduction to Structured Program Design in COBOL
T. Jumana Abu Shmais – AOU - Riyadh
Chapter 1 Introduction(1.1)
Chapter 2- Visual Basic Schneider
Chapter 3 – Introduction to C# Programming
Computer Programming-1 CSC 111
Chapter 2 part #1 C++ Program Structure
Programming Logic and Design Eighth Edition
Presentation transcript:

C# Programming: From Problem Analysis to Program Design Introduction to Computing and Programming 1 C# Programming: From Problem Analysis to Program Design 4th Edition C# Programming: From Problem Analysis to Program Design

Software (continued) Figure 1-1 A machine language instruction C# Programming: From Problem Analysis to Program Design

Steps in the Program Development Process (continued) Software development process is iterative As errors are discovered, it is often necessary to cycle back to a previous phase or step Figure 1-2 Steps in the software development process C# Programming: From Problem Analysis to Program Design

Programming Methodologies Structured Procedural Programming Emerged in the 1970s Object-Oriented Programming Newer approach C# Programming: From Problem Analysis to Program Design

Flowchart Parallelogram – inputs and output Oval – beginning and end Rectangular – processes Diamond – decision to be made Parallelogram – inputs and output Flow line Figure 1-7 Flowchart symbols and their interpretation C# Programming: From Problem Analysis to Program Design

Pseudocode or Structured English Tool used to develop an algorithm Steps written in pseudo or near code format Combination English statements and the chosen programming language Verbs like compute, calculate, sum, print, input, display are used Loops are shown with while or do while if and if/else used for decisions C# Programming: From Problem Analysis to Program Design

Figure 1-8 Pseudocode or Structured English for Rental Car application C# Programming: From Problem Analysis to Program Design

Why C# One of the newer programming languages Conforms closely to C and C++ Has the rapid graphical user interface (GUI) features of previous versions of Visual Basic Has the added power of C++ Has the object-oriented class libraries similar to Java C# Programming: From Problem Analysis to Program Design

Console Applications Normally send requests to the operating system Display text on the command console Easiest to create Simplest approach to learning software development Minimal overhead for input and output of data C# Programming: From Problem Analysis to Program Design

Output from the First C# Program Console-based application output Figure 1-14 Output from Example 1-1 console application C# Programming: From Problem Analysis to Program Design

Exploring the First C# Program From Example 1-1 line 1 // This is traditionally the first program written. line 2 using System; line 3 namespace HelloWorldProgram line 4 { line 5 class HelloWorld line 6 { line 7 static void Main( ) line 8 { line 9 Console.WriteLine("Hello World!"); line 10 } line 11 } line 12 } Comments in green Keywords in blue C# Programming: From Problem Analysis to Program Design

Elements of a C# Program Comments line 1 // This is traditionally the first program written. Like making a note to yourself or readers of your program Not considered instructions to the computer Not checked for rule violations Document what the program statements are doing C# Programming: From Problem Analysis to Program Design

Comments Make the code more readable Three types of commenting syntax Inline comments Multiline comments XML documentation comments C# Programming: From Problem Analysis to Program Design

Inline Comments Indicated by two forward slashes (//) Considered a one-line comment Everything to the right of the slashes ignored by the compiler Carriage return (Enter) ends the comment // This is traditionally the first program written. C# Programming: From Problem Analysis to Program Design

Multiline Comment Forward slash followed by an asterisk (/*) marks the beginning Opposite pattern (*/) marks the end Also called block comments /* This is the beginning of a block multiline comment. It can go on for several lines or just be on a single line. No additional symbols are needed after the beginning two characters. Notice there is no space placed between the two characters. To end the comment, use the following symbols. */ C# Programming: From Problem Analysis to Program Design

XML Documentation Comments Extensible Markup Language (XML) Markup language that provides a format for describing data using tags Similar to HTML tags Three forward slashes (///) mark beginning Advanced documentation technique used for XML-style comments Compiler generates XML documentation from them C# Programming: From Problem Analysis to Program Design

using Directive Permits use of classes found in specific namespaces without having to qualify them Framework class library Over 2,000 classes included Syntax using namespaceIdentifier; C# Programming: From Problem Analysis to Program Design

Namespace Namespaces provide scope for the names defined within the group Captain example Groups semantically related types under a single umbrella System: most important and frequently used namespace Can define your own namespace Each namespace enclosed in curly braces: { } C# Programming: From Problem Analysis to Program Design

Namespace (continued) Predefined namespace (System) – part of .NET FCL From Example 1-1 line 1 // This is traditionally the first program written. line 2 using System; line 3 namespace HelloWorldProgram line 4 { line 12 } User-defined namespace Body of user-defined namespace C# Programming: From Problem Analysis to Program Design

Class Definition Building block of object-oriented program Everything in C# is designed around a class Every program must have at least one class Classes define a category, or type, of object Every class is named C# Programming: From Problem Analysis to Program Design

Class Definition (continued) line 1 // This is traditionally the first program written. line 2 using System; line 3 namespace HelloWorldProgram line 4 { line 5 class HelloWorld line 6 { line 11 } line 12 } User-defined class C# Programming: From Problem Analysis to Program Design

Class Definition (continued) Define class members within curly braces Include data members Stores values associated with the state of the class Include method members Performs some behavior of the class Can call predefined classes’ methods Main( ) C# Programming: From Problem Analysis to Program Design

Main( ) Method “Entry point” for all applications Where the program begins execution Execution ends after last statement in Main( ) Can be placed anywhere inside the class definition Applications must have one Main( ) method Begins with uppercase character C# Programming: From Problem Analysis to Program Design

Main( ) Method Heading line 7 static void Main( ) Begins with the keyword static Second keyword → return type void signifies no value returned Name of the method Main is the name of Main( ) method Parentheses “( )” used for arguments No arguments for Main( ) – empty parentheses  C# Programming: From Problem Analysis to Program Design

Method Body − Statements Enclosed in curly braces Example Main( ) method body line 7 static void Main( ) line 8 { line 9 Console.WriteLine("Hello World!"); line 10 } Includes program statements Calls to other method Here Main( ) calling WriteLine( ) method C# Programming: From Problem Analysis to Program Design

Method Calls Program statements line 9 Console.WriteLine("Hello World!"); Program statements WriteLine( ) → member of the Console class Main( ) invoking WriteLine( ) method Member of Console class Method call ends in semicolon C# Programming: From Problem Analysis to Program Design

Program Statements Write ( ) → Member of Console class Argument(s) enclosed in double quotes inside ( ) "Hello World!" is the method’s argument "Hello World!" is string argument String of characters May be called with or without arguments Console.WriteLine( ); Console.WriteLine("WriteLine( ) is a method."); Console.Write("Main( ) is a method."); C# Programming: From Problem Analysis to Program Design

Program Statements (continued) Read( ) and ReadKey( ) accept one character from the input device ReadLine( ) accepts string of characters Until the enter key is pressed Write( ) does not automatically advance to next line Write("An example\n"); Same as WriteLine("An example"); Includes special escape sequences C# Programming: From Problem Analysis to Program Design

Escape Sequence Characters Table 1-1 Escape sequences C# Programming: From Problem Analysis to Program Design

Code Automatically Generated Figure 1-17 Code automatically generated by Visual Studio C# Programming: From Problem Analysis to Program Design

Rename Source Code Name Clicking Yes causes the class name to also be renamed Figure 1-18 Changing the source code name from Program C# Programming: From Problem Analysis to Program Design

Debugging an Application Types of errors Syntax errors Typing error Misspelled name Forget to end a statement with a semicolon Run-time errors Failing to fully understand the problem More difficult to detect C# Programming: From Problem Analysis to Program Design

Coding Standards Following standards leads to better solutions Following standards makes your code more maintainable Following standards saves you time when you go to modify your solution Developing standards that you consistently adhere to increases your coding efficiency C# Programming: From Problem Analysis to Program Design

Coding Standards - Pseudocode Suggestions Use action verbs to imply what type of activities should be performed Group items and add indentation to imply they belong together Use keywords like while or do while to imply looping Use if or if/else for testing the contents of memory locations C# Programming: From Problem Analysis to Program Design