Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

HELLLPPPPPP!


Rugz007
 Share

Recommended Posts

Capitalization has the exact same purpose as does indentation. A friend of mine, while learning Ruby, once said to me: "It is everything you expect from a programming language, plain English, case sensitive and indent sensitive."

Indentation allows you to visually identify code structure, and capitalization has the same, overall, function, allows you to identify, for instance, the accessibility of a variable.

Microsoft suggests two capitalization schemes: PascalCase and camelCase. (And a 'special case' when using acronyms)

 

For instance, accessibility identification should use this scheme:

 

If you see something like:

Class.variable

You know that the underlying definition of variable is:

private object variable;

As opposed to:

Class.Variable

Which would be implemented as:

public object Variable;

One very common thing to have in C# is:

class MyClass{   public object[] MyArray;   private object myObject;   public object MyObject   {      get      {         return myObject;      }      set      {         myObject = value;      }   }   public MyClass(object[] myArray, object myObject)   {      MyArray = myArray;      this.myObject = myObject;   }}

Microsoft provides a comprehensive set of guidelines for .NET development in their Framework Design Guidelines -> http://msdn.microsoft.com/en-us/library/ms229042(v=vs.110).aspx

Edited by pedro2555
  • Like 1
Link to comment
Share on other sites

LordOfTheBongs

i havent read through all of that link but i like to put underscore for private field referenced through public properties

 

i would write it as...

 

 

private object _myObject;public object MyObject{    get    {        return _myObject;    }    set    {        _myObject = value;    }}

 

because if i just saw myObject, i would assume it is not accessed in any way from other classes... while _myVar might be private but it still can be get or set from other classes

Link to comment
Share on other sites

maybe its because im not a coder, i just kid with coding, for example, i never heard about that "camel case" that you said ^^


Guys guys why dont u make a another topic?

 

lol, ok i will stop ^^

Link to comment
Share on other sites

i havent read through all of that link but i like to put underscore for private field referenced through public properties

 

i would write it as...

private object _myObject;public object MyObject{    get    {        return _myObject;    }    set    {        _myObject = value;    }}

because if i just saw myObject, i would assume it is not accessed in any way from other classes... while _myVar might be private but it still can be get or set from other classes

 

Actually the usage of underscore is dis encouraged by Microsoft's Design Guidelines for .NET. Quoting them:

 

√ DO choose easily readable identifier names.

For example, a property named HorizontalAlignment is more English-readable than AlignmentHorizontal.

√ DO favor readability over brevity.

The property name CanScrollHorizontally is better than ScrollableX (an obscure reference to the X-axis).

X DO NOT use underscores, hyphens, or any other nonalphanumeric characters.

X DO NOT use Hungarian notation.

X AVOID using identifiers that conflict with keywords of widely used programming languages.

 

The scheme I've presented is the one suggested and used by Microsoft (and me :D), but that's up to you.

Edited by pedro2555
  • Like 1
Link to comment
Share on other sites

NTAuthority

i believe u use the underscore for private fields refrenced through public properties

barely see a reason for not using automatic properties anyway

SsZgxdL.png

Inactive in GTA/R* title modification indefinitely pursuant to a court order obtained by TTWO. Good job acting against modding!

Link to comment
Share on other sites

LordOfTheBongs

 

i believe u use the underscore for private fields refrenced through public properties

barely see a reason for not using automatic properties anyway

 

well sometimes u need to wrap some extra code when setting or getting a value

 

 

private int myVal;public int MyVal{    set    {        OnMyValSet(EventArgs.Empty);        myVal = value;    }}

 

something like that

Edited by LordOfTheBongs
Link to comment
Share on other sites

NTAuthority

well sometimes u need to wrap some extra code when setting or getting a value

 

 

something like that

even though it's only an example I still feel the need to point out the Property Design section in the Member Design Guidelines stating the following:

 

X DO NOT provide set-only properties or properties with the setter having broader accessibility than the getter.

For example, do not use properties with a public setter and a protected getter.

If the property getter cannot be provided, implement the functionality as a method instead. Consider starting the method name with Set and follow with what you would have named the property. For example, AppDomain has a method called SetCachePath instead of having a set-only property called CachePath.

Edited by NTAuthority

SsZgxdL.png

Inactive in GTA/R* title modification indefinitely pursuant to a court order obtained by TTWO. Good job acting against modding!

Link to comment
Share on other sites

LordOfTheBongs

yeah it was just an example and i guess this would be better for a method... tbh i didnt even know that, it makes sense though.

Link to comment
Share on other sites

Guys guys why dont u make a another topic?

lol.

 

Why? Doesn't the discussion meet the topic title? I think it does.

Edited by pedro2555
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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.