|
bad one
That's why I always let resharper generate the properties directly from the Ctor parameters. Never ever again
Best regards and happy coding,
chris
|
|
|
|
|
Some languages would let you know about something called an unreferenced parameter.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Chris Meech wrote: Some languages would let you know about something called an unreferenced
parameter.
some will call you a idiot if you try to assign a variable to itself
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Which isn't what it's doing: they are just symantic sugar for
SetProperty(GetProperty()); And although it is a really bad idea, I have seen code where
MyProperty = MyProperty; Has a effect. Nasty, but it can be done.
(I even found myself coding it once, and had to quickly refactor a bunch of code to get rid of it)
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
my bad, don't see it's a property...
but even then, i already received warnings about assigning a property to himself... maybe it was one of the statical analysers we had here for a while.
They usually were wrong about the code, so the architect took them away...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
OriginalGriff wrote: Has a effect. Nasty, but it can be done.
The good old "Let's put a bunch of logic in a property setter" mentality. Seen that too.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
That would make sense, but only if the logic is just to validate the value, and i can't think of a case where doing MyProp = MyProp should do something
Converselly, i had to port a system, writen in vb 6, where all the properties had a explicit check for this, because otherwise this case would screw everything
Oh that moments when you catch yourself thinking if the original coder had too much or too little cafeine in their blood...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
I have actually written that at some point. I can't remember exactly why but it was something like triggering the data binding notification process. The line got a comment to say why I was doing it, though!
|
|
|
|
|
I always call a specific databinding method. Exactly because of the confusion it could cause, experienced first hand from code that I took over on one of my supported systems.
|
|
|
|
|
|
At the Company i am working in the Intellicence gave me These two methods.
Microcernel.Create<iprinter>().
1. PrintLabel()
2. PrintLable()
Both methods contained the same oneliner.
this._Label();
|
|
|
|
|
I'm not sure, but I've always thought it would be funny to leave this in some code and see people's faces:
if(10 != 10){
abort();
}
=====
\ | /
\|/
|
|-----|
| |
|_ |
_) | /
_) __/_
_) ____
| /|
| / |
| |
|-----|
|
=====
===
=
|
|
|
|
|
You need to combine that with an adapted vague comment:
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Do not feed the troll ! - Common proverb
|
|
|
|
|
I've seen that in older Fortran programs on compilers for systems that didn't have comparison against constants in their assembly language. They saved zero in a particular location and all comparisons were done against that location. Occasionally, someone would unknowingly pass 0 into a routine in the parameter position where the value was changed by the routine. That is when zero stopped becoming zero and was something completely different. It read something like
if ((0+1) .ne. 1) call abend
|
|
|
|
|
This variant is better for perplexing beginners:
if ( 010 == 10 || 07 != 7) {
abort();
}
(The test is false [ 010 is not equal to 10, but 07 is equal to 7 ] in most C derived languages)
|
|
|
|
|
I worked on a system where the Fortran compiler generated constants in memory locations. All subroutine calls used pass by reference, so it was very easy for a constant to get changed. And very difficult to debug with the tools available in that day and age.
|
|
|
|
|
Prime OS had that, as well as GEC (IIRC)
It made for some "interesting" debugging the first couple of times it happened, but then you leant not to trust constants!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Mine was a comment left by a former employee
"This is where the magic happens, Im a genius and it has nothing to do with Ducks!"
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Where 1=1
I mean that is obvious..
|
|
|
|
|
That's a good point to start complex WHERE clauses. Just add all other constraints with an AND X=Y . You do not need to worry if the statement is the first statement (no AND required) or not (AND required).
|
|
|
|
|
That's specially useful when you need to constantly comment in and out some of the conditions to find the right records.
Without that you'd have to worry to every time replace the AND for a WHERE and vice-versa.
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
----
Our heads are round so our thoughts can change direction - Francis Picabia
|
|
|
|
|
Fabio Franco wrote: That's specially useful when you need to constantly comment in and out some of
the conditions to find the right records. Without that you'd have
to worry to every time replace the AND for a WHERE and vice-versa.
For that, I use TRUE , e.g. in SQL:
WHERE TRUE
AND X=Y
AND A=B
You can then comment in / out the real conditions without any worries about whether a leading AND is needed or not or even if any conditions remain. e.g.
WhereClause = "WHERE TRUE "
& ( test1wanted ? "AND X=Y " : "" )
& ( test2wanted ? "AND A=B " : "" );
|
|
|
|
|
Same thing, except "1=1" is only three characters long
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
----
Our heads are round so our thoughts can change direction - Francis Picabia
|
|
|
|
|
My apologies! I had misread your previous comment.
|
|
|
|
|
No need to
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
----
Our heads are round so our thoughts can change direction - Francis Picabia
|
|
|
|