You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by "Saurabh Dixit (Jira)" <ji...@apache.org> on 2019/11/12 05:03:00 UTC

[jira] [Created] (ROL-2159) "@Override" should be used on overriding and implementing methods

Saurabh Dixit created ROL-2159:
----------------------------------

             Summary: "@Override" should be used on overriding and implementing methods
                 Key: ROL-2159
                 URL: https://issues.apache.org/jira/browse/ROL-2159
             Project: Apache Roller
          Issue Type: Improvement
    Affects Versions: 6.0.0
            Reporter: Saurabh Dixit
            Assignee: Saurabh Dixit


Using the {{@Override}} annotation is useful for two reasons :
 * It elicits a warning from the compiler if the annotated method doesn't actually override anything, as in the case of a misspelling.
 * It improves the readability of the source code by making it obvious that methods are overridden.

h2. Noncompliant Code Example
{code:java}
class ParentClass { 
    public boolean doSomething(){...}
} 

class FirstChildClass extends ParentClass { 
    public boolean doSomething(){...} // Noncompliant 
}{code}
h2. Compliant Solution
{code:java}
class ParentClass { 
    public boolean doSomething(){...} 
} 

class FirstChildClass extends ParentClass { 
    @Override 
    public boolean doSomething(){...} // Compliant 
}{code}
h2. Exceptions

This rule is relaxed when overriding a method from the {{Object}} class like {{toString()}}, {{hashCode()}}, ...



--
This message was sent by Atlassian Jira
(v8.3.4#803005)