Reputation: 2163
What are the purposes and meanings of this syntax? I'm seeing lines like private Object mSelectedOperationRow;
and mMessageService = pMessageService;
.
More complete code below.
public class SearchResponseBean extends BaseBean implements Serializable,
SearchResponse {
@Autowired
private SearchLifecycleService mSearchLifecycleService;
@Autowired
private ConfigurationServiceImpl mConfig;
@Value("#{sessionBean}")
private Session session;
@Value("#{searchRequestBean}")
private SearchRequest searchRequest;
@Value("#{searchResponseFilterByBean}")
private SearchResponseFilterBy searchResponseFilterBy;
@Value("#{searchHistoryBean}")
private HistoryBean<SearchHistoryItem> historyBean;
@Autowired
private SearchResponseDataModelFactory mSearchResponseDataModelFactory;
private int mCount;
private DataModel mDataModel;
private SearchPerspective mSearchPerspective;
private Operation mSelectedOperation;
private Object mSelectedOperationRow;
private List mSelectedList;
private List<String> mAvailableOperations;
private List mFilteredList;
private boolean mRelatedDocSearch;
private transient MessageService mMessageService;
public SearchResponseBean() {
mMessageService = new MessageServiceImpl();
}
public SearchResponseBean(MessageService pMessageService) {
mMessageService = pMessageService;
}
protected void init() {
String THIS_METHOD_NAME = "init";
mFilteredList = null;
mSelectedList = null;
mSelectedOperationRow = null;
mSelectedOperation = null;
mCount = -1;
mDataModel = null;
mSearchPerspective = null;
mAvailableOperations = null;
mRelatedDocSearch = false;
logger.debug(getClass(), THIS_METHOD_NAME,
"Initialized with null/defaults. ");
}
Upvotes: 5
Views: 5905
Reputation: 37
Well these are just naming conventions.
I think these are just leftover of C++ world or may be very early IDE versions of java, where it was probably hard to look at 'formatting' of a variable and identify if this is a local variable or a class level one.
Using 'm' and 'p' prefix these days, in my opinion, is just redundant with modern IDEs.
Upvotes: 2
Reputation: 310993
The m
and p
prefixes aren't part of Java's syntax per-se, they're just a convention used in some projects.
m
is short for "member" and p
is short for "parameter". This way, when reading a long block of code, it's clear where each variable comes from, and what it means. Modern IDEs color members differently so this convention may not be as useful as it used to be, but it's still employed in some projects.
Upvotes: 9
Reputation: 20059
This is not a syntax thing, its a project guideline thing. Some projects have naming conventions for variables, members, arguments ... and more.
Its meant to make it easier to distinguish between local variable, members and method arguments.
Upvotes: 12
Reputation: 20254
Its an example of Hungarian Notation, a naming convention which is rarely used these days in Java code.
Upvotes: 3