BBVA / qed

The scalable, auditable and high-performance tamper-evident log project
https://qed.readthedocs.io/
Apache License 2.0
95 stars 19 forks source link

Avoid (and remove) constructors which does nothing and has confusing formatting #129

Open gdiazlo opened 5 years ago

gdiazlo commented 5 years ago

We have a lot of constructors like:

package foo

func NewT(p1, p2, p3.....pN) *T {
    return &T{
           p1, 
           p2, 
           p3,
           ...,
          pN}
}

I think those constructors are useless and need to be removed. Only if the constructor does actually something, like calling make() or call other New() for its embedded types, should be preserved.

Also, on constructors, there is no need to repeat the parameters with huge names:

func New( myParameterTypedName TypedType, ....) T {
    return &T{
        myParameterTypedName: myParameterTypedName, 
        .....
    }

Could become

func New( p TypedType, ....) T {
    return &T{
        myParameterTypedName: p, 
        .....
    }

Last, I would love to avoid the form:

package foo

func NewT(
    p1, 
    p2, 
    p3,
    ...,
    pN) *T {
    return &T{
           p1, 
           p2, 
           p3,
           ...,
          pN}
}

It is confusing to see what is the struct and what is not. The point of that format is just to accommodate long parameter names which are never used outside the function.