3 ms·
If you have to pierce abstraction by stripping away the IDE, you've got an issue with the design of the language. Take python: I don't have to write getters an
by callahad 17y ago
If you have to pierce abstraction by stripping away the IDE, you've got an issue with the design of the language.
Take python: I don't have to write getters and setters, but if I need to tinker around "inside" one, I simply write a function and decorate it with @property. But that code is only present if I need to create an exception to the general case, rather than having everything, including the common cases, present in source and hidden by the IDE.
Edit: Check out Project Lombok (http://projectlombok.org/ http://projectlombok.org/), which tries to address some of these issues for Java (including the exceptional case, rather than hiding the general case). We discussed it a two months ago at http://news.ycombinator.com/item?id=738958 http://news.ycombinator.com/item?id=738958
- jrockway 17y agoPython is not even the best example here, in Common Lisp and Perl (and probably lots of other languages) provide even better abstractions. If you want to modify the behavior of one accessor, you can modify it with method modifiers. If you want to create a new class of accessor-generation behavior, you can write a new metaclass that works exactly the way you want. (And of course, you can write your own "defclass" macro that always uses your own metaclass, if you desire.) In Perl, we can even compose meta-roles into metaclasses; meaning that even tiny changes can be made easily reusable. This is generally preferable to editing code in an IDE.
- adw 17y agoYou can do the __metaclass__ thing in Python too. We'll find you and tut at you if you do, but you can do it.