DEV Community

Discussion on: What does inheritance mean when we talk about programming?

Collapse
 
stradivario profile image
Kristiqn Tachev • Edited

Totally agree with you!

I use classes only for "facades" and to structure better the actual code but i do not extend them.

Mostly i am using Reader monadic approach inspired from haskell

export type Reader<T, K> = (d?: T) => K;
Enter fullscreen mode Exit fullscreen mode

The way it is used

class MyClass {
  myMethod() {
    return 1;
  }
}
const myFunction: Reader<[MyClass], number> = () => ([myClass]) => myClass.myMethod()
Enter fullscreen mode Exit fullscreen mode

const myClass = new MyClass ();
myFunction()([myClass])
Enter fullscreen mode Exit fullscreen mode

This pattern suits me well and i have invested some time to create @rhtml/di

Dependency injection written in typescript and working inside Deno also

github.com/r-html/rhtml/tree/maste...

Cheers!

Collapse
 
leobdev profile image
Leo Barnuevo

Thanks for your contribution! I really appreciate it