4 ms·
Are there any legitimate use cases for that many methods?
by d33 10y ago
Are there any legitimate use cases for that many methods?
- taormina 10y agoI mean, it means you can't pull in Scala. I mean, you can, but pull in enough bloated Java 3rd party libraries and you might be hitting that limit pretty quickly. Google broke Google Play Services out into a large number of small dependencies once they were past the 15k method mark. Mind you, certain compilation settings will totally strip out unused methods, but it's still annoying.
- kelnos 10y agoIIRC the Facebook app had many more than that at one point, and had to use multi-dexing. Not sure if that's still the case. I've also heard that scala apps on Android can sometimes hit the limit, because pulling in the scala stdlib greatly bloats the method count.
- Exuma 10y agoAd SDK's have tons of methods.
- BoorishBears 10y agoIt sounds like a ridiculous number of methods until you realize just importing Guava brings in 20k methods, using half the Amazon SDKs would probably bring another 20k-40k, Apache's main utils bring about 10-20k, etc.
- jayd16 10y agoFor example, the amazon sdk jar has 40,000 alone or something insane. You can hit if you're using a few large libraries. That said, you can use proguard to strip your unused methods and it usually fine even for large applications.
- ungzd 10y agoBecause of "single responsibility principle" it's better if classes and methods do one thing. That usually leads to lots of small classes and small methods.
- vkou 10y agoJava's crippled generics, lack of tuple support, and lack of default parameters encourage interface bloat in utility libraries. Given how bloody good Java IDEs are (By which I mean to say - how good IntelliJ is), the cognitive cost of this interface bloat is very low... Until you start developing for Android.
- monocasa 10y agoWouldn't Java's crippled generics actually help reduce the method count since due to type erasure they're all the same method at the VM level anyway?
- Matthias247 10y agoFor reference types probably yes, but Java also often needs extra methods or overloads for handling primitive types, which would get unnecessarily boxed when used in generic methods.
- josefx 10y agoOn the one hand yes, on the other hand Java also generates Bridge methods when you implement a generic interface. A MyType implementing Comparable<MyType> will contain a compareTo( MyType ) method and a generated compareTo( Comparable ) bridge method. It is more likely that generated classes, countless getters and setters and a tendency to small methods has a higher impact.