Search This Blog

Monday, July 23, 2012

Reading in CODE

I have mentioned before things that will make you a better coder and this is just another tip on what you can do to improve your coding abilities.

There are many websites out there that have some really advanced coding, stuff that can make you feel like you have no idea what you are getting yourself into (trust me I know the feeling) and half the time when you view the source for the site you get lost and end up convincing yourself that you suck.

Recently I have noticed that coding and performing things that is unusual is actually not that hard. Reading the source code can be difficult sometimes but there is a reason why it is difficult and here are some of those possible reasons.

  1. You don't know the language they are using
  2. It looks so cluttered it frightens you away
  3. There are multiple sources
  4. Finally, there are hundreds of classes, ID's, NAMES, Tags, functions, variables, etc.
I'm going to take you step by step and hopefully help you guys out so you can read these source codes and learn a bit more about coding.

1. You don't know the language they are using
This one is simple but not easy or fun but if you really want to understand what they are doing with this mysterious language you must first learn what the language is by just Google searching one of the tag names or something you see commonly used in the source. 
Second you must become familiar with the Syntax in order to understand anything that is going on. This one may be the hardest only because it's a whole new language that you have to master in order to perform something you like on the website


2. It looks so cluttered it frightens you away.
When I first saw Javascript it looked like this 

Which nearly scared me away thinking "How the hell am I going to ever be able to understand this!?" Well the truth is that I really had to concentrate on the code itself and not the code as a whole. It would take hours to understand but if you go through it you can see little things that link together and it makes complete sense after a while. You still need to know the Syntax first!

What you can do to make it easier for you is to copy the code into a text pad like Notepad++ , set the language to Javascript (or whatever language you are having trouble with) and it will highlight and color the text differently which will make it easier to see what connects with what.

3. There are multiple sources.
Honestly I hate going through sources and seeing there are 20 different Javascript files, and 10 different Style Sheets, not to mention the 4 ASP and PHP files! It can really drive a guy mad... Now I'm not saying it's not useful when making a website just a pain in the butt when reading the source. 

The best way to get through it is to copy the codes into Notepad++ and connect the files together yourself, this way you see which files are being used where and why. I know it will take forever but no one said programming and developing was easy. Another thing you can do is open all the sources and read them, when you see something called from another source just read where it's calling from and what it's supposed to be doing. This has got to be the most tedious thing about learning new things in programming.

4.Finally, there are hundreds of classes, ID's, NAMES, Tags, functions, variables, etc.
Even though it's not always necessary people prefer to have a class just for the height of a div to be 200px and another class for it's width, another for it's position, and so on.

This really sucks for the reader because you have to go back and read what each class is doing for each element, however, although this is very difficult to read I do find it easier to code through classes rather than through individual ID's and when using Variables it's easier to have a variable for every aspect of the element or function than to rewrite everything. 
Again, using Notepad++ to read each class, element, tag, variable, function, etc. 

---------------------------------------------------------------------------------------
Open Source is the not only the best way to go but the only way! I know there are a lot of people out there that want to steal the code and gain profit from it for themselves but that's why you use different sources for one code, you have multiple classes, variable, tags, etc, and that's why make the entire thing cluttered which makes it hard for those thieves to steal the code. This makes it hard to everyone but is still considered open source. 

Thanks for all the love guys don't forget to subscribe, check out the Youtube, Facebook, and Twitter @DLCSpencer

Love you guys check back soon for more updates and videos!

No comments:

Post a Comment