ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Is the reign of frameworks over?

January 14, 2009 6:50am

Subscribe [9]
  • #1 / Jan 14, 2009 6:50am

    xwero

    4145 posts

    Yesterday i was made aware of the Flourish library and the points i found intriguing on the Motivations page are:

    Does not require use of MVC, especially the Front Controller variation

    Does not simply try to emulate another framework from another language

    The components concept isn’t a new one see Zend and EZComponents but to me it seems that every framework that comes out tries to let you see things their way.

    I was exited about the Recess! routing but when i downloaded the framework the annotations seem to appear almost everywhere as a substitute for configuration.

    But to get back to the motivation of the Flourish library.
    Having a rigid file structure limits developers to write DRY code, so they have to get inventive but this costs development time. 
    MVC also has its limits which makes developers create their kind of HMVC for more flexibility.

    I think the time of frameworks as a convenient base package are over and developers are going to start mix and matching libraries to create a mashup framework of their own.

    Not so long ago there was a discussion about the future of Codeigniter. And if you place that in the components point of view, i wonder which CI component excels from all the other similar components out there to get used in a mashup framework?

    Another thing i noticed is:

    Is not released in long monolithic release cycles

    If a bug is squatted or code is improved why not create a new release? Maybe some developers will suffer update fatigue but if you can work with the latest code while developing it means you have to create less workarounds. You can use the SVN files but the more developers that use the latest code the quicker unforeseen bugs can come to the surface.

  • #2 / Jan 14, 2009 7:52am

    Phil Sturgeon

    2889 posts

    I think PHP frameworks still have a place in the world. Forced file structures are a great way to keep a site in check and force lazy coders to get better. Nothing in CI is that forced (especially compared to other frameworks) so code can still be creative without too much time being eaten away.

    Frameworks still provide a great learning experience for new users, and provide a great way to create a medium to large site in very little time.

    Flourish is perhaps aimed at small sites that wish to pick and chose the components to use?

    Edit: After looking over the code I personally would never use this. It’s many files full of silly functions.

    Pointless

    /**
         * Indicates if the URL was accessed via the `DELETE` HTTP method
         * 
         * @return boolean  If the URL was accessed via the `DELETE` HTTP method
         */
        static public function isDelete()
        {
            return strtolower($_SERVER['REQUEST_METHOD']) == 'delete';
        }
        
        
        /**
         * Indicates if the URL was accessed via the `GET` HTTP method
         * 
         * @return boolean  If the URL was accessed via the `GET` HTTP method
         */
        static public function isGet()
        {
            return strtolower($_SERVER['REQUEST_METHOD']) == 'get';
        }
        
        
        /**
         * Indicates if the URL was accessed via the `POST` HTTP method
         * 
         * @return boolean  If the URL was accessed via the `POST` HTTP method
         */
        static public function isPost()
        {
            return strtolower($_SERVER['REQUEST_METHOD']) == 'post';
        }
        
        
        /**
         * Indicates if the URL was accessed via the `PUT` HTTP method
         * 
         * @return boolean  If the URL was accessed via the `PUT` HTTP method
         */
        static public function isPut()
        {
            return strtolower($_SERVER['REQUEST_METHOD']) == 'put';
        }

    Very pointless

    /**
         * Checks to see if this value is greater than the one passed
         * 
         * @throws fValidationException
         * 
         * @param  fMoney|string|integer $money  The money object to compare to - a string or integer will be converted to the default currency (if defined)
         * @return boolean  If this value is greater than the one passed
         */
        public function gt($money)
        {
            $money = $this->makeMoney($money);
            return $this->amount->gt($money->convert($this->currency)->amount);
        }
        
        
        /**
         * Checks to see if this value is greater than or equal to the one passed
         * 
         * @throws fValidationException
         * 
         * @param  fMoney|string|integer $money  The money object to compare to - a string or integer will be converted to the default currency (if defined)
         * @return boolean  If this value is greater than or equal to the one passed
         */
        public function gte($money)
        {
            $money = $this->makeMoney($money);
            return $this->amount->gte($money->convert($this->currency)->amount);
        }
        
        
        /**
         * Checks to see if this value is less than the one passed
         * 
         * @throws fValidationException
         * 
         * @param  fMoney|string|integer $money  The money object to compare to - a string or integer will be converted to the default currency (if defined)
         * @return boolean  If this value is less than the one passed
         */
        public function lt($money)
        {
            $money = $this->makeMoney($money);
            return $this->amount->lt($money->convert($this->currency)->amount);
        }
        
        
        /**
         * Checks to see if this value is less than or equal to the one passed
         * 
         * @throws fValidationException
         * 
         * @param  fMoney|string|integer $money  The money object to compare to - a string or integer will be converted to the default currency (if defined)
         * @return boolean  If this value is less than or equal to the one passed
         */
        public function lte($money)
        {
            $money = $this->makeMoney($money);
            return $this->amount->lte($money->convert($this->currency)->amount);
        }

    just plain wrong!

    /**
         * Resets the configuration of the class
         * 
         * @internal
         * 
         * @return void
         */
        static public function reset()
        {
            self::$currencies = array(
                'USD' => array(
                    'name'      => 'United States Dollar',
                    'symbol'    => '$',
                    'precision' => 2,
                    'value'     => '1.00000000'
                )
            );
            self::$default_currency  = NULL;
            self::$format_callback   = NULL;
            self::$unformat_callback = NULL;    
        }

    Any currencies you added would be wiped on reset… what the hell?

  • #3 / Jan 14, 2009 8:07am

    johnwbaxter

    651 posts

    Wow that looks really nice. Docs are nice too.

  • #4 / Jan 14, 2009 8:07am

    Phil Sturgeon

    2889 posts

    Oh come on!

    /**
         * Checks to see if a number is equal to zero
         * 
         * @param  string $number  The number to check, first character should be the sign
         * @return boolean  If the number is equal to zero
         */
        static private function isZero($number)
        {
            return trim(substr(str_replace('.', '', $number), 1), '0') == '';
        }

    Seriously?!

    He goes on to write functions for addition, multiplication, subtraction and division that take up 391 lines of code, not counting various private methods that they use such as stripLeadingZeros() and others. This library is a joke.

  • #5 / Jan 14, 2009 8:17am

    xwero

    4145 posts

    Frameworks still provide a great learning experience for new users, and provide a great way to create a medium to large site in very little time.

    A lot of people are complaining for a very long time about the lack of certain libraries in CI so for them the time they have to search for libraries they want to use is a waste of time. This means the quick development time argument goes down the drain.

    if you look at the javascript world, the thing that makes jQuery so fantastic is that it can coincide with the other libraries. Can you ever see CI running together with symphony or any other framework? I don’t think so because the frameworks force developers to follow their standards.

    I don’t think Flourish or other libraries aren’t targeting small site developers because if you create your own framework you can go as big as you want as long as you know the development of the library parts you are using continues.  I don’t know how Flourish will evolve but a library like Zend is backed up by a company.

  • #6 / Jan 14, 2009 8:20am

    johnwbaxter

    651 posts

    My wow that’s nice statement did not involve me looking at any code, it was mostly just looking at the features…

  • #7 / Jan 14, 2009 8:21am

    xwero

    4145 posts

    This library is a joke.

    It’s not a debate about Flourish but about the ideas behind the creation of the library.

  • #8 / Jan 14, 2009 8:44am

    wbond

    6 posts

    @xwero

    Hey, thanks for checking Flourish out! (I’m the developer who created it).

    I don’t think that the reign of frameworks is over. I think there are many situations where frameworks make the most sense and will cause a project to be the most stable and the developers to be the most productive. The MVC pattern, including the front controller variation, is useful for lots of stuff.

    That said, I think there plenty of situations where it is not the right choice. Sometimes using a front controller on a PHP site would not be useful, or would complicate thing unnecessarily. Sometimes you might want to bang out a single script that isn’t part of a full site.

    So anyway, choice is good. Having the choice between multiple frameworks and libraries is a good thing. They all really have their own strengths and weaknesses.

    @pyromaniac

    I agree with your first few paragraphs. Frameworks have lots of uses, I don’t see them going away.

    Moving onto your critue of some of the Flourish code, I think you are missing a few things.

    First, the request method static methods in fRequest could be termed slightly “pointless”, I guess. They are there because they cause the flow of written code to be more readable. You certainly could replace fRequest::isPost() with strtolower($_SERVER[‘REQUEST_METHOD’]) == ‘post’ whenever you need it.

    It might not even be necessary to wrap it in strtolower, I’m not positive if PHP always returns it uppercase on all web servers, so I include the strtolower to ensure everything works everywhere.

    Moving on to fMoney, are you familiar with doing arbitrary precision math? Basically the floating point math built into PHP (like many other languages) is not precise. When you are dealing with money, precision matters.

    That 391 line method is actually a native PHP implementation of arbitrary precision mathematics. You can get it through the bcmath extension, however that is not compiled into PHP by default, and I wanted Flourish to be as portable as possible.

    In addition, the lt, gt, lte and gte method allow you to compare amounts in different currencies without having to manually convert them. That is certainly not pointless.

    isZero() is used internally to homogenize all zero-like values to ensure they are really 0. Comparing 000000000000000000000000000000000000000000000000.00 to 0 as string will come out false even through they are both zero.

    The static reset methods throughout Flourish are all tagged @internal. If you check out the documentation on the website, @internal methods are public, however only intended to be used internally by Flourish. The static reset methods are necessary to do unit testing of Flourish since static methods and variables are only deleted when the PHP cli or web process ends. I use PHPUnit for my unit and integration testing, and the PHP process is not terminated after each test, so I need to reset the configuration, otherwise my tests would be leaking state from one to another.

  • #9 / Jan 14, 2009 9:21am

    xwero

    4145 posts

    Hey wbond, welcome to the CI community! Be careful you will not end up using CI more than your own library 😉

    It struck me when reading your motivations that in order to really have reusable code classes should not depend on a single environment. For example all the classes in CI have following code in the constructor :

    log_message('debug', "[Class] Initialized");

    Libraries are written to use in all kinds of environments which means library classes have to be written more robust than framework classes.

    Of course frameworks will keep on living but good libraries can create a dent in the idea that a framework is the best choice to develop any kind of website. Maybe in the future we can have a library class that is used by different frameworks and fade the ‘does not exist in my language’ syndrome.

  • #10 / Jan 14, 2009 9:23am

    Phil Sturgeon

    2889 posts

    First, the request method static methods in fRequest could be termed slightly “pointless”, I guess. They are there because they cause the flow of written code to be more readable. You certainly could replace fRequest::isPost() with strtolower($_SERVER[‘REQUEST_METHOD’]) == ‘post’ whenever you need it.</code></pre>

    It was an example of an over-the-top coding method used throughout the library. For readable code, you only need one such as freQuest::isMethod(‘post’) instead of a separate function for each, and this could be said for much of the other code.

    isZero() is used internally to homogenize all zero-like values to ensure they are really 0. Comparing 000000000000000000000000000000000000000000000000.00 to 0 as string will come out false even through they are both zero.

    (int) $variable === 0

    The static reset methods throughout Flourish are all tagged @internal. If you check out the documentation on the website, @internal methods are public, however only intended to be used internally by Flourish. The static reset methods are necessary to do unit testing of Flourish since static methods and variables are only deleted when the PHP cli or web process ends. I use PHPUnit for my unit and integration testing, and the PHP process is not terminated after each test, so I need to reset the configuration, otherwise my tests would be leaking state from one to another.

    Definatly, got to love the unit testing, my query was with setting the currency array with a single currency. It should use the same array it uses in the constructor to allow anyone using the library to set the currencies once and have them remembered in the class, not reset on each load.

    Anyway, we are thread-jacking - oops!

  • #11 / Jan 14, 2009 9:30am

    xwero

    4145 posts

    If it helps to output better code, thread-jack by all means 😊

  • #12 / Jan 14, 2009 10:07am

    Phil Sturgeon

    2889 posts

    Forgot to mention before xwero, your point about CI and other frameworks not playing nicely together. What exactly do you mean by this?

    Zend components can be used on CodeIgniter easily enough, and you can probably share plenty of classes from other frameworks with only minor changes. The first thing I do when I see a new framework or library is see what code I can steal for CI. It rarely takes much converting. If somebody wants to code in CI, they should learn to actually code in CI and make some libraries themselves.

    I’d much rather grab a framework with a bunch of good libraries and make a few myself for later re-use than wait around for a perfect framework with EVERYTHING already included. If you try and make a framework with EVERYTHING you end up with bloat-ware, Flourish, or no site at all.

    Except for Zend of course, but that has a little more funding than its peers.

  • #13 / Jan 14, 2009 11:03am

    wbond

    6 posts

    @pyromaniac

    I appreciate you taking the time to look through some of the code and offer criticism! It may be the case that Flourish isn’t something you’ll ever need or want to use, but dialog back and forth is always good.

    You certainly could write a method like that (isMethod()), as I said before, I really tried to make the flow of the API pretty nice, and I thought that not passing a parameter was a little nicer.

    In terms of testing for zero, your code example fails for the following example:

    (int) '0.00000001' === 0

    I think we are misunderstanding each other about the ::reset() methods. fMoney is set up so that you define your currencies by calling ::defineCurrency() for each. This is then stored in a static class variable for use by the rest of the class. On a normal website this configuration would probably be done in a configuration script, based off of exchange rates pulled daily from a remote source.

    However, when running unit tests I need to test setting and getting currencies and stuff. So test 1 might set up 3 currencies and check to see if each exists. Test 2 might set up one and check if the other two don’t exist. I need to clear out that static array of currency definitions between each test, so ::reset() does that. Specifically, it resets all of the static class variables to their initial state when the class is loaded (you can see the state at the top of the class). Again, you’ll never want to use this on a website, just for unit testing.

  • #14 / Jan 14, 2009 11:07am

    xwero

    4145 posts

    What if you want to run half a site based on symphony and half a site on CI. If the split is frontend/backend it could be done but if the sections are split it’s more difficult. Because then they will share configurations and language files, but where should you put them with the load methods that expect a certain file structure?
    Why does a blog module needs to be created for each framework while the functionality stays the same?

    Most frameworks use MVC but the basics like model, controller file constructions are different between the frameworks.

  • #15 / Jan 14, 2009 11:32am

    Nick Husher

    364 posts

    I don’t think that the reign of frameworks is over. I think there are many situations where frameworks make the most sense and will cause a project to be the most stable and the developers to be the most productive. The MVC pattern, including the front controller variation, is useful for lots of stuff.

    That said, I think there plenty of situations where it is not the right choice. Sometimes using a front controller on a PHP site would not be useful, or would complicate thing unnecessarily. Sometimes you might want to bang out a single script that isn’t part of a full site.

    So anyway, choice is good. Having the choice between multiple frameworks and libraries is a good thing. They all really have their own strengths and weaknesses.

    This. There are times where CodeIgniter is either too heavy or not fully-featured enough to get the job done as quickly as possible. Whenever someone says that a certain thing will solve all your problems, they’re either a zealot or are selling something.

    The comparison between the javascript world and the PHP world is a bit misconstructed. Most javascript operates in a “Document +” role rather than a “Web Application” role. It enhances a mostly-static document rather than operating like a true GUI application. Fully-featured javascript-based web applications do have frameworks, many of them quite restrictive. The lightest side of this spectrum would be YUI2, while the heaviest would be GWT or cappuccino.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases