opentelekomcloud / gophertelekomcloud

GopherTelekomCloud is an OpenTelekomCloud clouds Go SDK
Apache License 2.0
19 stars 9 forks source link

Style: `Builder` interface is redundant #274

Open outcatcher opened 2 years ago

outcatcher commented 2 years ago

In most cases <Smth>Builder interface has only one implementation, so this seems to be redundant in this case.

Pros in having interfaces:

  1. Other implementations can be used
  2. No implementation details available for the consumer (seems useless, as a consumer is declared in the same place)
  3. nil value is always correct input
  4. Can be mocked in tests (not used)
  5. Already in style guide

Cons in having interfaces:

  1. More code
  2. More public members in the package
lego963 commented 2 years ago

We can't do it right now, because we use ValueSpecs to extend struct

Aloento commented 2 years ago

If you know the Entity Framework, you can also find many interfaces with only one global implementation.

outcatcher commented 2 years ago

Not my problem anymore, but if you see someone using some approach, it doesn't matter it fits your cases — every approach has pros and cons, it's common to select approach fitting your needs 🤷‍♂️

Aloento commented 2 years ago

@outcatcher For me personally, I define their interfaces before I implement the functions and then do next.

outcatcher commented 2 years ago

I suppose both approaches are generally okay (though I personally prefer the simplest/with the least code). So that was a question if another way can be adopted — to be discussed whenever it should be closed or added to a backlog as a future plan.

Aloento commented 2 years ago

According to the discussion, we consider it redundant so it will be gradually cleaned up.