SystemVerilog OOP Mastery · All levels

Pure Virtual Methods as Compile-Time Contracts: Pitfalls

Pitfalls for Pure Virtual Methods as Compile-Time Contracts.

Pitfalls and red flags

  • Changing method argument types/order in a subclass, which breaks contract matching.

  • Assuming a partially implemented subclass is constructible even when required methods are still missing.

  • Declaring required hooks as regular virtual methods and accidentally allowing incomplete concrete classes.

  • Using pure virtual methods for optional behavior that should instead have safe default implementation.

Related topics