Title: Part 1 Introduction
1Part 1 - Introduction
- WXGA6101 Advanced Programming Issues
- By Rathija Subramaniam
- WGA 050015
2C History
- The C language, a widely known programming
language is actually a revised version of the
good old C. - Unlike other programming languages, C emerged
only in 1983. - It was written by Bjarne Stroustrup at Bell Labs
during 1983-1985. - The progress of C comes from C, which lacked
the object oriented paradigm in it. Thus, C was
developed as a superset of C. - The C language is developed to suit the current
ANSI and ISO standards. - A lament term for C would be C embedded with
class, a powerful function in the programming
environment. - Throughout the early years of its development, a
number of C versions were produced. The first
version 1.0 contained classes, inheritance,
overloading and polymorphism. - The 2nd version had multiple inheritances. In
1990, the C was modified to suit the ANSI/ISO
Standardization. Again in the year 1991 and 1994,
the 3rd version with generosity and exceptions
were developed - C gained popularity only after a few years of
its introduction to the programming world as
programmers found adapting to C was slightly
difficult in the beginning. Now, however, C has
become the base for development of other
programming language.
3Supported programming paradigm
- The programming paradigm or the grammar of C is
very wide. - In the C context, programming paradigm refers
to the technical grammar, instructive words used
in the language. - Similar to other programming language, C has
its own pattern to work with its paradigm. - This brings us to the most important aspect of
C, its object oriented functionality. Other
paradigms supported by C are, procedural
programming, object-based programming and generic
programming. - The major advantage of C from its paradigm
perspective would be that, a programmer can
design and build a program based on one or more
than one programming paradigm. - For example, a system build using the C
language can be done using procedural functions
or it can be a purely object-oriented program, or
the program can be done is such a way that it
contains elements of both paradigms. - In short, C supports multiple programming
paradigm which is very useful in creating large
application.
4Application Area
- Today, many application and programming language
run with a C logic. - Among them, Common Object Request Broker
Architecture (CORBA) has emerged as a new
language for the OMG. - C is also programmed for client server
architecture. Other application include, business
application, WMI application, video and audio
application. In fact, C is also used in many
Unix system due to its security and portability. - Other application developed using C
- Adobe Systems
- AliasWavefront Maya
- Apple OS X
- Sun
5C Features
- Namespace support solves the problem of
identifier name clashes in large applications. - Templates to develop a family of related
functions or classes. - Exception handling provides a standard method to
handle run-time errors. - New-style type-safe casting makes safe type
conversions even when working with polymorphous
classes. - Run-time type identification (RTTI) determines
the type of a data object at runtime virtual,
reference, or pointer. - Three distinct character types overload functions
based on a distinction between char, signed char,
and unsigned char. - New keywords and macros, such as bool, mutable,
explicit, and type name, provide greater
flexibility.
6C Security, Portability, Efficiency,
Extensibility/Maintainability
- Design patterns, the growing focus on design
patterns and idioms will enable C programmers
to benefit from successful techniques known to
expert C programmers, as well as to leverage
useful strategies and tactics from other language
communities. - In turn, this will increase the flexibility and
extensibility of C programs, without having to
switch languages. - For programming in Windows you will have to use
Visual C. Like elegance, efficiency comes from
knowing the type of each object at compile time. - For a small example like the one above,
performance is probably not an issue. - However, C is used in application areas where
performance is essential, such as high-energy
physics, gaming, and some embedded system
applications Stroustrup,2003. - In such applications, programs usually rely on
highly tuned libraries providing fundamental
operations. For example, there are vector and
matrix libraries that make the performance of
standard scientific and numeric computations as
good as that of Fortran while significantly
improving notation. - Extensibility/ Maintainability Completion of
the ANSI/ISO Standard -- this will finally allow
compiler vendors to build robust tools and to
enable the development of C applications that
can compile easily on more than one platform and
more than one compiler.
7C Compilation/Interpretation/Execution
- The other aspects of C include the advantage of
its compilation. - Since the code is designed to compile with the
ANSI, it runs on any ANSI C compiler. - However, most profiling runs were done with good
compiler optimizations disabled to prevent any
compiler-specific options influencing the output. - In fact, C involves templates and the Standard
Template Library for complex techniques. The C
is optimized to run on various platforms, but the
most common one would be the Microsoft Visual
C. - In short, C provides fast and coherent
compilation it has global optimization to
generate efficient codes, built in assembler that
allows assembly, procedural language to be
embedded in it to optimize the code. - C has been configured to adapt to
interpretation in its latest version. This is one
of Cs strengths. C is supported by all major
platform vendors and implemented according to its
international (ISO) standard It is therefore less
vulnerable to changes of fashion and the whims of
commercial organizations than proprietary
languages.
8Part II Description Of Language
9Scalar Data Objects
- A data object is a region of storage that
contains a value or group of values. - Each value can be accessed using its identifier
or a more complex expression that refers to the
object. In addition, each object has a unique
data type. - The data type of an object determines the storage
allocation for that object and the interpretation
of the values during subsequent access. - It is also used in any type checking operations.
Both the identifier and data type of an object
are established in the object declaration.
10Scalar Data Objects (Cont)
- Data types are often grouped into type categories
that overlap, such as - Fundamental types versus derived types
- Built-in types versus user-defined types
- Scalar types versus aggregate types
- Example
- double pidouble pi 3.14159265struct
payrollstruct payroll  char name            Â
     float salary              Â
employee
11Structured Objects
- Describes a system for generating an executable
C program from object-oriented design diagrams.
- Especially an event-trace diagram and a decision
table are used to describe an operational
definition. The decision table offers a
high-level language LOLA for the brief expression
of controls that are dependent on the data
structure. - This language allows the methods to be expressed
easily, briefly, and visually. - A C program was generated from these diagrams
in such a way that the part clichés are edited to
satisfy LOLA expression and embedded into the
frame cliché representing the skeleton of the
whole program
12Active Objects
- Active Objects are a form of multitasking for
computer systems. Specifically, they are a form
of cooperative multitasking. They are an
important feature of Symbian OS. - In the scheme, objects may make requests of
asynchronous services. (For example an
application may request to send an SMS). - Once the request has been made, control returns
to the object immediately. It may choose to do
other things, or return control back to the
operating system, which typically will schedule
other tasks or put the machine to sleep. When
making the request, the object includes a
reference to itself. - When the asynchronous task has completed, the
operating system will identify the thread
containing the requesting active object, and wake
up that thread. An "active scheduler" in that
thread will identify the object that made the
request, and pass control back to that object.
13Active Objects (Cont)
- The implementation of active objects in Symbian
OS is based around each thread having a "request
semaphore". This is incremented when a thread is
due to complete an asynchronous request, and
decremented when the request has been completed.
When there are no outstanding requests, the
thread is put to sleep. - In practice, there may be many objects in a
thread, each doing their own task. They can
interact by requesting things of each other, and
of active objects in other threads. They may even
request things of themselves. - Notice that this is a software implementation of
a very old idea that was developed to handle
software interruptions in the 70's. The operating
system was acting as the first object and the
peripheral as the second one.
14Composite Objects
- Composite objects are objects that have an
externally-discernible structure, and the
structure can be addressed via the public
interface of the composite object. The objects
that comprise a composite object are referred to
as component objects. Composite objects meet one
or both of the following criteria - the state of a composite object is directly
affected by the presence or absence of one or
more of its component objects, and/or - the component objects can be directly referenced
via the public interface of their corresponding
composite object. - It is useful to divide composite objects into two
subcategories heterogeneous composite objects
and homogeneous composite objects - A heterogeneous composite object is a composite
object that is conceptually composed of component
objects that are not all conceptually the same.
For example, a date (made up of a month object, a
day object, and a year object) is a heterogeneous
composite object. - A homogeneous composite object is a composite
object that is conceptually composed of component
objects that are all conceptually the same. For
example, a list of addresses is a homogeneous
composite object.
15Composite Objects (Cont)
- The rules for designing heterogeneous composite
objects are different from the rules for
designing homogeneous composite objects. - Composited objects are called fields, items,
members or attributes, and the resulting
composition a structure, record, tuple, or
composite type. The terms usually vary across
languages. Fields are given a unique name so that
each one can be distinguished from the others.
Sometimes an issue of ownership arises when a
composition is destroyed, should objects
belonging to it be destroyed as well? If not, the
case is sometimes called aggregation. - Example code
- typedef struct int age
- char name
- enum male, female
- sex Person
16Abstract Data Types
- Definition A set of data values and associated
operations that are precisely specified
independent of any particular implementation. - Also known as ADT.
- One of the simplest abstract data types is the
stack. The operations new(), push(v, S), top(S),
and popOff(S) may be defined with axiomatic
semantics as following. - new() returns a stack
- popOff(push(v, S)) S
- top(push(v, S)) v
- An abstract data structure is an abstract storage
for data defined in terms of the set of
operations to be performed on data and
computational complexity for performing these
operations, regardless of the implementation in a
concrete data structure. - Selection of an abstract data structure is
crucial in the design of efficient algorithms and
in estimating their computational complexity,
while selection of concrete data structures is
important for efficient implementation of
algorithms. - This notion is very close to that of an abstract
data type, used in the theory of programming
languages. The names of many abstract data
structures (and abstract data types) match the
names of concrete data structures.
17Part III Final Evaluation
18Do you have any basis to agree or disagree with
any claims of its security, portability,
efficiency, extensibility/maintainability?
- Modern critics of the language raise several
points. First, since C is based on and largely
compatible with C, it inherits most of the
criticisms levelled at that language. Taken as a
whole C has a large featureset, including all
of C plus a large set of its own additions, in
part leading to criticisms of being a "bloated"
and complicated language, especially for embedded
systems due to features such as exceptions and
RTTI which add to code size. - The Embedded C standard was specified to deal
with part of this, but it received criticism for
leaving out useful parts of the language that
incur no runtime penalty. Because of its large
featureset it can be quite difficult to fully
master, leading to programmers often bringing
unnecessarily advanced or complicated solutions
to simple problems, and it is relatively
difficult to write a good C parser with modern
algorithms.This is partly because the C grammar
is not LALR.Because of this, there are very few
tools for analyzing or performing non-trivial
transformations (e.g., refactoring) of existing
code. - C is also sometimes compared unfavorably with
single-paradigm object-oriented languages such as
Java, on the basis that it allows programmers to
"mix and match" object-oriented and procedural
programming, rather than strictly enforcing a
single paradigm. This is part of a wider debate
on the relative merits of the two programming
styles.
19What aspect of this language did you find most
difficult to learn/understand?
- The difficult part of this language is as
follows - The syntax / semantics
- Templates
- Memory managements
20How would you rate the programming environment?
Compiler/Interpreter messages?
- The C compiler is one of the best compiler I
would say. This is because C compiler has the
following advantages over other compilers. - Small language specification that retains
object-oriented features. - Avoids excessive memory consumption.
- Produces predictable run-time requirements.
- Generates ROMable code.
- Removes nonstandard extensions to C. Language
features that are not authorized by ANSI/ISO are
eliminated.
21Design mistakes (in my opinion and others
opinion)?
- There are few condemns in C design features
such as - Targets the wrong problem
- Lacks formal foundations
- Unlike components, does not provide reuse
- Leads to inefficient solutions
- Does not differ significantly from other
abstractions
22Would you use this language again?
- Yes, I would prefer C in my future assignments.
My inference for this opinion as below - A major contribution of C is its support for
defining abstract data types (ADTs) for
generic programming. - Example classes, parameterized types
exception handling. - For some systems, C s ADT support is more
important than using the OO features of language. - The C s OO features essential to build highly
flexible extensible software. - Example inheritance, dynamic binding RTTI
23Screen Shots
24Screen Shots
25Screen Shots
26Code Snippet
- class channel
- public
- void printHi()
- void setChannel()
- void donechannel()
- private
- char channel1
- char channel2
- char channel3
- char channel4
- char channel5
-
- void channeldonechannel()
-
- coutltlt"You have set the channels to the
following stations"ltltendl - coutltlt"RTM1 - Channel "ltltchannel1ltltendl
- coutltlt"RTM2 - Channel "ltltchannel2ltltendl
27REFERENCES
- 1 Mohamed Fayad and Douglas C. Schmidt,
Object-Oriented Application Frameworks, Special
Issue on Object-Oriented Application
Frameworks,volume. 40, No. 10, October 1997. - 2 Regan, David, ADO.NET and the Middle Tier,
Net Developers Journal,2003 - 3 Johson, Rod, J2EE Design and Development,
Published by Wiley Publishing, Inc.2003 - 4 Robert Chartier , Application Architecture
An N-Tier Approach - Part 1 ,Pioneering Active
Server