While coding (php5) on a new project today, I found myself struggling with the question to fit a collection of functions in a class or not. Or in other words, to maintain a procedural style, or more object orientated.
I only learned recently how to use objects and classes in php5 and I find myself mixing objects and procedural style within scripts. For instance, html templates and database abstraction is fitted in classes, while handling a form (collection -> validating ->processing) is done in a procedural style in my scripts.
I think that webapplication-coding is by nature more suitable for a procedural style. You have a very clear starting point and end. So the timeline in your script is very linear. Compare this with java, where applets mostly run in a loop waiting for userevents. The fundamental difference in nature (begin->end against looping) explains my struggle to code completely OOP with PHP.
Off course OOP has lots of advantages with PHP (execption handling, code reusability to name a few) but I think when coding webapplications, you will always find yourself coding a more or less procedural timeline within your script.
Posted by:
Merlijn on Wednesday, 31 of August , 2005 at 22:13
Tags:
oop,
PHP,
web 2.0 Categories:
Coding
Comments:
be the first (opens in a pop-up window)
Add this post to
del.icio.us or
digg it
For my Open University course I have started with “Visual Programming with Java”.
I know it’s more fun as Discrete Math :)
And it’s quite fun to finally “learn” programming, as I’m a autodidact. The level is very very basic, but that doesn’t matter to me. In the last years my experience is that it can be very helpfull to really learn the basics.
The real fun is that I have to use windows again. The course uses Borland Jbuilder 8, with a license which only runs on windows XP according to the manual, but I use it on my very old windows98 machine without any problems.
And oh boy, what is an IDE fun. Programming like playing with LEGO.
“You have forgotten a semi-colon right here”.
Oh…thanks :)
Instead of digging through 2500 lines of code where that missing T_SPACE is…
Java is also fun to work with. Very straightforward and easier than C (no memory management / garbage collection needed). I really can tell know where PHP has it’s roots. It really helps me getting some insight in OOP concepts, which are used in PHP 5 as well.
btw…writing this on windows, Wordpress really looks better in Firefox as in Safari…damn.
Posted by:
Merlijn on Saturday, 23 of July , 2005 at 13:53
Tags:
java,
oop,
open university,
PHP Categories:
Coding
Comments:
3 » (opens in a pop-up window)
Add this post to
del.icio.us or
digg it
I did it!
For over a year I glanced at PHP5, but put it aside as too unstable/experimental (a year ago) or too dangerous to migrate due to incompatibility issues.
Some of my projects where however advancing to a point, that procedural programming became to limited. And more and more I found myself looking at (Object Orientated Programming) OOP.
And being a absolute rookie in OOP, I decided that if I had to learn OOP, I wanted it to learn in PHP5 rightaway, instead of starting in PHP4.
Well, 2 weeks ago, I decided that the time has come. I downloaded php5, installed it on my development server and….it just worked?!
A closer look learned that JPgraph -scripts broke and some my legacy code also.
Fortunately, there are two configuration options who both can be set in a htaccess or virtualhost configuration:
zend.ze1_compatibility_mode
and
register_long_arrays
Enabling those two directives in the appropiate virtualhost config made all the scripts 100% working again!(yeah yeah I know, ditch the legacy code and wait for jpgraph 2.0, but we don’t live in a perfect world, do we?)
The last week I find myself coding in PHP5 OOP style for the first time, using the new mysqli extension (prepared statements kick ass!) and enjoying php5 very very much!
Posted by:
Merlijn on Sunday, 10 of April , 2005 at 09:05
Tags:
JPGraph,
oop,
PHP Categories:
Coding
Comments:
be the first (opens in a pop-up window)
Add this post to
del.icio.us or
digg it