Jump to content
Search Community

Why no $ before parameters?

mrpinc test
Moderator Tag

Recommended Posts

Just read the interview you did on ActiveTuts (Great read BTW) and was just wondering if you could shed some light as to why Grant Skinner would recommend losing the “$” in front of parameter names. I find this style very useful for distinguishing passed parameters from class/method variables.

 

Thanks.

Link to comment
Share on other sites

I felt exactly the same way, but Grant’s point was twofold (if I remember correctly):

 

1) Having “$” in front of all the parameters makes ASDocs less readable

 

2) It looks very “old school”, as the industry standard is to not use “$” in front of parameter names.

 

I became a big fan of using “$” in parameters and it was uncomfortable to let go of, but I’ve gotten used to it now. Removing them does make ASDocs more readable.

Link to comment
Share on other sites

Perhaps then using $ for method parameters would work since they are not subject to asdocs. I use _ for all class variables and simply use getters and setters if they need to be visible in asdocs (I know I know, you lose some speed because of the method calls)

Link to comment
Share on other sites

Sorry, that was poorly chosen terminology. What I meant to say was, if method parameters are subject to ASdocs then perhaps method variables (that only exist within the scope of a function) could use the $ prefix. That way your params still are clean for ASdocs, and the other vars in the method (which are not subject to ASDocs from what i understand) would be differentiated from the passed params.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...