https://kotlinlang.org logo
Title
m

mbonnin

11/14/2020, 10:39 AM
What's everyone take on using extension functions in libraries APIs?
1. bitmap = Bitmap.fromFile(file, options)
2. bitmap = BitmapFactory.decodeFile(file, options)
3. bitmap = file.toBitmap(options)
Is there any of the above you prefer and why?
💰 1
a

altavir

11/14/2020, 11:04 AM
As for the choise. If there is only one way to convert file to btimap and it is used quite broadly, then third option is good. If it is not that broadly used, then the option one is better since it does not polute
File
namespace.
Option two is useful only when there are a lot of different factories.
m

mbonnin

11/14/2020, 11:45 AM
Nice, thanks for the article 👍👍