OptionalParameter API initially contributed by mikko.koponen. The main problem is come when I try to create jsmpp examples for sending segmented/concatenated message using optional parameter (TLV or Tag Length Value).
short refNum = ....
OptionalParameter sarMsgRefNum = new OptionalParameter.Short(Tag.SAR_MSG_REF_NUM, refNum);
OptionalParameter sarSegmentSeqNum = new OptionalParameter.Byte(Tag.SAR_SEGMENT_SEQNUM, (byte)1);
OptionalParameter sarTotalSegments = new OptionalParameter.Byte(Tag.SAR_TOTAL_SEGMENTS, (byte)3);
Wow, it was to verbose. You will find out how tired writing code like that even if you use IDE that handle code completion.
Now lets see the simple version crossing my mind.
short refNum = ....
OptionalParameter sarMsgRefNum = OptionalParamertes.newSarMsgRefNum(refNum);
OptionalParameter sarSegmentSeqNum = OptionalParameters.newSarSegmentSeqNum(1);
OptionalParameter sarTotalSegments = OptionalParameters.newSarTotalSegments(3);
Does it more friendly?
I didn't throw the old API, I just add new utility functions to OptionalParameters as static method.
Good design might to complex and to hard to use by developer. It's just like test first development. So I try to construct the use case and then implement the code to meet the need of the use case.