Go Back   Christian Guitar Forum > Hobbies & Entertainment > Technology
Register FAQ Members List Calendar Arcade Mark Forums Read

Reply
LinkBack Thread Tools Display Modes
Unread 10-18-2016, 12:26 AM   #1
Lo, He comes...
 
IsaactheSyrian's Avatar
 

Joined: Apr 2002
Location: Vancouver, BC
Posts: 8,915
paid
Keeping track of variables when programming

How do you keep track of your variables when you're programming? In starting on Python I'm having a heck of a time keeping my variables straight - like, I've put my variable through a loop and now it's something else, or assigned it to some other value.

__________________
I believe, O Lord, and I confess, that You are truly the Christ, the Son of the Living God, who came into the world to save sinners, of whom I am the chief...
~ Ryan Isaac

Lo! How a rose e'er blooming from tender stem hath sprung,
Of Jesse's lineage coming, as seers of old hath sung,
It came a flower bright, amid the cold of winter,
When half-spent was the night.

Isaiah t'was foretold it, the rose I have in mind,
With Mary we behold it, the Virgin Mother kind,
To show God's love aright, she bore to us a Saviour,
When half-spent was the night.

O flower whose fragrance tender with gladness fills the air,
Dispel with glorious speldour the darkness everywhere,
True man, yet very God! From sin and death He saves us,
And lightens every load.

IsaactheSyrian is offline   Reply With Quote
Sponsored Links
Unread 10-18-2016, 06:59 PM   #2
Basically... run.
 
Giga Hertz's Avatar
 

Joined: Oct 2007
Location: 127.0.0.1
Posts: 4,820
paid
Adding comments/remarks helps a lot if you're losing track of where it's up to in the code.

Code:
#This is where Variable2 gets assigned the new values from Variable1 and Variable2 as determined by the earlier loop
variable2 = variable1 + variable2
Or whatever you're trying to do. If you find yourself getting lost in your code, adding a comment can be a real timesaver (and is super dooper especially important if you're working with other people who need access to your code).
__________________
~ Josh

Bass - Yamaha TRBX 505, Yamaha RBX 375
Acoustic Guitars - Ovation Celebrity Deluxe CC48, J. Watson & Co. WD150TB, J&D Luthier
Electric Guitars - Fender Classic '72 Telecaster Thinline (2007), Maton Mastersound, Epiphone Les Paul Studio Chameleon, SX VTG Series Tele copy, Ibanez SA
Guitar Amp - Fender Mustang IV V2
Bass Amp - Behringer Ultrabass BXL1800A
Gear - POD HD500X, Zoom G9.2tt, Zoom B9.1ut, Boss DD-20

Warning: This journal may contain diary

But He was pierced for our transgressions
He was crushed for our iniquities;
The punishment that brought us peace was upon Him,
And by His wounds we are healed.
Giga Hertz is offline   Reply With Quote
Unread 10-19-2016, 05:32 AM   #3
1v1 irl
 
Shift II's Avatar
 

Joined: Dec 2014
Location: In ur heart
Posts: 417
Printing them out at runtime can also be helpful.

print "Variable X =" + x

You could even have it print out every time something happens inside of the loops. this was my go-to when I was learnding.
Shift II is offline   Reply With Quote
Unread 10-19-2016, 09:54 AM   #4
\_(ツ)_/
 
Giuseppe's Avatar
 

Joined: Oct 2011
Location: Now look at this net!
Posts: 1,650
Also, name variables something extremely descriptive
__________________
Giuseppe is offline   Reply With Quote
Unread 10-19-2016, 01:12 PM   #5
Basically... run.
 
Giga Hertz's Avatar
 

Joined: Oct 2007
Location: 127.0.0.1
Posts: 4,820
paid
Quote:
Originally Posted by Shift II View Post
Printing them out at runtime can also be helpful.

print "Variable X =" + x

You could even have it print out every time something happens inside of the loops. this was my go-to when I was learnding.
Also this. Whenever I'm writing and something's not working out (or I quickly want to check that everything's going okay) I'll have it pop-up a message box on certain events with the output.

Also, if your IDE has an option to let you step through parts of the code as it's executing: use it.

Quote:
Originally Posted by Giuseppe View Post
Also, name variables something extremely descriptive
I didn't mention it because I thought it was obvious, but if you're not doing this already, definitely do this and never stop doing it.
__________________
~ Josh

Bass - Yamaha TRBX 505, Yamaha RBX 375
Acoustic Guitars - Ovation Celebrity Deluxe CC48, J. Watson & Co. WD150TB, J&D Luthier
Electric Guitars - Fender Classic '72 Telecaster Thinline (2007), Maton Mastersound, Epiphone Les Paul Studio Chameleon, SX VTG Series Tele copy, Ibanez SA
Guitar Amp - Fender Mustang IV V2
Bass Amp - Behringer Ultrabass BXL1800A
Gear - POD HD500X, Zoom G9.2tt, Zoom B9.1ut, Boss DD-20

Warning: This journal may contain diary

But He was pierced for our transgressions
He was crushed for our iniquities;
The punishment that brought us peace was upon Him,
And by His wounds we are healed.
Giga Hertz is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -6. The time now is 09:34 PM.


Search Engine Friendly URLs by vBSEO 3.6.0 PL2