Concept Location

Michael L. Collard, Ph.D.

Department of Computer Science, The University of Akron

Art of Illusion

  • 3D Modeling Studio
  • Written in Java
  • 487 classes
  • 153,645 LOC
  • Source

Art of Illusion Current Zoom

Change Request

Implement a zoom control

  • Currently, the only way to zoom is to enter the zoom value into a text box
  • Value of the zoom has to be typed in by the user
  • Default value is 100%
  • Implement zooming control that uses arrow keys

Role of Concept Location

  • Concept location is how we find the code snippet where the change should be made
  • Change requests are most often formulated in terms of domain concepts
  • E.g., "Correct error when trying to paste text"
  • Developer must find in the code the locations where the concept "paste" is located
  • This is the start of the change

Partial Code Comprehension

  • A single person cannot completely comprehend large programs
  • This is especially true when programs are undergoing changes
  • Developers seek the minimum essential understanding for the particular software task
  • Use an "as-needed strategy"
  • Analogy: first few days at a university

Concept Triangle

Concept Triangle

  • Name Name of a concept
  • Dog, chien, etc.
  • Intension An essential property or group of properties of a thing
  • Hairy, four-legged animal with fur …
  • Extension A specific example
  • Lassie, Fido, Millie, Bo

Concept Location

  • Concept extensions are implemented as code fragments
  • variables, classes, methods, etc.
  • Developers find these code fragments
  • Easier in small programs or the programs the developer is familiar with
  • Difficult in large programs or programs that the developer is not familiar with

Search Process

Formulating a Query

  • Extract the set of concepts used in the change request
  • Delete any concepts that are communication with the programmers
  • Delete the concepts that are unlikely to be implemented in the code
  • Concepts related to things outside of the scope of the program
  • Concepts that are unimplemented
  • Rank the remaining concepts by the likelihood that they can be easily located

E.g., Point of Sale System

  • Change request: "Implement a credit card payment"
  • Identify the concepts
  • implement
  • credit card
  • payment

E.g., Point of Sale System

  • Change request: "Implement a credit card payment"
  • Identify the concepts
  • implement communication with programmer
  • credit card
  • payment

E.g., Point of Sale System

  • Change request: "Implement a credit card payment"
  • Identify the concepts
  • implement communication with programmer
  • credit card unimplemented
  • payment

E.g., Point of Sale System

  • Change request: "Implement a credit card payment"
  • Identify the concepts
  • implement communication with programmer
  • credit card unimplemented
  • payment Significant, searchable concept

Recognizing Concepts

  • Code Reading
  • Identifiers
  • Comments
  • Experiment
  • Change the code slightly and see what happens

Code Analysis

  • static program analysis
  • Analysis of software source code and other artifacts

  • dynamic program analysis
  • Analysis of output/trace data from running programs

Concept Location Approaches

  • Human knowledge
  • Traceability tools
  • Dynamic search (execution traces)
  • Static search
  • Pattern Matching
  • Dependency Search
  • IR (Information Retrieval) techniques

grep

  • grep (global regular expression print)
  • grep prints out the lines from files that contain a match for a regular expression
  • UNIX tool, but features built into many IDEs
  • Advantages: Extremely fast, regex
  • Disadvantages: Does not understand the syntax

Concept Location with grep

  • Classical technique for concept location based on pattern matching
  • Developer formulates a query based on the concept name or names
  • grep searches the files
  • Finds corresponding lines of code, i.e., hits
  • Developer investigates the hits
  • If the search fails, repeat with a new query
  • Developer learns from failed search

Art of Illusion

  • 3D Modeling Studio
  • Written in Java
  • 487 classes
  • 153,645 LOC
  • Source

Change Request

Implement a zoom control

  • Currently, the only way to zoom is to enter the zoom value into a text box
  • Value of the zoom has to be typed in by the user
  • Default value is 100%
  • Implement zooming control that uses arrow keys

Concept Location: Use grep

  1. Search for "zoom"

Concept Location: Use grep

  1. Search for "zoom" - Returned 3 irrelevant lines

Concept Location: Use grep

  1. Search for "zoom" - Returned 3 irrelevant lines
  2. Search for "scale"

Concept Location: Use grep

  1. Search for "zoom" - Returned 3 irrelevant lines
  2. Search for "scale" - Returned 1733 lines, 170 classes, too large for inspection

Concept Location: Use grep

  1. Search for "zoom" - Returned 3 irrelevant lines
  2. Search for "scale" - Returned 1733 lines, 170 classes, too large for inspection
  3. Search for "100" in results for "scale"

Concept Location: Use grep

  1. Search for "zoom" - Returned 3 irrelevant lines
  2. Search for "scale" - Returned 1733 lines, 170 classes, too large for inspection
  3. Search for "100" in results for "scale" - Returned 5 results in classes IconGenerator, ViewerScaleControl, and ViewerCanvas

Concept Location: Use grep

  1. Search for "zoom" - Returned 3 irrelevant lines
  2. Search for "scale" - Returned 1733 lines, 170 classes, too large for inspection
  3. Search for "100" in results for "scale" - Returned 5 results in classes IconGenerator, ViewerScaleControl, and ViewerCanvas
  4. Inspection

Concept Location: Use grep

  1. Search for "zoom" - Returned 3 irrelevant lines
  2. Search for "scale" - Returned 1733 lines, 170 classes, too large for inspection
  3. Search for "100" in results for "scale" - Returned 5 results in classes IconGenerator, ViewerScaleControl, and ViewerCanvas
  4. Inspection - class ViewerCanvas is most likely the location

Concept Location: Another Approach

  • grep does not take into account syntax (such as classes) or organization of Object-Oriented programs
  • Object-Oriented programs are organized into classes
  • Classes form a dependency structure, which we could use to find the location
  • Equivalent to an organizational structure but graph based

Class Dependency Graph

  • Similar to UML Class Model, but only interested in dependencies and the dependency part of higher-level relationships
  • Point of Sale CDG

Art of Illusion

  • 3D Modeling Studio
  • Written in Java
  • 487 classes
  • 153,645 LOC
  • Source

Change Request

Implement a zoom control

  • Currently, the only way to zoom is to enter the zoom value into a text box
  • Value of the zoom has to be typed in by the user
  • Default value is 100%
  • Implement zooming control that uses arrow keys

Concept Location: Dependency Search

  • Uses CDG
  • local functionality concepts that are directly implemented in the module (class) and not delegated to other modules (classes)
  • composite functionality concepts that are directly implemented in the module (class), and concepts delegated to other modules (classes)
  • Determined by code reading and documentation

Example: Dependency Search

  • Where to start? Equivalent to main()
  • Was ModellingApp, now ArtOfIllusion
  • Inspect: class ArtOfIllusion
  • Read comments, and variable names, may even search
  • Concept not contained locally
  • The class LayoutWindow is responsible for constructing a window for each scene, so it seems a possibility

Example: Dependency Search

  • Inspect: class LayoutWindow
  • Concept is in the composite functionality, but not part of local functionality
  • It Looks like ValueField may implement the concept

Example: Dependency Search

  • Inspect: class ModelingApp, class ArtOfIllusion
  • Inspect: class LayoutWindow
  • Concept is in the composite functionality, but not part of local functionality
  • Looks like class ValueField may implement the concept
  • Inspect: class ValueField
  • Implements the text box
  • Concept is not present in the composite functionality
  • Backtrack to LayoutWindow

Example: Dependency Search

  • Inspect: class ModelingApp, class ArtOfIllusion
  • Inspect: class LayoutWindow
  • Inspect: class SceneViewer
  • Several functions responsible for responding to user events
  • Function updateImage() responsible for screen repainting
  • In the composite functionality, but not local functionality

Example: Dependency Search

  • Inspect: class ModelingApp, class ArtOfIllusion
  • Inspect: class LayoutWindow
  • Inspect: class SceneViewer
  • Inspect: class ViewerCanvas
  • Success! Contains the concept

Violet

  • Open-source UML editor
  • Supports drawing UML diagrams
  • E.g., Class, Sequence, State, Object, Use Case

Change Request

Record the author for each figure

  • Will make Violet more versatile
  • Supports cooperative work
  • Author that created the figure is more likely to know the semantics of the figure
  • Name of concept: "author"
  • Implicit concept extension
  • Not present in the current code
  • Where does it belong? figure properties

Locating Figure Properties

Software Change Review

  • Found it in class AbstractNode
  • Once implemented, it will work for all nodes, which is an even better feature-wise change
  • Increases the possible value of the change

Concept Triangle (Review)

Concept Terms (Review)

  • Name Name of a concept
  • E.g., cat, chat
  • Intension an essential property or group of properties of a thing
  • E.g., A small domesticated carnivorous mammal with soft fur, a short snout, and retractile claws
  • Extension a specific example
  • Garfield, Socks

Comparison

  • grep
  • Explicit concepts of name, part of intension, or extension
  • Depends on the use of naming conventions
  • Independent of class structure
  • Does not work for implicit concepts
  • static dependency search
  • Suitable for explicit and implicit concepts
  • Utilizes the class structure
  • Requires correct understanding of composite and local functionality