Title: A Generalised Structural Model of Structured and ObjectOriented Programs for Software Metrics Defini
1A Generalised Structural Model of Structured and
Object-Oriented Programs for Software Metrics
Definition
Boris Cogan Department of Computing, Multimedia
Technology, and Mathematics London Metropolitan
University, London, UK Elena Shalfeeva Institute
for Automation and Control Processes Russian
Academy of Sciences, Vladivostok, Russia
2Contents
- What was before us
- General Task and two Subtasks
- Language-Oriented Approach
- Basic Generalised Model of a Structured Program
- Generalised Model of a Program Unit
- Generalised Model of a Structured Program
- Basic Generalised Model of an Object-Oriented
Program - Generalised Class Inheritance Model
- Generalised Class Interaction Model
- Conclusions
- Future Work
- Publications
31. What was before us
- Many models and hundreds of metrics
- We considered only those metrics that are used in
software development practice
- Some metrics were and are used for both main
kinds of programs
Hierarchical models and metrics
Object-oriented models and metrics
42.1 The Task and two Subtasks
- We may use many model to explain metrics
- Too many models are impractical for developing
program measurement tools - Our general task is development of a generalised
structural model and then redefinition all
metrics for this new model - This model for measurement tools only!
52.2 The Task and two Subtasks
- Two subtasks for hierarchical and
object-oriented models
Generalised Structural Program Model
Generalised Structural Model of Structured
Programs
Generalised Structural Model of Object-Oriented
Programs
63.1 Language-Oriented Approach First stage
- First stage of program measurement
- Language Measuring Model
- PMM a set of relational tables
Program Measuring Model (PMM)
Program
Measuring Language Processor
73.2 Language-Oriented Approach Second stage
- A language to describe treatment of PMMs in terms
of product models and product metrics
- Its implementation is a general-purpose processor
Program Measuring Model (PMM)
Models
Metric values
Metric Evaluator
Model Constructor
84.1 Models for Structured Programs
Structural Model of Structured Programs
Generalised Graph Model of a Program Unit
Generalised Graph Model of a Structured Program
94.2 A Basic Generalised Model
- A generalised structural model has to cover
combinations of functional and informational
program components and/or elements as well as
relationships among them. - The model can be used to redefine
- software metrics defined using the particular
models - all widely-used 'particular' structural program
models by means of specifying values of the model
parameters.
104.3 The Basic Generalised Model
- The Generalised Graph Model (GGM) of a
component of a program is a directed multigraph
G (N, E) consisting of a set of nodes N and a
set of edges E. - Any node n ? N corresponds to a computer memory
fragment with 'information' or functions. - Any directed edge e ? E reflects a relationship
between two 'memory fragments' by information or
control. - GGM (Node, Edge).
114.4 The Basic Generalised Model
- Node (Node name,
- Program component type,
- Component attributes)
- Edge (N-1 name,
- N-2 name,
- Relationship type,
- Relationship characteristics)
124.5 Useful Characteristics of the Basic
Generalised Model
- The model has the characteristics used to define
software quality metrics - The number of nodes with a specific value of
Program component type - The number of edges with a specific value of
Relationship type - Fan-in/fan-out for a graph node (for the edges
with a specific value of Relationship type) - The number of loops in a graph
-
135.1 A Basic Model Specification for a Program
Unit
- The practical experience has shown that
properties of control and information flows
inside any program unit affect properties of the
complete program. - Use of many models it is inconvenient for the
development of software measurement tools. - The model for a program unit implies
consideration of main blocks, statements,
variables and relationships among them. - The control flow graph and the variable
dependence graph are sub-graphs of the model.
145.2 A Model for a Program Unit
- A Generalised Graph Model for a program unit is
a directed multigraph G (N, E) consisting of a
set of nodes N and a set of edges E. - Any node n ? N corresponds to a simple (s-)
statement, a main block or a variable used in the
program unit (local or non-local including global
and a formal parameter) and a function
invocation. - Any edge e ? E reflects a relationship between
two s-statements by control or using
variables in s-statements or
modification variable values in the s-statements.
155.3 A Model for a Program Unit A Node
- Node (Node name,
- Program component type,
- Component attributes)
- Program component type s-statement ? variable
- Component attributes (Node type, Node location)
- Node type S-statement-node type ? Variable
scope - S-statement-node type predicate ? procedure
- Variable scope parameter ? local ? non-local
- Node location first ? internal ? last
165.4 A Model for a Program Unit An Edge
- Edge (N-1 name,
- N-2 name,
- Relationship type,
- Relationship characteristics)
- Relationship type control ? data
- Relationship characteristics
- Characteristic
- Relationship characteristics,
Characteristic - Characteristic value t f Ø
175.5 A Program Unit and its Generalised
Structural Graph Model
185.6 Useful Characteristics of the Basic Program
Unit Model
- The characteristics of the model a program unit
can be expanded and used to define software
quality metrics
- The set of variable-nodes and the set of data
flow paths from a particular variable-node to
nodes of the set - The set of variable-nodes for non-local variables
and the set of incoming and outgoing edges for
these nodes - The number of linearly independent control paths
in the corresponding sub-graph (as well as simple
paths, visit-each-loop paths etc.) - ...
195.7 The Control Flow Graph
- Node Node (Node name, Program component type,
- Component attributes)
- Program component type s-statement
- Component attributes (Node type, Node location)
- Node type Statement-node type
- Statement-node type predicate ? procedure
- Node location first ? internal ? last
- Edge (N-1 name, N-2 name, Relationship type,
- Relationship characteristics)
- Relationship type control
- Relationship characteristics Characteristic
- Relationship characteristics,
Characteristic - Characteristic value t f Ø
205.8 The Control Flow Graph for the Previous
Program Example
215.9 A Possible Representation of the Control Flow
Graph of 5.8
225.10 An example of a Program Unit Metric
- McCabe's cyclomatic complexity measure
- The definition in the literature For a program
unit with flowgraph F, the cyclomatic number is
calculated as v(F) e n 2, where F has
e edges and n nodes. - In terms of the generalised model McCabe's
cyclomatic complexity of a program unit is
calculated by the formula e n 2, where
e is the number of edges with the value control
of the attribute Relationship type, and n is the
number of nodes with the value s-statement of the
attribute Program component type of the
generalised program unit model.
236.1 A Generalised Model Specification for a
Program
- Graph models used in the software assessment
practice cover different structural properties of
structured programs. - All the models represent the same object, a
program, and consider the program as a
combination of all its components and a set of
relationships among them. - The specification of the generalised model covers
all structural properties of a structured program
and takes into account needs of the software
assessment practice.
246.2 A Generalised Model of a Traditional Program
- The Generalised Graph Model of a structured
program is a directed multigraph G (N, E)
consisting of a set of nodes N and a set of edges
E. - Any node n ? N corresponds to a program unit, a
non-local variable or a file. - Any node has the name of a corresponding program
unit, a non-local variable or a file. - Any edge e ? E reflects a relationship between
two program units by control or by a parameter or
using a non-local variable or a file by a program
unit.
256.3 A Generalised Model of a Traditional
Program A Node
- Node (Node name,
- Program component type,
- Component attributes).
- Program component type p-unit ? n-variable ?
file - Component attributes Reusability ?
Structuredness - Reusability new ? reusable
- Structuredness simple ? complex
266.4. A Generalised Model of a Traditional
Program An Edge
- Edge (N-1 name, N-2 name,
- Relationship type, Relationship
characteristics) - Relationship type control ? data
- Relationship characteristics Number of
relationships - (Number of relationships, Dependence of N-2
from N-1) - Number of relationships integer
- Dependence of N-2 from N-1
- (Data role, Parameter structuredness)
- Data role controlling processed
- Parameter structuredness simple Structural
- Structural set of values
276.5 An Example of a Generalised Model of a
Traditional Program
286.6 An Example of Widely Used Program Models
- Call graph
- Node Node (Node name, Program component type,
- Component attributes)
- Component attributes Reusability
- Reusability new ? reusable
- Edge (N-1 name, N-2 name,
- Relationship type, Relationship
characteristics) - Program component type p-unit
- Relationship type control
296.7 An Example of the Program Call Graphs
306.8 A Possible Representation of the Call Graph
of 6.7
316.9 An Example of Program Metrics
- Call depth. In the literature "the length of the
longest path from the root node to a leaf node". - In terms of the model the length of the longest
control flow path in the generalised graph model
of a program. These conditions have to be met for
control paths - All nodes Ni of each path have the value p-unit
of the attribute Program component type - The first node of any path N1 has no incoming
edge with the value control of its attribute
Relationship type - Any edge of the path has the value control of its
attribute Relationship type, and it is not a loop
(N-2 name ? N-1 name) - The last node of any path has no outgoing edge
with the value control of its attribute
Relationship type except a loop (i.e., it may
have that edge with N-2 name N-1 name).
327.1 Models for Object-Oriented Programs
Generalised Structural Model of Object-Oriented
Programs
Generalised Model of Class Inheritance
Generalised Model of Class Interaction
337.2 The Basic Generalised Model
- The Generalised Graph Model of an object-oriented
program (OO-GGM) is a directed multigraph G (N,
E) consisting of a set of nodes N and a set of
edges E. - Any node n ? N corresponds to a class
- Any directed edge e ? E reflects a relationship
between two classes by information or control - OO-GGM (Node, Edge).
347.3 The Basic Generalised Model
- Node (Node name,
- Program component type,
- Program component
attributes) - Edge (N-1 name,
- N-2 name,
- Relationship type,
- Relationship characteristics)
358.1 A Generalised Model for Class Inheritance
- A Generalised Class Inheritance Model is a
directed multigraph G (N, E) consisting of a
set of nodes N and a set of edges E. - Any node n ? N corresponds to a class.
- Any edge e ? E reflects a relationship between
two classes by inheritance (a relationship
between superclass attributes and subclass ones,
superclass methods and subclass ones).
368.2 A Node of the Generalised Model for Class
Inheritance
- Node (Node name,
- Program component type,
- Program component attributes)
- Program component type class
- Program component attributes
- (Node type, Node location,
- List of fields, List of
methods) - Node type abstract specific
- Node location root intermediate end
- List of fields Field List of fields, Field
378.3 A Node of the Generalised Model for Class
Inheritance
- Field (Field name, Membership, Access type)
- Membership class instance
- Access type public private protected
- List of methods Method List of methods,
Method - Method (Method name, Method type,
- Access type, Membership,
Complexity) - Method type procedure function
- Complexity integer
388.4 An Edge of the Generalised Model for Class
Inheritance
- Edge (N-1 name,
- N-2 name,
- Relationship type,
- Relationship characteristics)
- Relationship type inheritance
- Relationship characteristics
- Dependence of Node N2 from
Node N1
398.5 An Edge of the Generalised Model for Class
Inheritance
- Dependence of Node N2 from Node N1
- (Dependence specification,
- Extent of inheritance)
- Dependence specification
- (Component name from N1,
- Component name from N2)
- Extent of inheritance field inheritance
- method inheritance
- field redefinition
- method redefinition
- method implementation
408.6 An Example of the Generalised Inheritance
Model
418.7 Metrics defined on this Generalised
Inheritance Model
- The characteristics of the generalised
inheritance model can be used to define software
quality metrics - The graph width (the width of the inheritance
hierarchy) - The maximum path length in the graph (the maximum
inheritance hierarchy level (depth)) - The average path length from roots to end nodes
(leaves) - Presence of nodes with more than one incoming
edge (i.e., presence of the multiple
inheritance) - ...
428.8 Inheritance Hierarchy Model
- Node (Node name,
- Program component type,
- Program component attributes)
- Program component type class
- Program component attributes
- (Node type, Node location,
- List of fields, List of
methods) - Node location root intermediate end
- Values of the node attributes Node type, List of
fields, List of methods are not considered here.
438.9 An Example of Inheritance Hierarchy Model
448.10 A Possible Representation of the Model of 8.9
458.11 An Example of Metrics defined on the
Inheritance Model
- Depth of inheritance tree of a class (DIT)
- A definition in the literature Depth of
inheritance tree of a class (DIT) is length of
maximal path from the node to the root of the
tree.
- In terms of the generalised model DIT of the
class C is the length of the path from the node
with the values root of the attribute Node
location to the node with the value C of the
attribute Node name .
469.1 A Generalised Component Interaction Model
- Methods are actually parts of classes (not of
objects), it is usual to develop model that,
first, include classes and then their methods. - There are not generally accepted names for these
models. Those static models consider interactions
of objects of different classes and/or of the
same class. - A method of a class can send messages to other
methods of different classes or to itself (i.e.,
can invoke the methods) besides it can access
fields (variables) of objects of its own or
different classes or fields of the classes
themselves.
479.2 Specification of the Generalised Component
Interaction Model
- The Generalised Component Interaction Model of an
object-oriented program is a directed multigraph
G (N, E) consisting of a set of nodes N and a
set of edges E.
- Any node n ? N corresponds to a class.
- Any edge e ? E reflects a relationship between
two classes by interaction.
- Two types of relationships between classes
messaging between a method of a classsender and
a method of a classreceiver and accessing by a
method of a class-sender (a client) to a field of
an object of a class-receiver or a field of a
class-receiver itself.
489.3 A Node of the Component Interaction Model
- Node (Node name,
- Program component type,
- Program component attributes)
- Program component type class
- Program component attributes
- (Node type, Reuse,
- List of fields, List of
methods) - Node type abstract specific
- Reuse new library
499.4 A Node of the Component Interaction Model
- List of fields Field List of fields, Field
- List of methods Method List of methods,
Method - Field (Field name, Structuredness)
- Field name identifier
- Structuredness simple Structured
- Structured set of values
- Method (Method name,
- Method parameter list length)
- Method parameter list length integer
509.5 An Edge of the Component Interaction Model
- Edge (N-1 name,
- N-2 name,
- Relationship type,
- Relationship characteristics)
- Relationship type
- transfer of control data
transfer - Relationship characteristics
- The number of relationships
- Dependence of N-2 from N-1
519.6 An Edge of the Component Interaction Model
- The number of relationships integer
- Dependence of N-2 from N-1
- Node relationship elaboration
- Node relationship elaboration
- (N-1 component name,
- N-2 component name)
529.7 An Example of the Model of Interaction of two
Classes
539.8 Metrics defined on this Generalised
Interaction Model
- The characteristics of the Generalised
Interaction Model can be used to define software
quality metrics, for example
- The number of node couples connected at least by
an edge - The number of nodes with at least one incoming
edge that goes out from a particular node
(interpreted as the number of program classes
accessed (used) by a particular class) - The number of nodes with at least one outgoing
edge that comes in a particular node (interpreted
as the number of program classes accessing
(using) a particular class)
549.9 The Model of Collaborating Classes
- Node (Node name,
- Program component type,
- Program component attributes)
- Program component type class
- Program component attributes
- (Node type, Reuse,
- List of fields, List of
methods) - Values of the node attributes Node type, List of
fields, List of methods are not considered here. - Edge (N-1 name, N-2 name,
- Relationship type, Relationship
characteristics) - Values of the node attributes Relationship type
and Relationship characteristics are not
considered here.
559.10 An Example of the Model of Collaborating
Classes
569.11 A Possible Representation of the Model of
9.10
579.12 An Example of the Model of Message Passing
589.12 A Possible Representation of the Model of
9.11
599.13 An Example of Metrics defined on the
Interaction Model
- A definition in the literature Fan-out is the
number of other collaborating classes
irrespective of the number of references.
- In terms of the generalised model The fan-out of
the class C is the number of nodes in the program
generalised component interaction model with
incoming edges having the following properties - (1) the value of the N-2 name attribute is C
and - (2) the value of the Relationship type
attribute is transfer of control .
6010.1 Conclusions
- A generalised graph model of a program written in
a traditional algorithmic or object-oriented
programming language is presented. This model
covers all informational and control
relationships between program elements and
components. - As a matter of fact, there are four generalised
models a model for a program unit,
a model for a
structured program,
a model for class inheritance, and
a model for class
interaction.
6110.1 Conclusions
Generalised Structural Program Model
Generalised Structural Model of Structured
Programs
Generalised Structural Model of Object-Oriented
Programs
Generalised Graph Model of a Program Unit
Generalised Graph Model of a Structured Program
Generalised Graph Model of Inheritance
Generalised Graph Model of Class Interaction
6210.3 Conclusions
- For any particular program, these models may be
generated by texts of compilation units of the
program. - A model comprises two tables, the table of nodes
and the table of edges, with all attribute values
that could be used for structure metric value
calculation.
6310.4 Conclusions
__ __ (_, _, ((_,_,_), ), ((_,_,_,_,_), )))
__ __ __ (_,_)
6410.5 Conclusions
- Any function of metric value calculation is a
function of extraction of attribute values from
the tables of nodes and edges and then making
simple calculations on these sets of values.
Program Measuring Model (PMM)
Models (N E)
Metric values
Metric Evaluator
Model Constructor
6511 Future Work
- No future work!
- All structural models of structured and
object-oriented programs have been covered in
this research!
6613 Publications
- Cogan B.I., Shalveeva E.A. Generalised structural
models of structured programs to define quality
metrics Research Report 35-2002. IACP FEB RAN,
2002 (in Russian) - Cogan B.I., Shalfeeva E.A. A generalised
structural model of structured programs for
software metrics definition, Proceedings of SQM
2002, pp 203-218, Limerick, 2002 - Cogan B.I., Shalfeeva E.A. (2002). A generalised
structural model of structured programs for
software metrics definition. Software Quality
Journal, 10, 147-165 - Cogan B.I., Shalfeeva E.A. A generalised
structural model of object-oriented programs for
software metrics definition Research Report
1-2003. IACP FEB RAN, 2003 (in Russian) - Cogan B.I., Shalfeeva E.A. A generalised
structural model of object-oriented programs for
software metrics definition, Proceedings of SQM
2004, pp 299-316, Canterbury, 2004
67(No Transcript)
68- Thank you very much for coming and listening to.
- Any questions, please