Is Virtual Sequence Base class mandatory?

I’am referring to example mentioned in following link: VirtualSequencer
for Virtual Sequences with Virtual Sequencer, Is it mandatory to use Virtual Sequence Base class ??

Instead can we use only one class for VirtualSequence like below ??


class example_virtual_seq extends uvm_sequence #(uvm_sequence_item);
// m_sequencer
virtual_sequencer v_sqr;

// Local sub-sequencer handles
bus_master_sequencer bus;
gpio_sequencer gpio;
 
random_bus_seq bus_seq;
random_gpio_chunk_seq gpio_seq;
 
`uvm_object_utils(example_virtual_seq)
 
function new(string name = "example_virtual_seq");
  super.new(name);
endfunction
 
task body();
  if(!$cast(v_sqr, m_sequencer)) begin
    `uvm_error(get_full_name(), "Virtual sequencer pointer cast failed");
  end 
  gpio_seq = random_gpio_chunk_seq::type_id::create("gpio_seq");
  bus_seq = random_bus_seq::type_id::create("bus_seq");
 
  repeat(20) begin 
    bus_seq.start(v_sqr.bus);
    gpio_seq.start(v_sqr.gpio);
  end 
endtask: body
 
endclass: example_virtual_seq

In reply to vvv:
the using virtual sequence base class to get the handle of sequencers into it.
It uses the inheritance concept. In above code its less flexible when you want to inherit from this sequence. when sequence is extended from example_virtual_seq , super.body() will execute the sequences of base class(example_virtual_seq.)

class extended_virtual extends example_virtual_seq;
.......
task body();
super.body() --> it needs to get the sequencer handle but it also execute sequence as it is not intended
endtask

it will be less flexible for factory override .

In reply to kddholak:

Just to clear the air, The alternate way which i have used is not wrong, it will work.
But its not recommended to use it this way, Am i write ??

In reply to vvv:

See this line of code,

if(!$cast(v_sqr, m_sequencer)) begin
  `uvm_error(get_full_name(), "Virtual sequencer pointer cast failed");
end

As you are not using base sequence to do this task, you need to write this code in all the sequences you create. For this case, it’s totally fine if you do not use a base sequence. But when repetition or common properties/methods gets more and more, it’s better to create a base sequence as change in one place can be effective in all sequences.

Also, instead of casting m_sequencer to v_sqr in body() method, you can create user defined function/method to do the task as well.