De presentatie wordt gedownload. Even geduld aub

De presentatie wordt gedownload. Even geduld aub

Programmeercursus O.O.P. met VISUAL BASIC.NET

Verwante presentaties


Presentatie over: "Programmeercursus O.O.P. met VISUAL BASIC.NET"— Transcript van de presentatie:

1 Programmeercursus O.O.P. met VISUAL BASIC.NET
Frans Vanrillaer & John Evans

2 Wat is .NET .Net is het samen voegen van de ‘Common Language Runtime’ met een verzameling ‘.NET base classes’ . .Net laat ons: robuuste, foutvrije, aanpasbare, eenvoudig te installeren, goed te onderhouden, taal onafhankelijke, aangepast aan de moderne technologie, Programma’s ontwikkelen.

3 Algemeen overzicht software scenario’s
Applicatie Types Ontwikkelings Model Intelligentie plaats

4 Ontwikkelings Model Cliënt Database Cliënt Server Database Server
One cannot appreciate .NET just by understanding its numerous features. To understand it in its correct perspective and realize what it is driving at one must take a broader look at what it is trying to address. So let us take a bird's eye-view of the overall software scenario. Firstly we need to understand what is the software development model that is adapted today and the problems that it faces. Secondly, we need to take a look at what different types of software applications are used today and what are the major concerns in developing these applications. Thirdly, we also need to a look at the places where the intelligence of the software application lies from a hardware perspective. Internet Explorer Outlook Express Cute FTP IIS MS Exchange Configured IIS MS Word MS Excel Spell Checker Charting Comp.

5 Applicatie Types Word Windows Apps Excel Scheduler.dll Componenten Lib
Chartmaster.dll Web Apps Elke Home page E-Commerce Site Distributie Apps Banking Applicatie E-Commerce Applicatie Mobile Apps Trip-Planner Pocket-Reminder Real-Time Emb. Apps Flight Controller Engine Controller

6 Intelligentie Plaats Mainframe Domme Terminal Intelligente Server PC
With Intelligence I mean the shift which is happening over the years. In the Mainframe model there is an Intelligent server and number of dumb terminals acting as clients connected to the Intelligent server. All the processing is done on the server with clients acting merely as an interface to the server. Thus intelligence is concentrated on the server. In case of PCs one machine acts like a server as well as client. All the parts of the software are on the single machine. Hence intelligence lies only one machine. With the advent of LANs once again an intelligence shift happened once again. In a LAN intelligence lies on both client as well as server. This distribution is more or less equal. If you take a look at the Internet model the intelligence has once again been shifted back on the server. Clients are not like dumb terminals. Instead they have an application like browser that allows us to interact with the server applications. They can be called "not so dumb" terminals. De Twee samen Netwerk Intelligente ? Intelligente ?

7 De .NET oplossing .NET Framework .NET Servers Ontwikkelings omgeving
CLR Base Classes SQL Server BizTalk Server Commerce Server Exchange Server ISA Server Mobile IIS CLR = Common Language Runtime BCL = Base Class Library FCL = Frame Class Library Visual Studio.Net Één ontwikkelings omgeving (IDE ) voor alle software types en alle .Net talen

8 .NET Interne opbouw Taal Infrastructuur Common Type System
VB.NET C# VC++.NET J#.NET JScript ……. Common Type System Type declaratie (waarde of referentie) Type management (stack of heap) Basis functies volgens Object-Oriented Model Implementatie regels voor nieuwe talen (CLS Common Language Specification) A developer can pick the .NET language that he likes most, write components in it, and share the compiled binary version of his component with other developers using other .NET languages. As on date there are 22 languages including VB.NET, VC++.NET, C#, COBOL, etc. from which the programmer can choose. Microsoft has made the specifications for .NET development platform freely available to compiler vendors in the form of Common Language Infrastructure (CLI). Vendors can develop compilers that produce standard binary code conforming to the CLI. CLI proposes a Common Type System which in turn contains Common Language Specification (CLS). The Common Type System defines how types are declared, used, and managed in the runtime. The common type system performs the following functions: · Defines how types should be declared (value or reference) and how they should be managed (stack or heap). · Provides base types in object-oriented form for languages to implement. · Defines rules that languages must follow, which helps ensure that types written in different languages can interact with each other. These rules are defined under the CLS. All .NET compliant languages have to follow the rules laid down by CLS to be truly interoperable. Some of these rules are listed below: Global variables and methods are not interoperable. If two variables are to be considered distinct, they must differ by more than just their case. Single type and name should not be used for a method and a variable. All dimensions of an array must have a zero lower bound. etc.

9 .NET Interne opbouw Programming Model Common Type System Client-Side
VB.NET C# VC++.NET J#.NET JScript ……. Common Type System Client-Side Server-Side Mobile-Side WinForms WinForm Controls Rich Client Apps. Components Windows Services WebForms WebForm Controls WebServices Mobile WebForms Smart Clients Real-Time Apps. Now that we understand how .NET is able to provide true language interoperability without loosing important features of OO, let us now take a look at the differnet applications that one can develop in .NET using the same programming model and a single .NET compliant language. The slide lists various applications under different heads. The elegance of .NET is that if a form (WinForm) has been designed in C#, one can either use it as it is or inherit that form to add some more functionality before displaying it. This is known as Visual Inheritance. .NET has extended the WinForm technology to the Rich Client applications. Unlike Java Applets and Applications where one has to alter the code while converting an applet to an application or vice versa, the same WinForm can be used directly on the Web too. WinForm when used on Web runs under a secured environment on the client side without danger of accessing the client machine resources. WinForm controls as compared to ActiveX controls can now be easily developed (by just inheriting a class) and can be used in the different languages. A class library can be developed without any problem of DLL Hell or a deployment nightmare. This is because .NET components are fully self-describing without any dependencies on separate files. They can be conveniently versioned and accessed depending on the version number. Web applications can now be developed as easily and consistently as Windows applications. WebForms can be designed by drag and drop method. Events from the controls can be linked to handlers in the code. The output of the WebForm is displayed in the browser on the client-side, whereas, handlers for buttons and other controls execute on the server. WebForm controls like WinForm controls can be easily developed. Creation of Mobile WebForms is also possible through simple drag and drop. WebServices extend the vision of distributed computing as they use the existing infrastructure of the Web as well as standard protocols. Mobile applications can now be easily developed with the introduction of .NET Compact Framework. It is also possible to develop Hard Real-Time applications with the introduction of Windows CE.NET.

10 .NET Interne opbouw Base Class Library Common Type System Client-Side
VB.NET C# VC++.NET J#.NET JScript ……. Common Type System Client-Side Server-Side Mobile-Side Base Class Library The .NET Framework includes a rich set of classes that provides the comprehensive functionality for any type of application one intends to develop. The applications that we saw in the previous slide would need functionalities like messaging, database access, security, drawing, and many more. All these functionalities can be provided through the classes present in the base class library. All the classes in the Framework Class Library are organized in different namespaces. GDI+ Networking Threading Web Protocols Messaging Serialization Security Reflection Timers ADO.NET Windowing

11 Common Language Runtime
.NET Interne opbouw Runtime VB.NET C# VC++.NET J#.NET JScript ……. Common Type System Client-Side Server-Side Mobile-Side Base Class Library Once an application is developed and executed the runtime takes care of it. .NET provides a enhanced runtime, as compared to the one provided by Windows, which comprises of the components listed in the slide. When a .NET compliant language compiler compiles the source code it emits code in intermediate language (IL). This code is processor independent code. The Just-In-Time (JIT) Compiler that the Common Language Runtime (CLR) provides compiles this code to the processor specific code (native code) which is then executed. The advantage of the IL is that it can be executed wherever .NET is present. Hence if .NET runtime is ported on different operating systems our code would get automatically ported on those operating systems. Also, it increases the performance of the applications because when JIT compiles IL to the native code it emits the code that is efficient for the underlying processor. CLR handles object creation and destruction and hence relieves programmer from destroying the objects explicitly.CLR releases the object when they are no longer being used. Automatic memory management eliminates memory leaks as well as some other common programming errors. CLR also handles runtime errors and informs the concerned application about them. CLR also provides a secured environment when a WinForm application is downloaded from the Web Server. It also checks for the integrity of components when they are loaded. It also checks for the type safety when types are accessed from different applications. CLR extends the Windows runtime concept of process by providing application domains. This allows multiple EXEs to run within the same process, but in different application domains without the risk of interference and at a considerably improved performance. Common Language Runtime Just In Time Comp. Garbage Collection Class loading Secure environment Handling Exceptions Application Domains

12 Common Language Runtime
.NET Interne opbouw Platform VB.NET C# VC++.NET J#.NET JScript ……. Common Type System Client-Side Server-Side Mobile-Side Base Class Library In spite of all the enhancements and power that the framework comprises, at the core it runs on Windows. The framework uses the functionality provided by Windows which is listed in the slide. The framework also provides services that are needed by enterprise applications and mission-critical applications. Since such services are provided by COM+, the framework borrows them from COM+. The services are listed in the slide. Common Language Runtime Windows COM+ Services Transaction support Message Queuing Object Pooling Load Balancing GUI Multitasking Event driven model

13 Common Language Runtime
.NET Interne opbouw .NET Framework VB.NET C# VC++.NET J#.NET JScript ……. Common Type System Client-Side Server-Side Mobile-Side .Net Framework Base Class Library Common Language Runtime Windows COM+ Services Windows 2000 / NT / XP

14 .NET Interne opbouw Hoe het werkt Uitvoering onder CLR VB.Net
Source Code IL Compiler Linker C# Source Code IL Compiler EXE of DLL Having understood the details of the .NET framework let us take a overview of the way a .NET based program works. Once our code is written, we compile it, and the compiler translates it to Microsoft Intermediate Language (MSIL). MSIL is a CPU-independent set of instructions that can be efficiently converted to native (CPU dependent) code. MSIL code is a language independent code. The Linker then links the IL code converted by one language compiler with the IL code compiled by another language compiler. The result is an EXE or DLL, containing the IL code, which is saved to disk. VS.NET comes with different language compilers to generate IL code. During execution the IL code and any requested functionality from the .NET base classes is brought together. The Just In Time (JIT) compiler processes the combined code creating managed native code (code that targets the runtime is called managed code) which is passed to the CLR. The runtime automatically handles object layout and manages references to objects, releasing them when they are no longer being used. Class Library JIT Compiler Uitvoering onder CLR Native Code

15 .NET Interne opbouw Algemeen Overzicht

16 VB.NET Console applicatie maken Start Visual Studio
File | New | Project Selecteer: Console Application Vul naam in: voorbeeld1 Geef locatie Klik Ok Creëert : Module Module1

17 Console Applicatie Automatische Code Imports System Module Module1
We maken het ons gemakkelijk en importeren expliciet de namespace System Noodzakelijk begin Keyword van een Module Naam vd Module Wordt meestal geweizigd Module Module1 Start naam Sub Main( ) Begin Keyword van een Subroutine Console.WriteLine ( "Hello VB.NET" ) Class van System Functie van deze Class End Sub End Module Sluit Subroutine af Sluit Module af Klik ‘F5’ of L-muis klik op:

18 Console Applicatie Met Command-Line Argumenten 1/2
Pas de code als volgt aan : Module Module1 Sub Main ( ByVal args( ) As String ) Dim s As String For Each s In args Console.WriteLine ( s ) Next End Sub End Module Imports System Om deze code te RUNNEN Select Start | Uitvoeren zoek met Browse naar het programma in de bin folder klik en type Frans Jan Nadine, dan klik OK. Andere manier We can stretch the first program done above to add the ability of printing the command-line arguments that may be supplied while executing the program. The enhanced program is shown in the slide. There are two ways of supplying command line arguments to a program: - Select Start | Run from menu item following the program name with the arguments that we intend to provide . - Alternatively right click on the project name from the Solution Explorer. Select properties. A property page would be displayed. Click on the configuration properties and select the debugging option from it. Supply the command line arguments. The For Each loop walks through the args( ) array printing each command-line argument in the process.

19 Console Applicatie Met Command-Line Argumenten 2/2 R

20 Overzicht volgende Les
Datatypes Controle Structuren Proceduren Option Strict Type Conversie ByVal/ByRef Meerdere Modules


Download ppt "Programmeercursus O.O.P. met VISUAL BASIC.NET"

Verwante presentaties


Ads door Google