Tags:
tag this topic
create new tag
view all tags
---+ Lazy Initialization %TOC% ---++ Context A general design rule for Java, related to the =toString= method that is implemented on =Object=. ---++ Description Non-abstract classes should not inherit the =toString()= implementation from =Object=. ---++ Rationale Implementing a toString method that provides a convenient representation of an object for display purposes makes it more easy to see and interpret the contents of variables in the Java debugger. This is not a do or die type of rule but merely encourages developers to develop a nice toString method for all their classes by ensuring they do not use the fairly useless implementation that is provided by the Object class. The rule does not apply to abstract classes because they do not have instances. ---++ Example None given. ---++ Definition ---+++ [[JQuery]] Query that finds violations: <verbatim> class(?Violation),NOT(modifier(?Violation,abstract)), package(?Violation,?Pack),re_name(?Pack,/^tyRuBa/), name(?Object,Object),class(?Object), method(?Object,?toString),name(?toString,toString), inheritedMethod(?Violation,?toString,?Object) </verbatim> ---+++ MetaL ---+++ AspectJ ---+++ HypotheticaL <verbatim> forall class( !abtract tyRuBa..* ) NOT( inherits( String Object.toString() ) ) </verbatim> ---++ Ruminations This is a generic rule which is generally a good principle for all Java programs. However, since it is not a "do or die" rule, users may still which to restrict the scope of the rule: what part of their code do they really want this rule to be enforced it. This raises the issue if we need some mechanism to allow users to reuse generic rules but tailor them to their own need, for example as is the case here by restricting the scope of the rule.
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2005-05-05
-
KrisDeVolder
Home
Site map
BETA web
Communications web
Faculty web
Imager web
LCI web
Main web
SPL web
Sandbox web
TWiki web
TestCases web
SPL Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback