Skip to content

bob: improve reference solution #1012

Closed

Description

@FridaTveit

All the public class and method access modifiers in the bob reference solution can be changed to package private (which is the default therefore the access modifier can be left out). For example, in Bob.java, public class Bob { should be changed to class Bob {.

We do this since it's best practice to restrict access to a class and its methods as much as possible (see our POLICIES doc for more information).

Also, there are if statements in the reference solution that aren't enclosed in curly braces, e.g.:

if (isQuestion(input))
     return "Sure.";

This is generally considered bad practice because it's very easy to add another line of code and not realise that it won't be part of the if statement. For example:

if (isQuestion(input))
     callSomeMethod();
     return "Sure.";

is the same as:

if (isQuestion(input)) {
     callSomeMethod();
}
return "Sure";

which isn't obvious. Therefore all the if statements in the reference solution should have curly braces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions