4 ms·
Like with any language, out can make it short to the point f obfuscation. The goal (and the opportunity) is to make your code very declarative. view.remov
by gibolt 7y ago
Like with any language, out can make it short to the point f obfuscation.
The goal (and the opportunity) is to make your code very declarative.
view.removeSelf()
vs.
ViewGroup parent = (ViewGroup) view.getParent();
parent.removeChild(view);
Extension Properties and data classes further help centralize the contents of a class.
- vbezhenar 7y agoLooks like a band-aid for bad API.
- joe_fishfish 7y agoWelcome to Android.
- wtetzner 7y agoOf course. And if you are using any sort of 3rd party library, there's a good chance it has some bad design decisions in it. Having extension methods allows you to clean them up. If the library is open source, you can of course try to contribute changes, but they may or may not be accepted, and maybe the library is in such wide use that they don't want to break backward compatibility.
- gambler 7y agoThis is the worst thing about Java. Almost all other languages have some way to deal with bad libraries or missing features in those libraries. Java has nothing of this sort and it gives library provides all kinds of tools to fuck you over.
- pjmlp 7y agoThe worst thing are developer that don't learn to use the tools that Java makes available at their disposition. In any language it is possible to fix broken libraries.
- pjmlp 7y agoNothing prevents one to achieve the same in Java with adapter classes or utility methods statically imported.
- wtetzner 7y agoThat’s true, but adapter classes can be pretty clunky to use, and while static methods are fairly lightweight, they aren’t very convenient if you’re trying to extend a fluent API.
- pjmlp 7y agoWith proper Java support that could be written as removeSelf(view) Not that bad, but then it doesn't sell Kotlin.