The worst coding style

Started by 蜃気楼 October 14th, 2008 6:19 PM
  • 1526 views
  • 13 replies
Seen February 27th, 2010
Posted October 20th, 2009
246 posts
15.9 Years
What is the worst coding style for you? Not obfuscated code, just a common poor coding pratice or indentation style.
I hate this HTML style:
<HTML>
<!-- the tags are full capitalized. -->
<HEAD>
<SCRIPT LANGUAGE=JavaScript >
if (window.navigator.appName == "Netscape") {
    alert("You are using Netscape"); /*I like line breaks after braces */
} else {
    alert("You are not using Netscape");
}

</SCRIPT>
<!-- Tags are not closed, but it can still be rendered -->
<BODY>

<TABLE BORDER=1 >
<TR>
<TD COLSPAN=2>
TABLE <!-- COLSPAN is full capitalized, and there's no quotes in the attr's value -->
</TD>
</TR>
<TR>
<TD>data here<BR>bad line break</TD>
<TD>2nd</TD>
</TABLE>
</BODY>
</HTML>
It will also work without closing tags at all:
<HTML>
<!-- the tags are full capitalized. -->
<HEAD>
<SCRIPT LANGUAGE=JavaScript >
if (window.navigator.appName == "Netscape") {
    alert("You are using Netscape"); /*I like line breaks after braces */
} else {
    alert("You are not using Netscape");
}
</SCRIPT>
<!-- SCRIPT tag must be closed -->
<!-- Tags are not closed, but it can still be rendered -->
<BODY>

<TABLE BORDER=1 >
<TR>
<TD COLSPAN=2>
TABLE <!-- COLSPAN is full capitalized, and there's no quotes in the attr's value -->

<TR>
<TD>data here<BR>bad line break
<TD>2nd
It should be tidyed like this:

<html>
<!-- the tags are full capitalized. -->
<head>
<script type="application/x-javascript" >
<!--
/* scripts should be hidden for old browsers */
if (window.navigator.appName == "Netscape")
{
    alert("You are using Netscape");
}
else
{
    alert("You are not using Netscape");
}
//-->
</script>

<body>

<table border="1" >
<tr>
<td colspan="2">
TABLE
</td>
</tr>
<tr>
<td>data here<br />
bad line break
</td>
<td>2nd</td>
</table>
</body>
</html>
I also hate some non-standard tags:
<marquee><strike><spacer> etc.

Sometimes I work with other webmasters, then I will see that coding style. I had a hard time at cleaning up the code.
Did it happen to your site?
Seen February 27th, 2010
Posted October 20th, 2009
246 posts
15.9 Years
I just hate HTML code that looks like that:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=JavaScript SRC=http://www.example.com/script.js ></SCRIPT>
<BODY>
<P>A paragraph. <BR> <FONT COLOR=red>Next line<BR>
</BODY>
</HTML>
Then I hate abuse of OOP. PHP and C++ doesn't abuse OOP because OOP is optional.
You can do same thing without OOP, DarkGDK for C++ is easier than XNA on C# because XNA is OOP

Ooka

Cosmic

Age 30
Challenging The E4
Seen September 15th, 2022
Posted January 18th, 2020
2,621 posts
15.8 Years
Yeah, IPB utilizes OOP horribly, I'm looking for someone that has even near as good OOP as IBB (ImperialBB).

I don't really feel like giving examples, but anything that isn't XHTML is horrible, usually, because if someone doesn't know how to XHTML standardize their code, they usually aren't that good at HTML in the first place.
Seen September 8th, 2013
Posted March 11th, 2013
402 posts
15.6 Years
I don't really feel like giving examples, but anything that isn't XHTML is horrible, usually, because if someone doesn't know how to XHTML standardize their code, they usually aren't that good at HTML in the first place.
HTML 4.01 is very nice, and makes a lot more sense than XHTML if you’re serving it with a text/html MIME type. Serving XHTML as non-XML kind of defeats the point of using it. My site is entirely HTML 4.01, although I do use XHTML 1.1 for local files on my own computer.

It’s not too big a deal, but I’ve never cared for embedded scripts and stylesheets (as opposed to linked ones). It just seems to me that if you’re using a different language, you should logically separate the code. Besides that, Javascript requires the ridiculous commenting methods. (Oddly enough CSS doesn’t, unless I’m missing something.)

How about examples of good coding style? I’ve always loved PunBB/FluxBB, which just feel so clean code-wise.
iimarck.us / hax.iimarck.us

If you want me, please contact me by email. [email protected]

If you want to hack Pokémon RBY or GSC, read, read, and read some more. This has tons of valuable information.

Pokémon Red disassembly project

Rules that should be rethought: 25charlimit, bumping.
Bad posts are bad posts, regardless of how many words are in them or how old the thread is.
Good posts are good posts, regardless of how old the thread is—and brevity is underrated.
Seen September 8th, 2013
Posted March 11th, 2013
402 posts
15.6 Years
HTML lets people write unreadable code.
You can write unreadable code in any language. If done properly, HTML looks just as nice as XHTML, with the lone exception (debatably) of self-closing tags.
I use XHTML, XML, SVG, XUL, so I must learn XML and XHTML
And that’s why you need to serve it as XML and not text/html. In general (though obviously not every case), using XHTML for web sites that don’t use other XML dialects is silly because it’s still being interpreted as tag soup by the browser.

I like XHTML more than HTML, but I only use it where it makes sense.


“debatably” is not a typo, it’s an adverb.
iimarck.us / hax.iimarck.us

If you want me, please contact me by email. [email protected]

If you want to hack Pokémon RBY or GSC, read, read, and read some more. This has tons of valuable information.

Pokémon Red disassembly project

Rules that should be rethought: 25charlimit, bumping.
Bad posts are bad posts, regardless of how many words are in them or how old the thread is.
Good posts are good posts, regardless of how old the thread is—and brevity is underrated.
Age 32
Male
Seen November 24th, 2014
Posted October 12th, 2012
317 posts
18.1 Years
Ironically, IPB's code is something I consider to be "the worst coding style" I've had to deal with. (The PHP, I mean, the HTML output is fine.)
I 100% agree with you Ausaudriel, that's why i limited myself just to go jumping around making webs and get someone else for the forums. Even though i am the kind of guy that likes to make things by himself O-(=.=Q) POW For forums i have this unique exception.

Anyways.

You can write unreadable code in any language. If done properly, HTML looks just as nice as XHTML, with the lone exception (debatable)(Typo was in here) of self-closing tags.
Almost any programming language can be written as unreadable as long as you do it properly (must resist... not to tell my online game secrets...) Oh well i will say it...

I work with the Dreamzide engine making online games scripts, i always divide them into several parts and put them alternately between them and will only trigger at the point when the first and the last scripts are being accommodated (I hope that's clear enough T.T) So i get rid of hackers, botters and any other exploiter in a pinch hehe.
Twitter!!~ Follow Re-follow :P

Faltzer

Male
Seen April 19th, 2020
Posted March 22nd, 2017
1,670 posts
17.6 Years
Yeah, IPB utilizes OOP horribly, I'm looking for someone that has even near as good OOP as IBB (ImperialBB).
Yeah, because viewing everything in an OO point of view is the best idea ever.

I don't really feel like giving examples, but anything that isn't XHTML is horrible, usually, because if someone doesn't know how to XHTML standardize their code, they usually aren't that good at HTML in the first place.
When using the XHTML 1.0/1.1 DTD, you are required to serve your HTML file as application/xhtml+xml which IE does not support at all. It won't even display on the screen, instead ask if you can download the file.

I'm all for web standards, but now is not the correct time to adopt this standard. HTML 4.01 Strict works just as fine for now, and triggers standard compliance mode in IE, unlike XHTML. Why even attempt to argue against this? You can do everything in HTML 4.01 Strict that you can in XHTML at the moment, except with better support from the most popular browser on the internet. There is a limit to where following 'cutting-edge' w3 standards is practical. XForms is designed to replace traditional HTML forms, but has no support at all. Why are you not attempting to adopt this?

You can be just as 'strict' as you wish with HTML, you don't need a barely supported doctype and some /'s after your tags to make your documents well formed. HTML 4.01 has been a standard for years and most likely will be for years to come.

http://www.spartanicus.utvinternet.ie/no-xhtml.htm is a good list of reasons why you should use HTML 4.01, if you don't for some reason trust me.

or from Mozilla: http://www.mozilla.org/docs/web-developer/faq.html#accept

I’ve always loved PunBB/FluxBB, which just feel so clean code-wise.
punBB's coding style really sucks. Globals are thrown about everywhere in the script, a lot of inconsistencies, and awful templating. They don't even use OOP right, and they have "coding islands" running amok in their source files. Simple is one thing, but spaghetti code is another big issue.


Seen September 8th, 2013
Posted March 11th, 2013
402 posts
15.6 Years
When using the XHTML 1.0/1.1 DTD, you are required to serve your HTML file as application/xhtml+xml which IE does not support at all.
application/xhtml+xml is optional for XHTML 1.0, but using text/html relies on the W3C’s backwards‐compatibility guidelines. Of course, following those seems just silly when you can use an HTML doctype instead (especially since they’re invalid SGML!).
You can do everything in HTML 4.01 Strict that you can in XHTML at the moment, except with better support from the most popular browser on the internet.
XHTML is useful for inline SVGs and MathML. This is one of the things that bothers me about HTML5; they seem to be trying to implement ways to embed XML dialects when XHTML already does it in a simple fashion.
http://www.spartanicus.utvinternet.ie/no-xhtml.htm is a good list of reasons why you should use HTML 4.01, if you don't for some reason trust me.
Slightly dated; article states that Gecko does not support incremental rendering for XHTML but this has been fixed since at least Firefox 3. Most other points are good though.
punBB's coding style really sucks. Globals are thrown about everywhere in the script, a lot of inconsistencies, and awful templating. They don't even use OOP right, and they have "coding islands" running amok in their source files. Simple is one thing, but spaghetti code is another big issue.
Guess I don’t understand PHP as well as I thought :( What would you recommend as a good example of bulletin board code? (Then again, I stopped liking PHP about when I began working with character encodings…)
iimarck.us / hax.iimarck.us

If you want me, please contact me by email. [email protected]

If you want to hack Pokémon RBY or GSC, read, read, and read some more. This has tons of valuable information.

Pokémon Red disassembly project

Rules that should be rethought: 25charlimit, bumping.
Bad posts are bad posts, regardless of how many words are in them or how old the thread is.
Good posts are good posts, regardless of how old the thread is—and brevity is underrated.

Faltzer

Male
Seen April 19th, 2020
Posted March 22nd, 2017
1,670 posts
17.6 Years
application/xhtml+xml is optional for XHTML 1.0, but using text/html relies on the W3C’s backwards‐compatibility guidelines. Of course, following those seems just silly when you can use an HTML doctype instead (especially since they’re invalid SGML!).
Agreed.

XHTML is useful for inline SVGs and MathML. This is one of the things that bothers me about HTML5; they seem to be trying to implement ways to embed XML dialects when XHTML already does it in a simple fashion.
When you consider all of the XML features and XForms, etc., that's really all XHTML is good for.. The point of my posts were to emphasize that if you have no clear reason to be using XHTML, then you shouldn't be using it.

Guess I don’t understand PHP as well as I thought :( What would you recommend as a good example of bulletin board code? (Then again, I stopped liking PHP about when I began working with character encodings…)
One that doesn't make superglobals a global in a function (I'm looking at you, imperialBB), or that avoids globals at all costs. vBulletin is the best I can tell you of. Their coding is precise, consistent and readable, which is why it's so easy to mod.

---------------------

As for ugly coding styles, here is what coding islands are:


<?php
include 'functions.php';
include 
'script_class.php';

$script = new Script;

$script->method();
?>
MY HTML HERE, EVEN THOUGH THERE ARE MUCH BETTER WAYS TO ADD TEXT WITHOUT SPLITTING THEM INTO CODING ISLANDS.
<?php
include 'hurrdurr.txt';
?>
and globals:


<?php
$obvious 
true;

class 
Hurr
{
    function 
durr()
    {
        global 
$obvious;
        
        if (
$obvious)
        {
            
$msg 'hurrdurr';
        }
    }
}

$hurr = new Hurr;

$hurr->durr();
?>

What also pisses me off the most is developers repeating themselves in their code, causing another abomination and impossible-to-maintain code cases.


Seen February 27th, 2010
Posted October 20th, 2009
246 posts
15.9 Years
I still want to embed SVG and Math in XHTML. I served it as application/xhtml+xml only when the request's header contain "Accept: application/xhtml+xml". On IE, the Accept header doesn't contain application/xhtml+xml, so it will be served as text/html.

if ( strpos($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml") ) //does it accept application/xhtml+xml?

{
    
header("Content-Type: application/xhtml+xml"); //if yes
}
else
{
    
header("Content-Type: text/html"); //else

About PHP and scripting, indentation style is more important for me.