Python Forum
Enigma Machine Working - Optimise
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enigma Machine Working - Optimise
#2
The first and most obvious thing is to stop using global. You want to be clear about what is going on in your functions. You do that with parameters and return values. See the function tutorial on how to do that.

The second thing is that this application really begs for classes. Take selectRotors. You have availableRotors and RotorsInUse, but neither of those contain rotors. They contain numbers pointing to rotors. So later on rather than just using the rotors, you have to use those numbers to find the rotors. With classes, availableRotors could just be a list of Rotor objects. When they select one, you could just remove it from availableRotors and put it in RotorsInUse, which would then be full of rotors. Check out the class basics tutorial for information on how to do that.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Enigma Machine Working - Optimise - by ichabod801 - Nov-18-2018, 04:46 PM
RE: Enigma Machine Working - Optimise - by Larz60+ - Mar-19-2019, 03:33 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020