You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by "Fred Ji (JIRA)" <ji...@apache.org> on 2017/03/22 00:48:41 UTC

[jira] [Created] (SAMZA-1160) Migrate MapConfig inherited Java classes to use composition over inheritance

Fred Ji created SAMZA-1160:
------------------------------

             Summary: Migrate MapConfig inherited Java classes to use composition over inheritance
                 Key: SAMZA-1160
                 URL: https://issues.apache.org/jira/browse/SAMZA-1160
             Project: Samza
          Issue Type: Task
            Reporter: Fred Ji


In Samza code, we have a lot of classes with the name "*Config" which inherits from MapConfig but only intending to exposing the APIs for the specific configuration.

For example, JavaStorageConfig, it currently extends MapConfig, but it only intends to manage/fetch storeNames and store related configs, but not other configs. With the inheritance, it does not have good encapsulation and it allows the object JavaStorageConfig to call any public API from MapConfig as well, for example, javaStorageConfig.get("yarn.resources.package.path"). With it, it mixes up the business logic for different types of Config.

A proposal for addressing this is to do composition over inheritance, each type of Config, for example, JavaStorageConfig can have a member variable config which can leverage the interface of Config class (or the implementation of MapConfig) but not exposing the APIs of Config further down. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)