References
J. Newkirk & A. A. Vorontsov, “How .NET’s Custom Attributes Affect Design”, IEEE Software, Sep/Oct 2002.Bertrand Meyer, “.NET is Coming, ” IEEE Computer, August 2001.J. Liberty, Programming C#, O’Reilly, 2002.J. Liberty & D. Hurwitz, Programming ASP.NET, O’Reilly, 2002.J. Richter, Applied Microsoft .NET Framework Programming, MS Press, 2002.
Outline
.NET Platform OverviewCustom Attributes & Their Applications
BugFixAttributeDesign By ContractWeb ServicesConditionalAttributeNUnit 2.0
Conclusion
Part I: .NET Platform Overview
Features of the .NET Platform (1/2)
Multi-language developmentC#, C++, VB.NET, JScript, J#, Eiffel, Perl, ML, etc.
Platform and processor independenceMicrosoft Intermediate Language (MSIL)
Automatic memory managementGarbage Collection (GC)
Version supportNo more “DLL Hell”
Support for open standardsSOAP, UDDI, WSDL, XML, ECMA standards, etc.
Features of the .NET Platform (2/2)
Easy deploymentXcopy deployment, and no registry
Distributed architectureWeb services
Interoperability with unmanaged codeCalling DLL function, using COM components, and calling .NET services from COM components
SecurityPerformance and Scalability
Microsoft.NET Framework
Base Class Library
Common Language Specification
Common Language Runtime (CLR)
Data and XML
VB C++ C#Visual Studio.N
ETJScript …
WebServices
UserInterface
The .NET Architecture (Meyer)
2-1
3-1
2-2
2-3
1
2
3
4
5
6
Web services
The top layer provides .NET users-persons and companies-with Web services for e-commerce and business-to-business applications.
Frameworks and libraries
A set of frameworks and libraries provides the most immediately attractive aspect for developers. These include ASP.NET, active server pages for developing smart Web sites and services; ADO.NET, and XML-based improvement to ActiveX Data Objects, for databases and object-relational processing; and Windows Forms for graphics. Altogether, .NET contains thousands of reusable components.
Development environment
The new Visual Studio.Net provides the tools of most direct use to developers: A common software development, compilation, browsing, and debugging shared by many languages. This environment allows third-party vendors to plug in tools and compilers for other languages.
Component model
Before .NET there were already three major contenders for leadership in the field of models and standards for component: CORBA, J2EE and COM.With .NET you can build assemblies, each consisting of a number of classes with well-defined interfaces.
Component model (2/2)ILDASM
Object model
The object model provides the conceptual basis on which everything else rests, in particular, .NET's OO type system. The common language specification defines restrictions ensuring language operability.
Common language runtime
A
Basic class library
Visual Studio.Net
Visual Studio.Net- new project
Visual Studio.Net- Win App. (1/3)
B
A
Visual Studio.Net- Win App. (2/3)
Visual Studio.Net- Win App. (3/3)
ASP.NET
Web controlsServer side web controlsAutomatically state maintenance
View stateSession state
Compiled approachClosing the gap (web form)
With .NET, a Web page is a program, and a program can easily become a Web page
Demo
ASP.NET- Demo
ASP.NET- Demo
ASP.NET- Demo
ASP.NET- Demo
Security
Type verificationOrigin verificationA fine-grained permission mechanismA notion of "principal"
Beyond Windows
The open source project- Mono:http://www.go-mono.comLasted version: 0.23 (2003/03/07)
Mono includes: a compiler for the C# language, a runtime for the Common Language Infrastructure (also referred as the CLR) and a set of class libraries. The runtime can be embedded into your application.
Mono has implementations of both ADO.NET and ASP.NET as part of its distribution.
Part II: Custom Attributes
What is Custom Attributes?
Attributes, such as public, private, staticcan be applied to types and members.How about defining our own attributes?Custom attributes is a way to associate additional information with a target.
The complier detects the attributes in the source code and emits the corresponding metadata.
Custom attributes example-in C#
Custom attributes example-in VB.Net
Custom attributes’s targetsAllAssemblyClassConstructorDelegateEnumEventField
InterfaceMethodModuleParameterPropertyReturn ValueStruct
The System.Attribute class
A custom attribute is simply an instance of a type. Custom attribute types must derived from System.Attribute class (directly or indirectly)The type must have a public constructor to create an instance of it. When applying an attribute to a target, the syntax is similar to that for calling one of the type’s instance constructors.
Example- BugFixAttribute
Real example- BugFixAttribute
MyMath
Tester
Output
Example- Design By Contract
DBC in Eiffel
precondition
postcondition
DBC in Java (iContract)
DBC in .NET platform (1/2)
DBC in .NET platform (2/2)
Example- Web Services
A Simple StockTicker
The StockTicker web service exposes two web methods:
GetNameExpects a stock symbol as an argument and returns a string containing the name of the stock.
GetPriceExpects a stock symbol as an argument and returns a number containing the current price of the stock.
Source Code (1/2)
Source Code (2/2)
Two web methods
The WebMethod attribute
It’s not necessary for the WebService class to expose all of its methods to consumers of the web service. Each method we want to expose must:
Be declared as public.Have the WebMethod attribute placed before the method declaration.
Invoke GetName (1/2)
Invoke GetName (2/2)
Invoke GetPrice (1/2)
Invoke GetPrice (2/2)
StockTicker’s WSDL
Example- ConditionalAttribute
Demo ConditionalAttribute
Output
Specifying a preprocessor symbol in VS.NET
Output
Example- NUnit 2.0
JUnit review
Custom attributes in NUnit 2.0
Conclusion
We now understand the major features of the .NET platform.JSR 175- A Metadata Facility for the Java Programming Language:
A metadata facility for the Java Programming Language would allow classes, interfaces, fields, and methods to be marked as having particular attributes.http://www.jcp.org/en/jsr/detail?id=175
Q&A
The .NET program execution modelMulti-language
Platform independence
Automatic memory management
*
Common Language Runtime (CLR)
Top Related