-2

What name should I give classes which are just for configuration? For example, when using JAX-RS, every application is required to have an Application class which extends the superclass javax.ws.rs.Application like so. The Application class is just to register the list of resource classes.

public class APPLICATION_NAME_HERE extends Application {
    public Set<Class<?>> getClasses() {
        return new HashSet<Class<?>>(){{
            add(RestfulResource.class);
            add(AnotherRestfulResource.class);
        }};
    }
}

All the tutorials I see call the class MyApplication or TestApplication or something like that. But none of these sound professional. I can't call the class Application either because it is extending Application, and Java shadows the imported Application with my class. What is the common convention for naming classes like this?

  • 1
    What do you call the executable? – Dan Pichelman Apr 13 '18 at 19:07
  • @DanPichelman depends on the project, for ex. API for this particular case – vikarjramun Apr 13 '18 at 19:21
0

Make up a name for your application, and use that. It doesn't have to mean anything, so you can make up a nonsense word, or just pick the name of something irrelevant that you'd like to refer to.

As well as giving you something to name this sort of class, this name should help you talk about your application unambiguously with your colleagues.

It seems currently you are calling your application API. I would look for something less general. What happens if your team needs to start maintaining two different API projects?

  • So just like StorefrontAPIApplication? – vikarjramun Apr 13 '18 at 19:31
  • No, I was thinking more like make up a word that doesn't mean anything relavent like 'dizex' or whatever. If you start using that you'll learn soon enough that it's the name of your particular application. – bdsl Apr 13 '18 at 19:38
  • 1
    You might want to wait a few hours or days for other answers before choosing an answer to accept. – bdsl Apr 13 '18 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.