Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. this (another C# programmer rant)

this (another C# programmer rant)

Scheduled Pinned Locked Moved The Lounge
csharpvisual-studiocomquestion
41 Posts 26 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Marc Clifton

    Code:

    	public override string ToString()
    	{
    		string s = String.Empty;
    
    		for (long i = 0; i < this.k; ++i)
    		{
    			s += this.data\[i\].ToString() + " ";
    		}
    
    		return s;
    	} // ToString()
    

    I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

    Thyme In The Country Interacx My Blog

    S Offline
    S Offline
    Shog9 0
    wrote on last edited by
    #5

    I've seen comments... probably here... from folk who use it to make it obvious they're using member variables (replacing the old m_ prefix, essentially). I don't care for it either.

    ----

    You're right. These facts that you've laid out totally contradict the wild ramblings that I pulled off the back of cornflakes packets.

    K 1 Reply Last reply
    0
    • M Marc Clifton

      Code:

      	public override string ToString()
      	{
      		string s = String.Empty;
      
      		for (long i = 0; i < this.k; ++i)
      		{
      			s += this.data\[i\].ToString() + " ";
      		}
      
      		return s;
      	} // ToString()
      

      I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

      Thyme In The Country Interacx My Blog

      D Offline
      D Offline
      Dave Parker
      wrote on last edited by
      #6

      I'd be more concerned about the lack of a StringBuilder to be honest.

      K 1 Reply Last reply
      0
      • M Marc Clifton

        Code:

        	public override string ToString()
        	{
        		string s = String.Empty;
        
        		for (long i = 0; i < this.k; ++i)
        		{
        			s += this.data\[i\].ToString() + " ";
        		}
        
        		return s;
        	} // ToString()
        

        I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

        Thyme In The Country Interacx My Blog

        S Offline
        S Offline
        StevenWalsh
        wrote on last edited by
        #7

        i use letters all the time for couters in a for loop, do you hate that?

        for(int i = 0; i < this.k; i++){
        MarcClifton.Anger++;
        }

        Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer. -Fred Brooks

        S M 2 Replies Last reply
        0
        • M Marc Clifton

          Code:

          	public override string ToString()
          	{
          		string s = String.Empty;
          
          		for (long i = 0; i < this.k; ++i)
          		{
          			s += this.data\[i\].ToString() + " ";
          		}
          
          		return s;
          	} // ToString()
          

          I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

          Thyme In The Country Interacx My Blog

          L Offline
          L Offline
          leonej_dt
          wrote on last edited by
          #8

          Agreed. this, Self and Me are keywords that serve no purpose.

          To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

          P D 2 Replies Last reply
          0
          • M Marc Clifton

            Code:

            	public override string ToString()
            	{
            		string s = String.Empty;
            
            		for (long i = 0; i < this.k; ++i)
            		{
            			s += this.data\[i\].ToString() + " ";
            		}
            
            		return s;
            	} // ToString()
            

            I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

            Thyme In The Country Interacx My Blog

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #9

            I do it just to piss people off. :-D

            R 1 Reply Last reply
            0
            • S StevenWalsh

              i use letters all the time for couters in a for loop, do you hate that?

              for(int i = 0; i < this.k; i++){
              MarcClifton.Anger++;
              }

              Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer. -Fred Brooks

              S Offline
              S Offline
              Shog9 0
              wrote on last edited by
              #10

              I think his complaint is that this.k could be easily written simply as k. Although yes, k is a terrible name for a class member.

              ----

              You're right. These facts that you've laid out totally contradict the wild ramblings that I pulled off the back of cornflakes packets.

              M 1 Reply Last reply
              0
              • D Dave Parker

                I'd be more concerned about the lack of a StringBuilder to be honest.

                K Offline
                K Offline
                keyboard warrior
                wrote on last edited by
                #11

                i was under the impression that using the "+" with stringbuilder would actually decrease performance? that you should use "append" ? in which case they should have both string builder and append.

                ----------------------------------------------------------- "When I first saw it, I just thought that you really, really enjoyed programming in java." - Leslie Sanford

                1 Reply Last reply
                0
                • M Marc Clifton

                  Code:

                  	public override string ToString()
                  	{
                  		string s = String.Empty;
                  
                  		for (long i = 0; i < this.k; ++i)
                  		{
                  			s += this.data\[i\].ToString() + " ";
                  		}
                  
                  		return s;
                  	} // ToString()
                  

                  I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

                  Thyme In The Country Interacx My Blog

                  R Offline
                  R Offline
                  Rama Krishna Vavilala
                  wrote on last edited by
                  #12

                  I hate it when people don't do this:). But it is more of a personal preference. The bottom line is to follow a set guideline throughout your project. For me,data[i].ToString() makes me feel pity about data. It seems as if he is orphan. When you prefix with this.data, I feel much happy about data, at least it has an object where it belongs to which takes its care.

                  Proud to be a CPHog user

                  1 Reply Last reply
                  0
                  • M Marc Clifton

                    Code:

                    	public override string ToString()
                    	{
                    		string s = String.Empty;
                    
                    		for (long i = 0; i < this.k; ++i)
                    		{
                    			s += this.data\[i\].ToString() + " ";
                    		}
                    
                    		return s;
                    	} // ToString()
                    

                    I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

                    Thyme In The Country Interacx My Blog

                    D Offline
                    D Offline
                    Douglas Troy
                    wrote on last edited by
                    #13

                    that.sucks;


                    :..::. Douglas H. Troy ::..
                    Bad Astronomy |VCF|wxWidgets|WTL

                    1 Reply Last reply
                    0
                    • L leonej_dt

                      Agreed. this, Self and Me are keywords that serve no purpose.

                      To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #14

                      They serve limited purpose, but rarely do any harm.

                      1 Reply Last reply
                      0
                      • L leonej_dt

                        Agreed. this, Self and Me are keywords that serve no purpose.

                        To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                        D Offline
                        D Offline
                        dandy72
                        wrote on last edited by
                        #15

                        leonej_dt wrote:

                        Agreed. this, Self and Me are keywords that serve no purpose.

                        I wouldn't go that far. I avoid 'this' like the plague as a general rule, but I'll still use it as a parameter to a function, for example. What's your alternative in that case?

                        L 1 Reply Last reply
                        0
                        • D dandy72

                          leonej_dt wrote:

                          Agreed. this, Self and Me are keywords that serve no purpose.

                          I wouldn't go that far. I avoid 'this' like the plague as a general rule, but I'll still use it as a parameter to a function, for example. What's your alternative in that case?

                          L Offline
                          L Offline
                          leonej_dt
                          wrote on last edited by
                          #16

                          Ah, I forgot that. Sorry.

                          To those who understand, I extend my hand. To the doubtful I demand: Take me as I am. Not under your command, I know where I stand. I won't change to fit yout plan. Take me as I am.

                          1 Reply Last reply
                          0
                          • P PIEBALDconsult

                            I do it just to piss people off. :-D

                            R Offline
                            R Offline
                            realJSOP
                            wrote on last edited by
                            #17

                            PIEBALDconsult wrote:

                            I do it just to piss people off.

                            You're one step closer to "Outlaw" status.

                            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                            -----
                            "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                            1 Reply Last reply
                            0
                            • M Marc Clifton

                              Code:

                              	public override string ToString()
                              	{
                              		string s = String.Empty;
                              
                              		for (long i = 0; i < this.k; ++i)
                              		{
                              			s += this.data\[i\].ToString() + " ";
                              		}
                              
                              		return s;
                              	} // ToString()
                              

                              I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

                              Thyme In The Country Interacx My Blog

                              L Offline
                              L Offline
                              Le centriste
                              wrote on last edited by
                              #18

                              I would be more concern of naming a member variable "k". Why do you hate "this" so much?

                              1 Reply Last reply
                              0
                              • M Marc Clifton

                                Code:

                                	public override string ToString()
                                	{
                                		string s = String.Empty;
                                
                                		for (long i = 0; i < this.k; ++i)
                                		{
                                			s += this.data\[i\].ToString() + " ";
                                		}
                                
                                		return s;
                                	} // ToString()
                                

                                I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

                                Thyme In The Country Interacx My Blog

                                M Offline
                                M Offline
                                Member 96
                                wrote on last edited by
                                #19

                                Almost certainly it's to kick in intellisense. I do it all the time; it's a form of insurance to gurantee you are typing the correct variable name. At worst it's a difference of esthetics, it makes no other difference.


                                "It's so simple to be wise. Just think of something stupid to say and then don't say it." -Sam Levenson

                                1 Reply Last reply
                                0
                                • S Shog9 0

                                  I think his complaint is that this.k could be easily written simply as k. Although yes, k is a terrible name for a class member.

                                  ----

                                  You're right. These facts that you've laid out totally contradict the wild ramblings that I pulled off the back of cornflakes packets.

                                  M Offline
                                  M Offline
                                  Marc Clifton
                                  wrote on last edited by
                                  #20

                                  Shog9 wrote:

                                  Although yes, k is a terrible name for a class member.

                                  In the context of the class, it makes sense. Combinations(n, k), where "n" and "k" are the common math terms for these concepts. Marc

                                  Thyme In The Country Interacx My Blog

                                  1 Reply Last reply
                                  0
                                  • S StevenWalsh

                                    i use letters all the time for couters in a for loop, do you hate that?

                                    for(int i = 0; i < this.k; i++){
                                    MarcClifton.Anger++;
                                    }

                                    Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer. -Fred Brooks

                                    M Offline
                                    M Offline
                                    Marc Clifton
                                    wrote on last edited by
                                    #21

                                    StevenWalsh wrote:

                                    i use letters all the time for couters in a for loop, do you hate that?

                                    I do that all the time. And I start with "i", harking back to the days of Fortran, where "i" was the first of several letters that defaulted to integer type. Pretty crazy. Marc

                                    Thyme In The Country Interacx My Blog

                                    1 Reply Last reply
                                    0
                                    • M Marc Clifton

                                      Code:

                                      	public override string ToString()
                                      	{
                                      		string s = String.Empty;
                                      
                                      		for (long i = 0; i < this.k; ++i)
                                      		{
                                      			s += this.data\[i\].ToString() + " ";
                                      		}
                                      
                                      		return s;
                                      	} // ToString()
                                      

                                      I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

                                      Thyme In The Country Interacx My Blog

                                      S Offline
                                      S Offline
                                      Single Step Debugger
                                      wrote on last edited by
                                      #22

                                      No C++ programmers in that thread. This.IsGreat(true); Personally, I really hate to see “::someMetod() “ in the code. Why it is so difficult for someone to type the base class name?!? - especially if you have a multiple inheritance.

                                      The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.

                                      modified on Thursday, September 18, 2008 2:19 PM

                                      S 1 Reply Last reply
                                      0
                                      • M Marc Clifton

                                        Code:

                                        	public override string ToString()
                                        	{
                                        		string s = String.Empty;
                                        
                                        		for (long i = 0; i < this.k; ++i)
                                        		{
                                        			s += this.data\[i\].ToString() + " ";
                                        		}
                                        
                                        		return s;
                                        	} // ToString()
                                        

                                        I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

                                        Thyme In The Country Interacx My Blog

                                        A Offline
                                        A Offline
                                        Adam Maras
                                        wrote on last edited by
                                        #23

                                        Uh... those of you that are playing the IntelliSense card... Alt+Right Arrow is your friend ;)

                                        1 Reply Last reply
                                        0
                                        • M Marc Clifton

                                          Code:

                                          	public override string ToString()
                                          	{
                                          		string s = String.Empty;
                                          
                                          		for (long i = 0; i < this.k; ++i)
                                          		{
                                          			s += this.data\[i\].ToString() + " ";
                                          		}
                                          
                                          		return s;
                                          	} // ToString()
                                          

                                          I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc

                                          Thyme In The Country Interacx My Blog

                                          J Offline
                                          J Offline
                                          jbarton
                                          wrote on last edited by
                                          #24

                                          I am not a fan of "this." as a prefix (coming from a C++ background). The place that I work at does new development in C# and has decided to use the Microsoft StyleCop to check the code style. One of the rules of the StyleCop is that member access must be prefixed by "this.". Apparently this is the Microsoft recommended way of indicating member variable access. John

                                          K 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups