akbkhome

Smoking toooooo much PHP



good
I learned a lot form this article
#1 - kinch ( Link) on 22 Mar 2008, 14:31 Delete Comment
Good Post
Nice to read other's take on developing standards with php, and agree with all of it. Well done, and hope you get to feeling better.
#2 - Hugh ( Link) on 23 Mar 2008, 02:44 Delete Comment
Start proofreading
You know what else is so 1999?

Posting something to a blog you want to be taken without proofreading it.

Please properly spell and punctuate your posts in the future, that was just hard to read.
#3 - Steve ( Link) on 24 Mar 2008, 05:54 Delete Comment
Proofreading
Actually this one's not too bad compared to some of my previous ones..

I did go through it again but fr**ging serendipity, which is what the backend of this thing uses timed out and lost the changes..

Not quite sure if Blogs are more just 'venting' frustration or ever supposed to be taken seriously....

#4 - Alan Knowles ( Link) on 24 Mar 2008, 10:57 Delete Comment
Just ok
I have to disagree with some of your points...

"Mixing PHP and HTML"
This should be retitled as "Mixing HTML and business logic". I think that's what you mean anyway. It's ok to mix php and html (how else do you generate a dynamic page), however, having your business logic interspersed with the display html is a PITA for code maintenance, among other things.

"Functional Crap (or Procedural code)"
I disagree that no complex program can be created procedurally. This is entirely programmer dependent. If the person doing the programming is competent and disciplined then anything that can be done w/OOP can be done just as well procedurally. The biggest advantage of OOP is reusability. Everything is in a nice, neat package that is able to be used over and over. Aside from that advantage (which is quite large), there is little more, in my opinion, than additional overhead that is added with OOP.
#5 - Andrew ( Link) on 24 Mar 2008, 20:35 Delete Comment
OOP is slower
OOP actually is slower. I was benchmarking some code, and when I had the algorithm down, I converted the function to a class method. Solely from putting the identical code into a class, its speed dropped by 30%. Apparently the engine has to do a lot more work from inside an object to call functions.

After I noticed that with 5.1.6, I was able to duplicate it on then-current 5.2.3.

Not that it mattered. That code got ported to Perl; it failed in production because I forgot PHP *still* can't handle large files. Grrr!
#6 - sapphirecat ( Link) on 24 Mar 2008, 20:45 Delete Comment
Well...
Well, I guess that is a most instructive post than the previous one, but there is a few points I disagree with.

*.class.php
As for me, using procedural AND objet in the same application is a quality for php, you don't have to modelize everything nor using static methods if you don't want to. I really love OOP, but I think a few things would have pissed me off if I had to turn them into classes. Even if using static functions make your code easy to organize, it stays slower than using simple functions, I guess.
What I want to say is using *.class.php extention is, in my opinions, very usefull as you know this file contains a class (named Plop for plop.class.php...) and there is no need to look for something in this file, you know what I mean ? (I'm not sure I understand my own words...)

Mixing PHP and HTML is pretty cool too, if your code is well-organized (queries at the top, not in the HTML code, for exemple)...).

I'm still using defines for config vars, but not as you said, I usually put them in a file named "config.php" or "needs.php" or something like that...

Php actually is a quite simple language you can do powerfull thing with without discouraging beginners with jiberish concepts... If I were you, I'll put a few "I think", "In my opinion" or "as for me" in my posts, otherwise it's a bit impetuous, just my 2 cents...

(I'm still french since my last comment, once again please excuse my english ;))
#7 - Palleas ( Link) on 25 Mar 2008, 05:48 Delete Comment
Just about Class nominating
I just wanted to add something about the class nomination.
I'm okay to say that a good nomination is important, but the way you explain (using Aaaa_Bbbbb_Cccc) makes me think that you are involved into the Zend fw :D.
Maybe it's a good idea the way they call their classes, but it's certainly not the only one.

Otherwise, I read an other post into your blog (the original post of this one, this one you listed the bad cms), and I disagree with you with the fact some cms does not use PDO or some PEAR code. I'm totally agree to the fact theses codes are powerful and they have a lot of user contributed features and 6 years of bug fixes. But sometime, on some web server, you don't have PDO or PEAR package. So if you use a cms/fw that need Pear/PDO, you screwed !
Maybe the better way is to have a cms/fw that could use pear/pdo but also implement their own scripts (or a functionnal else). Don't you ?


Sorry for my english..
#8 - cx42 ( Link) on 25 Mar 2008, 06:26 Delete Comment
Zend Framework components
As far as packaging goes you pretty much have to download the whole Zend Framework if you want to use it (with the exceptions of the Google Data APIs and Microsoft Infocard components which can be downloaded separately). However, just because you have to download it all doesn't mean you have to use it all. Zend Framework is really just a bunch of loosely coupled components that you can use to "glue" your application together. This is important to keep in mind - just because the whole framework is sitting on disk doesn't mean you have the overhead of a whole framework. You can use it like a class library that you pick-and-choose components from. There's really no reason to not use Zend Framework in your application - there's a lots of useful stuff in there that your application could most likely benefit from. There is, however, a Zend Framework MVC stack which you can use if you'd like. It's your choice, individual Zend Framework components or the whole MVC stack plus individual components.
#9 - Bradley Holt ( Link) on 26 Mar 2008, 02:55 Delete Comment
asdf
Full of yourself? Never "mixing" php and HTML? Are you advocating a use of a template system like Smarty (Hey, PHP IS a template system).

Not defining constants in a config file? Why not? You are assuming everyone uses the front controller pattern then if you only set it in index.php...what happens when you have another page? Oh no, they are defined there unless you include index.php too.

Get off your high horse and make a constructive post, instead of your "I'm better than you" junk you have up there.
#10 - Wow ( Link) on 26 Mar 2008, 03:38 Delete Comment
Couple points
Andrew - "It's ok to mix php and html (how else do you generate a dynamic page)"

Actually you can do this by using a JS front end that is only asking for data that it will mold on the clients side. I have a current project where the PHP is just generating JSON for an ext-js frontend. Though I still love having to have the ability to go into a current HTML page we have and throw in 5 lines of php where needed and not have rewrite the whole file.
#11 - ripsup ( Link) on 26 Mar 2008, 04:49 Delete Comment
Zend Fw rebund
@Bradley Holt : If your previous post was for me, I totally agree at the fact that you could use a part of the zend fw, and it's not because you have all the files that you need to load all of them. But I was talking about external needs. A framework that use PDO, Pear, is great because not use the "I created from scratch because I'm a roxor". But if your server does not have Pdo/Pear, you can't do nothing with this fw. That's why the most important framework (zend, cake, code igniter, etc) use their own abstract database, cache and view renderers.
#12 - cx42 ( Link) on 26 Mar 2008, 07:16 Delete Comment
Terminology
What are 'defines'? A common name for what you mean is 'constants'. They are called like that for ages.

Telling other people about 'sins' and then you don't even know how things are called...

Why do you notice the splinter in your brother's eye, but do not perceive the wooden beam in your own eye?

Telling others about unwritten laws and rules and saying they are sinning? How's that?

Nobody has told about what is the best, so you can't sin against it either. You can argue about best practices, but why calling it sins if one doens't comply with it?

- Unomi -
#13 - Unomi ( Link) on 26 Mar 2008, 17:12 Delete Comment
The Sins
LOL - Some people obviously dont get the sin's analogy...

The fact that good coding practices are often treated with religious fervor is quite an apt way to title the post...
#14 - Alan Knowles ( Link) on 26 Mar 2008, 17:35 Delete Comment
Filenaming
I name my class-files .class.php because I name my interface-files .interface.php, because I have interfaces and classes in OOP. And if I have Test-Cases (for unit-tests) I call this files .test.php .. and I have them all in the same directory: foo.class.php, foo.interface.php and foo.test.php

#15 - defel ( Link) on 26 Mar 2008, 19:21 Delete Comment
Javascript dependent pages are an accident waiting to happen
@ripsup:

"Actually you can do this by using a JS front end that is only asking for data that it will mold on the clients side."

I love jQuery and ext-js, however, it is insane in my opinion to have an entire web application completely dependent on javascript for rendering content. There are too many flukes, bugs, and discrepancies between the browsers for it to come anywhere near productive.

I've tried to use js as the main content display mechanism and I end up spending more time fighting the js to get it to work in all 3 major browsers than I do everything else...combined. In addition to that, performance when you have a large amount of data to display is on par with "stupidly slow". Sending the data from the server takes 2 seconds. Then js spends the next 60 rendering the html and attaching events to it, during which the browser is eating .5 a gig of ram, or more, and 95% processor time (I'm staring at you FIREFOX).

Not to mention the headaches that are caused with each "update" from the browsers. IE is especially bad about things like that...a supposedly minor update creates a new bug that will break your site.

I'm not saying it's not possible, but it's not for me :).
#16 - Andrew ( Link) on 28 Mar 2008, 19:57 Delete Comment


Name
Email
Homepage
Comment Title
Comment
 
Contact me at alan@akbkhome.com