4.7 Software Implementation


4.7 Software Implementation

The translation of a complete detailed design (algorithm and data descriptions) into a suitable programming language is called implementation. Pseudo-code is an intermediate notation between the modeling diagrams and the implementation programming language. In this book, KJP is used for writing the design and implementation, the translation to the Java programming language is carried out automatically by the KJP translator.

4.7.1 KJP and Java

Programming languages, including Java and KJP, have well-defined syntax and semantic rules. The syntax is defined by a set of grammar rules and a vocabulary (a set of words). The legal sentences are constructed using words in the form of statements. The set of words is divided into two groups:

  1. Reserved words have a predefined purpose in the language and are used in most statements with precise meaning, for example, class, inherits, variables, while, if, and others.

  2. Identifiers are names for variables, constants, functions, and classes that the programmer chooses, for example, salary, age, and employee_name.

The attributes in a class are defined as variable declarations. The data definitions inside a function are written as local variable declarations. Object-oriented programs include the following kinds of statements:

  • Class definitions

  • Declaration of simple variables

  • Declaration of object references

  • Definition of functions

  • Creation of objects

  • Manipulation of the objects created by calling (or invoking) the functions that belong to these objects

Note

In Java and KJP, the functions or operations are known as methods. Objects do not directly have names, instead, object reference variables are used to reference objects when they are created.

4.7.2 Definition of Classes

A class definition in KJP includes several sections. These must be written in the following order:

  1. The description statement encloses a textual description of the purpose of the class, author, date, and any other relevant information. This section ends with a star-slash (*/).

  2. The class statement defines the name of the class and other information related to the class.

  3. The private section includes declarations of the private attributes of the class and definitions of the private operations.

  4. The public section includes definitions of the public operations of the class.

  5. The endclass statement ends the class definition.

The general syntactic definition of a class is:

       description              .  .  .       class  class_name  is          private            constants                .  .  .            variables                .  .  .            objects                .  .  .          public                .  .  .        endclass  class_name  




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net