Enum within an enum

前端 未结 3 573
轻奢々
轻奢々 2020-12-03 09:42

This isn\'t a matter of me being stuck, but rather I\'m looking for a tidy way to write my code.

Essentially, I\'m writing an event driven application. The user trig

3条回答
  •  暖寄归人
    2020-12-03 10:29

    Perhaps use an inheritance hierarchy for the Events?

    So you have:

    - abstract Event
    -- MoveEvent(Direction)
    -- FooEvent()
    -- BarEvent()
    

    It may make more sense to have:

    - abstract Event
    -- abstract MoveEvent
    --- MoveUpEvent
    --- MoveDownEvent
    --- MoveRightEvent
    --- MoveLeftEvent
    -- FooEvent
    -- BarEvent
    

    If all the Move events have a distance, then pass that into the MoveEvent constructor (which will ripple down).

提交回复
热议问题