|
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
|
|
|
|
|
As a variation on that, you could do something like this:
if ('l' == '1')
{
Abort();
}
Just to play with people who would use fonts that don't distinguish the two well...
|
|
|
|
|
|
I have seen that code in a VB6 app and it was a convenient way to get an empty but initialized (containing columns you were interested in) RecordSet from the database that you could then populate with data and save.
|
|
|
|
|
Just make sure they do not come up with PrintLibel() and this._Libel.
|
|
|
|
|
I frequently use
select * from tbl where 1 = 2
when I'm trying to figure out the columns in a table.
|
|
|
|