jakartaee / config

Jakartaconfig project
Apache License 2.0
21 stars 16 forks source link

Fluent Builder API vs Builder pattern #210

Open jansupol opened 8 months ago

jansupol commented 8 months ago

The current Loader API looks

Loader.bootstrap().load()

However, we probably want to add other enrichments to the API, such as converters or sources. Then we would have something like

Loader.bootstrap().converter(...).source(...).load()

Which would make Loader mutable. Then we have two possibilities:

  1. To return a new instance of Loader for each converter, source, and other calls
  2. To use a Builder pattern using Loader.bootstrap().build().load() which would more nicely turn into Loader.builder().build().load()

In summary, should we use bootstrap() method, or builder() method?