C# requires the presence of the .NET runtime, and it will probably be a few years before most clients particularly most home computers – have .NET installed. In the meantime, installing a 01 application is likely to mean also installing the .NET redistributable components, Because of that, it is likely that we will see many C’ applications first in the enterprise environment. Indeed, C# arguably presents an outstanding opportunity for organizations that are interested in building robust, n-tiered client-server applications.
When combined with ASP.NET,C# has the ability to access quickly and generically data stores such as SQL Server and Oracle databases. The returned data sets can easily be infated using the ASP.NET object model or LINQ and automatically render as XML for transport across an office intranet.
Once a database schema has been established for a new project, C# excellent medium for implementing a layer of data access objects, each which could provide infration, updates, and delete or access to a different database table.
Because it’s the first component-based C language, C# i/a great language implementing a business objective, too. It encapsulates the messy plumbing for component c# unication, leaving developers free to focus on gluing their data access objects together in met s that accurately enforce their organizations’ business rules. Moreover, with attributes, C# business objects-can be outfitted for method-level security checks, object pooling. and JIT activation supplied by COM+ Services. Furthermore, .NET ships with utility programs that allow your new :NET business objects to interface with legacy COM components.
To create an enterprise application with C#, you create a Class Library project for the data access objects and another for the business objects. While developing, you can use Console projects to test the methods on your classes. Fans of extreme programming can build Console projects that can be executed automatically from batch files to unit test that working code has not been broken.
On a related note, C’ and .NET will probably influence the way you physically package your reusable classes. In the past, many developers crammed a multitude of classes into a single physical component because this arrangement made deployment a lot easier; if there was a versioning problem, you knew just where to look. Because deploying .NET enterprise components involves simply copying files into directories, developers can now package their classes into more logical, discrete components without encountering “DLL Hell.”
Last, but not least, ASP.NET pages coded in C# constitute an excellent medium for user interfaces. Because ASP.NET pages compile, they execute quickly. Because they can be debugged in the Visual Studio 2008 IDE, they are robust. Because they support full-scale language features such as early .binding, inheritance, and modularization, ASP.NET pages coded in C# are tidy and easily maintained.
Seasoned developers acquire a healthy skepticism about strongly hyped new technologies and languages and are reluctant to use new platforms simply because they are urged to. If you are an enterprise developer in an IT department, though, or if you provide application services across the World Wide Web, let us assure you that C# and .NET offer at least four solid benefits, even if some of the more exotic features like XML Web services and server-side controls don’t pan out:
- Component conflicts will become infrequent and deployment is easier because different versions of the same component can run side by side on the same machine without conflicting.
- Your ASP.NET code will not look like spaghetti code.
- You can leverage a lot of the functionality in the .NET base classes.
- For applications requiring a Windows Forms user interface, C# makes it very easy to write this kind of application.
This chapter has covered a lot of ground, briefly reviewing important aspects of the .NET Framework and C#’s relationship to it. It started by discussing how all languages that target .NET are compiled into Microsoft Intermediate Language (IL) before this is compiled and executed by the Common Language Runtime (CLR).This chapter also discussed the roles of the following features of .NET in the compilation and execution process:
- Assemblies and .NET base classes
- COM components
- JIT compilation
- Application domains
- Garbage collection
You learned about the characteristics of IL, particularly its strong data typing and object orientation, and how these characteristics influence the languages that target .NET,including Ct. You also learned how the strongly typed nature of IL enables language interoperability, as well as CLR services such as garbage collection and security, There was also a focus on the Common Language Specification (CLS) and the Common Type System (CLS) to help deal with language interoperability.
Finally, you learned how C# could be used as the basis for applications that are built on several .NET technologies, including ASP.NET.