1
Programming / [Python] Looking For Some Good Examples
« on: February 05, 2016, 07:34:57 PM »
I'm yet another new Programmer+Pythoner+roguedev that has been lurking around these forums for the last week or so after finishing the (in)famous python + libtcod tutorial. I've been giving some thought about where to go next, and there is some temptation to just keep adding onto that existing code. However, a fairly large part of me feels that in order to really know how to code, I have to code, not just follow along a tutorial or merely extend some existing logic. When I combine this thought with the fact I really don't like the way the tutorial code is written (all one file, globals all over the place, etc.) I decided the next stage for me is to essentially start from scratch with my own code, purposefully implementing things differently to both make certain I understand the logic as well as become more comfortable with Python.
I set out to attempt to follow a lot of these "best practices" I keep reading about and try a strict OOP style. So far I've recreated the basic "@" walking around the "." tech demo while borrowing as little from the tutorial as possible (there is some common code due to libtcod, but I tried to build all of mine from the docs rather than the tut). I'm getting ready to move to the next steps, but this also means I'll be adding more classes and possibly files and I'm purposely committing the grave sin of trying to factor before I code. I mean, I know I can code the next features, but I'm wanting to learn better ways to be coding them. Inheritance with relatively dumb base classes? Composition on top of relatively smart base classes? How big should my core "Engine" class be allowed to get? I have a lot of questions that I'm sure don't have really concrete answers, but I'm sure that there *are* answers.
I keep reading the advice here and elsewhere to "look at *good* code" and follow examples of how to structure things, and how to pass information between the classes, but there is a hitch. I am a new programmer, so despite the fact I can find 100s of python games on Github, I have no idea if I'm looking at *good* code to learn by example. A lot of the projects I have looked at, especially 7DRLs look like they have some terrible practices in use. I found some with circular imports and others with dozens of global variables (not counting CONSTANTS), and this just doesn't help me learn to be able to manage a large project.
What I'm hoping for is this: Will any of you be so kind as to point me to a (couple of) roguelike project(s) that are written in Python, use OOP and are written in what would reasonably be considered *good* code? Obviously there are many styles of coding, but there must be a few projects that most reasonably agree on are well written.
I set out to attempt to follow a lot of these "best practices" I keep reading about and try a strict OOP style. So far I've recreated the basic "@" walking around the "." tech demo while borrowing as little from the tutorial as possible (there is some common code due to libtcod, but I tried to build all of mine from the docs rather than the tut). I'm getting ready to move to the next steps, but this also means I'll be adding more classes and possibly files and I'm purposely committing the grave sin of trying to factor before I code. I mean, I know I can code the next features, but I'm wanting to learn better ways to be coding them. Inheritance with relatively dumb base classes? Composition on top of relatively smart base classes? How big should my core "Engine" class be allowed to get? I have a lot of questions that I'm sure don't have really concrete answers, but I'm sure that there *are* answers.
I keep reading the advice here and elsewhere to "look at *good* code" and follow examples of how to structure things, and how to pass information between the classes, but there is a hitch. I am a new programmer, so despite the fact I can find 100s of python games on Github, I have no idea if I'm looking at *good* code to learn by example. A lot of the projects I have looked at, especially 7DRLs look like they have some terrible practices in use. I found some with circular imports and others with dozens of global variables (not counting CONSTANTS), and this just doesn't help me learn to be able to manage a large project.
What I'm hoping for is this: Will any of you be so kind as to point me to a (couple of) roguelike project(s) that are written in Python, use OOP and are written in what would reasonably be considered *good* code? Obviously there are many styles of coding, but there must be a few projects that most reasonably agree on are well written.