Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "Aware" ? When should I include in my Class name?

Tags:

Sometimes, I find some class names including Aware such as ApplicationContextAware and MessageSourceAware (spring). Does this Aware have any special meanings or is it a famous rule?

like image 531
zono Avatar asked May 31 '11 13:05

zono


People also ask

How do you name a class?

Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).

Can class name contain number?

A class name is an identifier—a series of characters consisting of letters, digits, underscores ( _ ) and dollar signs ( $ ) that does not begin with a digit and does not contain spaces.

Should class names be singular or plural?

Class names should be nouns. E.g. Calculator instead of Calculate . They should always be singular.

Can a class name start with underscore?

A valid name should start with an underscore (_), a hyphen (-) or a letter (a-z)/(A-Z) which is followed by any numbers, hyphens, underscores, letters. It cannot start with a digit, starting with the digit is acceptable by HTML5 but not acceptable by CSS.


1 Answers

Those are not classes, are interfaces. The name is just a convention on Spring meaning that some special framework object is going to be injected to that class if it is managed by the framework.

Directly from the docs of ApplicationContextAware:

Interface to be implemented by any object that wishes to be notified of the ApplicationContext that it runs in.

In this case, the bean that implements this interface will get a reference to the ApplicationContext managing the application.

like image 69
mdrg Avatar answered Nov 04 '22 00:11

mdrg