Subscribe to MentalFloss Minutes        RSS Feed
-----

Programming Construct Idea

Icon Leave Comment
So, I was thinking about OOP and inheritance, and I got to thinking about a new construct in OOP where you specify dominant and recessive properties/methods like with real inheritance.

Consider two objects Mother, Father in a fictional language:

class Mother
{
    dominant void doWork()
    {

    }

    void beMotherly()
    {

    }
}

class Father
{
    void doWork()
    {

    }

    void beFatherly()
    {

    }
}



Then, you could create a new object that doesn't have a particular type itself, but is instead a juxtaposition of both provided types upon construction.

Child child = new (Father, Mother);
child.doWork(); // calls mother's doWork();
child.beMotherly();
child.beFatherly();



I think this could be interesting if developed further.

0 Comments On This Entry

 

June 2019

S M T W T F S
      1
2345678
9101112131415
161718 19 202122
23242526272829
30      

Tags

    Recent Entries

    Recent Comments

    Search My Blog

    1 user(s) viewing

    1 Guests
    0 member(s)
    0 anonymous member(s)