A Generalised Structural Model of Structured and ObjectOriented Programs for Software Metrics Defini - PowerPoint PPT Presentation

1 / 68
About This Presentation
Title:

A Generalised Structural Model of Structured and ObjectOriented Programs for Software Metrics Defini

Description:

Elena Shalfeeva. Institute for Automation and Control Processes. Russian Academy of Sciences, Vladivostok, Russia ... A Generalised Structural Model of ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 69
Provided by: boris99
Category:

less

Transcript and Presenter's Notes

Title: A Generalised Structural Model of Structured and ObjectOriented Programs for Software Metrics Defini


1
A 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
2
Contents
  • 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

3
1. 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
4
2.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!

5
2.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
6
3.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
7
3.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
8
4.1 Models for Structured Programs
Structural Model of Structured Programs
Generalised Graph Model of a Program Unit
Generalised Graph Model of a Structured Program
9
4.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.

10
4.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).

11
4.4 The Basic Generalised Model
  • Node (Node name,
  • Program component type,
  • Component attributes)
  • Edge (N-1 name,
  • N-2 name,
  • Relationship type,
  • Relationship characteristics)

12
4.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

13
5.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.

14
5.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.

15
5.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

16
5.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 Ø

17
5.5 A Program Unit and its Generalised
Structural Graph Model
18
5.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.)
  • ...

19
5.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 Ø

20
5.8 The Control Flow Graph for the Previous
Program Example

21
5.9 A Possible Representation of the Control Flow
Graph of 5.8
22
5.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.

23
6.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.

24
6.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.

25
6.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

26
6.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

27
6.5 An Example of a Generalised Model of a
Traditional Program
28
6.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

29
6.7 An Example of the Program Call Graphs
30
6.8 A Possible Representation of the Call Graph
of 6.7
31
6.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).

32
7.1 Models for Object-Oriented Programs
Generalised Structural Model of Object-Oriented
Programs
Generalised Model of Class Inheritance
Generalised Model of Class Interaction
33
7.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).

34
7.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)

35
8.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).

36
8.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

37
8.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

38
8.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

39
8.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

40
8.6 An Example of the Generalised Inheritance
Model
  •   .

41
8.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)
  • ...

42
8.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.

43
8.9 An Example of Inheritance Hierarchy Model

44
8.10 A Possible Representation of the Model of 8.9
45
8.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 .

46
9.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.

47
9.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.

48
9.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

49
9.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

50
9.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

51
9.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)

52
9.7 An Example of the Model of Interaction of two
Classes
53
9.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)

54
9.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.

55
9.10 An Example of the Model of Collaborating
Classes
56
9.11 A Possible Representation of the Model of
9.10
57
9.12 An Example of the Model of Message Passing
58
9.12 A Possible Representation of the Model of
9.11
59
9.13 An Example of Metrics defined on the
Interaction Model
  • Fan-out of a class
  • 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 .

60
10.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.

61
10.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
62
10.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.

63
10.4 Conclusions
  • Node
  • Edge

__ __ (_, _, ((_,_,_), ), ((_,_,_,_,_), )))
__ __ __ (_,_)
64
10.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
65
11 Future Work
  • No future work!
  • All structural models of structured and
    object-oriented programs have been covered in
    this research!

66
13 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
Write a Comment
User Comments (0)
About PowerShow.com