Sequence build in which phase

HI All,

Here is my code

  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    environment = env::type_id::create("env",this);
  endfunction : build_phase
  
  task run_phase(uvm_phase phase);
    seq = rand_sequence::type_id::create("seq",this);
    phase.raise_objection(this);
    seq.start(environment.seqr);
    
    phase.phase_done.set_drain_time(this, 20ns);
    phase.drop_objection(this);
      
  endtask : run_phase

env constructed in build phase, whereas seq constructed in run_phase.
Both can be constructed in build phase also.
I have ran the code by constructing boh in build phase, I am not seeing any simulation difference.

May I know will there be any advantage in terms of reuse or will this lead to any limitation?

Thank You,

I assume the code shown is your test component. All components must be constructed before the end of the build phase. All other classes just need to be constructed before the are used. As a general rule it’s best doing the construction as late as possible which gives you the most flexibility for factory overriding. But here in the test class it probably does not matter.