binchoo / PaimonGanyu

여행 비서 페이몬! Genshin Impact AWS workflows & KakaoTalk chatbot skills
https://pf.kakao.com/_mtPFb
GNU General Public License v3.0
7 stars 1 forks source link

[AwsUtils] Refactor AwsEventWrapperFactory's APIs #15

Closed binchoo closed 2 years ago

binchoo commented 2 years ago

As-is:

  1. AwsEventWrapperFactory depends on EventWrapperMapping instance.
  2. Its behaviors are changed by the AwsEventWrapperFactoryConfigurer instance that configures an EventWrapperMapping instance.
  3. This means AwsEventWrapperFactory relies on dynamic dependencies. However it has two static factory methods, one of which creates a AwsEventWrapper, the other creates a customized AwsEventWrapperFactory. This is why it has a strange interface for creating customized instances.
    var eventWapper = AwsEventWrapperFactory.getWrapper(snsEvent);
    var customFactory = AwsEventWrapperFactory.create(configurer);
    var eventWrapper2 = customFactory.getWrapper(snsEvent);
    • Line 1 and 3 create AwsEventWrappers.
    • Besides, Line 2 creates AwsEventWrapperFactory.
    • This is not a comprehensive interface.

To-be:

  1. Add a static factory method to create the default AwsEventWrapperFactory instance: getDefault().
  2. Add a static factory method to create custom AwsEventWrapperFactory instances: newInstance().
  3. Add a private constructor: AwsEventWrapperFactory(AwsEventWrapperFactoryConfigurer).
  4. Remove the static getWrapper() method. Make it non-static.