quote:
Originally posted by Amec
quote:
Originally posted by CookieRevised
js code:
with (OpenFileName) {
Every time you use a with statement, a teddy bear cries.
http://www.yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/
Yeah, well, you're 5 years to late....
Although I agree for 50%, it is mostly also a matter of schematics. There is essentially nothing wrong with using
with() if you know what the code will do. In the code snippet it is also used for the exact purpose that
with() statement was invented and there are enough
readDWORD() statements to justify the use of
with() imo.
May I also quote that very same page you linked to:
quote:
If you can’t read a program and be confident that you know what it is going to do, you can’t have confidence that it is going to work correctly. For this reason, the with statement should be avoided.
I can read the program and I am 100% confident in knowing what it is going to do and that it is going to work correctly.
Lastly, it is not my code:
quote:
Originally posted by CookieRevised
So here is my variation, based upon Matti's variation of Choli's snippet. It is of course different, but not that different to be completely 'new'. As such, I've also tried to keep most of the structure and variable names used in the previous variations.
Note that there are also other parts in the code which could be made shorter/smarter/cleaner/etc. But that was not the purpose of showing or updating that code.