Siriquelle said:

Siriquelle

On naming variables. Each word is capitalized? or just the first word after the pseudo-identifier. E.g. "strScreenName" or "strScreenname"?

1 year, 2 months ago.

14 comments so far

  • Adventsparky

    first word after the pseudo-identifier.

    1 year, 2 months ago by Adventsparky

  • eam0

    I vote for each word capitalized (also know as camel case) as its easier to read. I don't like pseudo-identifiers. In a strongly typed language the IDE should tell you the variable type. In a dynamically typed one the type can change so should not be in the variable name.

    1 year, 2 months ago by eam0

  • Adventsparky

    Oh wait, looking at the examples again I vote for strScreenName, thought the other option was StrScreeName for some reason.

    1 year, 2 months ago by Adventsparky

  • Siriquelle

    @Adventsparky: awh, ok, got to redo my entire bean class now,

    @eam0: I was thinking camel case would be better too... thanks, camel case it is.

    1 year, 2 months ago by Siriquelle

  • Adventsparky

    What way do you have them at the mo? We were always taught first word small and rest capital, What inspired you to change?

    1 year, 2 months ago by Adventsparky

  • eam0

    I do first word small then all subsequent words begin with a cap. It might depend on the language you are using what convention is more normal. This is from Java (also In Java the type is rarely prefixed to the variable name) The number one rule however is what your marker wants (or else explain to him in the comments why you are using a particular system). I had lots of arguments with my lectures about this kind of thing. They loved seeing my face coming into the classroom. Ah those were the days

    1 year, 2 months ago by eam0

  • Adventsparky

    Aha so we agreed all this time :P

    1 year, 2 months ago by Adventsparky

  • eam0

    yeah :)

    1 year, 2 months ago by eam0

  • Siriquelle

    intUserId. ID is an abbreviation for identification. intUserID seemed to look better but it wasn't a full word. and so I decided intUserid was more suitable. That set my standard then, was using access at the time.

    @eam0: I like the type prefix before the variable name it helps sometimes when I'm in a jsp page dragging a value from a class instance. e.g thisuser.getBoolIsLogged.

    1 year, 2 months ago by Siriquelle

  • Jabit

    I'm with @eam0 on this one. I would drop the type identifier in the variable name and go with something like screenName. However, whatever naming convention you use, the most important thing is that you are consistent. You might be interested in Hungarian notation

    1 year, 2 months ago by Jabit

  • Siriquelle

    That wiki makes a good point, variable notation is nearly completely redundant now shur the compiler knows the types anyway, I'm making changes now to bring my variable names up to a more modern naming style that takes into account the power of modern compilers.

    1 year, 2 months ago by Siriquelle

  • Festoon

    When did you start variable notation James? Just curious. Most compilers haven't needed them for a long, long time but they were handy for programmers.

    1 year, 2 months ago by Festoon

  • Siriquelle

    On work experience I was modifying an applicaiton in visual basic. The notation str = string, int = integer, bool = boolean was left there from the original developer I assume so I adopted it from then, and I've even used that notation in my third year project.

    1 year, 2 months ago by Siriquelle

  • Adventsparky

    Get with the times :P

    1 year, 2 months ago by Adventsparky

Sign in to add a comment