This.this.this.this.this... what has Intellisense done to us!?



  • So, coming from Java and then learning C# on my own, I carried the tradition of really only ever using "this.something" when it was really necessary to specify the scope. Now, in a larger code-base at a different company, I'm seeing code that looks like:

    if (this._SomeMember.IsSomething && this.Page.IsPostBack && !this.SomeFlag)
    	this._SomeMember.SomeMethod(this, this.SomeData);
    

    It's everywhere! Nobody can remember or type the methods or properties in their classes anymore. It's just this-dot-intellisense all day long!



  • this.We.Will.Convert(this.You, this.Yet);

     



  • this.is.funny = true;



  • You should read this :).

    And yeah, it annoys me to, but it is kinda convenient at the end of a long day to type this. and sit and think while the dropdown comes up. I tend to call methods before I've written them and all sorts of stuff like that though that Intellisense doesn't like, so I think I've avoided this disease.

    I've also seen coding conventions in which you're supposed to do this so you can tell if it's a local or a class-scope variable you're using. I hate it, personally; if your method is so big you can't see the local declarations, it needs splitting up anyway.



  • [quote user="djork"]

    So, coming from Java and then learning C# on my own, I carried the tradition of really only ever using "this.something" when it was really necessary to specify the scope. Now, in a larger code-base at a different company, I'm seeing code that looks like:

    if (this._SomeMember.IsSomething && this.Page.IsPostBack && !this.SomeFlag)
    this._SomeMember.SomeMethod(this, this.SomeData);

    It's everywhere! Nobody can remember or type the methods or properties in their classes anymore. It's just this-dot-intellisense all day long!

    [/quote]

    I don't think intellisense is the reason, you can just type CTRL-SPACE and the methods all pop up even without typeing "this." ... I think it's more likely a matter of style.  Overall, doesn't bother me either way.

    "this" does make it clear that you are using non-static methods of the class .... sometimes code is more readable when it is apparent that the method or property is from an instance of the class and not a static member of the class.

     

     


  • Discourse touched me in a no-no place

    Now, I do the this. thing too, but I'll usually go back and delete the this. after I've gotten the Intellisense.



  • @Jeff S said:

    I don't think intellisense is the reason, you can just type CTRL-SPACE and the methods all pop up even without typeing "this." ... I think it's more likely a matter of style.  Overall, doesn't bother me either way.

    "this" does make it clear that you are using non-static methods of the class .... sometimes code is more readable when it is apparent that the method or property is from an instance of the class and not a static member of the class.

     

     

    It's not a matter of style, per se, but a matter of method creeping into style. The style has been changed because nobody can remember anything.

    It also doesn't make ANYTHING clearer, because in that example I posted (which is 100% REAL LIVE CODE, anonymized) every single thing besides the if statement is prefixed with "this." It's really not hard to differentiate static from instance... just prefix static with the class-name-dot and leave instance variables and methods alone.



  • I've been doing Windows C++ development for over 7 years and I have yet to use Visual Studio as an editor.  I just could never stand it.  It always felt like an overblown notepad to me... just not useful.  It's gotten better over the years, but I've been living in the Vim world for far too long to look back.  I do use Visual Studio for debugging only, and now I also use it to compile projects (previously used cmd-line make tools, but this new company doesn't, unfortunately).

    At my previous job, our CTO was a hard-core linux lover, and wanted people to have strong linux/console skills to be hired, so interviewees had to take a programming test, and all we gave them was a linux console and access to vim/emacs.  Ironically we were a 95% windows shop.  We would have written everything for linux, but most companies want windows solutions for obvious reasons.  This is where I was "indoctrinated to the world of Vim"

    Long live Vim! (and Emacs I guess)....  The only intellisense I have is in my brain and sometimes with the help of grep and reference material :P

    [Edit: No I'm not trying to spark flame wars here.  Everyone has their preference and a work environment that works best for them.  This is mine.]



  • [quote user="FrostCat"]Now, I do the this. thing too, but I'll usually go back and delete the this. after I've gotten the Intellisense.[/quote]

     

    or you could just type the first couple of letter of what it is your trying to pull out of intelisense and hit CTRL-SPACE and it bring up intelisense or fill in the rest if there are no other "hits".  If anyone is typing "this." just to bring up a list of intelisense choices you might want to take 3 seconds to learn all the ways to use intelisense.



  • If you're using Visual Studio, then you need to own a copy of Resharper. Seriously, it's the best thing to happen to Visual Studio ever... forget the built-in refactorings, Resharper is much, much faster. Plus, its code-cleanup abilities are wonderful... they'll remove 'this.' everywhere they safely can.

    If you're using Eclipse, then ignore the above statement... Eclipse has plugins that do the same thing.



  • If you're relying on "this." to cue Intellisense simply because you can't remember all the stuff that's in the class, and its size makes it infeasible to easily scroll and check, then perhaps it's time to start doing a bit of refactoring.



  • [quote user="e.thermal"]

    [quote user="FrostCat"]Now, I do the this. thing too, but I'll usually go back and delete the this. after I've gotten the Intellisense.[/quote]

     

    or you could just type the first couple of letter of what it is your trying to pull out of intelisense and hit CTRL-SPACE and it bring up intelisense or fill in the rest if there are no other "hits".  If anyone is typing "this." just to bring up a list of intelisense choices you might want to take 3 seconds to learn all the ways to use intelisense.

    [/quote]

     

    this.S.M(space)&&this.P.IsP(enter)(space)

    this.Something.Property && this.Page.IsPostBack

    I'm a quick typist, so this.JustWorksForMe. 



  • @Benanov said:

     

    this.S.M(space)&&this.P.IsP(enter)(space)

    this.Something.Property && this.Page.IsPostBack

    I'm a quick typist, so this.JustWorksForMe. 

    If you're doing that approach, you don't need to type the "this." first to have it start suggesting (unless you've done something really weird with your VS settings).



  • [quote user="skippy"]

    I've been doing Windows C++ development for over 7 years and I have yet to use Visual Studio as an editor.  I just could never stand it.  It always felt like an overblown notepad to me... just not useful.  It's gotten better over the years, but I've been living in the Vim world for far too long to look back. 

    [/quote]

    Really? Being a C++ programmer I myself think that Visual Studio is about the only good application that MS has ever made, and also a wonderful example of solid, good user interface design.  Unfortunately, it also touts MS's infamously long version cycles and non-existant customer suppert. I've suffering from a (known) bug that makes IntelliSence hang from infinite regress when parsing recursive templates (it worked in VS.NET but the bug was introduced in VS 2005). It has been known for perhaps a year, and MS answer is that it will possibly be fixed in an upcoming service pack. Specific corporate customers can get a hotfix, but individuals are out of luck. Atm I'm forced to use an external editor when opening certain files, which I to my great dismay forget ever so often... (>,<)/



  • @Mikademus said:

    Specific corporate customers can get a hotfix, but individuals are out of luck.

    Now that's a pretty good WTF all by itself.



  • [quote user="skippy"]

    At my previous job, our CTO was a hard-core linux lover, and wanted people to have strong linux/console skills to be hired, so interviewees had to take a programming test, and all we gave them was a linux console and access to vim/emacs.

    [/quote]

    I am pretty good at unix, but I would fail your test as my attitude as a programmer is that unless I can have a graphical editor (usually nedit) with menus then the build machine is broken and I complain to the sysadmins.  If I was a sysadmin and setting up linux from scratch then learning vi or emacs would be mandatory, but as a programmer I assume the machine will be setup and an X server running before I go anywhere near it.

    knowing what crtl-X-Y-Z does in emacs != understanding of unix
     



  • You're right that vim/emacs are horrible editors to learn (but wonderful to use) and of course knowning the keyboard commands has nothing to do with being a good programmer.

     So let's take the cli editors out of the picture. You get to use KEdit/GEdit or whatever the current window-based text editor may be. The console is just an open shell, and you're running X and a desktop environment already. How would you do?

     
    The key, of course, is knowing the build process: editing, compiling, linking, running. For multiple files, writing makefiles. Do you know that, when using math functions defined in math.h, you'll have to link the libmath by adding -lm to the compiler options? Do you know how to specify the class path to run your java class, or how to build a jar file? Can you trhrow together a GUI without using an interface builder? Can you start a new project without relying on a 'Win32 command line application' wizard?

     If you don't know the details of the build process, and you have to rely on an IDE to do all the work for you, then you're missing out on some important knowledge that will slow you down as soon as you run into any kind of trouble. Understanding the system is essential for sensible debugging and troubleshooting :)

    I think that's the focus of the test, and that's why I like it.
     



  • [quote user="Nandurius"]

    You're right that vim/emacs are horrible editors to learn (but wonderful to use) and of course knowning the keyboard commands has nothing to do with being a good programmer.

     So let's take the cli editors out of the picture. You get to use KEdit/GEdit or whatever the current window-based text editor may be. The console is just an open shell, and you're running X and a desktop environment already. How would you do?

     
    The key, of course, is knowing the build process: editing, compiling, linking, running. For multiple files, writing makefiles. Do you know that, when using math functions defined in math.h, you'll have to link the libmath by adding -lm to the compiler options? Do you know how to specify the class path to run your java class, or how to build a jar file? Can you trhrow together a GUI without using an interface builder? Can you start a new project without relying on a 'Win32 command line application' wizard?

     If you don't know the details of the build process, and you have to rely on an IDE to do all the work for you, then you're missing out on some important knowledge that will slow you down as soon as you run into any kind of trouble. Understanding the system is essential for sensible debugging and troubleshooting :)

    I think that's the focus of the test, and that's why I like it.
     

    [/quote]

    I guess this would be an understandable test for a "programmer", but what if you're interviewing someone who knew all the coding syntax, rules, and standards well enough, but was better at doing the architecture of the system as a whole over the semantics of how to code it to make that architecture work? Constraining such a person to vim and emacs alone along with the command line compiler is like telling a construction foreman that he's only allowed to use a hammer, nails, 2x4 lumber and a plumb line to erect the walls of a house when an auto-nailer, laser sight/level, and various sizes of lumber might make the job much faster, and potentially with higher quality than with the "original" equipment alone.

    That just strikes me as an elitist bent of a WTF job rather than the typical moron WTF of most places. Both still contain some level of WTFery. 



  • [quote user="cavemanf16"]I guess this would be an understandable test for a "programmer", but what if you're interviewing someone who knew all the coding syntax, rules, and standards well enough, but was better at doing the architecture of the system as a whole over the semantics of how to code it to make that architecture work? Constraining such a person to vim and emacs alone along with the command line compiler is like telling a construction foreman that he's only allowed to use a hammer, nails, 2x4 lumber and a plumb line to erect the walls of a house when an auto-nailer, laser sight/level, and various sizes of lumber might make the job much faster, and potentially with higher quality than with the "original" equipment alone.

    That just strikes me as an elitist bent of a WTF job rather than the typical moron WTF of most places. Both still contain some level of WTFery. [/quote]

    The idea is (to continue your analogy) that any person in construction worth his salt should be able to use just a hammer, nails, and a plumb line when the auto-nailer, and laser sight/level are unavailable. Yes, it'll be slower going, but if you can use an auto-nailer but can't figure out a hammer and nails, you're not cut out for construction.

    Still, I agree with you -- it's a stupid test. Command-line compilation sucks my rosy ass, and any hard-core CL bastard should rot. The last thing I want to do is write out a ton of command-line switches for compilation and linking even once for a makefile (and believe me, they get frickin' long for even the simplest of programs) when I can use a GUI control panel and check a few boxes. It's not knowing that -lm is shorthand for -l math that's important, it's knowing that you have to link in the math.lib library if you used math.h. Why bother typing -lm (along with -l*, ad nauseum for all the libraries I used) when I can just type the names of the libraries I need into a text box and run? I like to type as much as the next guy, but that's just insane, living in the dark ages like that. skippy,  you need to give your former boss a casset tape player so he can move into the 80s. Maybe after a year or two there, he can finally get a CD player and move into the 90s.



  • [quote user="Nandurius"]Can you start a new project without relying on a 'Win32 command line application' wizard?[/quote]

    How about this: Can you write a C++ program in Visual Studio starting with a blank project? You have to add all the right switches and libraries...


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.