Transcript part01dbg

CIS205
Part 1 dbg --- Getting Acquainted with
Visual Studio.NET and C#
3 Programming Platforms
Visual
Studio.NET
Java
Open Source
(LAMP)
Windows
All platforms
Linux
.NET architecture
Java Virtual
Machine
Apache Server
Databases
supported
Several DBMS
Several DBMS
MySQL
Programming
languages
supported
C++, C#, VB, J#,
and some third
party languages
Java
PHP
Applets for client;
Servlets, JSPs for
web pages
Free
Advantages
Visual Designer
for GUIs;
ASP.NET for web
pages
Platform
Architecture
2
The Visual Studio.NET IDE
• Visual Studio.NET is an Integrated Development
Environment (IDE).
• It contains:
– the Designer which makes it easy to create Graphical
User Interfaces (GUIs)
– a context-sensitive text editor
– various language compilers (we will be using C#)
– a runtime environment for testing/debugging our code
• Visual Studio.NET can be used with other
programming languages such as C++ and
Visual Basic.
3
The .NET Framework
VB
C++
C#
…
J#
ASP.NET: Web Services and
Web Forms
Windows
Forms
ADO.NET: Data and XML
Framework Class Library
Visual Studio.NET
Common Language Specification
Common Language Runtime
4
Procedural programming
+ classes
1965
BCPL
1991
B
C
1967 1970
ANSI/ISO
C++
C++
Procedural programming
1972
2000
MS Visual
C++.NET
+ classes
1985
C# combines the best features of
C/C++, Java, and VB in a new
visual, fully object-oriented, eventdriven programming language
designed for use with the .NET
platform.
1998
2000
Sun Microsystems
Java
1995
2000
MS Visual
C#.NET
1997
2000
Fully OOP
BASIC
MS Visual
BASIC.NET
GUIs
MS
Visual BASIC
Web Programming
Where Does C# Fit?
Programming Windows with C#
•
•
•
•
•
A new language designed specifically for .NET
Fully object-oriented
Type safe language
Built-in Visual Editor for GUI development
Fundamental programming syntax resembles
that of C++ and Java
6
Importance of C#
• Microsoft wrote much of .NET system
programming in C# and is currently writing
next version of Windows (Longhorn) in C#.
• In “Special Report: Security”, PC Magazine,
pg 78, 8/3/04 issue:
“ ‘In the course of putting together Longhorn,’ says Nash, [of
Microsoft] ‘… we’re making sure that in the design phase, the
implementation phase, as we build the product , we’re looking
for security and quality issues.’
The company is also using design tools that are far more
conducive to building secure code. It has discarded notoriously
insecure languages like C and C++ in favor of C# and the
Microsoft .NET platform.”
7
C# Features
• A considerable amount of pre-defined code
resides in the Framework Class Library (FCL).
• C# can be used to develop
–
–
–
–
Console applications (procedural programming)
Interactive Windows Forms applications (GUIs)
Web Services (server programs)
Interactive Web Forms (via ASP.NET)
• Like other .NET languages, code is compiled
first into MSIL (MS Intermediary Language) and
then into machine language.
8
Objects
Object Oriented Terminology
Classes (templates)
• Classes are patterns for objects.
• You might think of a class as a cookie cutter and
a set of objects as cookies created with that
cutter (class).
Class
Objects
• An object is an instance of a class, and the
process of creating an object is called
instantiation.
10
Classes
• A class is code that defines the attributes and
operations of an object.
• In this course, we may define some custom
classes. But mostly, we will use classes that
already exist in .NET libraries.
• It is not necessary for a programmer who uses a
pre-existing class to know or understand its code
structure. This concept is called encapsulation.
11
Objects (nouns)
• An object is a person, place or thing.
• Objects are instances of classes
(template for object).
• All objects have attributes (variables)
and operations (methods).
• What class would each of the pictured
objects belong to?
12
Attributes (adjectives)
• Attributes (variables) are characteristics of
an object.
• All vehicle objects have make, model, color,
number of doors, and fuel type. These
attributes (variables) are described in the
class definition (template for objects).
• The pictured vehicle is a blue Smart forTwo
with 2 doors that runs on regular gasoline;
these characteristics represent values
assigned to attributes of this specific vehicle
object.
13
Operations (verbs)
• Operations (methods) are actions
related to an object.
• The code associated with these
operations (methods) is part of the
class definition.
• You might purchase, sell, repaint,
or crash a vehicle.
• These operations may affect the
values of the attributes of the
vehicle object.
14