Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I often see projects (in Java projects and teams using Eclipse) that prefix function parameters with p.

For example

public void filter (Result pResult) ...

I personally don't see any benefit in this, but would like to know what the reasoning is. The best explanation I've heard yet is that it is to distinguish the name of identical named fields.I have my issues with that explanation but I can understand the point.

share|improve this question
up vote 25 down vote accepted

The practices of adding meaningful prefixes to symbols, such as the well-publicized Hungarian Notation, date back to the times when IDEs did not exist or were too primitive. Today, when finding a point of declaration is a mouse click away, there is no point in spoiling the most precious part of the name, its first few letters, by assigning a common prefix.

share|improve this answer
I did know of the phenomena but didn't know that it even had a name. Thanks for pointing to the wikipedia entry on the issue. – oschrenk Aug 17 '12 at 14:28
Systems Hungarian Notation is a terrible practice that should be avoided. On the other hand, some Apps Hungarian Notation can be useful (such as for preventing unsafe user input from getting misused). – Darthfett Aug 17 '12 at 14:34
@Darthfett +1 thank you for noting that the common interpretation of Hungarian notation mentioned in this answer is incorrect, despite being the most common one. – Joshua Drake Aug 17 '12 at 15:36
@Darthfett: Even that sort of hungarian notation seems to be trying to implement an ad-hoc, manual type system directly in the variable names. Just use a good statically typed language and have a real type system track things like that for you automatically! – Tikhon Jelvis Aug 17 '12 at 19:46
@Darthfett: In C/C++ you can just wrap it in struct/union with one element. – Maciej Piechotka Aug 17 '12 at 20:22

As you suspect, it is to avoid name collisions between the parameter name and either member or local variable names. Member variables are sometimes given a prefix for the same reason (e.g., m_result). Personally, I prefer to just use the this prefix for member variables if there's a name collision. It's built in to the language and everyone already knows what it means.

share|improve this answer
That is what I do. Not using a prefix also helps in Eclipse when calling the method. If you built your object tree and name the variables like the parameter names of the method you like to invoke, it works like a charm, but if the parameter names are prefixed this doesn't work. – oschrenk Aug 17 '12 at 14:27

I only use a parameter prefix when the parameter is intended to be assigned to a member variable, such as a constructor or a setter.

Paint (newColor) {
  color = newColor;

For me, I find that using a different variable name is more blindingly obvious than using the "this" prefix.

For other situations, I avoid using a parameter that could be easily confused with a member variable.

If a method or class is so big that it is hard to tell what the variables mean, the real solution is to break it up into smaller methods/classes. Using prefixes is a band-aid solution that does address the underlying problem.

share|improve this answer

If you make a standard to use 'p' as a prefix with each method parameter name, you can easily recognize the method parameters in rest of the method body.

It saves your time to find the method parameters. You can debug your code easily.

share|improve this answer

I'm a fan of iParam for in, and oParam for out parameters. I'd say cParam for change, but that's not acceptable

share|improve this answer
Could you explain why you are a fan of this prefixing, what do you gain by using it? – Peter Jul 22 '13 at 13:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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