May 16, 2008

Keep Your Codes Neat!

Free Web Hosting, No Ads > CONTRIBUTE > Computers

free web hosting

Keep Your Codes Neat!

KansukeKojima
I don't know how many times I have been on a website, and looked at the source code, which is impossible to read. Why? There are no line breaks! Other times, when I code something very quickly, I don't take the time to be organized and unforseen problems occur, and are hard to fix because I can't locate areas in my codes. So recently, I have adopted a simple idea: the neater my codes are: the easier I can fix and edit it.

When you are coding, you should try to include a fair amount of spaces in your codes, etc. so that it is neat and easy to read. If your code is all jumbled up, etc. you run the risk of wasting time looking for hidden pieces of code. Now really, the main problem with this resides in HTML. Other languages require you to go to the next line for every command. So what is one method to preventing, un-organized HTML? Using a new line of code for each of your start and end tags. Observe:

CODE
<html>
<head>
<title>
Title here
</title>
</head>
<body>
Content here...
<div>
blalblalblblbalblabl
</div>
<span>
some stuff here
</span>
</body>
</html>


Understand what I mean? By using a new line for your start and end tags, you reduce the amount of clutter. Also, here is a method for organizing <div> tags.

CODE
<html>
<head>
<title>
Title here
</title>
</head>
<body>
<div id="wrapper">

                    <div class="some other class">
                      content goes here
                    </div>

                    <div class="some other class">
                      content goes here
                    </div>

</div>
</body>
</html>


In the above example, the two <div> tags are inside of a wrapper. So, we can show this by indenting the div tags so they become easier to read. Also, inbetween each section I included an extra line to help organize my codes.

Finally, I will cover inserting comments. Comments are another way to help organize your codes, especially when you include extra spacing inbetween tags, lines, etc.

CODE
<html>
<head>
<title>
Title here
</title>
</head>
<body>
<div id="wrapper">

<!--content part one start--!>

                    <div class="some other class">
                      content goes here
                    </div>

<!--content part two start--!>

                    <div class="some other class">
                      content goes here
                    </div>

</div>
</body>
</html>


If you have any other methods you like to use for organizing your codes, then please post them here. And remember, your codes become much easier to edit, etc. the more you organize them.

I hope this helped.

 

 

 


Reply

Dark_Prisoner
Well sometimes the code is well written but when the navigator download it's source linbreaks disappears and it become impossible to read , that happened with me
Any way it is really important to be organized when coding , because as you said , sometimes we can't understand what we made by our selves

Reply

galexcd
The goal of a website is not to have the source code easy to read. The goal is to be useful, and the more spaces and linebreaks you have the longer it will take for that particular page to load. I might be the wrong person to reply to this topic because I hate comments. Whenever I code something even if I don't look at it for a year I still know where every part is because I know the way I code. If I make something for somebody else then yes, I will include comments and spaces, otherwise no.

Reply

t3jem
I completely agree with coding for easy reading, I know you may not want other people reading your code; however, it's extremely hard to fix dirty code. One thing I like to do is compartmentalize my code, such as for a site with a site wide theme, i'll make a seperate file with all the theme data and layout design that doesn't change often and then use a php include statement on my content pages and all I need to enter on my content pages is the content and there is no need to change any layout stuff for each page. If I decide to change the layout, I change one file, not ten, such as recently when I added a new page and need to put a new link in my link bar, changed a couple lines in one file and the whole website adjusted, very easy from there.

Reply

KansukeKojima
QUOTE(t3jem @ Feb 20 2008, 03:26 PM) *
I completely agree with coding for easy reading, I know you may not want other people reading your code; however, it's extremely hard to fix dirty code. One thing I like to do is compartmentalize my code, such as for a site with a site wide theme, i'll make a seperate file with all the theme data and layout design that doesn't change often and then use a php include statement on my content pages and all I need to enter on my content pages is the content and there is no need to change any layout stuff for each page. If I decide to change the layout, I change one file, not ten, such as recently when I added a new page and need to put a new link in my link bar, changed a couple lines in one file and the whole website adjusted, very easy from there.

I use the same technique. I find it works nice... in general: your codes should be super nice and organized, but so should your files. That is one thing I hate about using exculsively HTML: if you have 100 pages, and you need to change one link in your navigation... time to suck back on the workahol...

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : codes, neat

  1. Html Ascii Codes - A Complete List
    downloadable php file (3)
  2. How To Make Your Signature Look Really Good!
    using various bb codes (15)
    I got a PM the other day asking how I did various things in my signature, well I'm going to show
    you all the secrets /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0"
    alt="biggrin.gif" /> So first of all theres those bars that show what you use and things
    they're called signature bars you can get them by clicking below signaturebar.com is
    fantastic for signature bars, you can even request one of your choice. It is supported by ads and
    donations also by a few talented developers with an eye for detail go take a look! Next theres
    the sl....
  3. Codes For Mobiles
    (4)
    I remember ages ago there was special codes you could put into you mobile to get information about
    it. Some even gave you free calls for 5 mins or free text messages for a limited time. This was a
    few years ago and i think it was for Nokia. Something like this *#123456789# then send and it
    would come back with serial number or something. Is there any codes about still that anyone knows
    of. I have a sony ericsson is there any codes for them ? Or if anyone has any cool sites that offer
    tricks and tips about mobiles can you direct me thanks........
  4. Kit And Ellis
    Neat game (0)
    I am not one much for computer games, but it is nice to have something for a little break or
    distraction from my daily grind. I've been watching the free games for awhile and have
    downloaded a few. Cubizoid was one I tried, but it is WAY to fast for my rather slow hand eye
    coordination. Another one I did like only let you play for an hour, so that was a bit of a
    dissapointment. But I really like Kit and Ellis. The story line is neat, and the game is not so
    fast paced that I get stuck forever on one level and get disgusted with it. It's nice to be
    able to....
  5. Photoshop -- Double Stroke
    Learn to create a neat-o text effect (2)
    Lets do this! 1. Create a new photoshop document with the dimensions 88x31. If your lost
    already... quit. 2.Alright make some random background and then put some random black-colored
    (#000000) text on it. Kind of like the picture below. 3. Select the text layer you have just
    created and click on the little f symbol near the bottom of the layer window. A sub menu should pop
    up. Click on stroke. 4. Some editing window should appear. Change all the values to what you
    see in the following image, make sure the stroke color is white (#FFFFFF). After this tu....
  6. Php Random Titles
    Learn to create neat-o random titles! (11)
    PHP Random Titles Description Ever wondered how some websites (ex:spoono.com) have those cool-o
    random titles appearing in the title bar? Now you get to learn how to do it using PHP. We will be
    using our knowledge of Variables and Echos in this tutorial. Try It Out Creating the code itself
    is fairly easy. To start, lets create some of our different titles. Code CODE <?php
    $title[1] = "This will be more fun that that time - never mind...";
    $title[2] = "Another random title... neat eh?"; $title[3] = ....
  7. Nasty Windows Tricks Using Vbs Codes
    blue screen of Death, Instant Shutdown, Endless Notepads (15)
    The CMD Codes- to use, open up notepad and copy and paste the code into the notepad. name the file
    (anyname).vbs (to make a .vbs file, when u save it or save as, it will ask u for a name and which
    type u want it, so choose all file then just name it as a .vbs file) then just click on the file u
    just made *NOTE* these codes do not stay on forever, they just stay on until the person shuts off
    the computer. The registry delete is one that PERMANETLY deletes files on the computer that cannot
    be recovered. this will DESTROY the computer -The blue screen of Death *The Blue....
  8. Nice Clean Php Layout Coding.
    Learn a nice neat way to code your layouts with php (7)
    There are basically two main ways to code your php. Method 1) Creating a php document with an html
    look. The you throw in include tags all over the place. Its unorganized, and you have lots of stray
    files hidden in folders and scattered in your base directory. Its difficult to organize, and you
    make mistakes easily. Example: This document would be called index.php Whatever
    Banner or something Some content here. Mostly along the lines of You might ask what
    the problem was? Well, those include tags tend to multiply, and so do all those unne....
  9. Looking Up Postal Codes
    (3)
    I'd like to have a postcode (zipcode for you US people) lookup automatically after a person
    enters a suburb (city) and state into a form. I can handle the mysql query and php code but how do I
    make the code execute _after_ the user enters the suburb and postcode but before they submit the
    form? Is there a way to control when the code executes so the user doesnt' have to submit
    before the code runs? I'd like them just to enter the suburb and then state and then have the
    post code enter automatically. Is this possible? Hints appreciated. ....
  10. Call Of Duty 1 Cheat Codes For Multiplayer.
    How To Get Cheat Codes For Call Of Duty In Multiplyer. (2)
    /sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> hi everyone i was
    wondering if any one knows how to get cheat codes for multiplayer in call of duty 1 i think i know
    how you must have to edit the scripts but i just don't know what file to edit so if any body
    knows just stop by and tell me. Thanks /smile.gif" style="vertical-align:middle" emoid=":)"
    border="0" alt="smile.gif" />....
  11. Three Neat Avatar-based Sites
    Zantarni, Menewsha and Elyzeria (4)
    I'm not sure if this goes here. Sorry if it's the wrong place. lol /tongue.gif"
    style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> I joined three neat sites
    this week: Zantarni, Menewsha and Elyzeria. Elyzeria This is a cool site. It's not
    avatar-based, actually. You make three characters on your account and they can have a certain class
    (mage, healer, or warrior). And they can be either a human, elf or dwarf. You have to feed them and
    basically improve their stats. You can go on quests. There's a whole lot more to it. I'll ....
  12. Yahoo! - Messy Codes
    (3)
    Well I was bored and had nothing to do but to check out how some of the big guys in the web code
    their web pages. And what I found on Yahoo's index page is a very messy code. View the page
    source code here: http://www.yahoo.com/ Currently, the website does not use XHTML 1.1 mark-up
    language and if it were to go through validation as XHTML, it would have 37 errors. Here's the
    link to it: http://validator.w3.org/check?uri=http%3A%...ww.yahoo.com%2F It seems that in the
    source code, all Javascript codes are all in their, no external JS files even CSS files. It....
  13. Anybody Got Codes Or Cheats For Nfs Underground 2
    (0)
    anybody got cheats or codes for NFS underground 2 ???? also please visit Nitto1320.com and do all
    ur racing on the strip /wink.gif" style="vertical-align:middle" emoid=";)" border="0"
    alt="wink.gif" /> also visit hellracers.net and join the racers /wink.gif"
    style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />....
  14. Microsoft Adcentre - Uk Promo Codes?
    (1)
    i just took a look at microsoft adcentre. it could be wirtha try. I had a $100 free promotion
    code but it wouldn't work for me as I'm in the UK. had a look around for some UK codes, but
    can't find any. any tips???....
  15. Php Codes: Adding Clothing, Ion Laser Guns And Shooting Projectile Cannons
    (3)
    Ok here is a set of codes that is on another forum website. It is really neat becuase you can have
    cursors and other objects on your webpage that can shot projectiles. Also you can add some other
    cool graphics. Go to the link below. php coding ....
  16. Untangling Other Peoples Codes...
    Sheesh! (9)
    So I graduated and I got a job, right? I just finished my three-month training and I was
    immediately thrusted into actual work. I have a degree in IT and I got a job as a programmer, well
    sort of, it's more like an application implementor. Anyways, what I do is I implement a system
    that someone else developed. That someone else doesn't know anything about table normalization.
    Not that I'm an expert at normalization but it's just so freakin annoying the way tables
    have 46 fields and I have to guess which field is for what. Grrr! The system is c....
  17. Colour "sniffer" Tool Needed
    to find out the Hex colour codes off of graphics. (9)
    I am in need of a "colour sniffer" tool that will hover over a graphic and tell me the Hex colour
    code that is under the eye-dropper thing. Does anyone have a link to a freeware tool that does
    this?....
  18. Some Codes Needed ? Please ...
    (3)
    Dear buddies i just start building my site in FrontPage. I just need some codes of follow things...
    * I just want to show the IP of the visitor on my frontpage of website . An animated chracter having
    a board showing the IP , Windows , Browser of the visitor. * I just want to place
    e-messenger on my site . * I want to place some Free java OR flash text and other effects on my
    site. * want to place Google seach on my site. * want to place a servye on my site. So please
    help me and tell me how to get codes for these..... ....
  19. How Do You Intsall A Phpbb Forum Note.
    How do you install it? custom phpbb codes. (1)
    Im trying to install somehting like this: http://www.antilost.com/community/index.php?showtopic=72
    into my phpbb forums, does anyone have any step-by step instructions on how to install it? Thanks. ....
  20. I Cant Use Codes =(
    phpnuke (4)
    i tried making a new block for me, a navigation and i put in the html code for my links and the the
    site wont take my html code. when i preview it all i see are the codes not even the links. so i
    tried converting it to php code and not even that worked..i dont understand argh what am i supposed
    to do now? can even make any html codes anywhere on my site....
  21. Mkds Friend Code Topic
    Post your friend codes here (2)
    Basically what it says on the tin! Post your MKDS Friend Codes here! Mine is: 408083-686561....
  22. Neat Little Google Search Feature
    (7)
    Heyas, Some probably know this, others dont /wink.gif' border='0' style='vertical-align:middle'
    alt='wink.gif' /> Goto www.google.com and type in "failure" in the search bar-- Then click on "Im
    feeling lucky" What do you see? /smile.gif' border='0' style='vertical-align:middle'
    alt='smile.gif' /> ....
  23. How To Stop People From Pirating Your Source Codes
    How to encrypt your webpage source sode (40)
    /ph34r.gif' border='0' style='vertical-align:middle'
    alt='ph34r.gif' /> -Encryption- /ph34r.gif' border='0' style='vertical-align:middle'
    alt='ph34r.gif' /> If your like me, you probably hate those Javascripts witch open a "Right
    Click Disabled" prompt. An easier way to confuse pirates from stealing your hard worked scripts or
    codes you can easily encrypt your html. In this tut i will show you how to both create
    an html encrypting script and will show you the diffrent methods of encryption. 1. The HE....
  24. Exploits Refrence
    Available source codes on NET (13)
    Hi all, I prefer to create a post here and send exploits all here, not in different posts ... Hope
    to enjoy /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> :: ProZilla
    "ftpsearch" Results Handling Client-Side Buffer Overflow Exploit #include #include #include
    #define OVERFLOW (1 #define SLEDSIZ (1 #define RETADDR 0x806977a+SLEDSIZ/2 #define OUTPUT
    "AdvResults.asp" /* * prozilla bug, found while auditing for gentoo bug #70090 *
    -taviso@gentoo.org */ /* execve() /bin/id */ unsigned char shellcode =
    "\x33\xc9\x83\....
  25. Codes Dont Work
    (5)
    www.mysite.trap17.com/join im testing this page as a join but none of my codes work can someone help
    me....
  26. Free Legal Opera Registration Codes
    10-year online anniversary party (14)
    You can get free legal opera registration codes as there's opera's 10-year online
    anniversary party! /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' />
    Get them while available! http://my.opera.com/community/party/reg.dml Cheers!....
  27. Html Cool Codes?
    (6)
    hey guys..whats up..well i ws just wondering if you guys have any cool codes for myspace or
    something..you know to design a page using html/css codes...see i tried googling around but all the
    sites had the same thing..they dont have a unique one...i want like games in my page...like my
    friend he had like tetris in his page..and i want a game// or anything like that to make my page
    cool /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' />
    anybody????plz...PEAcE!....
  28. Cheat Codes
    (11)
    Hello, Everyone I have found a website with lots of cheat codes Cheat Code Central . This website
    has a lot of pop-ups but you will get around them. Have fun. /biggrin.gif' border='0'
    style='vertical-align:middle' alt='biggrin.gif' /> /biggrin.gif' border='0'
    style='vertical-align:middle' alt='biggrin.gif' /> /cool.gif' border='0'
    style='vertical-align:middle' alt='cool.gif' /> ....
  29. Need Cheat Codes
    Counter Strike (27)
    hello:D im fiding for Cheat code COuntr-Strike /biggrin.gif' border='0'
    style='vertical-align:middle' alt='biggrin.gif' /> anyone can tell me ? like ~ and then we write..
    and we have good GUN /laugh.gif' border='0' style='vertical-align:middle' alt='laugh.gif' /> OR
    HOW FLY /tongue.gif' border='0' style='vertical-align:middle' alt='tongue.gif' /> ??i wanna this
    its nice Code Thanks /wink.gif' border='0' style='vertical-align:middle' alt='wink.gif' />
    /cool.gif' border='0' style='vertical-align:middle' alt='cool.gif' /> ....
  30. Call Of Duty Cheat Codes
    (15)
    MAIN Call of Duty CHEAT CODES: To enable Call of Duty cheats in the demo, modify your Call of Duty
    shortcut and add the following text in the target field AFTER all the other stuff: +set
    thereisacow 1337 +set developer 1 +set sv_cheats 1 +set monkeytoy 0 Then start the game using that
    shortcut and press to open the console, and type the following codes (NOTE: All the codes with 0/1
    are toggles; use 0 to turn them off and 1 to turn them on): Code: Description: god God mode
    give Gives indicated item give health Full health notarget The enemies won&#....

    1. Looking for codes, neat

Searching Video's for codes, neat
Similar
Html Ascii
Codes - A
Complete
List -
downloadable
php file
How To Make
Your
Signature
Look Really
Good! -
using
various bb
codes
Codes For
Mobiles
Kit And
Ellis - Neat
game
Photoshop --
Double
Stroke -
Learn to
create a
neat-o text
effect
Php Random
Titles -
Learn to
create
neat-o
random
titles!
Nasty
Windows
Tricks Using
Vbs Codes -
blue screen
of Death,
Instant
Shutdown,
Endless
Notepads
Nice Clean
Php Layout
Coding. -
Learn a nice
neat way to
code your
layouts with
php
Looking Up
Postal Codes
Call Of Duty
1 Cheat
Codes For
Multiplayer.
- How To Get
Cheat Codes
For Call Of
Duty In
Multiplyer.
Three Neat
Avatar-based
Sites -
Zantarni,
Menewsha and
Elyzeria
Yahoo! -
Messy Codes
Anybody Got
Codes Or
Cheats For
Nfs
Underground
2
Microsoft
Adcentre -
Uk Promo
Codes?
Php Codes:
Adding
Clothing,
Ion Laser
Guns And
Shooting
Projectile
Cannons
Untangling
Other
Peoples
Codes... -
Sheesh!
Colour
"sniffe
r" Tool
Needed - to
find out the
Hex colour
codes off of
graphics.
Some Codes
Needed ?
Please ...
How Do You
Intsall A
Phpbb Forum
Note. - How
do you
install it?
custom phpbb
codes.
I Cant Use
Codes =( -
phpnuke
Mkds Friend
Code Topic -
Post your
friend codes
here
Neat Little
Google
Search
Feature
How To Stop
People From
Pirating
Your Source
Codes - How
to encrypt
your webpage
source sode
Exploits
Refrence -
Available
source codes
on NET
Codes Dont
Work
Free Legal
Opera
Registration
Codes -
10-year
online
anniversary
party
Html Cool
Codes?
Cheat Codes
Need Cheat
Codes -
Counter
Strike
Call Of Duty
Cheat Codes
advertisement



Keep Your Codes Neat!



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE