Open klondikemarlen opened 6 years ago
Sounds like a lot of work! We should just ignore all their advice and continue to write shit code.
See pull request (work in progress) https://github.com/elthran/RPG-Game/pull/343 See branch https://github.com/elthran/RPG-Game/tree/modular_code
I demoed my code to my tech meetup group and received some feedback. I am going to try and write up what the suggestions were and try and implement them. This will be a major project.
[x] The main concept I want to try and implement is code/function separation policies. i.e. what each code object should know. Check out Modular Programming.
[x] I would like to separate my code into 'services', 'policies' (in addition to the current separations). And try and extract the game logic from the html update code. Much of the command code with be modified and moved to new files. This will allow me to do: move_to(hero, location) -> which should have all the appropriate error checking and information security built in. e.g. It should validate whether the hero is allowed to move to this location. It should also remove and endurance necessary ... or remove food used up during travel.
[x] Much of the database.py functions will be moved to there own modules. e.g. the encrypt function will be moved to a file called 'security?' that has the encrypt/decrypt methods in it.
[x] The User object will be renamed to Account.
[x] I will also try to look up a book that implements these concepts. Or ask my group for a recommendation.
[x] I would like to add the ability to save and query to the database objects. Hero.first ... Hero.get(5). Hero.save()?
[x] Use more Interfaces. i.e. If all objects support the '.save()' method .. it should be provided by the 'database_interface' module. This modules should interact with the database directly? Or maybe this should just call the database? "The interface to the database should be supported by one module (or group) and all parts of the program must be required to use that interface rather than directly providing that capability itself. This will keep the program more maintainable. If the database is changed, only the module interfacing to it should need to change. " - http://comptechdoc.org/independent/programming/programming-standards/software-best-practices.html
[ ] Input Validation The system must check all user input and try to be sure it is as close to the expected form as is possible. If the expected input is a whole number then only a whole number should be accepted. The system must check input for attempts to compromise the system deliberately. Errors should be corrected automatically where possible.
Useful links: