Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
C0D4667774yI suddenly don't feel bad for
//this will break the fuck out of everything if ran during tests - don't ask, just go with it.
If(!config.testsAreRunning){
// do this because it's an actual user
} -
This looks like a legitimate place for one of the most hard-to-write comments ever.
-
-
@Demolishun
That isn't enough information.
I don't know the language. But:
The combination of expression result caching and reevaluation on change of participating variables is probably not what the average coder expects to happen.
This probably triggers a WTF-is-going-on?! moment in whoever reads that code - including yourself one year from now...
// The always-true check on editing triggers reevaluation of
// the function whenever editing changes:
property var value: if(editing || !editing) function(othervalue)
This still isn't a really good comment, but it at least tries to explain, why the WTF expression is there and what the author expected it to do.
If reevaluation of expressions is rarely used (not a common idiom), you might want to also mention, that change of othervalue also triggers reevaluation... -
@Oktokolo After researching and seeing comments in posts on the forum for this language I am thinking this kind of hacking is common.
-
@Oktokolo Well I use 3 languages at once: QML, Javascript, and C++. It is also my job, so no running away. QML is declarative and uses signals to notify of value changes. This is the part I am hacking. The rest is "okay".
Related Rants
-
BrianValente33I'll start implementing this in my apps too.
-
nmunro15How I've decided to answer the "can you hack" question from here on in... "Can you show me how to hack this a...
-
nikolatesla13Friend: So you're a programmer? You must be good in hacking WiFis and sht. Me: Uhm.. Friend: Can you hack my...
Hacky code post:
property var value: if(editing || !editing) function(othervalue)
I am coding in a property system that only updates an expression if a variable involved emits a signal. Well the function won't get called unless I change a value. I also want to "value" to be updated when editing changes. I also want it to update even if editing doesn't change. So the or-ing of the state of editing.
The result is the function gets called when object is initialized. Then when the editing flag changes it gets updated again. The workaround of doing this is much worse and requires more hacky code. So I am resigned myself to just or-negating the editing value.
random
hack