Sign in to follow this  
Followers 0
darren_burgess

best practice programming

4 posts in this topic

Ok, so here is a general question. I am writing this script to automate recording in Cakewalk. It has several discreet sections, each does a specific task in the process and is commented as such. All of this is contained in a While loop.

I have thought that it might make sense to put each subroutine into user defined functions and then call the functions in the while loop. It would make my loop shorter and cleaner and I could shrink down each function in the editor if I am not working with it.

So is this a typical programming best practice? Or is there some other way that the pros do it? Or is it just personal preference? Or am I just being anal? LOL

Darren

Share this post


Link to post
Share on other sites



Hi,

i would do commands in funcs when need them more then once. Then you needn't to code the lines again and can can easily call the func. :whistle:

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Who are you programming for? Think about the person who will see the code, and what you think would best suit them. If its only going to be you. Do whatever you want. I normally put them into functions because its alot easier for me to go back to the code months lately and know exactly what im doing.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'll not go into what has already been discussed as those are good *coding practices*. I'll offer *app/script design* wisdom:

1 word: OPTIONS

Regardless of who/what you're programming for, NEVER HARD CODE values. Rather, take the time to create GUIs/parameters that give the user the option of adjusting values.

Another word: GUI

Creating a GUI for scripts may seem backwards, but it makes using/configuring the scripts easier. I've written a number of scripts and find that I use the GUI I've made to accomodate novice users as well. Granted, that brings me to my next word(s). Using CyberSlug's GUI builder makes creating GUI's just as easy as creating them in VB.

Another word: COMMAND LINE PARAMETERS (ok, that's 3)

Even thou I have GUIs for most of my scripts, I've set them up in a way that they can run without the GUI by accepting command line parameters. This lets users batch your script but also allows for shortcuts to be made by your GUI to the users desktop for repeated usage. (See my shuffler, renamer, autorun, and wmpplexp scripts at http://code.shrum.net for examples; source and online help is available within)

Just some of my coding mantra...your milage may vary.

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0