Software Engineering Principles and Practices / Software Maintainance & Evolution

Reverse Engineering

In software engineering, Reverse Engineering is the process of analyzing a system to identify its components and their interrelationships, and to create representations of the system in another form or at a higher level of abstraction.

Simply put: it is the process of going backward through the development lifecycle—starting with the source code and working back toward the design and requirements.


1. The Direction of Engineering

To understand Reverse Engineering, we must compare it to the standard flow:

  • Forward Engineering: Requirements $\rightarrow$ Design $\rightarrow$ Implementation (Code).

  • Reverse Engineering: Implementation (Code) $\rightarrow$ Design $\rightarrow$ Requirements.


2. Objectives of Reverse Engineering

Why would engineers want to work backward?

  • Understanding Complexity: To make sense of "Spaghetti Code" where no documentation exists.

  • Recovering Lost Information: In older "Legacy" systems, the original design documents are often lost or were never updated.

  • Detecting Side Effects: To understand how a small change in one module might break something deep within the system.

  • Facilitating Reuse: Identifying high-quality components within a large system that can be extracted and used in other projects.


3. The Levels of Reverse Engineering

Reverse engineering can happen at different "depths" depending on what the engineer needs to recover:

  1. Redocumentation: The simplest form. Generating new diagrams (like Flowcharts or Data Flow Diagrams) directly from the code.

  2. Design Recovery: Using the code, expert knowledge, and existing documentation to recreate the overall architecture and logic.

  3. Logic Recovery: Understanding the mathematical and logical algorithms used within specific functions.

  4. Data Recovery: Identifying the structure and relationships of the data stored in the system's databases.


4. Reverse Engineering Tools

Doing this manually is nearly impossible for large systems. Engineers use tools to automate the process:

  • Code Analyzers: Tools that read code and generate call graphs (showing which functions call which).

  • Decompilers: Tools that attempt to turn executable "machine code" back into readable source code.

  • Diagram Generators: Tools that can automatically draw UML Class Diagrams or Entity-Relationship Diagrams (ERD) from a database schema.


📊 Reverse Engineering vs. Re-engineering

Feature

Reverse Engineering

Software Re-engineering

Action

Analysis only.

Analysis + Modification.

Output

Better understanding/Diagrams.

A new, improved version of the system.

Code Change

Does not change the code.

Changes the code and structure.

Purpose

"How does this work?"

"How can we make this better?"


💡 The Ethical/Legal Boundary

It is important to note that reverse engineering is often used for Security Research (finding vulnerabilities) and Interoperability (making two systems talk to each other). However, reverse engineering proprietary software to steal "Trade Secrets" or bypass licensing is generally illegal and violates Terms of Service.