"If (YouLoveVCL = true) then TReadThisNow.Create();"
"If (YouLoveVCL = true) then TReadThisNow.Create();"
That was the subject on an EMBT marketing email I just received.
1. You should never compare a boolean with True
2. You should not do work in the constructor
3. This leaks memory (even on NextGen I think?)
Are you spotting any more bad coding practices? :)
That was the subject on an EMBT marketing email I just received.
1. You should never compare a boolean with True
2. You should not do work in the constructor
3. This leaks memory (even on NextGen I think?)
Are you spotting any more bad coding practices? :)
More of a personal preference but I like if statement to be on two lines, the second indented :-)
ReplyDeleteNicholas Ring Same, but as this was an email subject I don't argue about formatting :)
ReplyDeleteStefan Glienke Is it bad practice to put everything on one line? ;-)
ReplyDeleteAdd the useless parenthesis (both sets), this is not C or Java!
ReplyDeleteI prefer parenthesis when calling methods, makes it easier to differentiate between methods and properties and if one passes the return value of a method or the method itself.
ReplyDeleteNicholas Ring if your code is C/C++, it's ok to put everything in one line, nobody is going to debug/maintain your mess anyway ;-D
ReplyDeleteCreating a reading situation without executing it. I do not like the (), and since properties also can have side effects in the getter, I don't use them, even for clarity. I'd also break that line, omit the = true.
ReplyDeleteif You.LoveVCL
then You.ReadThisNow(rmASAP);
Makes me curious, though - what was the real story?
Promoting a coming webinar, I guess. I agree fewer parenthesis would have been better. Honestly, if it compiles, this is already quite good...
ReplyDeleteMarco Cantù Is that also the philosophy of FMX? If it compiles, ship it?
ReplyDeleteBefore we go full tilt, I remind and encourage us all that we stay with using the UnitNo5 group for rants and rages, and keep the climate here focused on solutions more than on complaints :)
ReplyDeleteIf this is a message that Embarcadero will focus on VCL again and fix VCL bugs, I am quite happy about that :)
ReplyDeleteOndrej Pokorny Yes, more VCL focus, some specific new features, VCL bug fixes... are in the works.
ReplyDeleteThis comparison with TRUE makes me mad every time I see it! Damn, it's a simple Boolean logic... And these useless parentheses - come on, this is not Java. The memory leak is obvious.
ReplyDeleteBasically: If You.LoveVCL then You.ReadThis(Now);
ReplyDeletePurely as a thought exercise: would this create a memory leak on an ARC-enabled platform? I would expect the object to be created, AddRef'd and immediately Release'd and therefore freed. But I'm not certain about that in this case, since the newly created object is never explicitly assigned to anything.
(It's a bit of a moot point in this case, since the post is about VCL, which implies no ARC).
Michael Thuma The semicolon is not really necessary if this statement is the only one in the begin...end block, but I prefer to use them anyway - makes the statement look complete.
ReplyDeleteMichael Thuma Now you have an extra closing parenthesis after the semicolon ;-)))))
ReplyDelete