I'm about to create a User class for my project. Any opinions as to whether it is bad practice to create such a commonly-named class? I could complement it with a prefix specific to my project.
Using common names is not a bad practice, until and unless you describe the name as that to the functionality of the class. keep in mind to create proper packages that can define your class more specifically.
I would suggest you to definitely prefix an application specific term to your User class. "User" is way too common and vague. You might easily end up using API which has "User" class or Interface. Though latest IDEs make it relatively easy to refactor your code, it would be cleaner and easier if you have a app specific "User" class.
You should use Java package
s to avoid name clashes. There is nothing wrong with using a common name, just be sure to put it in its own package. For example, you could have the following structure:
com/
yourwebsite/
yourproject/
userdata/
User.java
You then begin the file "User.java" with:
package com.yourwebsite.yourproject.userdata;
When you import it, you would use:
import com.yourwebsite.yourproject.userdata.User;
I always try to use common names like User for clarity. Just be sure the names are drawn from the problem domain and existing project vocabulary. Be alert for ambiguities, and if one arise, change the class name. Modern IDEs with automated refactoring support make that easy.
This name is unlikely to be used by any public API, so it's ok for an app to use it.