Exploring Code Structure: A Crowdsourced Graph Database Approach to Software Reuse

A graph database based crowdsourcing infrastructure for modelling and searching code structure

2014-11-11
Zeqi Lin, Junfeng Zhao, Bing Xie
Summary
Problem
Method
Results
Takeaways
Abstract

This paper introduces a graph-database-based crowdsourcing infrastructure for modeling and searching code structures. It leverages a labeled directed graph (CodeGraph) to represent software elements and relationships, utilizing Natural Language Processing (NLP) to map developer queries to specific analysis plugins contributed by the community.

TL;DR

Understanding complex code structures is the "final boss" of software reuse. This paper introduces a crowdsourcing infrastructure that transforms source code into a CodeGraph stored in a graph database. By allowing developers to contribute custom analysis plugins, it transforms natural language queries (like "Show me the inheritance tree") into precise visual subgraphs, boosting reuse efficiency by 17%.

Background: The Structural Blind Spot

When we reuse code, we don't just need to find a snippet; we need to understand how it lives within a system. Most current search engines excel at "What does this code do?" (textual search) but fail at "How does this code connect?" (structural search). Mapping out call sequences or inheritance hierarchies manually is a cognitive burden.

The researchers at Peking University recognized that no single algorithm can predict every structural question a developer might ask. Their solution? Collaborative Intelligence.

Problem & Motivation: Beyond the "Bag of Words"

Existing tools fall into two traps:

  1. The Language Barrier: Formal code query languages (like Wiggle or .QL) are powerful but require developers to learn a complex domain-specific language (DSL).
  2. The Granularity Trap: Tools like ASTs (Abstract Syntax Trees) are too detailed for human consumption, making it hard to see the forest (architecture) for the trees (individual statements).

The authors aimed to create a system that is as easy as a Google search but as structurally representative as a database.

Methodology: The CodeGraph & Crowdsourcing Pool

1. Modeling the CodeGraph

The core of the system is the GraphBuilder. It parses source code into an AST and then selectively simplifies it into a CodeGraph.

  • Nodes: Represent "Main Nodes" like Classes, Methods, and Interfaces.
  • Edges: Represent relationships like extend, implement, call, and operate.

Architectural Overview of the Infrastructure

2. The Plugin Pool & NLP

To bridge the gap between human language and graph queries, the infrastructure uses:

  • NLP Module: Parses the grammar of a query and links nouns to specific CodeGraph nodes.
  • Semantic Discriminant: Each plugin has a rule to decide if it's the right "tool for the job."
  • Feedback Module: Uses a voting system based on user selection to improve which plugins are recommended first for future queries.

3. Function Library: Easing the Burden

Writing a graph query is hard. The authors provided a Function Library that abstracts complex graph traversals into simple functions like extend(node) or callSeq(node). This allows contributors to write powerful analysis tools in just a few lines of code.

Experiments & Results: Real-World Gains

The framework was tested on major open-source projects like Apache Lucene and Apache POI.

Key Quantitative Findings:

  • Efficiency: Developers using the system were 17% faster at completing complex reuse tasks.
  • Development Speed: An inheritance tree plugin took only 4 lines of code with the infrastructure, compared to 93 lines using traditional AST parsing.

Model Architecture Success - Inheritance Tree Example

In an industrial case study for a "Smart City" program, developers created specialized plugins like StoreInDB (see result below), which visualizes exactly how data flows from a specific class to the database layer.

Sample Result for "How to store class GpsData?"

Critical Analysis & Conclusion

Takeaway

The genius of this work isn't just the use of graph databases—it's the crowdsourcing mechanism. By acknowledging that "search purposes are not determined," the authors built a flexible meta-tool that grows more capable as more developers use it.

Limitations & Future Work

While effective, the current system relies heavily on the quality of the "Semantic Discriminants" in the plugins. With the rise of Large Language Models (LLMs) since 2014 (the time of original publication), the NLP module could be significantly upgraded to handle more nuanced queries without requiring manual rule-matching for plugins. Expanding the "CodeGraph" to include cross-language dependencies (e.g., a Java backend calling a SQL database) remains a promising frontier.

By turning code structure into a searchable, contributable community resource, this infrastructure paves the way for a more collaborative approach to mastering software complexity.

Find Similar Papers

Try Our Examples

  • Find recent research papers that utilize graph databases like Neo4j for large-scale source code representation and vulnerability detection.
  • What are the seminal papers on "Search-Driven Software Engineering" (SDSE), and how does this paper's NLP-to-graph approach build upon them?
  • Explore how Large Language Models (LLMs) are currently being integrated with Knowledge Graphs or Graph Databases to improve code structural analysis and navigation.
Contents
Exploring Code Structure: A Crowdsourced Graph Database Approach to Software Reuse
1. TL;DR
2. Background: The Structural Blind Spot
3. Problem & Motivation: Beyond the "Bag of Words"
4. Methodology: The CodeGraph & Crowdsourcing Pool
4.1. 1. Modeling the CodeGraph
4.2. 2. The Plugin Pool & NLP
4.3. 3. Function Library: Easing the Burden
5. Experiments & Results: Real-World Gains
6. Critical Analysis & Conclusion
6.1. Takeaway
6.2. Limitations & Future Work