I just went through a complex message mapping, lots of ugly UDF are used.
1. The UDF name, just use get + the target field name. So we only know this UDF is used to map this field, but if we want to know what the logic is, we need to read the code.
2. Lots of hard code inside of UDF, some constant,just write in the code.
3. Lots of same function UDF but with different name are created.
All of above make the UDF creator or other reviewer unhappy.
So what is creative, pretty and make others and self happy code.
There are some pinciple I suggest that we can follow.
1. Write more common UDF, so we can share the UDF in this mapping, in other mapping.
2. Give the right name which can stand by the logic inside it.
3. Don’t use hard code. You can put the constant on the java section if they are used several times in different place. Or you can use as a parameter.
The constant always means the conditon, so we can know the mean without go into the detail code.
If you follow the above suggestion from me, you can enjoy your code.