3 ms·
Ugh, I dared look at the code and stepped back in horror...https://android.googlesource.com/platform/frameworks/base/+/dad385ae29e13a04500fd698e585f933cd352e53/
by eecc 8y ago
Ugh, I dared look at the code and stepped back in horror...https://android.googlesource.com/platform/frameworks/base/+/dad385ae29e13a04500fd698e585f933cd352e53/telephony/java/android/telephony/SignalStrength.java https://android.googlesource.com/platform/frameworks/base/+/...
- LeonM 8y agoI've scrolled through that code, though I'm not a java dev, I don't really see much 'horror'. Can you explain?
- orf 8y agoWell, there is about 600 lines of boilerplate before you get to anything remotely interesting.
- whoopdedo 8y agoIf the boilerplate is the horrific part, well that's just Java isn't it? The meaningful functions are straightforward and do what you expect. Describe the level of the first radio that returns non-zero starting with the most advanced technology. Or in the case of CDMA/EVDO, the lowest level.
- eecc 8y agoWell no, Java isn’t the best of languages but my criticism stems from other issues, such as weak type system, certain inscrutably bad decisions about the runtime libraries and other, but this code is bad also according to any self respecting java developer. An untyped (that is, it cops out to int) bunch of public static’s that should’ve been an enum. Daft combination of builders and constructors. Magic numbers. Adapter methods that should go into their own class. Validators that should also go into their own class (and even there, implemented differently, not as a parameterless method). Transformers that could be modeled as their own class (all these “in their own class” are for testabilty.) some of the names in these adapters suggest some other domain concerns (UI) are leaking into this model class. IOW, it’s a mess by any standard
- ashishb 8y ago> An untyped (that is, it cops out to int) bunch of public static’s that should’ve been an enum. Java platform code does not use enums since they are more taxing in terms of memory usage. Till Google I/O 2018, Google use to officially recommend that you should avoid enums in your app code if you can.