Forum Moderators: open

Message Too Old, No Replies

What is the benefit of strict

         

andrewsmd

5:58 pm on Jul 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm a php/asp developer. I know html because I have to. I've never studied it or had a class on it or anything like that. What is the benefit of using strict doc type over transitional? From what I can see strict doesn't like some tags like <center> or attributes like bgcolor. Why does that matter? I cannot tell you how often I use the <center> tag? I'm just curious. Thanks,

mattur

6:13 pm on Jul 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's strict ;)

If you validate your code you can use Strict doctypes to enforce stricter conditions on your code, so that using presentational markup like <center> or bgcolor="" or align="" etc generate errors in the validator.

andrewsmd

6:27 pm on Jul 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I understand that they generate errors. My question is, what was the need for those tags to be erroneous? Were they screwing up browsers at one time and now they don't? It just doesn't make sense to me because in my opinion, putting things inside a <center> tag is much easier then getting them all in a div that has it's style set to center.

mattur

6:57 pm on Jul 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's to encourage the use of CSS instead of using HTML3.2's presentational elements and attributes. There's two versions of HTML4.01/XHTML1.0 to aid the transition from the old method of styling web pages to the new method.

HTML4.01/XHTML1 Transitional: for making the transition from HTML3.2, they allow HTML3.2's presentational elements and attributes.

HTML4.01/XHTML1 Strict: for people who've made the transition to CSS, they disallow HTML3.2's presentational bits.

Presentational syntax is seen as a mistake in the development path of HTML, so the idea is to make those old features obsolete so people don't use them in future.

HTML5 only has one version <!DOCTYPE html>. The presentational bits from HTML3.2 and HTML4.01/XHTML1.0 transitional are removed for authors, but browsers are still required to support them.

[edited for clarity]

andrewsmd

7:19 pm on Jul 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's what I was looking for. So does that mean that one day I will have to use css for all my positioning?

mattur

7:53 pm on Jul 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In theory yes. In practice, probably not ;) Browsers will have to support old HTML for the foreseeable future. So no need to start panicking.

OTOH CSS is adding more and more features and support is getting better as older browsers die out, so you'll probably want to switch to CSS (and HTML5) at some point anyway, to use new functionality or to get other benefits. But there's no rush.

swa66

12:13 am on Jul 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



xhtml's transitional allows iframes, the strict xhtml does not, making it often quite hard to use in real life.
Anyway either xhtml is far more strict than html4.01 strict (needs to be well structured, while html4.01 still has implicit closing e.g.)

Anyway CSS really is the answer: it moves presentation out of the (x)html and into a separate (set of) files that control how it looks.

It means your code as a developer doesn't need to be intertwined with what the designer of the site needs to be done.
If well done it actually ultimately would make the two almost completely independent.

badbadmonkey

8:40 am on Jul 24, 2009 (gmt 0)

10+ Year Member



It's not just about CSS and presentation.

E.g. "strict" does not allow the use of "target" in hrefs, to open links in new windows.

Until browsers are sufficiently developed, and the audience/market sufficiently educated w.r.t. their usage, that sort of functionality impediment is enough to prevent me for one from adopting "strict".

andrewsmd

12:58 pm on Jul 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can understand separating the presentation for big projects, but there are times when that just doesn't make sense. If your developing a really small site, it is just a waste of time to create a separate css file, template file, and server side script file. Yes for large projects it makes sense, but it is just overkill sometimes. I have developers who will objectify everything, no matter what it is. Instead of spending three hours developing a mostly static site with a few things on the backend that are dynamic, they will spend twice as long on the coding because everything "has to be an object". To me, that just seems the same kind of thing here.

Gibble

1:29 pm on Jul 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The reason we make everything an object, and separate everything as though it were a large project, even for small projects is that 9 times out of 10, those small projects become large.

Solution1

12:19 pm on Jul 29, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



You separate content from presentation with a CMS or templating system, not with CSS. Presentation is always styling + structure, so why separate these? It just makes things less clear. This whole separating of styling from structure is, in my view, a flawed concept that the W3C has been pushing.

Something similar is the matter with the use of objects. Objects do have their uses for structuring code contributions from several developers. But there are simpler ways to structure code, that can be much clearer in appropriate instances.

Code using objects is also slow, because there's a lot of needless code loaded every time.

Yes, objects can easily be reused. But if code doesn't change while reuse is important, you can also build a code generator. You get much faster code that way.

Gibble

3:30 pm on Jul 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know where you work, but code that doesn't change only happens to code that is never used.

andrewsmd

5:37 pm on Jul 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know where you work, but I've writte lots of code that hasn't changed. It happens when you design websites for small businesses who can't afford to constantly update their websites. I.e. a simple contact us form with a captcha script, or a basic user system that allows them to change a small database of information with a gui interface. If you build it correct the first time, you don't have to edit it again. I've built dozens that I haven't touched in years. I understand when you build for large companies, then yes, you are constantly updating the site making bug fixes and what not. But trust me, there is a time when OOP is just a waste of time.

Gibble

4:19 am on Jul 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you coded that first small business website properly, and with OO in mind, the backend components could easily be reused amongst each with no modification. The only things needed for a new site would be a template, and some configuration files.

Which is why OOP is never really a waste of time.

I have knocked out apps in a day, with full OOP principles. Then 3 years down the road I find that I need something that does nearly the same thing again...and again.

Code using objects is also slow, because there's a lot of needless code loaded every time.

I still don't get this point. Define "needless code"?

badbadmonkey

4:57 am on Jul 31, 2009 (gmt 0)

10+ Year Member



You separate content from presentation with a CMS or templating system, not with CSS. Presentation is always styling + structure, so why separate these? It just makes things less clear. This whole separating of styling from structure is, in my view, a flawed concept that the W3C has been pushing.

The idea of CSS is not necessarily to separate structure in addition to styling. As the name suggests, it is about styles, not structure per se. Having the style separate to the content and structure is beneficial, as it permits the client to either ignore the suggested styling, or apply an alternative, etc.

Solution1

6:00 pm on Aug 1, 2009 (gmt 0)

10+ Year Member Top Contributors Of The Month



I have knocked out apps in a day, with full OOP principles. Then 3 years down the road I find that I need something that does nearly the same thing again...and again.

Or you do a copy and paste, and adapt the code.

I still don't get this point. Define "needless code"?

The code to make your object universally useable, like all kinds of checks to see if the new developer is using constructor and methods correctly. The code for connecting objects together through inheritance. All this separating up of various functionality.

Like I said, OOP is just a way to structure code. It works well in particular instances. But to use it in every single instance is to undeservedly idealize it.

Having the style separate to the content and structure is beneficial, as it permits the client to either ignore the suggested styling, or apply an alternative, etc.

Sure, there are instances where that can be useful. But what I find is that most of the time there is no real need for that, or it's considered undesirable (although I often do separate CSS from structure, out of habit). The graphic designer delivers a psd file of how the site should look, accorded by the client, and the developer just implements that. No variations needed.

If variations are needed, you might as well do that with server side scripting and simply change the template where the content is put into.

Reality is, that when the looks of a site are redesigned, structure changes as well, not just the CSS. And content usually also. There's no advantage to having separated things.

All this separation of various aspects of a site can sometimes make things clearer. But most of the time, it means that a lot of "looking up" needs to be done. Like, where, in which of the 3 CSS files, did that developer put the class "nothingbox"? Computers are extremely good at looking up. People with a dominant use of the left brain hemisphere do quite well with it (like the academic people in W3C). But it's a drag for more visually or intuitively oriented people, who use their right brain hemispheres more.

ronin

12:15 pm on Aug 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You separate content from presentation with a CMS or templating system, not with CSS.

Can a CMS recognise the user-agent (desktop browser, printer, screen-reader etc.) and format the page accordingly? (Genuine question because to date I've never used a CMS).

Gibble

5:35 pm on Aug 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or you do a copy and paste, and adapt the code.

Copying and pasting just introduces bugs.

Every line in an app should be typed out, and it's reason for being understood.

I'm sick of seeing c/p'd code, full of garbage dead weight. Variables that are set and never used. Methods that are never called. Etc, etc

The code to make your object universally useable, like all kinds of checks to see if the new developer is using constructor and methods correctly. The code for connecting objects together through inheritance. All this separating up of various functionality.

How do you use a constructor improperly?
And connecting objects through inheritance is nothing more than an addition of a few characters to show what class you are inheriting from. (And sometimes an interface)

As for separating functionality, that should be done regardless of whether or not you are programming procedurally or with OOP.

All this separation of various aspects of a site can sometimes make things clearer. But most of the time, it means that a lot of "looking up" needs to be done. Like, where, in which of the 3 CSS files, did that developer put the class "nothingbox"? Computers are extremely good at looking up. People with a dominant use of the left brain hemisphere do quite well with it (like the academic people in W3C). But it's a drag for more visually or intuitively oriented people, who use their right brain hemispheres more.

So...you're telling me a visually oriented person can't grasp that element layout is in the "layout-default.css" file, while color, font, style info is in "style-default.css" and that the overridden versions are in "layout-BB.css" and "style-BB.css" or "layout-iPhone.css", etc?

Really, these arguments are rather weak.

I'd rather look through five well named files, each with a distinct purpose, than one file with 3000 lines of code.

Not to mention when I'm changing the structure of a site, I don't give a damn about it's styling. I don't want to have to mess around with that part of the code, I just want to be in a file, that alters the structure.

When I'm modifying the data retrieval, I don't care how it's displayed, where, what page, or any of that. Why would I want all that code mixed in? It just makes it harder to make changes and easier to introduce errors.

andrewsmd

5:52 pm on Aug 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



These are just differences in programming styles. I see it all of the time in my development team. There are the OOP all of the time guys like Gibble here, and then there are the only when I have to guys like Solution1. The funny thing is, I have seen both styles work great and both styles blow up in my face. It really depends on the programmer. Both kinds of programmers are needed. The argument between you two is a reason that people like me have a job. I can code if I need to, but I excel at realizing when someone like Gibble should be doing a project, or when someone like Solution1 should be doing the project. Thanks for everyone's input.