OM2 Posted April 18, 2013 Share Posted April 18, 2013 (edited) I know how to code I don't need to learn about arrays and sorting and other things But... when I look at code, I just get lost!! I don't know what the heck is happening It all seems daunting Where does this function relate to? Why isn't this variable declared somewhere? What does this line do?? Is there anywhere I can find code samples that give a line by line explanation on everything + More and more complex examples - leading onto using Object Oriented code and frameworks Thanks OM Edited April 18, 2013 by OM2 Quote Link to comment https://forums.phpfreaks.com/topic/277100-need-example-code-with-step-by-step-explanations/ Share on other sites More sharing options...
Christian F. Posted April 18, 2013 Share Posted April 18, 2013 I think that you should find the PHP manual a very good resource for your questions, especially the function reference section. As far as not needing to learn about "arrays and sorting and other things": That is exactly what you need to learn about, especially basic variable types such as arrays. Saying that you don't need to learn about them is like saying that you don't need to learn about grammar or syntax, but that you still want to learn a foreign language. If you're daunted by the code, and cannot see the relationships between it, it is (most likely) because you're too unfamiliar with the syntax and vocabulary. The only solution to that, is to read more up on it, get to know it even better. Once you've learned it well enough, reading code will be like reading a second natural language. More or less, anyway. Quote Link to comment https://forums.phpfreaks.com/topic/277100-need-example-code-with-step-by-step-explanations/#findComment-1425560 Share on other sites More sharing options...
Jessica Posted April 18, 2013 Share Posted April 18, 2013 (edited) I'm a little confused about you wanting to learn OOP but not arrays. Do you mean you already understand how arrays work? Edited April 18, 2013 by Jessica Quote Link to comment https://forums.phpfreaks.com/topic/277100-need-example-code-with-step-by-step-explanations/#findComment-1425561 Share on other sites More sharing options...
trq Posted April 18, 2013 Share Posted April 18, 2013 Learning to read code is a skill in itself that needs to be learnt. In a lot of cases, just because you can write code does not mean you can read it well. What most people do is skim over the code too fast because they just want to figure out how a particular part works. They might skim the code beforehand. This can ofte trip you up. The first thing I always do is try and locate an (execution) entry point. Where does the execution of the piece of code I am looking at start? From there, you simply follow the logic (slowly) all the way into (and through) the part you need to understand. I'll usually do this a few times making sure I understand each block as I go. If I hit a point where I am lost, go back up a bit until you find your (execution) path. With practice, this process becomes quicker. Make sure though to always stop yourself from skimming past parts you think you understand until you truly do understand them. This process works for small blocks of code all the way up to larger more complex systems. Find an entry point and follow it. I thought I was reasonably good at this skill until I started working where I am currently. Our code base is currently over 2 million lines of code in several different languages spanned across two svn and several git repositories. Nothing is documented at all. I would read more code in an average day than I would write and it is VERY common for me to need to wonder into some part of our applications or libraries that I have never been before. There are guys at work that you can ask for help / advice, but there is no one there that knows the entire system well enough to get you through all situations. Hell, if we spent all day asking each other how different shit worked we would never get anything done anyway. Reading code is a very important skill to have. I actually think a lot of developers under estimate its importance. ANyway, to answer your question. No, your not likely to find some walk through that instructs you how some code base works. To read even the best documented code you still need the skills to be able to follow the execution path. You need practice, there are no short cuts. Quote Link to comment https://forums.phpfreaks.com/topic/277100-need-example-code-with-step-by-step-explanations/#findComment-1425570 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.