Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Is there any reason why all your methods are sychronized? There are no shared variables, so the methods could be stateless. The passed Socket to loadUser could be a reason why synchronized is needed. It is unusual to for the class User, to have a constructor which accepts a Socket. Data from the Socket should probably be read elsewhere and after that the constructor could be called.

Instead of the File class with its isFile() and canRead() methods, the more modern Path-based API could be used. see http://stackoverflow.com/questions/6903335/java-7-path-vs-file https://stackoverflow.com/questions/6903335/java-7-path-vs-file

edit: the properties of the User class seem to be public or protected. This should be replaced by setters or a constructor which makes sure your object is in a consistent state. like

public User(String id, String userName, String password)
{
this.id=id;
// etc.
}

Is there any reason why all your methods are sychronized? There are no shared variables, so the methods could be stateless. The passed Socket to loadUser could be a reason why synchronized is needed. It is unusual to for the class User, to have a constructor which accepts a Socket. Data from the Socket should probably be read elsewhere and after that the constructor could be called.

Instead of the File class with its isFile() and canRead() methods, the more modern Path-based API could be used. see http://stackoverflow.com/questions/6903335/java-7-path-vs-file

edit: the properties of the User class seem to be public or protected. This should be replaced by setters or a constructor which makes sure your object is in a consistent state. like

public User(String id, String userName, String password)
{
this.id=id;
// etc.
}

Is there any reason why all your methods are sychronized? There are no shared variables, so the methods could be stateless. The passed Socket to loadUser could be a reason why synchronized is needed. It is unusual to for the class User, to have a constructor which accepts a Socket. Data from the Socket should probably be read elsewhere and after that the constructor could be called.

Instead of the File class with its isFile() and canRead() methods, the more modern Path-based API could be used. see https://stackoverflow.com/questions/6903335/java-7-path-vs-file

edit: the properties of the User class seem to be public or protected. This should be replaced by setters or a constructor which makes sure your object is in a consistent state. like

public User(String id, String userName, String password)
{
this.id=id;
// etc.
}
added 296 characters in body
Source Link
user140547
  • 479
  • 3
  • 8

Is there any reason why all your methods are sychronized? There are no shared variables, so the methods could be stateless. The passed Socket to loadUser could be a reason why synchronized is needed. It is unusual to for the class User, to have a constructor which accepts a Socket. Data from the Socket should probably be read elsewhere and after that the constructor could be called.

Instead of the File class with its isFile() and canRead() methods, the more modern Path-based API could be used. see http://stackoverflow.com/questions/6903335/java-7-path-vs-file

edit: the properties of the User class seem to be public or protected. This should be replaced by setters or a constructor which makes sure your object is in a consistent state. like

public User(String id, String userName, String password)
{
this.id=id;
// etc.
}

Is there any reason why all your methods are sychronized? There are no shared variables, so the methods could be stateless. The passed Socket to loadUser could be a reason why synchronized is needed. It is unusual to for the class User, to have a constructor which accepts a Socket. Data from the Socket should probably be read elsewhere and after that the constructor could be called.

Instead of the File class with its isFile() and canRead() methods, the more modern Path-based API could be used. see http://stackoverflow.com/questions/6903335/java-7-path-vs-file

Is there any reason why all your methods are sychronized? There are no shared variables, so the methods could be stateless. The passed Socket to loadUser could be a reason why synchronized is needed. It is unusual to for the class User, to have a constructor which accepts a Socket. Data from the Socket should probably be read elsewhere and after that the constructor could be called.

Instead of the File class with its isFile() and canRead() methods, the more modern Path-based API could be used. see http://stackoverflow.com/questions/6903335/java-7-path-vs-file

edit: the properties of the User class seem to be public or protected. This should be replaced by setters or a constructor which makes sure your object is in a consistent state. like

public User(String id, String userName, String password)
{
this.id=id;
// etc.
}
Source Link
user140547
  • 479
  • 3
  • 8

Is there any reason why all your methods are sychronized? There are no shared variables, so the methods could be stateless. The passed Socket to loadUser could be a reason why synchronized is needed. It is unusual to for the class User, to have a constructor which accepts a Socket. Data from the Socket should probably be read elsewhere and after that the constructor could be called.

Instead of the File class with its isFile() and canRead() methods, the more modern Path-based API could be used. see http://stackoverflow.com/questions/6903335/java-7-path-vs-file

lang-java

AltStyle によって変換されたページ (->オリジナル) /