C#
Question: Which software engineering principles are
supported by C#? How does this language help in the development
of large software systems?
Answer:
-
Type-safety. C# is a type-safe language, which means
that the compiler checks the correct usage of types in expressions,
assigments and method calls (also across class and component
boundaries). In the development of large software systems
this helps to detect errors early (i.e. at compilation time)
instead of at run time during testing. This significally
reduces the software development and maintenance costs.
-
Data abstraction. C# allows programmers to combine data
and operations to objects. The interfaces of these objects
can be kept simple; any complexities can be hidden behind
the interface inside the implementation of the objects
(information hiding). This helps in the development of large
software systems because it allows developers to structure
their data and operations and to keep the interfaces between
objects small. Modifications to the software are therefore
kept local most of the time. This helps to reduce maintenance
costs.
-
Object-orientation. This is the next step beyond data
abstraction. Objects (consisting of data and methods) are
instances of classes that can be organized in type hierarchies.
A class can inherit code from another class. This speeds up
software development: only those parts of a subclass have to
be implemented that cannot be inherited from its base class.
Interface types can be used to define the method protocol
that a certain type should support. All classes that implement
this interface are guaranteed to support these methods.
Dynamic binding makes it possible to work with variables
without knowing the run-time type of the object that is
stored in this variable. As long as the static type of the
variable supports a certain method, the method can be invoked
on this variable, and the object that is stored in this
variable will respond. Object-orientation is important for
making large software systems extensible.
-
Component-based programming. .NET assemblies are
components that are used via their interfaces. They are stored
in binary form as DLL or EXE files and can be dynamically
loaded. Assemblies can be separately deployed and replaced
with new versions on demand. Since assemblies also contain
metadata (i.e. type information) they can by inspected and
manipulated at run time using reflection. This makes it
possible to configure a system of components at run time
using a builder tool.
-
Exception handling. This is a feature that is available
in most modern programming languages. It allows programmers
to keep the normal (error-free) program logic separate from
error-handling code. Exceptions can be thrown in one method
and caught (i.e. handled) in one of the callers. The CLR
makes sure that an exception that is not handled causes the
program to terminate so that errors cannot go undetected.
Large programs rely on this technique to handle all possible
errors in a systematic way.
-
Threading. C# supports light-weight parallel processes.
Several activities in a program can be executed concurrently
without blocking each other. The access to common data can be
guarded with lock statements which are an implementation of
the well-known monitor concept. Threading is especially useful
for the implementation of user interfaces and servers.
|