Is there an easy way to implement properties of an interface within a class instead of having to duplicate almost the exact same code with generic properties?

interface A
{
    @property int data();
    @property int data(int value);

}

class B : A
{
  @property int data() { return m_data; } // read property
@property int data(int value) { return m_data = value; } // write property
}

lots of duplicate info, specially when there are a lot of properties, and changing anything in the interface requires changing it in the class.

Instead I'd like to do something like

class B : A
{
    ....

    implement!A;
}

where implement!A implements all the properties and functions in A that are not already defined in B using simple methods(just returning default values for functions and wrapping a field for properties).

This way I can design the structural aspect of the software without having to worry about implementation but still do some basic testing. I can also slowly build up the functionality of the code by implementing properties and functions without having to worry about an all or nothing approach(or having to worry about the original problem of code duplication).

Reply via email to