Skip to content

Comment on How many lines of Java would this take?parent

Comments

Here's a trivial scenario for you: a user inputs a URL which represents a web service and a method name. Your code needs to determine if the object which will get returned as JSON by that web service implements the method or not.

You wouldn't do that by reflection, you'd have a mapping between service method names and objects that perform the service. In fact, this sort of thing is pretty typical in web frameworks based on dynamic languages as well. I don't want you calling Object.notifyAll or whatever just by fiddling with urls. Reflection does come up but it's usually in more magical places - serialization (the built-in serialization is an example of interface-by-convention), profilers, debuggers, prototyping tools.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.