Page 72 - DCAP404 _Object Oriented Programming
P. 72

Unit 3: Review of Functions




                                                                                                Notes
             The tutorial will be held from 9:30 a.m. on Saturday, July 29, at the Amphitheater of the
             Centre for Development of Advanced Computing (C-DAC) here. Dr Venkatesh Choppella
             and Mr Satish Babu will anchor the session, an IEEE spokesman said.

             The last decade has seen Java transition into a mature, powerful, well-supported language
             capable of building scalable applications for the enterprise. Much intellectual effort has
             gone into exploring extensions to the core Java language.

             Two of these extensions are gradually gaining ground: Aspect/J, the Java extensions for
             Aspect-Oriented Programming (AOP), and Java Modeling Language (JML). Although
             completely different in nature, both these extensions demonstrate the power of the core
             Java language. Also, both are completely compatible with traditional Java.

             Relevance of AOP
             Both procedural programming and object-oriented programming focuses on separation
             and encapsulation of concerns. Some software concerns, however, defy easy encapsulation.
             These are called ‘cross-cutting’ concerns because they exist in many parts of the program.
             For example, a logging strategy affects every single part of the system. Logging thereby
             crosscuts all classes, methods, and procedures. Other crosscutting concerns include security
             and debugging.
             AOP allows “weaving in” of  code to implement crosscutting  concerns across  existing
             classes and methods through a construct called an “aspect.” Aspects permit associating an
             “advice” (code snippets) to “join points” (weave-in points in existing methods where the
             advice should be invoked).
             For example, for an application written without security in mind, a security advice can
             retrofit user authentication just before every method call in a class. The aspect is completely
             separate, and the original source file is unmodified.
             Versatile JML
             Design-by-contract (DBC) provides a formal mechanism to ensure the correct working of
             a software procedure or method. At the minimum, DBC requires that preconditions, post-
             conditions, invariants and side effects can be tested (through mechanisms such as assertions).
             JML provides a way to describe contracts in a Java-compatible manner, by embedding
             JML statements as special comments within Java source files. This way, JML is totally non-
             intrusive, and at the same time, provides much more rigour to the module by enforcing
             DBC.

          3.6 Summary

          An application written in C++ may have a number of classes.  One of these classes must contain
          one (and only one) method called main method.  Although a private main method is permissible
          in C++ it is seldom used.  For all practical purposes the main method should be declared as
          public method. A function may take zero or more arguments when called. The number and type
          of arguments that a function may take is defined in the function itself. If a function call fails to
          comply by the number and type of argument(s), the compiler reports the same as error. When
          any program is compiled the output of compilation is a set of machine language instructions,
          which is in executable program. When a program is run, this complied copy of program is put
          into memory. C++ functions can have arguments having default values. The default values are
          given in the function prototype declaration. Prototype of a function is the function without its
          body. The C++ compiler needs to about a function before you call it, and you can let the compiler




                                           LOVELY PROFESSIONAL UNIVERSITY                                   65
   67   68   69   70   71   72   73   74   75   76   77