Writing enterprise applications in Go with high unit test coverage

Hi Gophers,

I am working on enterprise applications and writing it using Go. One thing that I am noticing is that we are not following go idioms, like package and interface naming convention are not being followed. We are layering our code as business layer, dal layer and using factory and abstract factory pattern (interfaces) to define the contracts. So we are end up using lot’s of interfaces and this is making code is less readable for other developers.

We followed this approach to decouple and abstract the problems and more of achieving high code coverage. By using interface contract we are able to mock the calls and able to achieve high code coverage.

Wanted to check if this approach is right or not and if not what is suggested in Go to handle this problem.

Thanks,
Praveen Upadhyay

It sounds like you are bringing in a lot of baggage from Java or C# and trying to implement a type hierarchy.

Specifically you say [quote=“praveen24989, post:1, topic:4769”]
We are layering our code as business layer, dal layer and using factory and abstract factory pattern (interfaces) to define the contracts.
[/quote]

Which I interpret to mean, you are writing things twice; once as an interface, and once as a single implementation. My advice is to step back and write only the code you need to solve your problem today.

Can you give some specific examples of code that you have written and are concerned about?

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.