Joe Nuxoll's Weblog

« 3-D glasses anyone? ... | Main | Gobble gobble »

20051122 Tuesday November 22, 2005

Java Properties and Events

Graham Hamilton recently posted an entry on his blog requesting suggestions for future Java language innovations. I work with Graham, and have had the opportunity to talk with him about a wide range of Java subjects. One place where we haven't seen exactly eye-to-eye is the area of language-level properties and events. I personally believe this is the #1 missing ease-of-development feature in the Java language (and platform, for that matter).

Adding properties and events to the Java language itself does more than eliminate common boiler-plate code, as is often used as the primary pro argument. The more important benefit of adding these concepts to the language itself is that it promotes the notion of "component library" instead of "class library" when designing new APIs and systems. Component-based development is what makes learning and developing with some "other" software platforms so much easier. The Java language is still very focused on the notion of "class library", which was long ago supplanted by "component libraries" in other platforms.

JavaBeans has been around for a long time. It was the *original* move toward component-based software for the Java platform. The notion of components promotes a plug-and-play method of software development where the common interfaces between components and an application are well defined. This makes it very easy for visual tools to aide in application design and building. It also makes it very easy for new concepts to be introduced to the end developer. A developer is handed a set of JavaBeans which they can study and poke-around with until they learn the new concepts implemented by the suite of JavaBeans. The only problem is... JavaBeans is just a conventional pattern, and not built into the language itself, and therefore completely ignored in most APIs. New technologies and APIs rarely use JavaBeans patterns, and the JavaBeans patterns themselves have gaping holes where tool vendors have had to fill in the gaps.

If these component-oriented concepts were in the language itself, they would be used across the board for new technologies. Any new API (or JSR, etc) would provide a set of components for a developer to use, as opposed to defining a set APIs to implement or leverage. Things would just be easier - both for tool vendors - and for end developers.

I have compiled my thoughts into a document that outlines how this might be accomplished. Please comment!

( Nov 22 2005, 08:18:30 PM PST ) Permalink Comments [4]

Trackback URL: http://blogs.sun.com/joe/entry/java_properties_and_events
Comments:

Nice thought!!

For properties I definitly like the idea! But I would personnaly not like the method body in the field declaration. While most of the time a simple "public Color bgColor get set;" would be enough, why not just extend the syntax to keep special case simple.

Exemples:

property Color bgColor get setBgColor

The property keyword indicates to the compiler a private field must be created. Also, the accessor for that field must have the same access as the method specified (if other then set and get specified, which are always public).

The above exemple would produce this bytecode - for an existing public void setBgColor(String newBgColor):

private Color $bgColor;
public Color $bgColor$get() {
   return( this.$bgColor);
}
public void $bgColor$set(String value) {
   this.setBgColor(value);
}

But would produce the following for a private setBgColor method:

private Color $bgColor;
public Color $bgColor$get() {
   return( this.$bgColor);
}
private void $bgColor$set(String value) {
   this.setBgColor(value);
}

And while being at brain storming... why not use that to create the appropriate code for adding listener functionality?

property TYPE propName [get[:getterMethod]] [set|:setterMethod]] [bound] [constrained]

The property keyword indicates to generate a private field.

The get keyword indicates to create a public read accessor, unless a getterMethod is specifed. In which case, the accessor will have the same access as the specified method.

Same thing with the write accessor using the set keyword.

The bound and constrained keyword would make the compiler generate the appropriate code for property listener support.

Indexed properties could be automatically recognize when the type is an array, and then again appropriate code could be create for bounded and constrained properties.

But, I would keep as method call the property listeners manipulation methods - hum... - maybe forcing to use an interface (IJavaBean) - hum... looks ugly. Anyway.

Ok, maybe I gone a little bit too far....

Posted by Hugues Ferland on November 23, 2005 at 07:16 AM PST #

I *think* you had a typo in your prototype line: the "|" between the "set" and ":setterMethod". If you made that a "[" (like the "get" case), then I like it. I think I'd leave the event firing out of the picture for the language-level feature. I also don't think you actually need the property keyword to make this work. I do, however, like the inline get/set methods as options.

TYPE propName [get[:readMethod]|{...}] [set[:writeMethod]|{...}]

Posted by Joe Nuxoll on November 23, 2005 at 09:53 AM PST #

对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 对不起我的最爱 暧昧 冬天快乐 披着羊皮的狼 桃花朵朵开 神话 笔记 吉祥三宝 发如雪 爸爸妈妈 我很想爱他 夜曲 千里之外 不得不爱 王子变青蛙 冰菊舞 飞舞 爱我别走 听妈妈的话 只剩我一个 我不后悔 飞行部落 反转地球 死了都要爱 好姑娘 一万个理由 曹操 qq爱 认真的雪 舞娘 老婆老婆我爱你 约定 大城小爱 号码 老公老公我爱你 天下无双 狼爱上羊 寻找李慧珍 不要再来伤害我 不怕不怕 香飘飘 我们都是好孩子 求佛 秋天不回来 香水有毒 皇后与梦想 每一面都美太美丽 那一夜 真爱 隐形的翅膀 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 一夜情 黄色聊天室 乱伦 明星走光图片 肛交 美女视频 成人聊天室 网友自拍 黄色录象 少妇自拍 成人小电影 日本av女优 口交 美女图片 黄色 偷拍 性交 色情聊天室 走光图片 性爱电影 成人文学 色情小说 性爱贴图 成人漫画 成人书库 色情漫画 免费激情电影 成人游戏 黄色电影 艳情小说 激情小电影 黄色图片 色情图片 性生活 成人图片 成人色情 成人贴图 色情电影 激情图片 黄色小说 成人电影 激情电影 色情网站 激情女郎 劲舞团 三级片 性爱图片 跑跑卡丁车 激情正点自拍 黄色网站 美女走光 免费黄色电影 诱惑自拍下载 色情文学 情色电影 裸体图片 裸体美女视频自拍 免费电影 成人小说 成人论坛 成人网站 pp点点通 色情论坛 免费三级片 激情视频自拍 免费成人电影 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 一夜情 黄色聊天室 乱伦 明星走光图片 肛交 美女视频 成人聊天室 网友自拍 黄色录象 少妇自拍 成人小电影 日本av女优 口交 美女图片 黄色 偷拍 性交 色情聊天室 走光图片 性爱电影 成人文学 色情小说 性爱贴图 成人漫画 成人书库 色情漫画 免费激情电影 成人游戏 黄色电影 艳情小说 激情小电影 黄色图片 色情图片 性生活 成人图片 成人色情 成人贴图 色情电影 激情图片 黄色小说 成人电影 激情电影 色情网站 激情女郎 劲舞团 三级片 性爱图片 跑跑卡丁车 激情正点自拍 黄色网站 美女走光 免费黄色电影 诱惑自拍下载 色情文学 情色电影 裸体图片 裸体美女视频自拍 免费电影 成人小说 成人论坛 成人网站 pp点点通 色情论坛 免费三级片 激情视频自拍 免费成人电影 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 一夜情 黄色聊天室 乱伦 明星走光图片 肛交 美女视频 成人聊天室 网友自拍 黄色录象 少妇自拍 成人小电影 日本av女优 口交 美女图片 黄色 偷拍 性交 色情聊天室 走光图片 性爱电影 成人文学 色情小说 性爱贴图 成人漫画 成人书库 色情漫画 免费激情电影 成人游戏 黄色电影 艳情小说 激情小电影 黄色图片 色情图片 性生活 成人图片 成人色情 成人贴图 色情电影 激情图片 黄色小说 成人电影 激情电影 色情网站 激情女郎 劲舞团 三级片 性爱图片 跑跑卡丁车 激情正点自拍 黄色网站 美女走光 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 免费黄色电影 诱惑自拍下载 色情文学 情色电影 裸体图片 裸体美女视频自拍 免费电影 成人小说 成人论坛 成人网站 pp点点通 色情论坛 免费三级片 激情视频自拍 免费成人电影 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 一夜情 黄色聊天室 乱伦 明星走光图片 肛交 美女视频 成人聊天室 网友自拍 黄色录象 少妇自拍 成人小电影 日本av女优 口交 七夕情人站 360家具家居网 剧情网 育崽妈咪网 泡泡写真图库 狐谷娱乐 狐谷小游戏 上网就要去 美女图片 黄色 偷拍 性交 色情聊天室 走光图片 性爱电影 黄色小说 裸体美女 韩国三级片 免费黄色电影下载 黄色小电影下载 激情免费电影 激情电影免费 免费成人电影 成人文学 色情小说 性爱贴图 成人漫画 成人书库 色情漫画 免费激情电影 成人游戏 黄色电影 艳情小说 激情小电影 黄色图片 色情图片 性生活 成人图片 成人色情 成人贴图 色情电影 激情图片 黄色小说 成人电影 激情电影 色情网站 激情女郎 劲舞团 三级片 性爱图片 跑跑卡丁车 激情正点自拍 黄色网站 美女走光 免费黄色电影 诱惑自拍下载 色情文学 情色电影 裸体图片 裸体美女视频自拍 免费电影 成人小说 成人论坛 成人网站 pp点点通 色情论坛 免费三级片 激情视频自拍 免费成人电影 韩国色情片 制服诱惑 欧美无码 性爱卡通影片 欧美激情 性爱卡通 免费激情电影 激情黄色电影 免费黄色电影 色情小说 黄色论坛 一夜情 黄色聊天室 乱伦 明星走光图片 肛交 美女视频 成人聊天室 网友自拍 黄色录象 少妇自拍 成人小电影 日本av女优 口交 美女图片 黄色 偷拍 性交 色情聊天室 走光图片 性爱电影 成人文学 色情小说 性爱贴图 成人漫画 成人书库 色情漫画 免费激情电影 成人游戏 黄色电影 艳情小说 激情小电影 黄色图片 色情图片 性生活 成人图片 成人色情 成人贴图 色情电影 激情图片 黄色小说 成人电影 激情电影 色情网站 激情女郎 劲舞团 三级片 性爱图片 跑跑卡丁车 激情正点自拍 黄色网站 美女走光 免费黄色电影 诱惑自拍下载 色情文学 情色电影 裸体图片 裸体美女视频自拍 免费电影 成人小说 成人论坛 成人网站 pp点点通 色情论坛 免费三级片 激情视频自拍 免费成人电影 偷拍桌球室里的丰满少妇 乳沟深深 意外偷拍到的镜头 酒吧美女脱衣舞秀丁字裤 抓拍沙滩上没穿胸罩的MM 丝袜诱惑 波霸美少女视频 脱衣舞-夜总会艳舞07 色情男人看A片玩激情 宿舍里玩弄巨乳女学生 奴隶情人 女秘书办公室妩媚自拍 视频主持MM自拍性感热舞 诱人的脱衣舞表演 激情男女QQ视频热舞 美女与野兽 韩国三级明星写真 视频聊天室的风骚女室主 法国透明内衣秀 欧美性感AV女郎火辣自拍 一个聊天室MM的性感热舞 超性感AV女优室内激情 抓拍漂亮MM蹦床超级走光 美女记者前故意撕衫走光 全裸喂奶的真实镜头 性感少妇跳风骚脱衣舞 脱衣舞-夜总会艳舞06 网友自拍室友房内激情事 两洋妞超下流激情自拍 红衣爆乳妹浪情写真 石屋女子唤醒野性欲望 免费点歌 手机视频 手机彩图 热门铃声 劲爆DJ 求佛 秋天不回来 月亮之上 qq爱 不怕不怕 香水有毒 千里之外 大城小爱 老婆老婆我爱你 听妈妈的话 今天你要嫁给我 那一夜 狼爱上羊 隐形的翅膀 认真的雪 寂寞沙洲冷 一万个理由 不要再来伤害我 期待 飞舞 夜曲 爸爸妈妈 我不后悔 本草纲目 笔记 触电 号码 爱我别走 太美丽 127日 反转地球 对不起我的最爱 曹操 死了都要爱 真爱 不得不爱 玩美 香飘飘 美丽心情 吻别 花的嫁纱 莫斯科没有眼泪 千年之恋 爱如潮水 哎呀 发如雪 化蝶飞 蓝眼泪 飘雪 你的眼神 天下无双 婴儿 樱花草 七天七世纪 今夜你会不会来 大城小事 你怎么舍得我难过 十元人民币 天亮了 千千阙歌 借口 分手快乐 寓言 偏偏喜欢你 香水百合 两只小蜜蜂 上海滩 桃花朵朵开 遗失的美好 我们能不能不分手 爱上你我很快乐 一路上有你 快乐练习曲 天涯 高手 恋曲1990 江湖笑 大约在冬季 情画 爱我就别伤害我 放飞美丽 喜欢你 女人花 一生爱你千百回 你的样子 春泥 昨日重现 谢谢你的爱 一千零一夜 心雨 月亮惹的祸 说爱你 分飞 回头太难 哑巴新娘 曾经最美 西厢 希望 别怕我伤心 我只在乎你 你到底爱谁 爱很简单 当你孤单你会想起谁 心肝宝贝 一直很安静 光辉岁月 盖世英雄 冰菊舞 吉祥三宝 祝你一路顺风 欧若拉 水手 解脱 丝路 我说我爱你 安静 燕尾蝶 月光 一千个伤心的理由 一个人哭 爱情木瓜 我要的世界 无间道 梁祝 眉飞色舞 雨人 感恩的心 轨迹 红模仿 红色石头 折子戏 挪威的森林 戒不掉 童年 美丽的神话 猪都笑了 快乐崇拜 give me five 别说我的眼泪你无所谓 广岛之恋 我的果汁分你一半 让泪化作相思雨 精忠报国 双鱼座 秋天的童话 在他乡 虫儿飞 过火 我们都是好孩子 爱情 双截棍 完美世界 嘻唰唰 黑色幽默 假装 蜗牛 潘朵拉 爱如空气 容易受伤的女人 手放开 见习爱神 一剪梅 你的微笑 我不想说我是鸡 童话 无尽的爱 蓝莲花 我爱你你却爱着他 恋着多喜欢 大舌头 我要抱着你 绝口不提爱你 走出喜马拉雅 披着羊皮的狼 铁血丹心 从开始到现在 我不愿看见你再流泪 爱笑的眼睛 明天会更好 受了点伤 如果没有你 记事本 大地 都是你 如果爱 天空 说爱我 小薇 曾经的你 倒带 不痛 痛快 断了的弦 晴天 星光游乐园 真爱你的云 <a href="http://www.popyy.cn/music/

Posted by fdasfdsa on October 12, 2006 at 07:19 PM PDT #

For the times when I want a simple "property", I just use a public member variable with no getter/setter methods.

For the times when I want added getter/setter logic, I use a private member variable and public getter/setter methods.

Most Java frameworks will use the getter/setter methods first if they are available and use the direct member variable if they are not.

No boilerplate code at all. Why are new language features needed?

Posted by javadev on October 07, 2007 at 10:14 AM PDT #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed