Giter VIP home page Giter VIP logo

goddamninheritance's Introduction

God Damn Inheritance Design Pattern

The God Damn Inheritance desing pattern derives from the Fuckington design pattern, but instead of forcing the user to implement a FUCK class that instantiate the Fuckington, the God Damn Inheritance defines a class where the ONLY way to use it is by implementing a class named GOD_DAMN_INHERITANCE (yes, the uppercase words 'god damn inheritance' joined by underscores '_') in your code and the GOD_DAMN_INHERITANCE class MUST inherit your class.

In a God Damn Inheritance all methods and/or members are private (including all constructors and desctructors) your God Damn Inheritance class MUST have a friend class called GOD_DAMN_INHERITANCE, the God Damn Inheritance itself has to have at least on pure virtual non-static private method, that will forces the user to implement the GOD_DAMN_INHERITANCE inheriting your class and implementing this pure virtual method whatever he wants.

A good pratice to combine with the God Damn Inheritance is mading all the methods statics so the GOD_DAME_INHERITANCE class can also expose than as static methods and the entire code that uses your implementation will look like this:

GOD_DAMN_INHERITANCE::DoStuff();
GOD_DAMN_INHERITANCE::DoSomething();
GOD_DAMN_INHERITANCE::StopDoingThis();

In the GOD_DAMN_INHERITANCE class the user can expose the private methods and/or members whatever he wants. The GOD_DAMN_INHERITANCE class can combine by inheritance how many God Dman Inheritance class you want.

A God Damn Inheritance class will look like this:

class GOD_DAMN_INHERITANCE;

class MyGodDamnInheritance {
    friend class GOD_DAMN_INHERITANCE;

   private:
    MyGodDamnInheritance() = default;
    ~MyGodDamnInheritance() = default;

    virtual void OverrideThis() = 0;

    static int MyGodDamnSum(int a, int b)
    {
        return a + b;
    }
};

You can see a God Damn Inheritacen full example in the "damn_inheritance.h" file included in this Git repository and also the God Damn Inheritance usage in the "example.cc" file.

goddamninheritance's People

Contributors

gringolito avatar

Stargazers

Natanael Rabello avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.