Interface class in UVM objects

Hi UVM forum,
Hi have class named packet_object that extends uvm_object.
many other classes extend packet_object and each one of them do something else.
I want to make sure that each class implements certain methods.
I use interface class to do it and it works, but I am little bit concern that this method is not so common.
Is there a better and more conventional way to do it?


class interface packet_must;
  pure virtual function string get_packet_name();
endclass

class packet_object extends uvm_object implements packet_must;
  ...
  virtual function string get_packet_name(); end_function
endclass

class packet_eth extends packet_object implements packet_must;
  ...
  virtual function string get_packet_name();
    return "packet eth"; 
  endfunction
endclass

In reply to shimonc:

I would consider making packet_object a virtual class and declare get_packet_name() as a pure virtual function inside the packet_object class.

This would enforce the requirement that every class derived from packet_object provides
an implementation of the get_packet_name() function.

But then I will not be able to construct the child’s using


function new (string name="child")
  super.name(name);
endfunction

Because virtual class cant have a constructor.
But I do need that ‘child’ extend uvm_object.

In reply to shimonc:

There are a growing number of papers and examples using interface classes with the UVM.

https://verificationacademy.com/forums/systemverilog/application-interface-classes-system-verilog#reply-42564

https://verificationacademy.com/forums/uvm/multiple-inheritance

the second best paper of DVCon 2016 5.1 SystemVerilog Interface Classes - More Useful Than You Thought