How to analyze other people's codes?

62 views
Skip to first unread message

Abdelhalim abulmagd

unread,
Feb 28, 2024, 8:44:22 PMFeb 28
to Python Programming for Autodesk Maya
I'm still a beginner and the most advice I've received while learning. It is that I have to read other people's codes. But when I tried, I found it very difficult. I tried to read the code line by line, but that was very tiring, especially in the long codes. I also tried other methods and they did not work and did not lead me to anything. 
What is the best way to read other people’s codes and find out how they work?

Reza Aarabi

unread,
Feb 28, 2024, 11:04:04 PMFeb 28
to python_in...@googlegroups.com
You never find out what other people did in their code
Especially in big studios
It’s a complete chaos
:D

But first you should look at the task the code dies, software, tool or plugin as a whole
Then you should see which APIs they used
And in the main programming language how they have implemented the libraries, classes or functions
And how these codes are related to each other

Of course if you can find API documentation in any studio for their libraries (if you find any let me know) it would be great to learn functionality of each class and function

If not you have to read the code
Module by module
Function by function 
Or line by line to be able to use them 
I’m talking about using APIs (or custom libraries) especially in VFX …

Good luck tho



---------------------
--= Reza Aarabi =--


On Wed, Feb 28, 2024 at 17:44 Abdelhalim abulmagd <abdelhali...@gmail.com> wrote:
I'm still a beginner and the most advice I've received while learning. It is that I have to read other people's codes. But when I tried, I found it very difficult. I tried to read the code line by line, but that was very tiring, especially in the long codes. I also tried other methods and they did not work and did not lead me to anything. 
What is the best way to read other people’s codes and find out how they work?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/266c36ad-dc3c-4b66-9eb3-dca5799e01a4n%40googlegroups.com.

Justin Israel

unread,
Feb 29, 2024, 1:34:25 AMFeb 29
to python_in...@googlegroups.com
It's a tough question to answer with absolute certainty, as it can really depend on a lot of factors.

It can depend on the quality of the code.
* does it contain helpful comments to explain the intent of sections of code
* is it written with other developers in mind, or is the original developer using a lot of cute shorthand code and trying to be compact and appear complex 
* is the project well structured over all

And then, it can depend on your own experience as a reader. 
* Are you very familiar with the language syntax in the first place. Otherwise you may be spending an extra amount of time trying to evaluate every part of the expression of every line, as opposed to more quickly understanding the intent.
* are you familiar with the problem domain. That is, if it's code dealing with Houdini SDK, do you know houdini well enough to understand the domain specific code

It can take time to develop the skill to build a mental model of code, and keep a running visualization in your head of what the overall program is doing. If you are just trying to understand what the program is doing and not trying to find bugs, you may not need to spend as much time parsing the values of every single line. Try then to explain what a function is doing, instead of a line. 

One approach for a larger project might be to start top-down, where you start at the 'main' or first call into the code. Then you track what it does with the inputs, through the program and the various control flow that can make it go one way or another. It can help to take notes about what you know along the way, if you find it difficult to remember. 
You could also start from bottom-up and try to read what the lowest level functions do first, and then figure out who calls them. The problem with this approach could be that you don't have enough context to know why the lower level stuff is there without knowing first who called it and why. 

As Reza said, if there are docs, that is the best place to start, to get the big picture. 
Overall it really just takes practice with a particular language. When you learn more than one programming language and review enough code, you start to get faster at reviewing because a lot of concepts are the same, with different words and symbols to express them. 



Abdelhalim abulmagd

unread,
Apr 18, 2024, 5:00:58 AMApr 18
to Python Programming for Autodesk Maya
thank you all <3
Reply all
Reply to author
Forward
0 new messages