News from National -- Current Articles
2/1/2002
11:19:19 AM
C# & .NET Expert
Christian Nagel
Interview by S. Ibaraki, I.S.P.
This week, Stephen Ibaraki, I.S.P., has an exclusive interview with
Christian Nagel. Christian is a highly respected authority on C#, and
application development and author of, “Beginning C#” which is intended for
beginners or relatively inexperienced programmers, e.g. programmers who write
scripts for ASP development. This book explains the basic of C# programming
and gives an in-depth look into object oriented programming plus discusses
the basics of Windows programming, dynamic web pages, and web services. He
has co-authored two additional books: “Professional C# Web Services” and
“Data Centric .NET Programming with C#.” Professional C# Web Services covers
both ASP.NET Web Services as well as .NET Remoting. Data Centric .NET
Programming with C# provides information to create data-centric applications
and covers ADO.NET, XML, Active Directory, Messaging Services, etc. As a
reviewer, Stephen finds all of Christian’s books of the highest quality.
Stephen conducted this interview with Christian who resides in Austria and
works in Curriculum Management Software Development for Global Knowledge and
as MSDN Regional Director Austria.
*****
Q: First of all, thank you Christian for agreeing to this interview. What
does your family think about your career as a noted author?
A: My wife fully supports all my activities. We both are workaholics and our
motto is “full speed ahead”.
Q: For your latest book on C# and .NET development, you were on tight
deadline. Please expand on the topics you were forced to delay?
A: There was a tight deadline, but it didn’t influence the topics covered in
the book. Beginning C# has all chapters useful for a beginner doing software
development with C# and the .NET Framework. We not only cover the syntax of
C# and an introduction to object oriented programming, but also major topics
of the .NET framework like creating rich client applications, database
access, Web services, and so on.
Of course I had to reduce and to delay some of my other activities, e.g. I
reduced the time that I spent for Kart racing to a large extent.
Q: Christian, can you expand on how .NET is so different: a new way to build
distributed desktop applications; a new way to produce mobile applications;
very different from classic COM (no class factory, doesn’t use IUknown, no
registration in the registry)?
A: All what you say is correct: .NET is a new way to build distributed
applications, desktop applications, mobile applications, and it is very
different from classic COM. But the major issue with .NET is that the time
required to program applications can be reduced. Today it is very important
to get solutions fast to the market, if the development cycle takes too long,
the product is already old and cannot be sold anymore.
We have to reduce the time dealing with technology issues and focusing on the
solution. .NET helps a lot with these issues; no matter if desktop,
distributed, mobile, Web, etc applications are to be developed.
Q: What is C#?
A: C# is a new component-oriented programming language that was designed for
the .NET Framework. There are many similarities with C++ and Java, but there
are also many new ideas added that help with component development.
Q: What are your tips for learning the types defined in the .NET base class
libraries since this is the heart of .NET and not necessarily learning the
syntax of C# or other supported languages?
A: First the syntax of C# or any other programming language and concepts of
object orientation must be learned before going into the .NET base class
libraries. The chapters of the book Beginning C# are very well ordered in so
far that the reader learns about the C# syntax, gets grips with object
orientation, and digs into the classes of the .NET framework. Not only
reading the book, but also doing the exercises that complete every chapter
helps a lot learning the class libraries. Besides reading the book, the
courses at Global Knowledge lead to a profound understanding of .NET.
Q: Your experiences as a respected and widely known guru would be of benefit
to many veterans. Can you detail your personal history and how you came to
write? What personally prompted you to enter the computing field? What led
you to becoming a note expert on application development?
A: Now I have been working with different systems like PDP11, VMS, Unix,
Windows, different technologies like X-Windows, Motif, DCE, DCOM, MTS, … for
many years. Before writing books I have created special courses for Global
Knowledge, and I was a reviewer for a lot of ATL / COM titles at Wrox Press.
Q: Can you share your 20 leading tips for those thinking of getting into the
computing field? Can you describe your role with your company and how you
plan to shape the company one year and two years into the future, and in the
long term?
A: I don’t have 20 tips, but here are a few I regard as really important:
The most important tip is that it is awfully necessary to have an
irresistible urge for diving into the computing field. If you want to be
successful, don’t ever think about a 40 hours job. In this field you have to
be open-minded for new things which include continuous learning.
Be aware of your talents. There is an immense broad spectrum of talents
needed in the computing field. Graphical talents are required for the user
interface design for both Web and Windows applications, interaction with
customers, writing talents, mathematically thinking… You shouldn’t be afraid
of trying something out; from the beginning it is often not clear what your
talents really are.
At Global Knowledge I’m trainer and Curriculum Manager for the software
development business in Central Europe. Global Knowledge is the world’s
largest independent IT training and certification company offering more than
700 courses in more than 60 international locations. Every year, Global
Knowledge trains more than 300.000 IT professionals on the leading edge
technologies which their companies need to stay competitive. In Austria we
are very successful in teaching software development; during the last years
we succeeded in growing this business line dramatically. For the next years I
plan to extend this success to Germany and Switzerland as well.
Q: You have a reputation for being plugged into the stream of computing
consciousness about where it’s going now and in the long term. You’ve also
done a lot of research. Can you comment on the studies that you’ve performed,
what you have learned, and your experiences? Where is technology today and
where is it going?
A: I am happy that I started development on the PDP11 system where I created
assembler programs to test devices. That way I’ve learned how a system really
works. Later I’ve created applications on VMS and UNIX systems, before I
turned to Microsoft technologies. Here I used C++, OLE, COM, COM+, etc before
I learned .NET in the summer of 2000.
Looking back to that way, the applications that are developed become more and
more complex. This is only possible by adding abstractions so that the focus
can be put more and more on the solution instead of the technology. One
abstraction was done with virtual memory and threads. Managed code adds
another important layer where the runtime deals with a lot of issues that we
had to deal before. These abstractions make it possible to create more
complex applications in a shorter time.
Q: Can you comment on the integration of mainframe, Unix, and Windows-based
technologies and how they all fit in large, complex, enterprise environments?
A: Let’s set a step backward. We have CORBA, DCOM, and EJB for object
communication. CORBA from the OMG has the problem that different
implementations couldn’t be well integrated even if they were running on the
same platform. Microsoft founded the Active Group that built DCOM not only
for Windows, but also for UNIX hosts and mainframes. But don’t expect a
mainframe administrator to install some Microsoft technology on the host. Sun
has EJB where Java is a requirement. All these technologies have their market
place, but we cannot expect that one of these technologies will get 100%
market share and all the others disappear.
With XML Web Services we have a way to integrate these different
technologies. The SOAP protocol used by XML Web Services is a standard
initiated by Microsoft where many different vendors – including Sun - agreed
to. XML Web Services is the way to go to integrate different platforms.
Q: What are your views on top four programming environments and their future?
A: Instead of programming environments I want to put my focus on languages.
As for me C++ will not be that important as it is today. It will still be
used to create device drivers, but the importance for creating business
solutions will drop. Java still has the advantage of being platform
independent. .NET still needs some time to meet such a requirement. For development
on Windows systems, .NET already has a lot of advantages and is the way to
go. I don’t think that C# will be the only important language on this
platform. Visual Basic is used by a lot of programmers nowadays. Working with
.NET they have to learn many new things. For example Visual Basic 6 didn’t
support full object oriented programming, this is now possible with Visual
Basic .NET. In the future I’m convinced that .NET programming will be made
easier for Visual Basic .NET programmers with some designer extensions and
design time controls. I believe that C# will be the major language on this
new platform. It is not only newly designed to have an extremely good fit for
.NET, it is also made available as a standard (see http://www.ecma.ch). C#
will not only be available for Windows systems, but for other platforms as
well. Therefore C# will be the most important language in the future. All
other languages I didn’t talk about will not play a major role.
Q: What are your views on XML and its future?
A: XML is an important technology that laid the foundation for most of the
new technologies we see today. A lot of standards based on XML that are
necessary for the rich business applications still must be defined, e.g. the
Global XML Web Services Architecture (GXA) that includes reliable messaging,
transactions, security, referral, licensing… for web services.
Q: EAI, CRM, B2B are exploding? What are your views about these in related
areas for the current and future marketplace?
A: Exploding? Of course there are some products in these areas that are
really hot-sellers. But there is more need for EAI, CRM, B2B products; I
still see a lot of growth. The problem I have with existing products is that
they are too expensive and complex for smaller companies. .NET makes it a lot
easier to build EAI, CRM, and B2B products, so I see great opportunities for
cheaper and not so complex solutions.
Q: For those relatively new in the computing field and for seasoned veterans,
which 10 areas should they target for future study, what are the high-growth
areas, and can you provide specific advice?
A: Web services are the most important part to look into. This does not only
mean to know XML, SOAP, UDDI…, but also future infrastructure protocols and
SOAP modules where transactions, security, licensing will be added to web
services.
Many web applications that are now based on Active Server Pages, Perl, Java
Servlets and Java Server Pages will be written with ASP.NET because the time
to market can be reduced. So Web Forms with ASP.NET is another area that
should be targeted for future study.
Small devices will get more and more important. With hand-held devices
Microsoft outperformed the competition again. The .NET compact framework will
play an important role. To support such devices across the Internet, and even
small cellular phones, the Mobile Internet Toolkit should be looked at.
Last but not least I expect the Tablet PC with pen based input to become a
huge success.
Q: What changes do you see for the future of computing, conducting business,
and the use of the Internet?
A: The Internet already changed our lives a lot, but so far we have only seen
the beginning. Information at your fingertips will become reality. Today we
can be contacted by mobile phones no matter where we are. In the future it
will be completely normal to have access to information at any place with any
device.
Q: You are highly regarded and I have no hesitation in recommending your book
for the seasoned professional. Please describe your book, how and where they
are available? How did you get involved in being an author and what would be
your 20 biggest tips drawn from the book on C sharp? What additional books
are you planning in the near and far term? What would you do different if you
started again, having gone through this authoring experience over the years?
A: The book Beginning C# is intended for beginners or relatively
inexperienced programmers, e.g. programmers who wrote scripts for ASP
development. This book explains the basic of C# programming and shows an
in-depth look into object oriented programming. We also discuss the basics of
Windows programming, dynamic web pages, and web services.
This book can be bought in book stores, or on the Web, e.g.
http://www.amazon.com, or http://www.bookpool.com.
I have co-authored two books that are released soon: Professional C# Web
Services and Data Centric .NET Programming with C#. Professional C# Web
Services covers both ASP.NET Web Services as well as .NET Remoting. Data
Centric .NET Programming with C# provides information to create data-centric
applications and covers ADO.NET, XML, Active Directory, Messaging Services,
etc. At this stage I cannot comment on my future plans, but you will read it
soon.
With this authoring experience I have now I would not change a lot. Maybe I
would start writing books earlier in my career path.
Q: What would be your recommended top ten references for the serious
developer?
A:
Q: It’s a blank slate, what added comments would you like to give to
enterprise corporations and organizations?
A: Often I have seen project teams that used a good technology, but they
failed. Either the technology was used in a wrong way, or they simply chose
the wrong technology for their problem. Many hours work can be reduced by
using the correct tool in a correct way. The problem why these teams failed
was because of missing knowledge. Investment in good training and consulting
pays off easily!
Here are some interview questions with a focused technical bent where I would
be interested in your perspective:
1. Can you discuss .NET?
A: In the 70s our programs were written using machine code using physical
memory interrupt handling for specific CPU’s. Using virtual memory, threads
and user-mode code added an abstraction to the program development that made
it much easier to write applications. Managed code adds another abstraction
layer to application development. The .NET compilers produce Microsoft IL
code that can be managed by the runtime. The runtime can check the code at
runtime for uninitialized variables, unsafe casts, and deals with security,
exceptions, memory allocations, etc.
2. What’s the main benefit of .NET?
A: The .NET platform is a robust and secure execution environment that
dramatically simplifies application development and also simplifies
deployment and management.
3. Give an overview of.NET?
A: There are many aspects of .NET to look at. With .NET we not only talk
about the .NET platform. Microsoft server products are grouped in category
.NET Enterprise Server. Upcoming web services are called .NET My Services.
The successor of the Windows 2000 Server is the Windows .NET Server. And of
course we have the .NET platform that is available for nearly all Microsoft
operating systems, and can also be implemented by different manufacturers as
it was sent for standardization. The essential parts of all these .NET
products are web services.
But let’s look at applications written for the .NET platform. A .NET
application consists of assemblies. A .NET compiler creates assemblies that
include Microsoft IL code with metadata that describes the assembly. When the
application is started, the IL code is translated to native code before it
runs. It is also possible to generate native code at installation time.
4. Define the Common Type System and .NET base class libraries?
A: The .NET runtime was designed to support multiple programming languages.
The Common Type System defines rules how data types can be defined and such
used from different languages.
A: The .NET base class library has many multi-purpose classes that can be
used for any application types, e.g. collection and thread classes.
5. Overview the Common Language Specification and the Common Language
Runtime?
A: COM already supported multiple programming languages. With COM it is
possible to create a component with C++, and use this component from Visual
Basic. Using COM we always had to develop the component in a way that it
could be used by the target language. Each language has different
characteristics, so a scripting language can only use IDispatch interfaces
and cannot ask for interfaces other from the default interface. That’s
different with .NET. The Common Language Specification defines exactly what
is needed to support other languages. It is still possible that we use the
features of a language to some extent which cannot be used by other
languages. By setting an attribute CLSCompliant which means that we are
compliant with the Common Language Specification it is guaranteed that all
other languages that support .NET can use this component.
6. Does C++ worth with .NET?
A: Microsoft extended C++ in the ANSI spirit to support .NET. .NET classes
can be used from C++, and it is possible to create .NET types with C++.
The advantage of Managed C++ compared to C# or Visual Basic .NET is that this
language can be used to mix native and managed code – not only within a
program, but also within a class or within a method. If there is an existent
C++ class library, Managed C++ is the best way to make this available for
.NET.
7. Where does IL or Intermediate Language code come into play with .NET?
A: The .NET Managed Compilers produce Microsoft IL code that is translated to
native code when the program is started, or at installation time. Contrary to
the Java byte code, the Microsoft IL code is not designed to be interpreted;
it must be compiled to native code.
8. Overview both metadata and reflection in .NET?
A: An assembly is described by its metadata that is stored in the assembly
itself. Using custom attributes it is possible to store custom information in
an assembly that can be used at design- or runtime by reading the metadata
information using .NET reflection. Examples where such attributes are used
are XML serialization to define the XML elements and attributes how an object
should be stored, web service attributes that define the WSDL information,
COM+ attributes, etc.
9. How does a namespace differ from an assembly?
A: The name of an assembly and the namespace are two completely independent
concepts. The namespace is used to uniquely identify types. The assembly has
a manifest with version, security, and culture information. Classes from the
same namespace can be spread across multiple assemblies, and a single
assembly can hold classes from different namespaces.
10. Overview private and shared assemblies?
A: With COM all components can be found in the registry where the path of the
component can be found. So in principle all COM components are shared. With
.NET we differentiate private and shared assemblies. Private assemblies are
copied with the application; shared assemblies can be used by multiple
applications. With shared assemblies we use a strong name to uniquely
identify an assembly. Part of this strong name is the version and a public
key.
11. Overview unmanaged code and data?
A: We have to differentiate between managed code and managed data. C# and
Visual Basic .NET always produce managed code. The Managed C++ compiler
generates both managed and unmanaged (native) code. But this is different
from managed data. With C# we can use pointers to access .NET components.
Using pointers we have to pay attention that the garbage collector doesn’t
move the object where the pointer points to in memory. We have to pin the
object to a fixed address. This is where unmanaged data comes into play.
Unmanaged data is not managed by the garbage collector.
12. Can .NET work with older software such as the Win32 API and COM?
A: One of the major goals with the design of .NET was the support of legacy
software such as Win32 API and COM. There’s no need for a complete rewrite of
existing components and libraries. COM and Win32 can be easily used from
within .NET. The same way it is possible to use .NET components as COM
components in a legacy application.
13. Is there security in .NET?
A: Security is an important built-in concept with .NET. Components can be
downloaded from the Internet, started from a network server, etc. .NET
security is based on the identity of the code, and can be administratively
configured via policies.
14. Overview application deployment in .NET?
A: Components no longer need the registry to store information. Deployment
can be as simple as an xcopy. For an application only the assemblies and
configuration files must be copied. This doesn’t mean that the Microsoft
Installer technology makes no sense anymore. If it should be possible to
select product directories and specific features for installation, the
Windows Installer adds a lot of features for the installation of Windows
applications. How installer packages can be created with Visual Studio .NET
can be read in the book Beginning C#.
15. Overview C#?
A: C# is a new language that is designed for .NET. It follows many ideas from
C++ and Java, but adds a lot of new features that make it easier to create
components.
16. Give us a history of the C#?
A: C played an important role as structural programming language in the 70s.
Stroustrup created C++ by extended and adding features for object orientation
to the language. The new language C# took the ideas from C++ without the
necessity to be compatible with C++ and added features for component
programming.
17. How is C# better than traditional C++?
A: With managed code it is no longer necessary to deal with memory leaks,
fragmented memory, etc.
18. What can’t you do with C#?
A: You cannot write device drivers with C#.
19. Overview how .NET is superior to using Microsoft Foundation Classes (MFC)
and Active Template Library ATL?
A: Writing programs using MFC and ATL you have to know the libraries inside
out. Instead of focusing on the problem domain for the solution to be built
we have to know the inside of these libraries to a large extent. That’s
different with the .NET base classes. They are a lot easier to use, but they
are also extendable if they don’t fit the purpose exactly. Another big issue
I like to mention is that the .NET classes can be used from any languages. MFC
and ATL is built only for C++.
20. Overview System.Object, the common root of all C# objects?
A: Unlike to C++ but similar to Java .NET has one root class. This is the
reason why every class supports the methods of the base class System.Object,
e.g. ToString() to get the string representation of a class. With the Object
class it is also possible that every object can be passed to methods that
accept an Object parameter. Useful examples are methods of collection classes
that can manage objects of every type. The VARIANT type used with COM is now
obsolete.
21. In one sentence how does C# differ from C++?
A: C# adds syntax for a component based approach.
22. What does the preprocessor do in C#?
A: In C++ preprocessor is a heritage of C. With C++ there are a lot of
features that make many parts of the preprocessor obsolete; Macros and
constants can now be created differently. C++ just paid the price for
compatibility with C. Today the preprocessor still is useful to differentiate
build versions, e.g. a debug and a release build of the code. For C# a simple
version compared to C++ of the preprocessor is available to support different
build versions.
23. Overview some complex data structures in C# and compare to C++?
A: C++ really makes no difference between structs and classes. With C# a very
useful differentiation was found: structs are value types, where classes are
reference types.
Because pointers don’t have the big use in C# as they have in C++, arrays are
much more powerful. In C# we have a different syntax for rectangular
multi-dimensional and jagged arrays.
Strings are a very complex beast with C++. We have to differentiate ASCII
strings, DBCS, Unicode, BSTR, etc. This gets easier with .NET: all the .NET
strings are Unicode.
24. Are pointers used in C#?
A: Pointers are an essential language construct with C++, and often pointers
are the reason for programming errors. In most applications pointers are no
longer needed with C#. But there is a way to use pointers with C# in unsafe
code segments. This can be especially useful if some complex methods in
legacy DLL’s must be called.
25. Overview value and reference types in C++ and C#?
A: With C++ if a variable is put to the stack or the heap depends on the
declaration. Using a pointer and the new operator with C++ results in a
reference. C++ does not make any differences with structs and classes. With
C# Microsoft found a good way to distinguish between structs and classes. A
struct defines a value type, a class a reference type. In contrast to Java we
are no longer embarrassed to create custom value types.
26. Overview dynamic memory allocation in C#?
A: With the new operator memory for reference types is allocated on the heap.
The garbage collector manages the memory. It is not necessary that allocated
objects must be deleted because this is the job of the garbage collector. The
garbage collector can reclaim the memory if there is no longer a reference to
the object. To boost the performance of the garbage collector it uses a
generational model to differentiate the objects based on their lifetime. For
short-lived objects the probability is higher that they are not needed
anymore on the next run compared to long-lived objects.
27. Overview garbage collection in C#?
A: There is less need to implement destructors as dynamically allocated
memory will be freed automatically. However if unmanaged resources are used
there is some code necessary that should run when the object is destroyed.
Here it is important to pay attention to the behavior of the garbage
collector: the time when garbage collection happens is not defined, the
destructor code can be run by a different thread, and the order of objects
destructed is not defined. Finalization code should only be implemented if
there are some unmanaged resources that must be freed. Typically if a
destructor is added to the class, also the interface IDisposable should be
implemented to make it possible to release the unmanaged resources at an
earlier time.
28. Overview the difference in inheritance between C# and C++?
A: C# only supports single inheritance with classes, C++ supports multiple
inheritance. The rare case where multiple inheritance is useful doesn’t
justify the problems multiple inheritance adds.
29. Overview polymorphism in C#?
A: Polymorphism is very similar to C++ with the exception with C# there are
more thoughts about versioning because it is not necessary to recompile the
derived class if the base class changes. To override a virtual method in a
base class the overrides keyword must be used.
|