4 ms·
LOL. I actually laughed IRL when I read the article title. Java is a language that's supposed to have encapsulation. Now they are wondering if developers are br
by lhgaghl 13y ago
LOL. I actually laughed IRL when I read the article title. Java is a language that's supposed to have encapsulation. Now they are wondering if developers are breaking encapsulation to the point that they need a survey? What a joke.
Java's like the language that's supposed to have encapsulation and types, but actually has neither in practice. (everyone uses reflection / casting)
- virmundi 13y agoI didn't down vote you, but I would like to take a moment to respond to your statements. The survey is due to some people such as library makers using this feature to make really advanced, complex, rule-breaking things in Java. It wasn't intended to get out, but it is. So Oracle, and by extension OpenJDK, want to know what would happen if they got rid of it. Presumably they would replace it with a more open API. Now as to encapsulation and types not being used, I've seldom seen that be the case pretty much ever. Normal developers will use casting, yes, but probably not reflection directly. They will use libraries that will use reflection, sure. For example, few on my team use reflection directly (I know, we've talked, they've been confused because they've never done it). I'm the team lead. I use it a lot. We have data parsers. That data needs to get mapped into a canonical model. My code, the mapper factory, uses reflection and naming standards and code generation to automatically pick the proper mapper based on the inbound parsed object. So my code really does have an API of "interface Converter:public Object mapper(Object)". Behind the scenes, using the reflection API, the first step is to determine the parsed object's package. Replace a keyword in that package to find another package for the mapper and the reflectively load the mapper that implements that interface if it doesn't exist. Thus the SingletonFactoryFactory of Java! But following that scant 50-100 lines of code is about 15k of plan old, getString->setString, auto-generated mapper code. Boring, encapsulated, typed. And all of that allows me to know if the mapping documents the BAs created are good. If they compile, they're good. If not, got to talk to the BAs.