Skysnake Posted December 8, 2017 Posted December 8, 2017 (edited) Quote The rule is that Case statements with most events should be in top of the list. From From here, bottom of the post I am not arguing the logic of this, merely would like to point out that if there is such a rule, it is not documented... Are there other such rules? Skysnake Edited December 8, 2017 by Skysnake Skysnake Why is the snake in the sky?
jchd Posted December 8, 2017 Posted December 8, 2017 It isn't a rule, but something you can consider in any on-the-fly interpreted language. Consider this simple sequence: If <Condition> Then [13,000 lines of code] Else [Action] End It's obvious that, unless a form of compilation has taken place which can jump direct to [Action] when <Condition> isn't met, the interpreter will have to read and ignore 13,000 lines, something which wastes time. Hence if you expect the false branch to be significantly more frequent than the true branch, you should swap them and negate Condition. Earthshine and Skysnake 2 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Earthshine Posted December 8, 2017 Posted December 8, 2017 lol, never send an if to do a switch's (case) job My resources are limited. You must ask the right questions
Skysnake Posted December 8, 2017 Author Posted December 8, 2017 Thank you. Perhaps this thread should live with the "good coding practice" posts? Are there any other such? (eager to learn) Earthshine 1 Skysnake Why is the snake in the sky?
Earthshine Posted December 8, 2017 Posted December 8, 2017 (edited) Follow Modular design patterns in general. Split things into small autonomous units. Never glom everything into a monolithic structure. (this one is important. Having one place to edit in case of changes instead of many files to edit. maintainability) Use good meaningful variable names Don't get carried away with macros, not to say don't use them Keep functions small, over 50 lines and you need new supporting functions (this works well with C/C++/C# but not sure if applicable to AutoIT and otehr scripting languages, but I try to do this with AutoIT. Most of what makes my functions longer are just logging if they get long in AutoIT cause I am a logging fool Don't follow the Single Entry Single Exit nonsense bullcrap either. If you run into a condition you need to break from the function, then do it Don't use GoTo statements (obviously they lead to spaghetti logic that can't be maintained) Use Constants for strings and stuff that does not change. that way, when something needs to change, it changes in one spot, not many Edited December 8, 2017 by Earthshine Skysnake 1 My resources are limited. You must ask the right questions
Moderators JLogan3o13 Posted December 8, 2017 Moderators Posted December 8, 2017 1 hour ago, Skysnake said: Thank you. Perhaps this thread should live with the "good coding practice" posts? Are there any other such? (eager to learn) I would agree. Why not add them to the existing thread below rather than starting another. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
LarsJ Posted December 10, 2017 Posted December 10, 2017 I added the note about order of Case statements in relation to code in a WM_NOTIFY message handler. This is important for a message handler which handles a huge number of events which is the case for a virtual listview. This is in accordance with the warning under remarks for GUIRegisterMsg function in the help file. GUIRegisterMsg is used to create the message handler. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now