The Philosophy of Visual Studio 'NET - PowerPoint PPT Presentation

1 / 57
About This Presentation
Title:

The Philosophy of Visual Studio 'NET

Description:

... as a free download from Microsoft. Slide ... used by Windows 98, Windows 2000, and Windows XP ... the process is similar to the Java Virtual Machine. Slide 20 ... – PowerPoint PPT presentation

Number of Views:219
Avg rating:3.0/5.0
Slides: 58
Provided by: Michaelv54
Category:

less

Transcript and Presenter's Notes

Title: The Philosophy of Visual Studio 'NET


1
Chapter 1
  • The Philosophy of Visual Studio .NET

2
Objectives (1)
  • Be introduced to Visual Basic .NET and Visual
    Studio .NET
  • Learn about the features of Visual Studio .NET
  • Learn how to choose a development language
  • Learn about the design and implementation of the
    .NET Framework
  • Understand the purpose of the Common Language
    Runtime

3
Objectives (2)
  • Receive an introduction to assemblies
  • Understand the organization of namespaces
  • Understand the .NET Framework class library
  • Create a first VB .NET application
  • Understand the syntax of Intermediate Language

4
Introduction to Visual Basic .NET (1)
  • Visual Studio .NET revolutionizes software
    development
  • Programs can be developed in any of the four
    Visual Studio .NET languages
  • C, C, Visual Basic .NET, Visual J
  • Third party languages are also supported
  • Each language supplies nearly identical
    functionality
  • Each language has the same performance
    characteristics

5
Introduction to Visual Basic .NET (2)
  • Only the .NET Framework needs to be installed to
    compile and test .NET applications
  • Notepad or any text editor will work
  • The .NET Framework contains all of the .NET
    compilers and libraries
  • Strictly speaking, Visual Studio .NET is not
    required

6
Summarizing the New Visual Studio .NET Features
(1)
  • All languages share the same integrated
    development environment
  • Languages may be selected at install time
  • Help system has been reorganized
  • Index topics organized by namespaces and types
    within those namespaces
  • New controls are supported
  • Some VB 6 controls are obsolete
  • New types of applications are supported
  • ASP.NET, Web Services, Windows Services

7
Summarizing the New Visual Studio .NET Features
(2)
  • XML is used to communicate information between
    applications and to send and receive data
  • New debugging features are supported
  • Refer to Appendix A
  • Deployment tools have been overhauled
  • Deployment accomplished through a new project
    type called a Setup Project

8
Language Enhancements
  • All Visual Studio .NET languages are
    object-oriented
  • True inheritance and polymorphism are supported
  • No matter the language, all programs have a
    similar structure
  • VB .NET supports several new keywords
  • Note that the language has changed considerably
    since VB 6
  • C (C-sharp) is a new language
  • File structure is similar for all languages
  • All programs compiled into Intermediate Language
    (IL)

9
Choosing a Development Language
  • C is similar to C and may be preferred by C
    developers
  • Signed and unsigned types are supported
  • Combines syntax and semantics of VB and C
  • Strict type checking is optional in VB .NET but
    required by C
  • VB .NET supports optional procedure arguments but
    C does not
  • C and J have a similar syntax
  • Note J is not compatible with Java and does not
    use the Java Virtual Machine

10
The Design and Implementation of the .NET
Framework
  • The .NET Framework is at the heart of Visual
    Studio .NET
  • The .NET Framework defines the rules for language
    interoperability
  • The .NET Framework must be installed to compile
    and test any .NET application
  • The .NET Framework is installed along with Visual
    Studio .NET
  • Available as a free download from Microsoft

11
Relationship Between Visual Studio .NET and the
.NET Framework
  • Visual Studio .NET provides the Integrated
    Development Environment (IDE)
  • Use to develop and test applications
  • Visual designers are used to create the interface
    for an application (forms)
  • Visual designers are used to manage XML documents
  • Other specialized Visual designers exist
  • Use Visual Studio .NET to compile and execute
    applications

12
(No Transcript)
13
Parts of the .NET Framework
  • Common Language Runtime (CLR) manages the
    execution of an application
  • Memory allocation and memory deallocation
  • Just-In-Time (JIT) compiler translates
    Intermediate Language into a native executable
    when executable is run
  • .NET Framework class library contains reusable
    components created by the .NET team

14
Requirements of the .NET Framework
  • The .NET Framework must be installed to develop
    and test any application
  • The .NET Framework is installed when installing
    Visual Studio .NET
  • The .NET Framework can be downloaded from
    Microsoft
  • Runs on all Windows versions except Windows 95
  • Limited functionality on Windows 98 and Windows
    ME because of limited operating system support

15
.NET Framework Versions
  • Two versions
  • Desktop version used by Windows 98, Windows 2000,
    and Windows XP
  • Compact version used by PDAs and mobile devices
  • Microsoft is working with third party vendors to
    work with proprietary operating systems
  • Visual Studio .NET 2003 is released
  • Almost identical to first version
  • Note the project files are not backward compatible

16
The Common Language Runtime (CLR)
  • Integral part of the .NET Framework
  • Services
  • Common Type System (CTS) defines standard data
    types and their formats
  • Common Language Specification (CLS) defines rules
    for language interoperability
  • Just-In-Time (JIT) compiler translates IL into a
    native executable
  • Process is called JITting
  • CLR manages execution of a running application
  • Garbage Collector deallocates memory

17
The Common Type System (CTS)
  • Defines the primary .NET data types used by all
    applications
  • Defines how memory for structures and classes is
    allocated
  • Allows components developed in different
    languages to operate together
  • Enforces type safety

18
The Common Language Specification (CLS)
  • A subset of the Common Type System
  • Defines rules for naming variables
  • Defines primitive data types
  • Prohibits unsigned numeric data types
  • Supports 0-based arrays
  • Specifies rules for function argument lists
  • Specifies event rules
  • Prohibits memory pointers and pointers to
    functions
  • A limited form of function pointers are supplied
    through delegates

19
Intermediate Language (IL)
  • .NET is designed to work with different hardware
    architectures
  • Conceptually, an application can run on any
    computer
  • All programs are compiled into a machine
    independent Intermediate Language (IL)
  • Format is similar to assembly language but is
    hardware independent
  • Just-In-Time compiler translates IL into a native
    executable
  • Conceptually, the process is similar to the Java
    Virtual Machine

20
Execution Management
  • Code executed by the CLR is called managed code
  • One application cannot interfere with the memory
    allocated to another application

21
Execution Management
22
Introduction to the Garbage Collector (GC)
  • CLR performs memory management
  • A contiguous area of memory allocated to a
    process is called the managed heap
  • Reference types are allocated from the managed
    heap
  • CLR reclaims memory using the Garbage Collector
    (GC)
  • GC examines variables to reclaim unused memory
  • Looks for memory without a corresponding variable
    (root)
  • GC uses 3 generations to optimize performance
  • Allocated memory propagated from generation 0 to
    generation 1 to generation 2

23
Introduction to Assemblies
  • IL files have a well-defined format called an
    assembly
  • Assemblies are the primary physical building
    blocks of an application
  • Every application is considered an assembly
  • .NET Framework classes are stored in assemblies
  • Assemblies are a special form of executable file
  • DLL files are assemblies too

24
Assembly Contents
  • The assembly manifest contains a description of
    the assembly
  • Manifest referred to as metadata
  • Manifest contains
  • A descriptive name and localization information
    are called the assembly identity
  • Assembly contents describe the types exposed by
    the assembly
  • Dependencies reference other assemblies required
    for the current assembly to operate
  • Permissions dictate who can use the assembly
  • Both users and other processes

25
Common Assemblies
  • System.dll defines the primary data types
  • System.Data.dll defines the components that make
    up ADO.NET
  • System.Drawing.dll contains the components used
    to draw various shapes to an output device
  • Forms and printers are output devices
  • System.Windows.Forms.dll contains components to
    implement desktop forms
  • System.XML.dll is used to process XML documents

26
The Organization of Namespaces
  • Assemblies are physical Namespaces are logical
  • An assembly may contain one or more namespaces
  • Namespaces are organized into a hierarchy
  • Namespaces are connected together with a dot (.)
  • The System namespace contains components
    developed by the .NET team
  • The Microsoft namespace contains components
    developed by Microsoft but outside of the .NET
    development team
  • Microsoft.VisualBasic for example

27
Common Namespaces
  • System namespace contains fundamental classes
  • System.Data namespace contains classes supplying
    data access capabilities
  • ADO.NET
  • System.Drawing provides access to the Graphical
    Device Interface allowing shapes to be drawn to
    forms and printers
  • System.IO provides access to files
  • System.Windows.Forms supplies the capabilities to
    create forms and control instances on those forms

28
Introduction to Types
  • Types are divided into two categories
  • Value types store data directly in the variable
  • Int32, Int64, Single, Double for example
  • Reference types store a memory address in the
    variable
  • A memory address points to the address of the
    actual object
  • Object memory allocated from the managed heap
  • String, Array

29
Namespace Contents (1)
  • Classes
  • Reference types
  • Support fields, events, methods, and properties
  • Delegates
  • Reference types
  • Delegates provide event support
  • Structures
  • Value types
  • Support properties and methods
  • Conceptually similar to VB 6 user-defined types

30
Namespace Contents (2)
  • Enumerations
  • Limited form of a value type
  • Associate a mnemonic name with a constant value
  • Many object properties are enumerations
  • Interfaces
  • Define members that other classes implement
  • Interfaces define the task a class must perform
    but not how to perform that task

31
Relationship Between Types
32
The System.Console Class
  • Definition
  • Use to read and write characters or lines from a
    system console (Command Prompt window)
  • Methods
  • Read method reads a character from the input
    stream
  • ReadLine method reads a line from the input
    stream
  • Line contains one or more characters
  • Carriage return character at the end of line is
    removed
  • Write method writes a character to an output
    stream
  • WriteLine method writes a line to the output
    stream
  • Line is terminated with a carriage return
    character

33
The System.Console Class (Example)
  • Read a character
  • pintCharacter System.Console.Read()
  • Read a line
  • pstrLine System.Console.ReadLine()
  • Write a string
  • System.Console.Write("Course Technology")
  • Write a string terminated by a carriage return
  • System.Console.WriteLine("Course Technology")

34
The .NET Framework Class Library (Introduction)
  • Contains all types defined by the .NET Framework
  • All classes, delegates, enumerators, interfaces,
    and structures are types
  • Types are created from other types using
    inheritance
  • All types ultimately derive from the superclass
    named System.Object

35
The .NET Framework Class Library (Organization)
36
Members of System.Object
  • A constructor is a procedure named New that
    executes when the CLR creates a class instance
  • Equals tests whether two objects contain the same
    data
  • GetHasCode defines the hashing function
  • GetType returns the data type of the object
  • ReferenceEquals tests for reference equality
  • ToString converts the object's value to a String
  • By default, ToString returns the fully qualified
    name of a class

37
Primary .NET Framework Data Types
38
Declaring a Variable
  • Use an access modifier, followed by the variable
    name, followed by the data type
  • Example
  • Dim pintCurrent As System.Int32
  • Dim pintCurrent As Integer
  • The preceding statements are equivalent
  • The first uses the formal syntax and the later
    uses convenience syntax
  • Both declare an Integer variable named pintCurrent

39
Type Inheritance
  • Every type is inherited from another type
  • Ultimately, all types inherit from System.Object
    (the superclass)
  • System.ValueType inherits from System.Object
  • System.Int32 inherits from System.ValueType
  • System.Array (reference type) inherits from
    System.Object directly
  • System.String (reference type) inherits from
    System.Object directly

40
Type Inheritance (Illustration)
41
The Implementation of Structures
  • Structures have methods and fields
  • Int32 has fields named MinValue and MaxValue
    storing minimum and maximum possible values
  • Example
  • pintMin System.Int32.MinValue()
  • pintMax System.Int32.MaxValue()
  • pstrMin pintMin.ToString()
  • pstrMax pintMax.ToString()

42
Type Conversion (1)
  • Converting data from one type to another is
    called type conversion
  • Using implicit type conversion, VB .NET will
    attempt to convert one type to another
    automatically
  • Using explicit type conversion, VB .NET will
    automatically convert more restrictive types to
    less restrictive types but not the other way
    around
  • Option Strict statement enables or disables
    strict type checking
  • Option Strict On
  • Option Strict Off

43
Type Conversion (2)
  • Integer will implicitly convert to Long because
    Long is less restrictive
  • Single will implicitly convert to Double because
    Double is less restrictive
  • Integer will implicitly convert to Single or
    Double

44
The System.Convert Class
  • Use the methods of the System.Convert class to
    perform explicit type conversion
  • ToBoolean converts to a Boolean value
  • ToDateTime converts to a DateTime structure
  • ToInt16 converts to a Short Integer
  • ToInt32 converts to an Integer
  • ToInt64 converts to a Long Integer
  • ToSingle converts to a single precision number
  • ToDouble converts to a double precision number
  • ToString converts to a string

45
The System.Convert Class (Example)
  • Read a line and convert the contents to an
    Integer (Int32)
  • Note that an error will occur if the value cannot
    be converted
  • Dim pstrCurrent As String
  • Dim pintCurrent As Integer
  • pstrCurrent System.Console.ReadLine()
  • pintCurrent System.Convert.ToInt32(pstrCurrent)

46
The System.Math Class
  • Fields
  • E represents the natural logarithmic base
    specified by the constant e
  • PI stores the value of Pi
  • Methods
  • Abs returns the absolute value of its argument
  • Cos returns the cosine of an angle
  • Sign indicates whether the argument is positive
    or negative
  • Sin returns the sine of an angle
  • Sqrt returns the square root of an argument
  • Tan returns the tangent of an angle

47
Organization of System.Convert and System.Math
48
Creating a First Application
  • A program can be created in a module block
    beginning with the Module and End Module
    keywords, respectively
  • Statements appear between the Module and End
    Module keywords
  • Example
  • Module Startup01
  • ' Statements
  • End Module

49
Creating a Startup Procedure
  • VB .NET executes a sub procedure named Main when
    a program starts
  • Example
  • Module Startup01
  • Public Sub Main()
  • ' Statements
  • End Sub
  • End Module

50
Locating the Visual Basic .NET Compiler
  • The compiler is not stored in a searchable path
    by default
  • Copy the script named corvars.bat to a searchable
    path
  • Use vsvars.bat for .NET 2003
  • Execute the script to reset the path as necessary

51
Running Corvars.bat
52
Compiling a Visual Basic .NET Application
  • The compiler uses a command line interface
  • Flags control compiler options
  • /debug enables debugging
  • /libpath specifies a directory to search for
    assemblies
  • /main specifies the class or module containing
    Sub Main
  • /optionexplicit enforces explicit variable
    declaration
  • /optionstrict enforces strict type checking
  • /out - defines executable file name
  • /reference makes an assembly available
  • /verbose displays compiler information

53
Compiling a Visual Basic .NET Application
(Example)
54
Executing the Application
55
The Syntax of Intermediate Language
  • All programs are compiled to IL format
  • ILDasm.exe can be run from a Command Prompt
    window to produce a disassembled output file
  • A graphical interface is also supported
  • Command Prompt Example
  • ILDasm Startup01.exe /OutStartup01.il

56
ILDasm in a Window
57
ILDasm displaying Manifest
Write a Comment
User Comments (0)
About PowerShow.com