Graph Buddy

Semantic Code Graph seamlessly integrated with IDE

Typical software problems

  • Code structure degradations over time.
  • Problems with library updates or replacements.
  • Reading, browsing and understanding the poorly structured source code is hard.

Fixing current broken state

  • What are the natural candidates for separate modules?
  • What are the problematic parts?
  • Can we do that gradually?
  • Can we automate the process?

Maintaining a clear project structure

There are no tools to assist software development in that regard.

  • What about monitoring new releases and validating the project structure changes?
  • Is our piece of software going into right direction?
  • How do we prevent unintended dependency across different software modules?

Visual help

Applying graph theory

  • Particular nodes
    • Betweenness centrality
    • Clustering coefficient
    • Modularity class
  • Whole graph
    • Finding communities
    • Average node degree
    • Graph diameter
    • Modularity 
    • Graph depth

Where we want to be

 hypothesis:

the code structure of any program can be represented as a directed graph, precise enough to be valuable in various analyses and visualizations

Semantic Code Graph

Semantic Code Graph in Scala

class A()
object AFactory {
  def createA() = {
    new A()
  }
}

Semantic Code Graph in Scala

class A()
object AFactory {
  def createA() = {
    new A()
  }
}

Code Syntax + Semantics

  • Code Structure
    • Scala Trees
  • Code Semantics
    • SemanticDB

Common format

syntax = "proto3";

message Location {
    string uri = 1;
    int32 startLine = 2;
    int32 startCharacter = 3;
    int32 endLine = 4;
    int32 endCharacter = 5;
}

message Edge {
    string to = 1;
    string type = 2;
    Location location = 3;
    map<string, string> properties = 4;
}

message GraphNode {
    string id = 1;
    string kind = 2;
    Location location = 3;
    map<string, string> properties = 4;
    string displayName = 5;
    repeated Edge edges = 6;
}

message SemanticGraphFile {
    string uri = 1;
    repeated GraphNode nodes = 2;
}

Graph Buddy process

Graph Buddy architecture

Future use cases

  • Project visualizations
    • getting insight on how the current software is structured
  • Project modularization guidance
    • possible modules extractions
    • exposing architectural smells
    • finding critical for migration places
  • Release changes analysis
    • are we on right track with our migration?
  • Choosing the right reviewer for code changes
Made with Slides.com