C++

CIS162AD - C#
Introduction
01_intro.ppt
Introduction to C#
 Software Development Life Cycle (SDLC)
 C# History (brief)
 Compiling Process
 Categories of Programming Errors
CIS162AD
2
Programming
 Programming is solving a problem using a
computer.
 A program is a set of specific instructions for a
computer to follow.
 It is a complex process and each program takes
on a life of it’s own called SDLC.
 SDLC – Software Development Life Cycle
CIS162AD
3
SDLC
 Software Development Life Cycle
(Program Development Cycle)
 There are various methodologies to develop
programs, but most follow the same process.
 The actual name for each step in the process
may vary by vendor.
CIS162AD
4
SDLC – 3 Phases, 8 Steps
 Problem Solving Phase
– Problem Definition
– Algorithm Design
 Implementation Phase
– Build, Test, Install, and Train
 Support Phase
– Maintenance
– Obsolete
CIS162AD
5
SDLC - Problem Solving Phase
1.
Problem definition (Analysis of the task)
Users need a form to do a
Sales Order Calculation
(qty, price, tax, freight)
2.
Algorithm Design (Solution)
Design the interface.
Desk check with common and extreme data.
Programming language not necessarily selected yet.
CIS162AD
6
Problem Solving Diagrams
 Analysis Diagrams / Tools
– Data Flow Diagram
(DFD)
– Entity Relationship
Diagrams (ERD)
– Functional Descriptions
– Use Case Diagrams
(Object-Oriented)
 Design Diagrams / Tools
– Input Output Charts
(IPO)
– Flowcharts
– Structure Charts
– Class Diagrams
(Object-Oriented)
Diagrams are independent of programming languages.
We will see some examples of design diagrams
throughout the course.
CIS162AD
7
SDLC – Implementation Phase
3. Implement or Build (Code the program).
4. Test the program using test data.
Actual output must match expected results.
5. Deploy or install
May require data conversion or hardware
upgrades.
6. Training & User Documentation.
CIS162AD
8
SDLC – Support Phase
7. Maintenance – change program as needed
new tax rates, new freight carrier,
zip+4, Y2K, new area code.
8. Obsolete – program is discarded due to
requiring too much effort to correct
or new technology (DOS -> Windows).
CIS162AD
9
In Homework Assignments…
 You will be provided a
1. problem definition
 You will
2. Design Algorithm
3. Build it
4. Test it
CIS162AD
10
Programming Categories
 Object-Oriented Programming (OOP)
– Emphasis is on identifying objects in a problem (student, faculty, etc).
– Objects are then categorized into classes (person).
– Classes are used in programs to create and manipulate objects.
objCustomer = new clsCustomer;
 Procedural Programming
– Emphasis is on identifying the procedures or steps to solve a problem
and then creating a program as the solution.
 Event Programming
– Usually related to GUI programming.
– Program reacts to events, such as a user clicking on a mouse.
 All of these techniques will be used throughout our
C#.NET assignments.
CIS162AD
11
History of C#
 In 2000 Microsoft released the .Net programming
platform.
 Microsoft included it’s new language C#
(pronounced C-Sharp).
 Roots are in C, C++, and Java.
 .Net includes a rich library of pre-built components
that are shared among the .Net languages such as
Visual Basic (VB).
 If you know VB, you should recognize some of the
classes and methods that are used in C#.
CIS162AD
12
IDE Software
 C# programs are created in a GUI IDE .
– GUI : Graphical User Interface
– IDE : Integrated Development Environment
 C# IDE provides the tools and capabilities to
create very powerful and flexible programs.
 Can create Forms, Classes, Programs, Database
connections, and many other things.
 The IDE includes a smart editor, compiler,
linker, and debugger.
CIS162AD
13
Key Elements of a C# Program






Design the forms (user interface).
Design the methods that will be executed.
Create forms using various control objects.
Write methods that react to object events.
Each statement must end with a semi-colon.
Most blocks of code required an open and close
brace { }.
private void calculateButton_Click(…)
{
int intQuanity;
decimal decPrice;
}
CIS162AD
14
C# to Machine Language
 C# programs are typed in as text.
 Programs have a .cs extension.
– CS1Form.cs
 Form Resources have a .resx extension.
– CS1Form.resx
 Must be converted to machine language.
 How?
 By compiling…
CIS162AD
15
Compiler and Linker
 Compiler
– Verifies the program is coded with commands it
recognizes and that the proper syntax was used.
– Creates an object file (machine language).
 Linker
– Combines the program’s object file with object code of
standard routines from the library.
– Creates the final executable file (.exe).
– In the .Net Framework, Common Language Runtime
(CLR) is the linker.
CIS162AD
16
IDE Editor
Compiling
CS1.cs
Compiler
Microsoft
Intermediate
Language
(MSIL)
Common Language
Runtime (CLR)
CIS162AD
Syntax
Errors
Warnings
Library
Objects
CS1.exe
in memory
17
Syntax
 There are several languages to choose from.
 Each language has a set of commands that can
be used.
 Each language has a set of syntax rules that
must be followed.
– Syntax determines many things - like how
commands are entered and how each command
should end (period, semi-colon, etc).
CIS162AD
18
Three Categories of Errors
 Syntax Errors and Warnings
 Logic Errors
 Run-time Errors
– Actually are logic errors.
CIS162AD
19
Syntax Errors & Warnings
 Detected by compiler.
 Violation of grammar rules.
 Mistyped command.
 Compiler tells you what the error is
or what it thinks it is.
 Compiler tries to tell you where the error occurred.
 Warnings
– Passes syntax rules but not normally coded this way.
– Programmer should check for possible logic error.
CIS162AD
20
Logic Errors
 Detected and corrected by programmer.
 Program designed or written incorrectly.
 Output generated does NOT match expected
output.
 Simple to very complex.
– Using * (multiply) instead of + (add)
 Test, test, test and verify results.
 This is where programmers earn their money.
CIS162AD
21
Run-time Errors
 Usually discovered by user, but corrected by
programmer.
 Program terminates unexpectedly.
– Error: access violation …
 Usually based on a logic error.
– Divide by zero
 Users do something programmer didn’t expect
them to do.
– Processing unexpected input, such as
letters instead of numbers.
 Users need to document what they were doing
when the error occurred to help programmer.
CIS162AD
22
Summary
 Software Development Life Cycle (SDLC)
 # History
 Compiling Process
 Categories of Errors
CIS162AD
23