Click to See Complete Forum and Search --> : Regarding code appearance...


dalecosp
09-30-2003, 02:40 AM
I called up my brother the NT sysadmin guy and asked him for help with a CSS issue that turns out wasn't much of one.

He commented on the fact that "I didn't care what my HTML source looked like."

Now, he doesn't have much concept of database-driven/scripted sites ....

How much effort do you go to to ensure that the *HTML source* of your sites are properly 'tabbed' and 'newlined', etc., particularly when you're trying to whip stuff out at the lowest cost for the client?

Form or function, or both?

LordShryku
09-30-2003, 02:42 AM
None at all, unless there's a need to(HTML mail, etc). My highly non-standardized way of doing things again tells me functionality is better than pretty. They don't nned to be lookin at that stuff anyway

-my two cents

Nehle
09-30-2003, 02:57 AM
I often write for functionality at first, if I have time after that, I try to make my sites both XHTML and CSS validated. Takes a couple of extra hours, of course, but I like to be certain my sites works on any webbrowser (except that IE has some CSS problems, but screw them :P )

Moonglobe
09-30-2003, 02:58 AM
just a hobbiest myself, but that could soon change..... in any case if it's just for me i try and make things pretty.......... if it's not perfect i don't mind. If i was getting paid then i agree with LordShryku totally.

onyx
09-30-2003, 06:34 AM
I never generally bother to do proper indenting (and when I can be bothered I just get emacs to automatically do it) but I always make my sites xhtml 1.0 transitional and my CSS comply. I never used to do this and converting it all was quite a pain but now I just churn out compliant HTML and CSS without even thinking about it. I certainly think it is good practice to do so to aid understanding, maintainance and complience.

Nehle
09-30-2003, 02:09 PM
Vim does indent properly for me. And if it doesn't it's an easy command.
I like having properly indented code, makes debugging hell of a lot. easier, and it's also easier for others to understand

LordShryku
09-30-2003, 02:12 PM
Indenting code is one thing....
My PHP code is pristine with it's indentation and formatting. I think he's talking about the HTML code generated from the PHP code though. In which case, I really don't care too much unless I have to.

bliss322
09-30-2003, 04:12 PM
"They don't need to be lookin at that stuff anyway"

well, i was about to mention that they just might HAVE to look at it someday.

proper form (server side and client side) is a treat to the person that has to come behind you and maintain your work; whether that's another freelancer or an employee of your client. i work for a large enough company that the other offices often buy third party web apps that i then have to support.

but then LordShryku reminded me about php generated html, so i figured i'd shut up cause i'm guilty there. :rolleyes:

LordShryku
09-30-2003, 04:31 PM
Like I said. My PHP is all properly indented, and I give plenty of free space in there to keep things well seperated. In fact, I give hell to people that don't do that. But my generated HTML isn't always the prettiest thing to look at....

eoghain
09-30-2003, 05:32 PM
Personally for me I like to try and make my HTML somewhat readable. Now I don't do much HTML work anymore but when I did I found it very annoying to try and see what went wrong in my HTML if it wasn't formatted somewhat. Now it may not have been the pretiest HTML but at least the various sections were identifiable for me to track down errors.

But if I don't have to deal with the HTML then I don't bother with any formatting issues. My code looks good and is understandable and that is all that matters.

Sxooter
09-30-2003, 05:40 PM
The worst offense to me is the single very long line web page. We've all seen it. A 16k string on one line, no CRs or breaks. ugh.

As long as the html has CRs in it I'm pretty happy.

Nixon
09-30-2003, 06:27 PM
Hey, I always try to keep my PHP in good form. If its in good form it tends to be easier to update and so on.... HTML I use dreamweaver to do all my html then I manually code the PHP. Dreamweaver sorts most of it out for me.

LordShryku
09-30-2003, 06:29 PM
I don't think these people get the difference between coding HTML and generated HTML...

I'm with you Sxooter. I see that stuff all the time with these canned php nukes. Hurts my eyes...

dalecosp
09-30-2003, 06:34 PM
Originally posted by eoghain
Now it may not have been the pretiest HTML but at least the various sections were identifiable for me to track down errors. And that was the gist of my OP ... my brother only codes for his employer's site, (and deals will over a hundred users daily with only one assistant IT dude) but he's real picky about perfect looking HTML and CSS. That's fine ... he's salaried ;)

Me, I've got 8 or more sites either in development or in the maintenance phase, plus a "few fire and forget's" and I've got no one else working, plus I have LAN's in various offices and residential customers calling me everytime they get a virus or a modem zotted by lightning, (which this time of year is more often that some other times...)

If a site works, I don't much care, although I don't like to forget the "\n" 's as Sxooter says ...it's nice if it fits on a screen when viewing source. And, I'm *never* sure that the browser I'm using is "da bomb" when it comes to interpreting CSS (but that's another subject...)

I called my brother 'cause I was adjusting type sizes in CSS and it wasn't doing anything in the browser ... and we needed to figure out what containers were open, and which might be overriding another.

He has a good point, but cleaning up the code is going to take awhile, and some of my clients are probably getting near the point of not being so happy when they get my invoices.... :eek:

I guess it's like anything else ... use your head in each circumstance.

The source for the page we were looking at last night looks much better today :D

drawmack
09-30-2003, 08:07 PM
There are a couple of important things here

1) I do not generate html from inside of php. I create templates that just have variables in them and then I include those files. This being the case it's very easy for me to format my html properly

2) I validate my xhtml templates before I even start writting php. I do not validate my css because it yells at me for things it shouldn't like leaving out a bgcolor.

3) I like well formated html for me not for them. I often have to look at my html source as part of finding the errors in the php and this is much easier if it's well formated.

tbach2
09-30-2003, 11:47 PM
I've got to agree with drawmack-- I use phplib's template which makes it really simple to have easy-to-read html. Which is really handy when your customer wants you to go back and make it look different.

Jeb.
10-01-2003, 05:50 AM
Again, with drawmack. I try to avoid generating HTML inside PHP as much as possible (it's just a maintenance mess later on).

But then again I don't care how nice it looks. I'll take the time to put in the CR-LF's, and I'll preserve what indenting my editor gives, but I'm not going to ensure each tag is exactly 1 indent under the parent tag, etc.

tekky
10-04-2003, 10:55 AM
if I have an error, or problem with an HTML output... I just add a debug keyword or \n\r above/below it so it stands out until fixed, I could care less what the HTML looks like I care more about the PHP source as thats what I do the most of

function not form :)

drawmack
10-04-2003, 12:40 PM
I have read the function/form and the form/function arguments and as far as I'm concerned neither of them holds water.

I personally believe form = function.

Here is why I way this:
Code that doesn't work but looks beautiful, i.e. good form poor functionality, is useless.

Code that looks horrible but works is not reusable and is almost impossible to change and update. Therefor this code is also useless.

If anyone argues with this then I guess that in php your variables are all named $one, $two and you never use indenting or line returns either.

To me it doesn't make any sense to format some of your code, i.e. format the php and not the html.

That's like writting half a user's manual.

Merve
10-04-2003, 12:48 PM
...and leaving someone like me to figure it out :D

Formatting the HTML is important for me too, I guess. I don't want crazy fly-away generated HTML...I think what drawmack means by reusable is changeable. It is hard to change unformatted all-over-the-place HTML. It is easy to reuse without any changes the HTML, all you have to do is copy+paste, but that is just a temporary solution.

dalecosp
10-04-2003, 01:11 PM
This discussion is proving quite thought-provoking and useful for me; I particularly thank drawmack for sharing his POV on the subject.

I started doing HTML with some WYSIWYG editor in the mid-90's, and never had a reason to do any different or better until I started adding clientside scripts and discovered server-side technologies, like PHP.

Most of my PHP at the beginning was generally culled from examples and sample scripts from books, web, wherever, and these writers apparently had a habit of demonstrating everything in PHP or JS or whatever, so my coding style quickly began to mimic theirs, which in the case of one book I've recommended around here, was:setcookie($mydomain, "whatever");
echo "<html><head><title>$title</title></head>";
include 'headerstuff.php';
if ($loggedIn) {
echo "Welcome to the site, $username!";
} and so on.

Great for learning, but as my scripts are getting more complex, it's been tough on debugging and such.

I'm hoping to start on a new project this month (my biggest client yet, and someone else gets to do graphics, hallelujah!) and this will definitely be in the forefront of my mind as I begin the process of coding the scripts.

Thanks guys! :)

feldon23
11-30-2003, 04:40 AM
I meticulously indent my HTML and standardize on capitalized HTML tags <BODY> <HTML> etc. and lowercase CSS

<DIV style="font-family: Helvetica, Arial, san-serif;" class="elvis">
<B>Hello there!</B></DIV>

I find more bugs that way. By having my code written like that, then the errors jump right out at me.

Moonglobe
11-30-2003, 06:14 AM
but with uppercase tags you're not being XHTML comliant.

plus they look ugly. :D

feldon23
11-30-2003, 03:39 PM
I still think most of these standards are just to give someone a job instead of actually improving compatibility.

All-caps HTML jumps out at you, doesn't it? Good!

LordShryku
11-30-2003, 04:36 PM
Flame away guys, but I still use tables for my layout. I agree in some ways with feldon23. I like to follow HTML 4.01. It still allows me my tabular layout. Say what you want, but it's just easier for me.

Moonglobe
11-30-2003, 05:36 PM
XHTML allows for tabular layouts, its just that many of the same people who advocate XHTML also advocate non-tabular layouts.......

and feldon, no they don't. i find them much harder to read than lowercase tags.

LordShryku
11-30-2003, 06:50 PM
XHTML depreciates many of the attributes used in a tabular layout. I tried for a couple weeks to do my current site in XHTML 1.1, and was doing okay for a while, but eventually hit a roadblock, kept trying, got pissed, went back. I'm sure when I have more time to play with it, I will, but for something on a time limit, I'm going to stick to what's comfortable.

pyro
11-30-2003, 07:38 PM
I agree with Moonglobe, I definitly prefer lowercase tags over uppercase tags, even if we are only talking appearance. Also, even when using HTML 4.01 Stict, I adhear to most of the XHTML rules. Lowercase tags, quoted attrubutes, etc...
Originally posted by LordShryku
XHTML depreciates many of the attributes used in a tabular layout.Indeed. And that is because you should be using CSS to style your documents... ;) Also, you'll find that XHTML is not so different from HTML 4.01 Strict. If you pages validate 4.01 Strict, XHTML 1.1 will be a cinch.

AstroTeg
12-02-2003, 05:06 PM
I'm a huge fan of keeping my PHP and HTML tidy. Granted, every now if I need to output a little HTML from PHP, I get a little lazy with the output (I'll toss in carriage returns here and there, but I usually ditch tabbing).

I've built my own template system which I've been using for over the past year and its really made life easy when it comes to adding or tweaking features. Its also allowed me to re-use chunks of HTML which means less work for me.

Keeping the code tidy, in my opinion, not only helps you and the next person out when it comes time to look at it again, but also straight on demonstrates how professional and serious you are about writing code (be it for the web or an actual desktop application). If you're sloppy with the code, it just means you're too lazy to keep it clean. And I would think if other coders looked at the sloppy code, they would think the coder who did the work must be sloppy or lazy too.

Being rushed for time is one thing, but is not a good excuse for writing messy code (regardless if its HTML, PHP, C/C++, etc).

The highest complement I've had since I've been coding was from a fellow coder - and this was when I was doing ASP JScript. The comment was "you copy this from a book or website?" I told him no and asked why (almost insulted because I'd never copy entire chunks of code to call my own). He said the code looked too perfect and it was all lined up as if it had been published in a book or web site. This made me feel pretty good - another coder could read my code.

Maybe I'm wacky, but I strive to keep my code presentable...

Merve
12-02-2003, 09:13 PM
My opinion is this. Go ahead and use tabular layouts if you can see all the borders. If you hide the borders, then don't use the tabular layout. I personally don't like tabular layouts very much, and I am switching to a CSS-based layout for my site (when I have the time :D)

Weedpacket
12-02-2003, 10:11 PM
Originally posted by Merve
My opinion is this. Go ahead and use tabular layouts if you can see all the borders. If you hide the borders, then don't use the tabular layout. I personally don't like tabular layouts very much, and I am switching to a CSS-based layout for my site (when I have the time :D) What, and miss out on all the fun (http://www.markschenk.com/cssexp/bordermania/bordermania.html)?

pyro
12-03-2003, 12:10 AM
My opinion is don't use tables for layout, if at all possible to use CSS... Some layouts are virtually impossible to create with CSS at this point, and I won't go so far as to say one should not use such layouts, but most layouts can be created with CSS if one just takes the time to learn.

LordShryku
12-03-2003, 12:13 AM
I say use what works for you. There's all kinds of zealots out there that say "that ain't right, do it my way". Do what you're comfortable doing.

pyro
12-03-2003, 12:35 AM
Originally posted by LordShryku
I say use what works for you.I don't necessarily agree with that... If you use all sorts of depreciated, invalid sh*t code, and ask for opinions on the site, I'll tell you mine... ;)

LordShryku
12-03-2003, 01:07 AM
Well, maybe I just won't ask for your opinion then. Sh*t code in your view greatly differs from mine.

Moonglobe
12-03-2003, 01:08 AM
i have no problem with old HTML as long as it conforms to HTML 4.01.... if the tabular layout looks good, fine. i just find CSS so much easier to work with.

Weedpacket
12-03-2003, 07:06 AM
Originally posted by LordShryku
Well, maybe I just won't ask for your opinion then. Sh*t code in your view greatly differs from mine. And sh*t code differs greatly in Google's view from either of us. I mean, if Google can't read it properly, where will you be?

LordShryku
12-03-2003, 07:41 AM
Originally posted by Weedpacket
And sh*t code differs greatly in Google's view from either of us. I mean, if Google can't read it properly, where will you be?
Safely tucked behind the irewall of my work intranet, where Google can't go anyway