我有几种相同方法的实现:SetRateForMeasure
package repartition
type Repartition interface {
Name() string
Compute(meters []models.Meter, totalsProd, totalsConso map[string]float64) []models.Meter
SetRateForMeasure(meter models.Meter, measure models.Measure, total float64) float64
}
然后,在我的代码中(在repartition.go中),我称之为:
rate := repartition.SetRateForMeasure(meter, measure, total)
其中,重新分区是之前定义的接口。
问题是,当我添加此方法的新实现时,我的函数的参数可能会有所不同。
例如,静态重新分区使用仅在此情况下使用的静态百分比。
我最终添加了参数,以便我为所有方法提供了一个通用接口,但是根据实现的不同,它会导致有很多未使用的参数。
如果我将其添加到公共接口,它将不用于其他定义。
我试图从我的接口定义中删除此方法,但现在
rate := repartition.SetRateForMeasure()
不再定义。
我应该如何组织我的代码?
元芳怎么了
温温酱
相关分类