|
Unless I have a construct like:
public class X{
private int number;
public X(int number){
this.number = number;
}
}
I rarely uses this .
|
|
|
|
|
I would say to use the property assignment 'this' in the following scenario:
void foo(int someValue)
{
this.someValue = someValue;
this.SomeMethod(AnotherClass.SomeMethod());
}
But not in the following scenario:
void foo()
{
someValue = 5;
SomeMethod(5);
}
With ThisClass.SomeStaticMethod() I'd always use is as you did unless of course you are using the static method of the class you are working in, then I'd just use SomeStaticMethod.
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >>
|
|
|
|
|
this is good and I use it normally. The fact that it seems to annoy some pooples just encourages me to use it more.
|
|
|
|
|
such a trouble maker and non-conformist.
|
|
|
|
|
"this." triggers any auto-completion or Intellisense in the world. Yes I'm lazy - I wouldn't train machines to do men's work if I wasn't
|
|
|
|
|
If you just type one or two letters and then press Ctrl + Space, you would also get Intellisense and have to type even less.
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
I don't think you have to type anything at all...
My blog[ ^]
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
It has become a habit for me to use 'this,' to type in access modifiers even when not required, and to never create duplicate names, but, over the last two years, I have transitioned to using 'var freely which I know causes some people to break out in a poison sweat.
I don't think these are particularly "bad" habits, but they are not any saving-grace of poor-quality design, or coding, either. At best, a syntactic sugar that may contribute to maintainability and future re-use ? But, I work alone, not in a team-setting.
If (gods forbid) I was managing a commercial software dev team, oh yeah, I'd plump for standards.
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Interesting that a lot of people do use this. I did not expect that.
I don't like it. It just clutters up with extra code that is unnecessary.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
BillWoodruff wrote: At best, a syntactic sugar Almost agreed.
The var keyword can actually be quite dangerous as I have witnessed a few times myself.
I work with Entity Framework a lot, which uses IQueryable to create queries that run on the database and return a result as IEnumerable that can be used in your application. Interface-wise there is little difference between IQueryable and IEnumerable , but the function of the two differs greatly! A few times I changed my IQueryable to IEnumerable and nothing broke, because the IQueryable was declared using var . The type of my variable just 'silently' changed to IEnumerable and all of a sudden my app wouldn't perform very well. Thing is, in order to create an IEnumerable the query was executed on the database. This was supposed to happen a few lines later, but because I put a ToList() function somewhere in between this was done to early. All my filter functions were done on the in-memory collection instead of the database.
Of course you'd also have this problem if you declared your IQueryable as IEnumerable (an IQueryable IS an IEnumerable ), but at least you'd explicitly choose to define it as such.
I haven't seen this problem with other .NET interfaces, probably because none of them are so common and so costly as IQueryable , but I could imagine it happening when working with Streams or some such base class which has a few subclasses that do different things.
My blog[ ^]
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
I have noticed in Android (and Java generally) they often prefix with m like mSomeMemberVariable instead of using this.
maybe it depends on the IDE if it has a good IntelliSense.
modified 20-Oct-19 21:02pm.
|
|
|
|
|
In the world of free VS, first there was the Express edition, which lacked things like a resource editor (for unmanaged code), etc. Anyone know what the deal is with the Community edition? Is it still gimped somehow? The sales pitch says it has more to it than the Express edition, but doesn't say what exactly.
I won't install it since I have 2013 Ultimate, but my MSDN sub expired and I really don't feel like getting a new one when VS 2015 hits the scene.
Jeremy Falcon
|
|
|
|
|
|
Richard's post was exactly what I was looking for. Thanks though.
Jeremy Falcon
|
|
|
|
|
It's VS2013 Pro with a limited license:
- Any individual developer can use Visual Studio Community to create their own free or paid apps.
- An unlimited number of users within an organization can use Visual Studio Community for the following scenarios: in a classroom learning environment, for academic research, or for contributing to open source projects.
- For all other usage scenarios: In non-enterprise organizations, up to 5 users can use Visual Studio Community.
In enterprise organizations (meaning those with >250 PCs or > $1 Million US Dollars in annual revenue), no use is permitted beyond the open source, academic research, and classroom learning environment scenarios described above.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That's actually pretty cool. I really like the OSS touch. Crazy to see MS heading in that direction. The times; they are-a changing.
Jeremy Falcon
|
|
|
|
|
|
Yeah I read about that man. Even though I'm still a C/C++ guy, I have to admit I'm liking this a lot. If it becomes truly cross platform, instead of having to use a mono-type knock-off, I'm going to be extremely tempted to make the switch.
Jeremy Falcon
|
|
|
|
|
Is it just me, or is there a huge gap between companies that have ~250 PCs, and companies that make in the neighborhood of $1 million in yearly revenue?
Or to put it another way... what company has 249 PCs but makes less than $1 million a year?
Pretty sure there should be an extra 0 or 2 on that revenue amount for the comparison to be relevant.
|
|
|
|
|
I think they intended that as a catch-all, to prevent someone from using it for free in a large corporation that did not yet have sales, or never would.
I suppose a research subsidiary of a for-profit corporation?
A million in revenue is a pretty low target too. Product sales company on a 5% net margin, still only $50K a year net income.
|
|
|
|
|
I think revenue is a company's gross income, not their net.
Even non-profit organizations require revenue to pay the salaries of their employees.
How many employees can a company afford to have if they are making less than $1 million a year?
|
|
|
|
|
Yes, I was pointing out that as it applies to for-profit companies, the license restricts it to probably 1 or 2 employees.
They're aiming at making it free for start-ups, students, and lone programmers, probably on the theory that if you write enough of your code in it, you'll pay to use it rather than switch.
|
|
|
|
|
The problem is that MS doesn't currently offer a viable solution for "small" software development companies anymore.
In "ye olden tymes", it was simple, you just bought a MSDN subscription for every in-house developer and they were legal to create software for every MS OS using any/every Microsoft tool available.
Now you have to purchase separate licenses for the particular version of Visual Studio you want to use/support, so you end up with situations like ours: a small handful of people doing "new" work in Visual Studio 2012 while the rest do their maintenance work using VS2005.
I had hoped that the new Community Edition might provide a solution, but MS's odd definition of "Enterprise Organization" leaves us out.
|
|
|
|
|
Perhaps the Microsoft definition of 'Enterprise Organization' should read 'Possibly Viable Business'.
Once a startup has a few paying customers, Microsoft wants a piece of the action.
Probably someone tallied up their net revenue from educational licences and realized that it would be far cheaper to give the software away.
|
|
|
|
|
Just get it. Get it now!
(I was able to modify some MFC code I couldn't work on before. I also did a 30 sec test of the resource editor in a C# project, and it worked. Far better than Express, and worth the additional 5 GB on the hard drive.)
|
|
|
|