Mark Watson's Blog
I am the author of 13 published computer books and a consultant specializing in Java, C++, and Smalltalk development. Please check out my two Free Web Books at my main site


Subscribe to "Mark Watson's Blog" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.



  Friday, May 2, 2003

I propose a change to the Java language

This is a really minor tweak, but I would like to add three new keywords to class data definitions:
  • readwrite - automatically generates "invisible" getter/setter methods
  • read - automatically generates "invisible" getter method
  • write - automatically generates "invisible" setter method
I was thinking of this yesterday while I was adding JavaDoc comments to all the classes that I have written for a client - but, I skipped commenting the getter/setter methods.

Then, I started thinking about how much cleaner the code would be without having to expressly write getters/setters - just add a keyword like this:

    private readwrite String lastName;
Smart editors like Emacs and IntelliJ could show variables with one of these three keywords in a slightly different color, as a reminder to the programmer that "invisible" getters/setters are available.

One of the things that I really like about Common Lisp is how concise code is - 1000 ines of Lisp code generally does a lot more than 1000 lines of Java or C++ code. A smaller codebase makes for easier maintenance and modifications.
8:22:01 AM    

Click here to visit the Radio UserLand website. © Copyright 2003 Mark Watson.
Last update: 9/16/03; 7:36:30 AM.

May 2003
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Apr   Jun