Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualthok

Posted 23 April 2013 - 04:41 AM

I think you're going to get much more from people on this forum if you ask for help to understand a very specific piece of code. I doubt anyone is going to want to dig into someone else's code and comment it for you.

 

I've got a better idea: Why not try to comment it yourself? Take a copy of the code and read through it, but don't just read it like a book from start to finish. Get your self whiteboard or a big blank piece of paper and make notes and sketches about the various components of the code. For example, you can start by making a list of the source files:

 

- client.py

- encoding.py

- mkuser.py

- player.py

- server.py

- world.py

 

Next, open each file and take note of what it contains. Does it import anything? Make a note of that. What classes does it contain? What functions does it contain? Don't look at the code in too much detail, just look for names. If the code is written well, the names should give you good conceptual ideas.

 

Also look for `main` functions or a `if __name__ == "__main__"` block in the code, or something like that. Find the "entry point" of the client and server (see the README.txt). From the entry point, read through the first few steps of what it is doing. What kind of functions is it calling? What kind of objects is it creating? What are the relationships of those objects?

 

Once you think understand the conceptual idea about a piece of code (a class, a function, etc.), add some comments. Even if you're wrong, just add comments about what you THINK the code is doing. Correct them later if you need to. Comments can even be questions, like "# why is this necessary?".

 

Have you run the code? If not, do it. Try the different examples in the README. Become a "power user" first. Then, start thinking about what feature you might add. Make it something small. Try to build it, and ask questions if you need help.

 

I hope that helps. =)


#1thok

Posted 23 April 2013 - 04:39 AM

I think you're going to get much more from people on this forum if you ask for help to understand a very specific piece of code. I doubt anyone is going to want to dig into someone else's code and comment it for you.

 

I've got a better idea: Why not try to comment it yourself? Take a copy of the code and read through it, but don't just read it like a book from start to finish. Get your self whiteboard or a big blank piece of paper and make notes and sketches about the various components of the code. For example, you can start by making a list of the source files:

 

- client.py

- encoding.py

- mkuser.py

- player.py

- server.py

- world.py

 

Next, open each file and take note of what it contains. Does it import anything? Make a note of that. What classes does it contain? What functions does it contain? Don't look at the code in too much detail, just look for names. If the code is written well, the names should give you good conceptual ideas.

 

Also look for `main` functions or a `if __name__ == "__main__"` block in the code, or something like that. Find the "entry point" of the client and server (see the README.txt). From the entry point, read through the first few steps of what it is doing. What kind of functions is it calling? What kind of objects is it creating? What are the relationships of those objects?

 

Have you run the code? If not, do it. Try the different examples in the README. Become a "power user" first. Then, start thinking about what feature you might add. Make it something small. Try to build it, and ask questions if you need help.

 

I hope that helps. =)


PARTNERS