Why Use convert2string() in UVM When We Can Simply Use display()?

I’m trying to understand the practical advantages of convert2string() in UVM.

In plain SystemVerilog, I often create a transaction class with a custom display method:

class transaction;

  int addr;
  int data;

  function void display();
    $display("addr=%0h data=%0h", addr, data);
  endfunction

endclass

Then I can call:

tr.display();

from the driver, monitor, scoreboard, or anywhere else.

In UVM, many engineers recommend implementing:

function string convert2string();
  return $sformatf("addr=%0h data=%0h", addr, data);
endfunction

instead.

My questions are:

  1. What practical benefits does convert2string() provide over a normal display() method?

  2. Why return a string using $sformatf() instead of directly using $display()?

  3. In real projects, do engineers typically use only convert2string(), only display(), or both?

  4. Can you share situations where convert2string() becomes significantly more useful than a custom display method?

Looking for real-world verification/UVM perspectives rather than textbook definitions.

In a UVM testbench you should neither use $display nor convert2string explicitly. Instead use `uvm_info. This provides moe detailed information about time and where it comes from than display.