We need to think, do we really need default labels or not. And if answer is yes, we need to think, how we will implement it.
There is several ways to implement:
- Introduce new annotation
@DefLabel or @LabelDef that will be used only for methods. It will has a parameter name with specified label string.
- Increase functionality of
@Action annotation and defLabels parameter.
Maybe there are other considerable ways, but currently only two are accepted.
Why?:
There are cases, when analytic with same category and action has 2 or 3 different labels.
For example: _category_= quiz, _action_= send, _label_= question/answer
In current implementation we can create an enum with two variants:
enum class QuizSendLabel {
QUIESTION, ANSWER
}
And then pass it as a parameter of appropriate method:
interface AnalyticsQuiz {
fun send(label: QuizSendLabel)
}
But maybe in such cases it is more interesting to write something like:
interface AnalyticsQuiz {
@Action("send") @DefLabel("question") fun question()
@Action("send") @DefLabel("answer") fun answer()
}
It seems that result takes up more space, but we eliminate one enum class with two additional instances. So it can be more important for space critical apps.
Also, with second proposed approach in the beginning of issue it will look like:
interface AnalyticsQuiz {
@Action(name = "send", defLabel = "question") fun question()
@Action(name = "send", defLabel = "answer") fun answer()
}
Which gives us possibility to not use redundant annotation, but takes up even more space.
P.S.: There is 3rd less obvious solutions: annotation @LabelFun with parameter action
which will turn name of the method to label name and action is needed to be defined as a parameter, by user of library:
interface AnalyticsQuiz {
@LabelFun("send") fun question()
@LabelFun("send") fun answer()
}
So it will take small space, but we will eliminate redundant objects and enum.
Also, it will have additional second parameter label for explicit defining a label.
We need to think, do we really need default labels or not. And if answer is yes, we need to think, how we will implement it.
There is several ways to implement:
@DefLabelor@LabelDefthat will be used only for methods. It will has a parameter name with specified label string.@Actionannotation anddefLabelsparameter.Maybe there are other considerable ways, but currently only two are accepted.
Why?:
There are cases, when analytic with same category and action has 2 or 3 different labels.
For example:
_category_= quiz, _action_= send, _label_= question/answerIn current implementation we can create an
enumwith two variants:And then pass it as a parameter of appropriate method:
But maybe in such cases it is more interesting to write something like:
It seems that result takes up more space, but we eliminate one
enum classwith two additional instances. So it can be more important for space critical apps.Also, with second proposed approach in the beginning of issue it will look like:
Which gives us possibility to not use redundant annotation, but takes up even more space.
P.S.: There is 3rd less obvious solutions: annotation
@LabelFunwith parameteractionwhich will turn name of the method to label name and action is needed to be defined as a parameter, by user of library:
So it will take small space, but we will eliminate redundant objects and enum.
Also, it will have additional second parameter
labelfor explicit defining a label.