[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Declare variables with the interface type
timfox
do-not-reply at jboss.com
Thu May 8 05:48:30 EDT 2008
I've noticed quite a few places in the code where the implementation type is being used to declare variables, not the interface type, e.g.:
| ArrayList myList = new ArrayList();
|
Yuck!, should be:
| List myList = new ArrayList();
|
or:
| MessageImpl message = new MessageImpl(JBossTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
|
Should be:
| Message message = new MessageImpl(JBossTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
|
Please don't use the implementation type in this way, it leaks implementation details and defeats the purpose of the interface/implementation split.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4149374#4149374
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4149374
More information about the jboss-dev-forums
mailing list