Visual Studio 2005
Visual Studio is by far the most popular tool for creating .NET applications today. The current version, Visual Studio 2005, is the successor to Visual Studio .NET, which was itself the first version of this tool to support creating managed code. Both tools provide a very large set of services for developers, including all of the
Figure 1-8 shows how Visual Studio looks to the creator of a simple .NET Framework application. Different
Figure 1-8. Visual Studio provides a range of support for
|
|
Visual Studio is a family of products |
Visual Studio 2005 is actually a family of products, each aimed at a particular kind of developer. This family includes Visual Studio 2005 Express Edition, aimed at beginning developers and hobbyists, Visual Studio Standard Edition, aimed at more serious developers, and Visual Studio 2005 Professional Edition, intended for hard-
What's New in Visual Studio 2005The introduction of Visual Studio Team System and support for DSLs are probably the two biggest innovations in Visual Studio 2005. This new version of Microsoft's flagship development tool also adds several other interesting new features, including the following:
|
As already described, several different programming languages can be used to create .NET Framework applications. Visual Studio 2005 ships with support for C#, VB, C++, and other languages, giving developers a range of choices. The 2005 version of the tool also adds support for using
domain-specific languages (DSLs)
, an idea that's described later in this chapter. The main focus of Visual Studio, however, is helping developers create applications using general purpose CLR-based programming languages, and so the
|
Visual Studio 2005 provides a variety of different languages |
Perspective: The Fate of Pre-.NET Applications
Applications built using the Windows DNA technologies that preceded .NET, such as COM and Visual Basic 6 (VB6), won't
The answer depends on what kind of application we're talking about and what kind of organization is responsible for it. For example, think about a VB6 application built by a typical enterprise that
But suppose this VB6 application needs to be modified in some way. It's always possible to just keep on using an older version of Visual Studio, one that (unlike Visual Studio 2005) supports VB6. But Microsoft's support for these older development environments is fading away, and many organizations feel uncomfortable relying on unsupported tools. In this case, the application may need to be rewritten solely to avoid this fate.
What about applications written by independent software
Perhaps the hardest problem is that faced by ISVs or
Yet another challenge of transitioning to a
|
|
Visual Studio 2005 supports CLR-based languages |
Although Visual Studio supports many different programming languages, the CLR defines the core semantics for most of them. Yet while the way those languages behave often has a good deal in common, a developer can still choose the language that feels most natural to her. All of these languages use at least some of the services provided by the CLR, and some expose virtually everything the CLR has to offer. Also, with the exception of C++, it's not possible to create traditional standalone binary executables in these languages. Instead, every application is compiled into MSIL and so requires the .NET Framework to execute. This section provides a short introduction to each of the most commonly used general purpose languages built on the CLR.
The two dominant languages for Windows development in the pre-.NET world were C++ and Visual Basic 6 (VB6). Both had
|
C# is the natural language for .NET Framework developers who prefer a C-based syntax |
C# looks familiar to
Support for implementation inheritance, allowing a new child class to inherit code from one parent class, sometimes referred to as single inheritance
The ability for a child class to override one or more methods in its parent
Support for exception handling
Full multithreading (using the .NET Framework class library)
The ability to define interfaces directly in C#
Support for properties and events
Support for attributes, allowing features such as transaction support and Web services to be implemented by inserting keywords in source code
Garbage collection, freeing developers from the need to destroy explicitly objects they have created
Support for generic types, a concept similar to templates in C++
The ability to write code that directly
C++ or Java developers, who are accustomed to a C-like syntax, usually prefer C# for writing .NET Framework applications. VB6 developers, however, fond of their own style of syntax, often prefer the .NET version of VB, described next.
From its
|
Visual Basic is a very widely used language |
VB.NET, the first CLR-based version of this language, was a huge step in Microsoft's evolution of VB. In addition to being enormously different from the original Basic language, it was a big leap from its immediate predecessor, VB6. The primary reason for this substantial change was that VB.NET was built entirely on the CLR. The version in Visual Studio 2005, officially known as Visual Basic 2005,
|
VB.NET was a big change from VB6 |
VB 2005 is much like C#, which shouldn't be surprising. Both are built on the CLR, and both expose the same core functionality.
The biggest difference between C# and VB today is in syntax; functionally, the two languages are very similar. In fact, the list of interesting features in VB mirrors C#'s list:
Support for single implementation inheritance
Method overriding
Support for exception handling
Full multithreading (using the .NET Framework class library)
The ability to define interfaces directly in VB
Support for properties and events
Support for attributes
Garbage collection
Support for generic types
|
Visual Basic 2005 provides almost exactly the same features as C# |
Unlike its sibling C#, VB doesn't allow creating unsafe code. The 2005 version of VB does, however, provide an addition called the My namespace, making it easier to perform some common operations. Despite these differences, it's important to realize how similar VB and C# really are. The old division between C++ and VB6, two
C++ presented a challenge to the creators of .NET. To be able to build .NET Framework applications, this popular language had to be modified to use the CLR. Yet some of the core semantics of C++, which allows things such as a child class inheriting directly from multiple parents (known as multiple inheritance ), conflict with those of the CLR. And since C++ plays an important role as the dominant language for creating non-Framework-based Windows applications, modifying it to be purely Framework specific wasn't the right approach. What's the solution?
|
The semantics of C++
|
Microsoft's answer is to support standard C++ as always, leaving this powerful language able to create efficient processor-specific binaries as before. To allow the use of C++ to create .NET Framework applications, Microsoft added a set of extensions to the language. The C++
|
.NET Framework applications can be created using C++/CLI |
Because not all applications will use the .NET Framework, Visual Studio still allows building traditional Windows applications in C++. Rather than using C++/CLI, a developer can write standard C++ code and then compile it into processor-specific binaries. Unlike VB and C#, C++ is not required to compile into MSIL.
|
Standard C++ can also be used to create non-Framework-based applications |
|
Visual Studio 2005 also supports JScript .NET and J# |
It's fair to say that the great majority of .NET development is done in C#, VB .NET, and C++. Still, Visual Studio 2005 also supports two other CLR-based languages that are worth mentioning:
JScript:
JScript is based on ECMAScript, the current standard version of the language originally christened as JavaScript. As such, JScript provides developers with a loosely typed development environment, support for regular expressions, and other aspects typical of the JavaScript language family. Yet because it's based on the CLR, the .NET version of JScript also implements CLR-style classes, which can contain methods, implement interfaces, and more. While JScript can be used for creating
J#: Microsoft's implementation of the Java programming language, J# provides Java's syntax on top of the CLR. Don't be confusedJ# isn't intended for creating applications that run on a standard Java virtual machine. Microsoft also doesn't support many of the major Java libraries, such as Enterprise JavaBeans (EJB). Instead, J# provides a way to more easily transition Java developers and existing Java code to the world of .NET.
Microsoft also makes available a CLR-based version of the increasingly popular Python language. While it's not an integral part of Visual Studio, this implementation does allow access to the .NET Framework class library. It also
|
Microsoft provides Python for the CLR |
Other vendors also provide tools and languages for creating .NET Framework applications. The most popular of these is probably Borland's Delphi. Widely admired as a language, Delphi has a
|
Other vendors, such as Borland, provide CLR-based languages |
Support for multiple programming languages is one of the most interesting things about the .NET Framework. Chapter 3 takes a closer look at C#, VB, and C++/CLI, the three most popular languages for building .NET Framework applications.
General purpose programming languages such as C# and VB are the mainstays of modern development. Yet the idea of
model-driven development (MDD)
, where software creation depends at least in part on some kind of underlying abstract model, is a hot idea in the industry today. Visual Studio 2005 reflects this in its support for what are known as
domain specific languages
(DSLs). In general, a DSL might be
|
Domain specific languages can help in moving toward model-driven development |
Visual Studio 2005 supports several graphical DSLs. Each is implemented in a specific graphical tool that focuses on a particular problem domain. For example, every version of Visual Studio 2005, except the Express Editions, includes a tool called the Class Designer. As Figure 1-9 illustrates, this tool provides a graphical DSL for creating and modifying classes and class hierarchies.
|
Visual Studio 2005 provides a Class Designer and other DSLs |
|
The Class Designer DSL generates code from class diagrams |
The Class Designer allows a developer to create a new class by dragging and dropping an icon from the toolbox (shown on the left in Figure 1-9) onto the design surface. Properties, methods, and other aspects of the class can also be added graphically. This is more than just a tool for drawing pictures, however. The Class Designer actually generates code that reflects the defined classes. Changes to the diagram are reflected in the code, and changes made directly to the code are also reflected in the diagram. Especially for more complex scenarios, the ability to visualize classes and their relationships can be a big help in writing good code.
Perspective: Microsoft's Approach to Model-Driven DevelopmentThe dream of creating software through pictures has been with us for decades. Yet especially when they're expressed graphically, it's easy to look at DSLs and be reminded of the failure of computer-aided software engineering (CASE). Now that memories of the CASE debacle are fading, are DSLs just a repeat of this idea being foisted on a new generation?
Maybeit's too soon to know. But increased developer productivity is a laudable goal, one that's worth taking some risks to achieve. The CASE technologies of the 1980s were far broader in scope than the relatively simple DSLs that are included in Visual Studio 2005. By avoiding the grand
Microsoft is taking a small step in the DSL direction with Visual Studio 2005. The company's stated goal is to make developers perceive that modeling has value, not to move to a completely model-based development environment. Given this, starting small seems wise. Building this approach into one of the world's most widely used developer tools will
Microsoft isn't alone in promoting MDD, however. The Object Management Group (OMG), a multivendor consortium, has created a set of specifications for MDD. These
Microsoft and the OMG have never had an especially cordial relationship. OMG's first creation was the Common Object Request Broker Architecture (CORBA), a direct competitor to Microsoft's DCOM. Like CORBA, MDA takes an explicitly cross-platform, vendor-neutral approach. In fact, a primary MDA goal is to create models that can be implemented equally well using different technologies, such as .NET and Java. Given its diverse membership, it's not surprising that OMG starts from this perspective.
It's also not surprising that Microsoft doesn't see the value in this. Visual Studio is a tool for building Windows applications, so why complicate things by implementing an MDD approach that strives to be cross-platform? And if you're Microsoft, what value is there in working with a committee of others to define what will ultimately be a Windows technology? Unsurprisingly, Microsoft continues to believe that for Windows programming interfaces, it should be in the driver's seat. Also, like the products of many standards
|
Like any development tool, the goal of Visual Studio is to help developers be more effective. Yet the majority of software today, and virtually all enterprise software, isn't created by a single individual. Software development has become a team sport, complete with specialized
|
Most software today is created by groups, not individuals |
|
Visual Studio 2005 Team System includes several different tools |
Visual Studio 2005 Team System recognizes this fact. As Figure 1-10 shows, this product suite includes components that target each member of a modern development group. Those
Visual Studio 2005 Team Edition for Software
Visual Studio 2005 Team Edition for Software Developers:
includes tools that are useful for people who actually write code. These tools support static code analysis, exposing problems such as using an
Visual Studio 2005 Team Edition for Software Testers: offers tools focused on the tasks performed by people who test code, such as tools for creating and running unit tests and for load testing.
Visual Studio 2005 Team Foundation Server:
provides the common platform for the other Team System components. Implemented as a standalone server application, Team Foundation Server keeps track of team projects, maintains a work items database, supports version control of a project's source code, and provides other common services that a software development team needs. The projects
Except for Team Foundation Server, all of the components of Visual Studio 2005 Team System are built on Visual Studio 2005 Professional Edition, which means that each one includes a complete development environment. While many .NET developers are happy with just a standalone version of Visual Studio, larger