-
this
When I want to use a method in my own class is it faster to call it via
this.MethodName() or just the MethodName(). Does it really matter?
-
Re: this
Doesn't matter. The compiler compiles it to the same IL code anyway.
--
Nathan Alden
Microsoft Certified Solution Developer
-
Re: this
Thanks. Although I will probably stick to this because of readability.
"Nathan Alden" <liverpg@hotmail.com> wrote in message
news:3c828a40@10.1.10.29...
> Doesn't matter. The compiler compiles it to the same IL code anyway.
> --
> Nathan Alden
> Microsoft Certified Solution Developer
>
>
-
Re: this
Actually, I would not recommend that. I would be quite annoyed if all I saw
on a code page were "this." everywhere. I can figure out where the
method/property/field exists simply by inspecting it. "this." is a little
too verbose.
--
Nathan Alden
Microsoft Certified Solution Developer
-
Re: this
Great, what are your thoughts on const should the appear in all uppercase or
camel notation?
"Nathan Alden" <liverpg@hotmail.com> wrote in message
news:3c828c3c@10.1.10.29...
> Actually, I would not recommend that. I would be quite annoyed if all I
saw
> on a code page were "this." everywhere. I can figure out where the
> method/property/field exists simply by inspecting it. "this." is a little
> too verbose.
> --
> Nathan Alden
> Microsoft Certified Solution Developer
>
>
-
Re: this
The docs say that constants should use PascalCase. Of course, that only
applies to ones marked public.
--
Jonathan Allen
"Humberto Morales" <humberto@socal.rr.com> wrote in message
news:3c828ee9$1@10.1.10.29...
> Great, what are your thoughts on const should the appear in all uppercase
or
> camel notation?
>
> "Nathan Alden" <liverpg@hotmail.com> wrote in message
> news:3c828c3c@10.1.10.29...
> > Actually, I would not recommend that. I would be quite annoyed if all I
> saw
> > on a code page were "this." everywhere. I can figure out where the
> > method/property/field exists simply by inspecting it. "this." is a
little
> > too verbose.
> > --
> > Nathan Alden
> > Microsoft Certified Solution Developer
> >
> >
>
>
-
Re: this
I would only recomend the "this" if your parameter names in a constructor
or a set method is the same to that of the member variable names. Secondly,
when you are dealing with windows forms and you have created a class to deal
with logic from an event on the main from and that class needs to be instantiated
in the main form. By passing the this to that class, you will have access
to the main form's controls.
-Jaleel
"Jonathan Allen" <greywolfghost@cox.net> wrote:
>The docs say that constants should use PascalCase. Of course, that only
>applies to ones marked public.
>
>--
>Jonathan Allen
>
>
>"Humberto Morales" <humberto@socal.rr.com> wrote in message
>news:3c828ee9$1@10.1.10.29...
>> Great, what are your thoughts on const should the appear in all uppercase
>or
>> camel notation?
>>
>> "Nathan Alden" <liverpg@hotmail.com> wrote in message
>> news:3c828c3c@10.1.10.29...
>> > Actually, I would not recommend that. I would be quite annoyed if all
I
>> saw
>> > on a code page were "this." everywhere. I can figure out where the
>> > method/property/field exists simply by inspecting it. "this." is a
>little
>> > too verbose.
>> > --
>> > Nathan Alden
>> > Microsoft Certified Solution Developer
>> >
>> >
>>
>>
>
>
-
Re: this
I was using "this" for readability, but it's difficult to type, it clutters
up my code, and I sometimes forget to put it in. That does not seem to increase
readability to me.
What I found works, and works well, is if you develop the convention of prefixing
class variables with an underscore.
private string _myVariable = "";
That way, you get the benefit of readability without the clutter, and the
compiler usually tells you when you have made a mistake.
This also removes all ambiguity when you have a property and a class variable
with the same name.
Try it out and see if you like it. I thought it was silly the first time
I saw it, but now that I have started using it, I think it's a really amazing
coding convention!
-
Re: this
> I would only recomend the "this" if your parameter names in a constructor
> or a set method is the same to that of the member variable names.
You shouldn't use a naming scheme that relies on "this" to resolve
ambiguities, as it leads to logic errors.
--
Jonathan Allen
"jaleel" <jaleel_severin@yahoo.com> wrote in message
news:3c83dd19$1@10.1.10.29...
>
> I would only recomend the "this" if your parameter names in a constructor
> or a set method is the same to that of the member variable names.
Secondly,
> when you are dealing with windows forms and you have created a class to
deal
> with logic from an event on the main from and that class needs to be
instantiated
> in the main form. By passing the this to that class, you will have access
> to the main form's controls.
>
> -Jaleel
>
>
> "Jonathan Allen" <greywolfghost@cox.net> wrote:
> >The docs say that constants should use PascalCase. Of course, that only
> >applies to ones marked public.
> >
> >--
> >Jonathan Allen
> >
> >
> >"Humberto Morales" <humberto@socal.rr.com> wrote in message
> >news:3c828ee9$1@10.1.10.29...
> >> Great, what are your thoughts on const should the appear in all
uppercase
> >or
> >> camel notation?
> >>
> >> "Nathan Alden" <liverpg@hotmail.com> wrote in message
> >> news:3c828c3c@10.1.10.29...
> >> > Actually, I would not recommend that. I would be quite annoyed if all
> I
> >> saw
> >> > on a code page were "this." everywhere. I can figure out where the
> >> > method/property/field exists simply by inspecting it. "this." is a
> >little
> >> > too verbose.
> >> > --
> >> > Nathan Alden
> >> > Microsoft Certified Solution Developer
> >> >
> >> >
> >>
> >>
> >
> >
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks