Design patterns to reduce coupling in Swing application

后端 未结 7 1811
刺人心
刺人心 2021-02-09 12:20

Hey all, I\'m currently working on a Java Swing application and I was looking for some guidence. The application is fairly small, but I\'m noticing that as the code base is grow

7条回答
  •  执念已碎
    2021-02-09 12:58

    I don't agree with the people who suggest to use Event bus, because

    • because of code like EventBus.subscribe(SymbolListChangeEvent.class, this); your whole code will depend on a single event bus instance which makes it very hard to test,
    • it is hard to find out where a specific event is used.

    Instead I suggest to use interfaces to encapsulate external dependencies of a module. If you like, you can use them with the listener pattern, but generally are free to refactor everything if you like.

提交回复
热议问题