SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 52
  1. #26
    SitePoint Evangelist Ian R. Gordon's Avatar
    Join Date
    Feb 2004
    Location
    New York
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heh, I thought this thread might spark some debate, however, I am really still debating the procedural or OO path...they are a bit different but the results are fundamentally the same.

    To be fair I am going to being using PHP5 so I might really want to consider OO since it is very much improved in PHP5.

    I am really just looking for an efficient way to come up with a gateway for my script without having to call seperate files in the script while still working with a database. I know there are lots of solutions, I was just curious about procedural patterns and if they existed since OO patterns are touted about so much.
    Ian Gordon
    CSS / XHTML / PHP Programmer
    http://www.iangordon.us

  2. #27
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lastcraft
    (Yawn) what overhead? The cost of a method call dispatch? Be serious.
    No , the overhead of loading all the MVC class heirarchy & infrastructure to basically decide which content (dynamic or static) to pull (this is not JAVA).
    This is not the deciding factor for anthing BTW just a response to the oxymoronic turbocharger .


    Quote Originally Posted by lastcraft
    The following is a bit unfair, given you typed this off the top of your head, but it makes a nice illustration . Please forgiveme.
    forgiven , I thought when posting ... should I stop and think of a real example or just a general idea ? , recognition of such appreciated.

    Quote Originally Posted by lastcraft
    1) Whatever is in the common functions is loaded regardless. The pages should handle their own resources. Thay will need a different set of resources during testing or when on development boxes. I think you should strip this line.
    OK , change it to require_once 'config.php' , in my own system , config.php will load the required database drivers (I dont like generic abstraction classes) and a few required functions/classes for basic filters (io,caching,injection etc), paths & for application scope constants and variables , basically anything that can be considered application-scope beleive me I load nothing conditional

    Quote Originally Posted by lastcraft
    2) clean() is likely to be context sensitive (what about file upload for example?). The function has side effects and will be difficult to test or to combine with other frameworks/libraries that do the same thing. Better that each page pulls the values that it is interested in and filters just those.
    I dont actually use a clean() function in this manner , but such is the manner of forums like this that not at least pretending to filter _REQUEST results in food fights for the hyenas

    & _FILES is not part of _REQUEST any more and I do filter ALL incoming _REQUEST at all times (config.php) , basic filtering that is , anything out of the ordinary would be handled elsewhere.

    Quote Originally Posted by lastcraft
    3) This code does little more than modrewrite. You use a front controller when the page structure is dynamic, e.g. a Wiki or newsgroup. Selecting a page is usually more complex in these cases. If you pull it from the database, what about page caching? It would be nice to hide that behind a function, but you have to hide the choce of a testing database behind that function too. The only way to handle multiple behaviour changing factors is with flags or passing function names. Lot's of flags leads to explosions of case statements. Passing function names is fragile, because their parameters can change. All this is easy for OO though.
    `non-the-less , its still a frog`

    Quote Originally Posted by lastcraft
    4) I do hope FILE_ROOT isn't really a constant. Even assemblers have the notion of relocatable code. The mapping of the request to the file should really happen behind closed doors or you won't be able to put your page handlers in different directories. And what about mixing truly dynamic pages with static ones?
    oh it is , I don't like using string constants (its innefficient after all) however I always use absolute paths , I could solve 10 forum posts a day with `use absolute paths` and the resulting 5 follow-ups with `use a constant or global for the root`.
    You also assume that $page.php is the content , it may itself be a controller , I dont know , I just made it up.

    In my own system Static pages would never get this far in the first place , cached output would have been handled somewhere in config.php , its just another filter.

    Quote Originally Posted by lastcraft
    I may not want to, but I can. In other words these systems scale.
    I dont think you can pin the scaleability factor purely down to OO.. can you ?

    Quote Originally Posted by lastcraft
    Classes carry behaviour. This behaviour may appear property like if we want something very simple (getters and setters), but we can add more complex behaviour at will.
    agreed , bad example , but my point indeed was that you probably can't translate all design patterns to procedural code.


    Quote Originally Posted by lastcraft
    I would also like someone to give a tour of functional patterns (reducers, currying and the like) and hardest of all I think - data model patterns.
    And thats why I am glad this thread appeared , other threads with similar content appear to have been sent for `re-education` which is sad.

    As a disclaimer I don't use a front controller myself , I generate a page controller (unsure if thats the right term) for all pages which setup the page and build the content , again static or cached content never gets this far. The controllers themselves are generated by (OO!) script but thats another story.
    I do know some good software that does though , FUDforum for instance uses a procedural (call it what you want) front-controller quite nicely.

  3. #28
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ian R. Gordon
    I am really just looking for an efficient way to come up with a gateway for my script without having to call seperate files in the script while still working with a database.
    Perhaps your front-controller need not do all the work ? e.g. with an articles page , your front-controller need do no more than recognise 'articles' , load the appropriate articles script (after checking for cached versions) and then let that script worry about what request data is availabe to produce the required content.

    You could translate this into section and subsection heirarchy as well if you wished.

  4. #29
    SitePoint Evangelist Ian R. Gordon's Avatar
    Join Date
    Feb 2004
    Location
    New York
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You see I really don't want this script to be bloated with unnecessary code. What I am essentially trying to do is when a user requests a "page" (page being a variable linked to a specific action), an action is then loaded, if the action doesn't exisit an error is shown. That is more or less the global gist.

    However to be more specific, the action needs to connect to a MySQL database and pull data for both content and template (i know templates in databases is considered bad, blah, blah, blah) data then meld them together in the browser at the end of the scripts execution. If the action messes up show an error page.

    Sounds simple enough but, I am running into all sorts of problems, mainly deciding to code in procedural or object oriented. Then I am thinking about using design patterns to help make the process simplier but, then everyone starts arguing their own points about OO or procedural programming and I don't really get helped. Everyone expects me to do everything myself, the research, learning how to do it (creating the class or function) when I really don't know how (thats why I am asking for help, duh). It's a bit of a confusing mess, I know the basics but, when I trying to code it I get programmers block.

    Overall, I am just trying to right now get a mysql connection via a function or class made so I am move on with the rest of my script. I am also trying to think of a way to effectively store my templates in my database while retrieving them to add the content data from the same MySQL database together in a effective and efficient manner.

    Quite a mouthfull, eh?
    Ian Gordon
    CSS / XHTML / PHP Programmer
    http://www.iangordon.us

  5. #30
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would agree with many people that things like recursion, etc is a pattern, which applies both in procedural and OO obviously. Some patterns are more generalized / abstract than others. For instance, OO to Relational mapping patterns (Inheritance Mappers, Class Table Inheritance, etc) obviously spell out the words OOP. Things like the PoEAA special case pattern again are more cut out for OO as polymorphism + interfaces are the way forward to implement those, however, that doesn't mean it can't be done with a normal function (i.e. C function pointer, where the collection of function pointers all follow the same calling interface. Again this is more suited to C due to the compiler checks).

    Things like the MVC pattern are very flexible with their implementation and the way some might interpret it. For instance The model might be based round classes (seeing as this is where the most reuse lies imo), templates and functions might make up the view and your controller can be free standing PHP code with some mod rewrite trickery. Of course, this doesn't scale as well.

    As far as OO vs procedural in speed is concerned. As Marcus said, the difference is a few look ups involved in a method call dispatches, which is nothing in terms of CPU cycles. The overhead is probably incurred more by bad programming technique and incorrect pattern use / over engineering with patterns, probably something we are all guilty of at some-point, especially when you are learning (well I know I am). The speed issue has nothing to do with OO verus procedural. And really to me is unrelated to this topic. That is a down to programming technique and using patterns correctly.

    Again, the the whole idea of design patterns is to encourage reuse in many ways. OO + generic programming have the edge of procedural code for when it comes to reuse.

  6. #31
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sweatje
    On the other hand, you can only inherit once. There are probably much more compelling inhertiance hierarchies in your domain model, so why waste your inheritance when you can write the pattern out in 5 lines of code?

    </devil's advocate>
    hello advocate

    at first i wanted to answer that java has learned us that interfaces are a reasonable work-around for the single-inheritance problem.

    but then i realised that oop is more than inheritance only. and in this case composition is probably a good solution to make the class fit in the model and reuse the pattern implementation...

  7. #32
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the past I have thought about trying to do a PHP "mix-in" for this, but it is very hard (impossible) to accuratly determine the class of a static method call if that call is made from within another class (think factory or whatever). So the only option would be to pass the class name in as well, and that just starts to look ugly:
    PHP Code:
    $some_model = new SomeModel::getInstance('SomeModel'); 

  8. #33
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sweatje
    On the other hand, you can only inherit once.
    That's a language vs language issue, not a procedural vs OO one. For example, C++ supports multiple inheritance and Ruby supports mixins. PHP doesn't support either

    Example of a Singleton with Mixins: http://c2.com/cgi/wiki?RubySingleton

    I did see a site with a list of a lot of procedural patterns on in, though I can't find a link to it atm If I do, I'll post it later.

    Douglas
    Hello World

  9. #34
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ian R. Gordon
    the results are fundamentally the same.
    Would it be right to say that becuse PHP using a procedural and an OO style is still Turing Complete, anything that can be done in procedural can be done in OO, and vice versa?

    If so, arguments that you can or can't do something one way or another really boil down to whether it is earier or harder to do something one way rather than another.

    Douglas
    Hello World

  10. #35
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If so, arguments that you can or can't do something one way or another really boil down to whether it is earier or harder to do something one way rather than another.
    It really comes down to degree. Within most every OO method is a chunk of procedural code.

    The question becomes: does OO permiate your design or not? When you read the likes of Fowler and he promotes Domain Model he is really promoting an approach that moves OO forward in the design process and forces/enables more/better OO in the implementation. Doing that may help or hinder you or your team, it depends.

    I tend to think of decision, for example, between implementing Transaction Script, Table Data Gateway, or Domain Model is just a choice based on the requirements. Others see them as steps of increasing preference.
    Christopher

  11. #36
    SitePoint Evangelist ghurtado's Avatar
    Join Date
    Sep 2003
    Location
    Wixom, Michigan
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    It really comes down to degree. Within most every OO method is a chunk of procedural code.
    This is because OOP is not fundamentally different from procedural programming, in that both have to adhere to the syntax of the language you are using just the same (save for OO specific syntax, of course). When I look at a piece of nicely written OO code, I dont look at the "procedural" parts and think "oh, look, they had to use procedural code here". OOP is in essence the techniques and practices used to take procedural code (really, the code itself is only of one kind, not procedural or OO) and wrap it into a higher level of abstraction that brings you all the benefits that come with OOP (and I will spare you listing them all).

    What I do find interesting is that the resistance to use this higher level of abstraction, almost always comes from a lack of understanding of OOP, I have never heard of a programmer who thouroughly understood OOP and yet conciously decided to use procedural programming when faced with the choice.

    To me, OOP is like the Hotel California, you can check in any time you like, but you can never leave...
    Garcia

  12. #37
    SitePoint Evangelist Ian R. Gordon's Avatar
    Join Date
    Feb 2004
    Location
    New York
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Again a matter of opinion...

    PHP I believe was originally designed to be programmed in a procedural fashion, however because it is open source, it has object oriented functionally built into it too by people wanted to start using Object Oriented approaches to creating scripts. Of course with this comes lots of debates, blah, blah, blah.

    However, I am still up in the air, I have a pretty solid grasp of OO and Procedural, I am just in a slump right now seeing if I can come up with something simple for the get go, rather than writing hundreds or thousands of lines of codes when only a couple hundred would have sufficed and been just as effective.

    I believe this is a goal for all programmers, I guess I am just really trying to understand it all before I program which in itself I would surmise is a paradigm shift I shouldn't have taken.
    Ian Gordon
    CSS / XHTML / PHP Programmer
    http://www.iangordon.us

  13. #38
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    at first people only wrote a sequence of instructions.

    then they noticed that parts of those sequences occured more than once and they found a way to avoid copy-pasting: functions and parameters

    and then they noticed that some functions were manipulation the same set of data so they found a way to couple that data with the functions: classes and methods and properties

    it's obvious the 3 approaches allow you to achieve the same results... and they all have their pros and cons... if you start programming you want to make sure you test them all so you can make up your own mind based on experience (and not on the everlasting mine-is-better/bigger than yours discussions )

  14. #39
    SitePoint Addict mx2k's Avatar
    Join Date
    Jan 2005
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i considered it a stength of php to be able to use both oop and procedural. That often makes .net over kill when it comes to doing small websites.

    Putting everything into a class, when only a couple lines of procedural code needed to do that one task would have done the job perfectly well. If i am not reusing the code in the same project over and over, why put forth the extra effort and lines?

    if you use the code over multiple projects, but not multiples times within each project, they make these things called code snippets that you can copy and paste or just click and add to the project =)

    now on the other hand if i was using the code multiple times through out a project, hello OOP!.

    keeping an open mind and a willingness to learn is key to staying on top of things. and the question was definitely a valid one to ask. any patterns that help with keeping things short, sweet and straight to the point whether if it is blocked code, functions or nicely tucked classes is definitely welcomed

  15. #40
    SitePoint Guru OfficeOfTheLaw's Avatar
    Join Date
    Apr 2004
    Location
    Quincy
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ian R. Gordon
    Again a matter of opinion...

    PHP I believe was originally designed to be programmed in a procedural fashion, however because it is open source, it has object oriented functionally built into it too by people wanted to start using Object Oriented approaches to creating scripts. Of course with this comes lots of debates, blah, blah, blah.

    However, I am still up in the air, I have a pretty solid grasp of OO and Procedural, I am just in a slump right now seeing if I can come up with something simple for the get go, rather than writing hundreds or thousands of lines of codes when only a couple hundred would have sufficed and been just as effective.

    I believe this is a goal for all programmers, I guess I am just really trying to understand it all before I program which in itself I would surmise is a paradigm shift I shouldn't have taken.
    When I started learning, I found the best way was to refactor procedural code into object oriented code... I always thought of it as a way to organize things, I'd take segments of code that performed particular actions that were related, and group them into a class that represented what those segments of code were operating on in an abstract sense.

    I don't really think it's a matter of preferrence, but it just generates cleaner code. For example, rather than having SQL queries littered throughout a file, with multiple calls to mysql_query, mysql_fetch_assoc, etc, it's nice to have something like:
    PHP Code:
    ...
    $person PeopleGatway::getPersonByID($id);
    $order_history Orders::getByPID($id);

    $page =& new CustomerPage();
    $page->displayOrderHistory($person$order_history); 
    The point is, it abstracts details you don't want to concearn yourself with at that level. that's the way I view it.. abstraction. That, and it's just cleaner... need to add a field to the people table? just edit the sql in the class for the changes... as compared to changing 20 to 30 queries spread out across 10 files.

    James Carr, Software Engineer


    assertEquals(newXPJob, you.ask(officeOfTheLaw));

  16. #41
    SitePoint Evangelist Ian R. Gordon's Avatar
    Join Date
    Feb 2004
    Location
    New York
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's your opinion and while you may have a point that is simply another way of doing something. I know there are probably a lot of people who would heartily disagree with you.

    I see your point though.
    Ian Gordon
    CSS / XHTML / PHP Programmer
    http://www.iangordon.us

  17. #42
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Plenty of room at the Hotel California. Such a lovely place.

    You must spread some Reputation around before giving it to ghurtado again.

  18. #43
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ian R. Gordon
    Again a matter of opinion...
    This seems to be your answer to post of the posts in this thread... can you give an example of something that wouldn't be "just an opinion"?

    Quote Originally Posted by Ian R. Gordon
    with procedural programming there is usually a lot more flexibility in how you are able to structure a script
    Are you sure about this?? The flexibility of OO code is one of the areas that it is attacked on, because of the lack of a "one true way" to do something. See: http://c2.com/cgi/wiki?OoLacksConsistencyDiscussion

    Douglas
    Hello World

  19. #44
    SitePoint Zealot
    Join Date
    Feb 2003
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    This seems to be your answer to post of the posts in this thread... can you give an example of something that wouldn't be "just an opinion"?
    Either someone keeps defending his POV and becomes and Anti-OO zealot, or one tries to agree to disagree and is implicitly accused of the Relativist Fallacy. Interesting.

    If we look to science, than e.g. an educated opinion or a conclusion based on agreed premises and hard ("experimental") data (instead of just anectodal evidence) is better than "just an opinion". However everybody in their right mind is not going to apply any of that to this discussion in this forum (and many other places as well).

  20. #45
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by R. U. Serious
    However everybody in their right mind is not going to apply any of that to this discussion in this forum (and many other places as well).
    It felt like Ian was just passing everything off as "well that's just your POV", sorry for going OT
    Hello World

  21. #46
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Computer science originally arised from mathematics and physics in my view...

    Object Oriented methodology as I see it, has sprung from this from as far back as the late 60s and early 70s. So what I'm basically saying is that OO was born before the modern programming langauges we have today.

    Stop for a moment, and think carefully about this yes? Ask yourself why the scientists and mathameticians devised OO in the first place. To me to use procedural programming is like going back to those decades where punch cards were in use.

    There is a reason and a purpose behind OO and thank god the people with the skill and knowledge 50 years ago, to come up with OO methodologies and programming, otherwise we'd still be using punch cards today

    Just my thoughts but I think I've made my point.

  22. #47
    SitePoint Evangelist Ian R. Gordon's Avatar
    Join Date
    Feb 2004
    Location
    New York
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    It felt like Ian was just passing everything off as "well that's just your POV", sorry for going OT
    Well, I was passing everything off...more specifically I did not want to have to bog myself down too much with details. I notice that in a lot of these threads they go on for pages, where its just two or three people they are more or less just defending their point of view offering up examples, showing theories and other stuff that just in my opinion just digresses from usually what I think people want when they ask questions and want some pretty simple and straightforward answers.

    Can you tell me you have just given a simple straightforward answer and not tried to support your opinion in a response with some form of debate? Can you tell me that you don't try to debate with others who offer up criticisms, even at the expense of not answering someone's questions?

    I digress, you don't have to answer those questions, I was just trying to make point. I just wanted simple answers, something I think no one really can give without trying to explain their own point of view or address a possible fault with someone elses explaination or code example. I am sure even though this was merely a response, lots more non-related responses will follow, right? The nature of the forum!?
    Ian Gordon
    CSS / XHTML / PHP Programmer
    http://www.iangordon.us

  23. #48
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ghurtado
    ...almost always comes from a lack of understanding of OOP, I have never heard of a programmer who thouroughly understood OOP and yet conciously decided to use procedural programming when faced with the choice.
    Ilia Alshanetsky probably understands OO , he maintains lots of PHP & PECL code including the very OO SQlite.
    Dig through the code of FUDforum and tell me what you see.

    Indeed serendipity is partially OO , but look at the codebase again , then look at who the developers are.

    Perhaps they are just exceptions (no pun intended) ?

    DOugBTW , these discussions are ALL a POV , a matter of opinion , there is no factual proof of OO or procedural methods being 'best' or even 'better' its totally subjective and always circumstansial.

    Dr L , who invented procedural programming ? probably monkeys .. and thats about as relevant

  24. #49
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    off topic, but following the lead of the original poster

    Quote Originally Posted by Ian R. Gordon
    Can you tell me you have just given a simple straightforward answer and not tried to support your opinion in a response with some form of debate? Can you tell me that you don't try to debate with others who offer up criticisms, even at the expense of not answering someone's questions?
    Unless I am misunderstanding your questions, the answer for me is: YES!
    http://www.sitepoint.com/forums/showthread.php?t=238143

    I offered an OOP solution which worked for the original poster. Someone else showed a recursive solution. I said cool. Stereofrog offered a function to perform the same. Someone else pointed a limitation of the procedural solution based on a design assumption and then I offered a work around to overcome that limitation.

    OTOH, sometimes people will present an attitude in the posts which seems to indicate their solution/architecture/approach/paradigm/methodology works, and they have no inclination to look at or evaluate another. This lack of a desire to learn annoies me, but usually I would be content to back away and let those individuals wallow in their ignorance. Sometimes I think this medium might somehow be exasterbating this phenomina though...
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  25. #50
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ian R. Gordon
    The nature of the forum!?
    Yes if you suggest there is another god other than OO.

    Personally I think for PHP the answer lies somewhere in-between (not in a fence sitting way) but then you still get arguments about specifics.

    I run several sites off of my own mostly class based libraries , I have after much grunting and groaning identified the areas where I (e.g. IMO) think that the benefits of OO are too good to pass up & areas where its simply quicker to just use procedural code (of coure you still use OO elements from your base libraries within such)

    e.g. despite earlier procrastinations I have a set of base classes that handle file writing and reading , these include recursive directory structure creation etc , things that are a pain to code as you need them but benefit from OO in that you can tweak your methods and add drivers etc very easily.
    They are small and efficient and I am happy to include them at runtime.

    OK file ops is an easy one for OO in that its hard to end up with markup etc in those classes , things like templating and shopping carts etc benefit from OO reuse but its harder to keep bad smells out of them without getting into much more complex OO & patterns which is something I don't like doing , I know Marcus and the others will say otherwise but there is an overhead with such methodologies that I personally can not accept in an interpreted PHP environment.

    So I end up generating either procedural code or smaller class libraries from my base libraries for use at runtime , this requires a `build` system which has its drawbacks in compexity but allows me to be happy with my alledgedly more efficient runtime code and also happy in the knowledge that due to the build system these routines get rebuilt whenever I change the logic of by base libraries (& if I was into unit testing etc I would probably feel safer whenever I press the `build` button )

    What this means for me is that I can actually set up a complex site skeleton from a simple array mostly thanks to the OO backend but end up with a site that does not require a complex OO heirarchy to run , one that can then accomodate further OO or procedural runtime logic (e.g. application specific routines are not part of the core system though anything possibly reusable (FAQ/link/news/etc) is normally made into a module.

    Of course all of this work is pointless if you take the view that OO has no overhead in PHP , a point that we have gone over and disagreed about many times before.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •