I am trying to look at code so i can learn but some of the code i looked at are so complicated it is next to impossible to understand a thing. This might sound dumb but any tips on reading source codes? (C++)
inovermyhead
reading source code
-
- Posts: 26
- Joined: Mon Aug 03, 2009 2:16 pm
-
- Posts: 326
- Joined: Wed Dec 14, 2005 10:08 pm
What code are you trying to read? What are you trying to learn? C++? Irrlicht? Both?
Some people write horrible code that no one else would have a hope in hell of understanding. Some people write beautiful code that can be understood by everyone. Sometimes code can't be written beautifully due to the complexity of what the code is doing or has to be written in a fairly unreadable manner for the sake of efficiency.
If you're trying to learn C++ then there's loads of very simple, easy to follow tutorials that you can find by googling for them.
If you're trying to learn Irrlicht then there's the tutorials that come with the SDK which should be pretty easy to follow.
Some people write horrible code that no one else would have a hope in hell of understanding. Some people write beautiful code that can be understood by everyone. Sometimes code can't be written beautifully due to the complexity of what the code is doing or has to be written in a fairly unreadable manner for the sake of efficiency.
If you're trying to learn C++ then there's loads of very simple, easy to follow tutorials that you can find by googling for them.
If you're trying to learn Irrlicht then there's the tutorials that come with the SDK which should be pretty easy to follow.
-
- Posts: 26
- Joined: Mon Aug 03, 2009 2:16 pm
Sorry, i should have been clearer but i was in a rush. I know C++ very well, well sort of but reading someone elses code is an education Some people break rules, and make the code more confusing. I am just trying to read code on skeletal animation
I am trying to develop aa aquarium in realtime
inovermyhead
I am trying to develop aa aquarium in realtime
inovermyhead
Source code is always harder to read than it is to write, but the (un)tidiness of any code can usually be attributed to its history. The skinned mesh code started out as the MS3D loader and animation player, Luke built the B3D loader based on it. The B3D loader/player was then refactored to make the SkinnedMesh animation player, the skinned format loaders were adapted to push data into this new mesh type.
If you add up the different programming styles, the bugfixes, optimizations and workarounds, both historic and recent, you've got a reasonable explanation of why it may be untidy or confusing in places.
Once you've read and understood it, feel free to post patches which tidy it up!
If you add up the different programming styles, the bugfixes, optimizations and workarounds, both historic and recent, you've got a reasonable explanation of why it may be untidy or confusing in places.
Once you've read and understood it, feel free to post patches which tidy it up!
Well, when I'm trying to learn someone else's code, I'll put a debug break on the line where I want to begin and start stepping through the code in execution order.
If I already understand what the function call does, then maybe I'll 'step over' it, and there's a lot of times where you'll be sent to STL ctors where it is best to just 'step out'.
It's best to include the Irrlicht source into your workspace as a separate project. Be sure to set your dependencies correctly. This is so you can guarantee the debug symbols are loaded and it makes stepping through the code easier.
If I already understand what the function call does, then maybe I'll 'step over' it, and there's a lot of times where you'll be sent to STL ctors where it is best to just 'step out'.
It's best to include the Irrlicht source into your workspace as a separate project. Be sure to set your dependencies correctly. This is so you can guarantee the debug symbols are loaded and it makes stepping through the code easier.
-James