Page 1 of 1 1
Topic Options
#116456 - 2004-03-19 07:57 PM Tips to stay organized when coding?
mrwumpus Offline
Fresh Scripter

Registered: 2003-09-04
Posts: 14
Loc: California, USA
I'm a noob at KiX (all programming really) but a veteran at being disorganized. I start KiX projects that I can hardly read the next day. Does anyone have tips or links to help me organize a project beforehand and stay organized during?

I know about properly labeling variables and functions, but does anyone actually map out their program beforehand, a script for their script if you will? I know this is probably Computer Science 101 but I was an English major!
_________________________
Jason

Top
#116457 - 2004-03-19 08:05 PM Re: Tips to stay organized when coding?
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
as an arts major, you should stick to asking if someone wants to supersize their meal.



OK... a few things

when I write an IF statement, I'll write the IF and then ENDIF, and then fill the parameters in

the same goes for Function/endfunction, for next, do while etc...

I will do similar things for quotes:' ' or " " and then fill it in.


UDFs should go to the end of the script, to get them out of the way.

Make sure to use lots of comments to describe the logical steps in your code
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#116458 - 2004-03-19 09:11 PM Re: Tips to stay organized when coding?
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3165
Loc: Houston TX
Quote:

I'm a noob at KiX (all programming really) but a veteran at being disorganized. I start KiX projects that I can hardly read the next day. Does anyone have tips or links to help me organize a project beforehand and stay organized during?

I know about properly labeling variables and functions, but does anyone actually map out their program beforehand, a script for their script if you will? I know this is probably Computer Science 101 but I was an English major!




i once had a 12th grade public school teacher make us write out on pen and paper and get it approved by her the entire program before we even got a change to type it in to the computer (BASIC on a Apple IIe)

the really sad thing about that class... i think i knew more than the teacher... and to top it all off... the class that i HAD to take in the 12th grade, was the same class that i look as a intro to computer science in the 6th grade while in a different school system.... BASIC on a apple IIe......


As for keeping orginized.... use white space TAB, space, line returns to organize your code. Use comments.... Don't try to GOLF your code right away... take your time... spread out get to know the logic behind the process you are trying to do before you look at condensing it.

Also as of late...i find my self programming more and more UDF's that call other UDF's.... this lets me compartmentalize my code, break it down to small chucks that are easier to handle. This type of behavior is really apparent in KixForms scripts!

Top
#116459 - 2004-03-19 09:34 PM Re: Tips to stay organized when coding?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I failed 11th grade computer science. Had to retake the course and had the shameful experience of having my own younger sister in my computer class ... she got an A+ and I failed yet again. I remember the teacher telling me (never forget this) that I should consider some other profession other than programming ... true story.

Top
#116460 - 2004-03-19 09:42 PM Re: Tips to stay organized when coding?
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
probably from you spending so much time looking at sheep
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#116461 - 2004-03-19 09:51 PM Re: Tips to stay organized when coding?
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
rofl - right on - I was baaaaaad
Top
#116462 - 2004-03-19 10:37 PM Re: Tips to stay organized when coding?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11570
Loc: CA
Shawn,

Was this the sign your sister put on your door after school?


Top
#116463 - 2004-03-22 10:58 AM Re: Tips to stay organized when coding?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
Well, asking is a good sign that you are on the right track.

Some varied rambling thoughts...

Scan the FAQs for some guidelines on coding techniques and good practices. They are not hard and fast rules - some are personal preferences and some have evolved through discussion, but they make an excellent starting point.

If you find yourself using "GOTO" when you know that the modern pedantic coder considers it an anathema don't fret - you are learning and you will not know how to avoid it in some situations. When you post the code and are lambasted for such an appallling lack of coding grace you can ask how to code it differently, and you will learn something new

Get a piece of paper and sketch out your objectives. Start with the high level and get a loose definition of the process down. Use your artistic talents and produce a flow-chart.

Break down the high level process into tasks - keep the task descriptions very short.

Doing this beforehand will naturally lead you into laying out your program as a series of tasks, sections or modules. This will tend to encourage your code to be organised.

You may also see common or similar tasks appearing repeatedly in your process - these are opportunities for User Defined Functions.

Now you have an idea of what you want to do, you should be able to look at the processes and make sure that you know what you need for each task - gather together information about server names, directory paths, WMI or ADSI objects, the format of data files or user input and so-on.

Once you have that all together, you might as well getting something in your script file. Rough out the script by putting in comment sections that mirror your tasks, and define all your User Defined Functions - the actual code will come later.

At the top of every script you start, include the following lines:
Code:
Break ON
$=SetOption("Explicit","ON")
$=SetOption("ASCII","ON")
$=SetOption("WrapAtEOL","ON)



You may want to take out the BREAK ON when the code goes into production, but leave it in while developing.

You should also try to avoid using variables within strings and set the option:

Code:
$=SetOption("NoVarsInStrings","ON")



DIM all your variables near the top of your script, and avoid GLOBAL variables. GLOBAL variables are useful for static (constant) information and to maintain stateful information for UDFs, but are rarely needed and will cause you trouble if you rely on them.

Give your variables meaningful names - there are good recommendations for a protocol called "short form hungarian notation" in the FAQs.

Indent your code. It is not vital that you choose tabs or spaces, but be consistant in both the characters and the number that you use for each level of indentation. When you add or remove code, take time to go back and fix the indentation if it has changed - you will find that this alone will trap many of the common errors like IF without ENDIF.

Work on each of the tasks in your script one at a time where possible - don't try to write the entire script at the same time. Once you are happy that the section is clean, accurate and as good as it is going to get you can move on to the next.

When you come to complex tasks, write down the detail on paper in pseudo-code. This is just a simple English description of the process which you can translate directly into script once you have a better idea how it is going to work.

If you have any really complex code that you think will take a few attempts to get right, take just the complex process and work on it in a temporary script. When you have worked it out and are happy, transfer it into your main script.

The most important thing is to have a clear idea of the layout of the script before you begin. Once you are experienced you will do this in your head for simpler scripts, but while you are learning get it on paper first.

Top
#116464 - 2004-03-22 06:43 PM Re: Tips to stay organized when coding?
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4290
Loc: New Jersey
Well, first and formost (especially after Radimus said "as an arts major, you should stick to asking if someone wants to supersize their meal."), know that IT people have a strange sense of humor. Assume we're teasing/busting first.

Second, write comments in your code - lots of them. In some of my larger projects, you will find up to 45% of the file is comment text! I usually can't remember what I had for breakfast by the second cup of coffee, so don't expect me to remember why I coded it that way 9 months ago!

Third, use meaningful variable names. Personally, I like to use CAPS for GLOBAL and MixedCase for Local var names. Find a general style you are comfortable with and stick with it. Look at other peoples code to see how it is laid out, decide what you like/don't like and adopt the best.

Fourth (should be first, but had to reference the others) - Never take Lonk's advice verbatim! (see - there's the sarcastic humor!) He'll tell you to use no comments, minimal spaces, no indents, and single-character var names! He covers the "Good" and "Ugly" parts of the "Good, Bad, and Ugly" trilogy, and codes everything for a KixGolf project! It's great code, if a bit uncomprehensible.

Finally, Richard's comments are right on target. Many of us write and even respond to questions in "pseudo-code" - a mix of code, logic, and descriptions of what we haven't yet decided how to code. It's a great way to organize your ideas, and pseudocode often becomes the comments in your code.

Welcome to the board..

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#116465 - 2004-03-22 07:14 PM Re: Tips to stay organized when coding?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Also, NEVER super-size Beavers ;-)
_________________________
There are two types of vessels, submarines and targets.

Top
#116466 - 2004-03-22 08:22 PM Re: Tips to stay organized when coding?
mrwumpus Offline
Fresh Scripter

Registered: 2003-09-04
Posts: 14
Loc: California, USA
Great stuff, guys. Richard's reply looked like it came straight out of a polished FAQ. Very useful to someone in my shoes.

I've seen beginner tips sprinkled throughout the existing FAQs like KiXtart Starter's Guide and Best Practices and Methods but I think a more comprehensive beginner's guide is in order. I don't know how that works on here, but basically I was thinking of using Richard's reply as the basis and breaking it into sections like Before You Being Typing and maybe ending with a short style guide for beginners entitled GOTO hell. Then I thought I could add my own noob questions and comments, post it in this thread, and you guys could comment. After a few revisions perhaps it would be a worthy new FAQ. Richard? Anyone?

On a side note, I was an arts major but I have been a computer jock for many years. While my geek and nerd friends learned assembly language, I programmed BASIC to animate a 16x16 breakdancer. Somehow I never found my true calling so here I am today managing Active Directory yet still baffled by arrays and that darn OSI layer model. But I bet I could make a mean cheeseburger...
_________________________
Jason

Top
#116467 - 2004-03-23 10:57 AM Re: Tips to stay organized when coding?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
No a bad idea - also maybe start a "Diary of a KiXtart noob" in the general topics forum, I always enjoy reading those

A guide from a starters perspective would be quite useful. By the time we think about writing an FAQ it's because we know most of the As to the Qs. This means that the documents can be dry and hard to read as we assume that the reader has a level of understanding which they may not.

The FAQ forum is moderated, so once you have something that you think is suitable, have a word with one of the forum moderators and get some advice on format.

Be prepared for your work to be criticised and debated - you are after all proposing to produce a document which is going to set out best practices for fellow starters, so it needs to be clear, accurate and uncontentious, and we can be quite vigorously opinionated around these type of subjects.

I hope I haven't put you off as it is worthwhile and you will find that your time and effort spent to give something back to the KiXtart community will be appreciated.

Top
#116468 - 2004-03-23 02:20 PM Re: Tips to stay organized when coding?
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Quote:

I've seen beginner tips sprinkled throughout the existing FAQs like KiXtart Starter's Guide and Best Practices and Methods but I think a more comprehensive beginner's guide is in order.




Maybe, but this is definitely worthwhile - The Start to Finish Guide to Scripting with KiXtart

What the Author and Ruud have done with this book is break it down in to it's most vital components and show how each goes together. From editors or functions to macros and examples of each.

Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#116469 - 2004-03-31 12:19 AM Re: Tips to stay organized when coding?
mrwumpus Offline
Fresh Scripter

Registered: 2003-09-04
Posts: 14
Loc: California, USA
Can anyone here personally recommend that book ("The Start to Finish Guide to Scripting with KiXtart")? There's just one review on Amazon.com and I was hoping for feedback from people on here about it. Would it be particularly helpful to a newbie?
_________________________
Jason

Top
#116470 - 2004-03-31 01:48 AM Re: Tips to stay organized when coding?
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
The thing that is good about the book is that it takes the approach that it does not talk down or talk up to you. It is a good read and guide no matter your expertise.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#116471 - 2004-03-31 06:13 AM Re: Tips to stay organized when coding?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
It's as helpful as the KiXtart Manual, especially for a newbie. Unfortunately, most newbies don't use these resources.
_________________________
There are two types of vessels, submarines and targets.

Top
#116472 - 2004-04-02 06:21 AM Re: Tips to stay organized when coding?
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
My 2-cents worth,

I think Richard's & Glenn's comment cover the basics but I always try to write in 'modules'. I think of my program as a bunch of sub-tasks & I solve each sub-task & write it as a separate entity & test it. After I have enough of these modules done I string them together. This tends to make code easier to read & seem less complex. Often when I start a project, I have no clear design in mind. I just build the modules I need and as I build them the overall design becomes clear.

Indentation for loops & if statemets, lots of white space & comments help a lot. Then with experience you will evolve a stlye that suits you.
_________________________
Jack

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Arend_) and 175 anonymous users online.
Newest Members
gkustra, emnipetro, Hirze, thequeen, ameliaryan
17642 Registered Users

Generated in 0.04 seconds in which 0.011 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org