Skip to main content

I have three classes that work together to do one function (from the perspective of the rest of my program). There is a little bit of set up between them, so, to make it easier for the rest of my program, I grouped them into a ListManager object, which initializes them to the right values when it is constructed. The three objects it stores are: Timer, TriggerManager, and CueList. CueList is a linked list with the usual getters and setters that come with that. TriggerManager is basically a wrapper around an ArrayList that manages Trigger objects.

  • ListManager: object, which initializes them to the right values when it is constructed. The three objects it stores are:

    • Timer:
    • TriggerManager: basically a wrapper around an ArrayList that manages Trigger objects
    • CueList: a linked list with the usual getters and setters that come with that.

Since the rest of my program is only interacting/referencing the TriggerManagerTriggerManager class, should I write wrapper methods for the objects it manages? So should I make ListManager.add(Cue c) as a wrapper for CueList.add(Cue c). OR should I just add getters for the three objects and let the rest of my program use that to manipulate them.

  1. So should I make ListManager.add(Cue c) as a wrapper for CueList.add(Cue c).
  2. OR should I just add getters for the three objects and let the rest of my program use that to manipulate them.

I tend to think that the later option is far more maintainable, but at the same time, the code produced if I make the wrapper just seems... prettier...

What's the best practice in situations like this?

I have three classes that work together to do one function (from the perspective of the rest of my program). There is a little bit of set up between them, so, to make it easier for the rest of my program, I grouped them into a ListManager object, which initializes them to the right values when it is constructed. The three objects it stores are: Timer, TriggerManager, and CueList. CueList is a linked list with the usual getters and setters that come with that. TriggerManager is basically a wrapper around an ArrayList that manages Trigger objects. Since the rest of my program is only interacting/referencing the TriggerManager class, should I write wrapper methods for the objects it manages? So should I make ListManager.add(Cue c) as a wrapper for CueList.add(Cue c). OR should I just add getters for the three objects and let the rest of my program use that to manipulate them.

I tend to think that the later option is far more maintainable, but at the same time, the code produced if I make the wrapper just seems... prettier...

What's the best practice in situations like this?

I have three classes that work together to do one function (from the perspective of the rest of my program). There is a little bit of set up between them, so, to make it easier for the rest of my program, I grouped them into:

  • ListManager: object, which initializes them to the right values when it is constructed. The three objects it stores are:

    • Timer:
    • TriggerManager: basically a wrapper around an ArrayList that manages Trigger objects
    • CueList: a linked list with the usual getters and setters that come with that.

Since the rest of my program is only interacting/referencing the TriggerManager class, should I write wrapper methods for the objects it manages?

  1. So should I make ListManager.add(Cue c) as a wrapper for CueList.add(Cue c).
  2. OR should I just add getters for the three objects and let the rest of my program use that to manipulate them.

I tend to think that the later option is far more maintainable, but at the same time, the code produced if I make the wrapper just seems... prettier...

What's the best practice in situations like this?

Source Link
sinθ
  • 1.3k
  • 1
  • 15
  • 25

Should I write a wrapper within a manager object?

I have three classes that work together to do one function (from the perspective of the rest of my program). There is a little bit of set up between them, so, to make it easier for the rest of my program, I grouped them into a ListManager object, which initializes them to the right values when it is constructed. The three objects it stores are: Timer, TriggerManager, and CueList. CueList is a linked list with the usual getters and setters that come with that. TriggerManager is basically a wrapper around an ArrayList that manages Trigger objects. Since the rest of my program is only interacting/referencing the TriggerManager class, should I write wrapper methods for the objects it manages? So should I make ListManager.add(Cue c) as a wrapper for CueList.add(Cue c). OR should I just add getters for the three objects and let the rest of my program use that to manipulate them.

I tend to think that the later option is far more maintainable, but at the same time, the code produced if I make the wrapper just seems... prettier...

What's the best practice in situations like this?