“Sets” of a particular enum type but with generics

后端 未结 4 1978
北荒
北荒 2021-01-31 16:24

Let\'s say I have an abstract class

public abstract class Trainer{}

I have specific trainers like :

pub         


        
4条回答
  •  后悔当初
    2021-01-31 16:40

    I will post that for further consideration, even there is already accepted answer

    If you read this question, consider using more loose coupled elements, with aggregation etc. instead of highly specific and complicated type hierarchy and generics.

    With just plain aggregation you can achieve at least the same type & logical safety, but loose coupled design. Like I mentioned in comments:

    Propably better will be more collections, agregations etc. to ensure type safety and elasticyty together (different trainers with different abilities to different animals in any combinations, including mixing, not locking a person to be a super-specific training master for some super specific abilities of specific animal and nothing more).

    Of course I mean a "John than can teach horse to trot and a dog to bark", not "John that can teach horse or dog to trot or bark"

提交回复
热议问题