Typescript class composition


#1

Hey guys,

I have a Project with a User class which has a Position attribute (custom class). From this Position class, I wanna have an User’s class attribute how can I do this ?

Thanks for your help :slight_smile:


#2

My position is that the only things that should be classes in your app are concrete things that are instantiated by the DI system. Any business logic that you are managing yourself (generally from reanimated JSON received from servers) should be interfaces, not classes.

I also consider it a design flaw in general when a B can be embedded in an A, and there is a need for knowing what A we are in having only a B. Every time I’ve tried that, I ended up going back later and scrapping the design.