K
kk_oop
Hi. I'm looking to find a way to apply Design by Contract in my C++
programs.
The problem that I'm having deals with pure abstract base classes.
Since these are often how an object gets exposed to clients via
polymorphism, it seems critical that an abstract base class can define
and enforce its contracts. Defining contracts is critical, so LSP can
be utilized when defining derived implementation classes. However, if
the pure abstract base class defines a method to enforce its contract,
it will no longer be pure abstract. This poses a problem, for instance,
if the abstract class is being used to apply multiple interface
inheritance. In that case, the abstract class really needs to be pure
abstract.
Is there a way for C++ to somehow enable an pure abstract base class to
enforce its contracts? Seems like an unfixable paradox.
Any thoughts?
Thanks,
Ken
programs.
The problem that I'm having deals with pure abstract base classes.
Since these are often how an object gets exposed to clients via
polymorphism, it seems critical that an abstract base class can define
and enforce its contracts. Defining contracts is critical, so LSP can
be utilized when defining derived implementation classes. However, if
the pure abstract base class defines a method to enforce its contract,
it will no longer be pure abstract. This poses a problem, for instance,
if the abstract class is being used to apply multiple interface
inheritance. In that case, the abstract class really needs to be pure
abstract.
Is there a way for C++ to somehow enable an pure abstract base class to
enforce its contracts? Seems like an unfixable paradox.
Any thoughts?
Thanks,
Ken