SitePoint Sponsor

User Tag List

Page 3 of 5 FirstFirst 12345 LastLast
Results 51 to 75 of 110
  1. #51
    SitePoint Guru
    Join Date
    Nov 2002
    Posts
    841
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Isn't it ironic that PHP adds static typing features to PHP 5 in order to lure java developers just at the same time that more and more java developers are deciding they aren't that thrilled with static typing after all.

  2. #52
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And Java finally got a foreach statement because Iterators for everything can get so annoying. It's interesting that where you are going depends on where you have been, yet programmers from may different languages seem to cyclically converge on similar conclusions about best practices.
    Christopher

  3. #53
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Trent Reimer
    This sounds like a minor detail but it is important. "mice" is the plural of "mouse", "moose" is both singular AND plural, etc. By the time you have rules in place to handle the entire english language you have to think about the guy who wants to set up database objects in french If you get around that hurdle it means you're wasting computing resources on stuff that really is distracting from the job at hand. Often the simple way is the right way.
    I'm not a native english speaker, yet all my code (and even comments) are in english. Except for the french, this seems to be a common convention.
    Actually it's not that complicated to pluralize english words. I don't remember where, but I saw an algoritm recently, which did it quite effectively.

  4. #54
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jayboots
    This is not exceptional logic, it is application logic.
    Application logic can be, and often is, exceptional.

    Quote Originally Posted by jayboots
    If I want to conditionally show b if a is not available, I should test for a (file_exists) and then try to show b if it is not available. Catching a FILE_NOT_EXISTS represents something else: I *expected* that the file *ought* exist, but it did not.
    If you expect that the file exists, and it doesn't, that's an exception to the rule.

    But we can argue over semantics all day long. Essentially there is no difference between using exceptions and conditional logic, except that exceptions often provide more information. Also, exceptions are object oriented, while conditional logic tends to be procedural.

    To each what suits them best.

  5. #55
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    Toronto
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    Application logic can be, and often is, exceptional.

    If you expect that the file exists, and it doesn't, that's an exception to the rule.

    But we can argue over semantics all day long. Essentially there is no difference between using exceptions and conditional logic, except that exceptions often provide more information. Also, exceptions are object oriented, while conditional logic tends to be procedural.
    I fundamentally disagree. An exceptional error condition is when I expect the file to exist (I tested for its existance) but when I try to read it, for some reason it did not actually exist. Application logic is never "exceptional" in the meaning that try/catch uses "exceptional". In other words, try/catch is not meant to (and ought not be used to) determine valid application states. This is not semantics and there is a huge difference between the two. If you mix application logic into your error handling you are asking for big trouble.

  6. #56
    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
    By this logic we should ignore the opinions of the "majority of advanced PHP developers"
    I think it's a rather bold jump to conclusions to infer that either mine or Berislav's opinion imply just what you said. To add to the confusion, you selectively quote from both his and my post and "frankenstein" an opinion that, quite frankly, neither he nor I have expressed.

    Quote Originally Posted by arborint
    I think if there is and "identity crisis", it is about which direction makes "PHP more like PHP".
    I believe there is an identity crisis within PHP, and I believe that this thread was started partly because of that. You may not agree with this opinion, and I respect that, but I am not the only one that is seeing the consequences of this identity crisis. For one, as it was mentioned by someone else before, it may not make much sense for everyone to have interfaces and type hinting in PHP, yet the main reason those features were added to the language is probably because of Java. I suppose that at the very least we can agree that PHP is following more and more in the footsteps of Java as it grows up. What we probably disagree on is whether this is a good or a bad thing.
    Garcia

  7. #57
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ghurtado
    I believe there is an identity crisis within PHP, and I believe that this thread was started partly because of that. You may not agree with this opinion, and I respect that, but I am not the only one that is seeing the consequences of this identity crisis.
    This thread was started because of lack of standards I think. If PHP has an identity crisis is is because it is an programming system for amateurs that can now be used by professionals. Those two groups obviously have different skills and needs.
    Quote Originally Posted by ghurtado
    For one, as it was mentioned by someone else before, it may not make much sense for everyone to have interfaces and type hinting in PHP, yet the main reason those features were added to the language is probably because of Java.
    I think they were added because they can be useful. Certainly Java was not the first language with typed parameters.
    Quote Originally Posted by ghurtado
    I suppose that at the very least we can agree that PHP is following more and more in the footsteps of Java as it grows up. What we probably disagree on is whether this is a good or a bad thing.
    I wish it would follow someone with a clue. From mixins to AOP to persistence to DI etc etc etc, there are so many powerful things that other languages provide that we see programmers here struggle just to get a half-baked prototype of in PHP. There is a reason why there aren't good versions of things like Hibernate or Rails in PHP -- it's because PHP does not provide support for building cutting edge stuff. I'd say it's less of an identity crisis and more of a capability crisis.
    Christopher

  8. #58
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Selkirk
    Isn't it ironic that PHP adds static typing features to PHP 5 in order to lure java developers just at the same time that more and more java developers are deciding they aren't that thrilled with static typing after all.
    That's exactly the problem with overzealous language designers. Just like PHP doesn't need interfaces and type hinting, Java never really needed strongly typed variables. They put it there probably just to lure C++ folk over... And it could have been such a great dynamic language.

  9. #59
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    There is a reason why there aren't good versions of things like Hibernate or Rails in PHP -- it's because PHP does not provide support for building cutting edge stuff.
    Oh, come on!

    What in PHP prevents it from using e.g. Rails ideas? Everything I saw in Rails can be recreated using PHP. And for Hibernate, it probably makes no sense to port it, as it follows the Java philosophy which isn't really appropriate for PHP.

    The reason why is there no such things in PHP is because PHP has a much different learning curve and overall approach than either Java or Ruby. In PHP, you actually need to learn very little in order to make workable Web sites/applications; in those two, you have to know the language very well before you can write for Web.

  10. #60
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    Oh, come on!

    What in PHP prevents it from using e.g. Rails ideas? Everything I saw in Rails can be recreated using PHP.
    Given how hot Rails is someone should have whipped up a better clone in PHP, but you really can't without mixins and the capabilty to create a real ActiveRecord. It just can't be done in PHP.
    Quote Originally Posted by BerislavLopac
    And for Hibernate, it probably makes no sense to port it, as it follows the Java philosophy which isn't really appropriate for PHP.
    Maybe appropriate, maybe not. How would we know because again you can't build it in PHP.

    Quote Originally Posted by BerislavLopac
    The reason why is there no such things in PHP is because PHP has a much different learning curve and overall approach than either Java or Ruby.
    I think you are mixing learning curve, overall approach and capabilies. Java itself is not difficult to learn -- it's class libraries are huge. Ruby does not seem more difficult that PHP to learn.
    Quote Originally Posted by BerislavLopac
    In PHP, you actually need to learn very little in order to make workable Web sites/applications; in those two, you have to know the language very well before you can write for Web.
    I would agree that you need to learn very little in order to make workable SMALL Web sites/applications. That is obviously PHP's strength. But as the size and complexity increases it is difficult to implement those things that decrease the amount and complexity of application code.
    Christopher

  11. #61
    SitePoint Guru thr's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    664
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whoa, the argueing gets intense while I'm a sleep... While I agree with pretty much of all of you, in the same time(yes). I think we've gone a bit off-topic? Sure the Exception vs. If-Else thing can be argued untill the end of time... but will it get us a decent framework? Nope. The 404 vs. (Insert Random)-approach can also be argued for ever... and it won't get us anywhere.

    But one argument I agree heavliy on and want to put down my POV on, is the fact that PHP is in an identity chrisis - or atleast for us. I've migrated here to sitepoint.com's forum from a smaller swedish swedish forum, and you can't even compare the skill level of the scripters(I would not even call them programmers, as most of them lack any "real" software egineering skill) to the people on this forum. And I think it's here the real identity chrisis lies... that we have two so different usersbases that it's close to impossible to get them to co-operate or use the same standards. So we, in the more advanced community, basicly have two choices... unite and build something that works, or we can standard aside and watch php miss it's chance to grab the top spot of web-application-development-languages.


    Another thing I have on my mind is the fact how WACT, Mojavi, PHP-MVC, is built up. They have already made so many design-critical desisions for the developer/user of the framework that if he don't like them there's no way to "
    still use WACT but don't use *that* part he doesnt like. The same goes for Mojavi and all the others. If you look at for example ASP.NET and Rails they have made *some* desicions that effect the design of your application but not even close as many as WACT and Mojavi have done. If you work with WACT and don't follow 100% WACT... basicly, your ****ed. With ASP.NET you can choose to use thier type of approach, but you can also ditch it and go on and use parts of thier(MS) and parts of your own home-grown style.


    If we ever get out of argueing and discussing code instead, I think the main focus we should try to stay on building such a basic framework that it can be applied to almost any case. And you could pick parts from it that you *realy* want, and ditch the rest. Or you could choose to build your application completly in the framework. While the Logger/Log classes/interfaces probably was a bit to hasty, I think we'd need to discuss more code and how we should approach this problem directly - and not so much theory argueing over little bits and bytes.

    For example, if we choose to build some type of MVC-implementation we could provide code/classes for the Controllers(Front/Application), Filters(Intercepting,tec.), Commands(aka. Actions) and Request/Response. These should be intermediatly(spelling?) coupled to eachother. As the command, controlers, filters and requests/reponse don't have anything to do with the View or the Model we could provide a view and model code-base that the user could use if they wanted to. But if the wanted to use thier own home grown, or smarty or whatever you could possibly imagine for either model or view... that should be possible.

    What do you say?

  12. #62
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello everyone,

    Well, following this thread as well as the "Proposal for Standards..." thread has taught me a few things. Firstly, and most obviously, that it is almost impossible, among a group of professionals to come to a single common conclusion regarding much of any topic. Secondly, it has taught me that the least intrusive solution, in many situations, is the best solution. Third it has taught me that, in a number of other situations, a nicely bundled and ready to go "just work" box of application code will do just fine. Knowing what to do when is what seperates a "good" developer from a "bad" developer.

    Secondly, in response to the post prior to this (by thr), almost any application is designed to fix a series of functional specifications. Meaning it's supposed to do something within a reasonable pattern, such that users can, at least more easily, grasp the algorithm of the system and thus leverage it without a tremendous amount of brain power on every turn. So yes, I argue that, in the case of a framework, a "way" is a good thing -- but not always, and furthermore, should not be set in stone. Not by the framework code, and not by the developers of that framework.

    Having said that, I'd like to do a shameless plug. I've just begun Mojavi 4 development. It's a complete rewrite, and is pretty ambitious. However, unlike many existing frameworks, it's not being written in a "here's the end all solution" manner. The "philosophy" behind the design is much less of "framework" but of a "canvas". With the prototype code I've written thusfar, for example, it's possible to completely change the framework execution simply by messing with configurations and changing classes around. Right now everything is liquid, and it's unusable in any real sense, but that's where it should be. Right now it's a loose canvas, and I'm massaging it this way and that. I've posted for help already on my forums, and have a few responses, but more would certainly be useful. I don't want this post of mine to be a "you guys are looking for a place to put all your creative framework-design energies, why not put them here?" but it may very well be. If I feel it's worth it, I'll post an official "Mojavi 4 Development" thread on this forum, but I'm not sure it is. Sometimes it's better have a focused group of developers who have a shared vision. Having dividers on a team is not the solution, that only leads to a fork and drag on the moral and spirit of the team. I will largely ignore, at least at this moment, that dividers are often times useful people, because they weed out bad ideas, but none-the-less, I hold my opinion regard that "type" of team-developer strongly. The last and final thing I'll mention that I've learned from reading the threads mentioned above is just that -- dividers, while serving a purpose, often times are a greater liability to a project than they are an asset.

    For those of you that are interested in Mojavi 4, check out my announcement page on the Mojavi forums at http://forum.mojavi.org/index.php?showtopic=1330

    Regards,

  13. #63
    SitePoint Guru thr's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    664
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    illusina: Hmm.. interesting proposal. Do you have any documents,UMLs,etc. over how you're looking to shape m4?

  14. #64
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thr,

    Yes, though many of the diagrams have changed a tad since I made them a month or so ago, so you'll have to excuse minor fluctuations. The diagrams were initially to be Mojavi 3.1.0, but when the previous project leader handed the project over to me, I decided to break with the m3 completely.

    UML Diagrams can be found at http://forum.mojavi.org/index.php?sh...36&st=0&p=6534 (thread information at http://forum.mojavi.org/index.php?showtopic=1235)
    Mojavi Trac (where I write my research ideas) can be found at http://trac.mojavi.org/ (and http://trac.mojavi.org/wiki/ResearchAndDevelopmentIndex)

    Note that, like I was saying, some of the diagrams/ideas are stale and have been udpated since I made the diagrams, which I will eventually go about documenting. If you look around the forums there are a number of Mojavi 4 related threads that might be of interest -- ranging from usage of DI in the framework to configuration file formats and what-not.

    Regards,

  15. #65
    SitePoint Guru thr's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    664
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi.

    (This is off-topic, yes.)
    Well, considering your ideas and after reading the UML diagrams(that I found on mojavi.org a couple of hours ago) - I'd say that I'm very interested in working on it. I started this thread for something like this to come up. Being able to work on m4 with the codebase of m3 plus an already known name would be a tremendous resource.

    Is there anyway I could contact you on any IM client(preferably MSN) ? Or over mail/irc? I think it's more appropiate to have this kind of discussion on some type of IM-media.

    Regards, Fredrik.

  16. #66
    SitePoint Guru thr's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    664
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To get more ontopic, I'd just like to point out that my current pov is this: http://www.sitepoint.com/forums/show...6&postcount=61 , which I'd love some comments on from the other active people in this thread?

  17. #67
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Location
    Santa Rosa, CA
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "It's not possible to write a real ActiveRecord in PHP."

    Sigh...I and many other people have already done this. Maybe it'd be pretty hard in PHP 4, but in PHP 5 it works fine.

    Check out CakePHP some time...it's shaping up to be a pretty good framework in the Rails style. Several other frameworks have ActiveRecord-style ORM classes. Stop spreading the FUD, OK?

    Jared

  18. #68
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What might be of relevance here is that Mojavi 4 is in the works. Considering the fact that the framework is in pre-beta-stage, would this perhaps present us with a chance to get a real de facto standard thing going?

    I actually had a moment of deja vu reading through illusina's code -- it's like he was reading our Application Controller thread for reference and mixed'n'matched with Mojavi stuff. See this tiny clip, for instance:
    PHP Code:
    interface Controller
    {

    public function 
    execute(Context $context);


    Now, have I not seen that somewhere else? Well, the guy seems to be a really able designer and I'm liking the looks of it thus far.

    Edit:

    Ha! I was right: here are both the skeleton and application controller threads listed below the heading "Inspirational Texts". No wonder I occasionally felt like I was looking at my own code. :P

  19. #69
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ezku,

    Firstly, thanks for the comments.

    Yep -- I've read many a theory thread on sitepoint before I began to layout Mojavi 3.1.0 (what Mojavi 4 was called). Probably the most considerable thread, as far as really jolting me into thinking was the skeleton thread, and the code that came from it. I think it would be in order, in the credits, to credit the authors of those threads and their respective code.

    I spoke with thr today, and he seems really interested in the helping out with the project -- though I don't know to what extent. At this very moment I have 2-4 people prepared to begin working on it (depending on how you look at it), either on theoretical usage examples (e.g. http://forum.mojavi.org/index.php?sh...1335&hl=reader), or just thinking about current design issues (e.g. http://forum.mojavi.org/index.php?sh...1328&hl=reader). However, there is much work to be done, and this week, unfortunately, I have quite a bit of school work. By Friday, however, I'll have a _little_ freetime with which to look at writing some preliminary code for, perhaps, the Action/View layers. Any feedback is welcome, and I'd like to have anyone else who's interested on board.

    Regards,

  20. #70
    SitePoint Guru thr's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    664
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by illusina
    I spoke with thr today, and he seems really interested in the helping out with the project -- though I don't know to what extent.
    Yeah, I gotta say
    I'm realy interested, and as Ezku says the good thing is that it's in it's pre-beta-stage which would allow us(you,me,everyone) to get some type of de-facto standard going. And the good thing with doing it under such a name as Mojavi is that you already have a userbase, etc.

    So yes, I'm very thrilled about this. I'm going to look at your UMLs more indepth today and read all the posts about m4 over at the Mojavi forums/RaD-sites. As I have pretty much spare time atm. (I've got university classes yes, but no hard subjects) I'm interested in just about everything from design, to code, testing, etc. Need something to do while I'm home all day .

    Illusina, I read the thread bout the Datareaders, and I actually have some old php5-beta code lying around from when I was messing with SPL. It's built ontop of SPL(which imho is something realy sweat) which takes any type of SPLReader(i think) and converts it into an DOMXML Heriarchy. Quite like the FileReader/Tokenizer example. (Just gotta get the code from an old server that's offline atm).

    Edit: Another crucial point imho. is configuration files. Everyone hate them, and it is possible to go (almost) without them (not completly w/o them, but the amount that mojavi2-3 has atm. is just insane imho.).

    Edit #2: To comment on Mojavi 4 directly, or well - your UML diagrams. While they look incredibly well thought out there's one (of possibly many things) thing that bugs me, let me point it out: http://www.javiwerks.com/images/moja...datasource.JPG This is the diargram over the datasource, and if you look at IDataSource, FilesystemDatasource and (one of the database) MySqlDatabaseSource - in code they would look something like this:

    PHP Code:
    <?php
    interface IDataSource
    {
        
    /*
            Shouldn't the "protected $resource"-field from 
            DatabaseDatasource be here? As all DataSources must
            have a resource to get data from?
        */
        
    public function connect();
        public function 
    disconnec();
        public function 
    getResource();
        public function 
    initialize($var);
    }
    class 
    FilesystemDatasource implements IDataSource
    {
        
    /*
         Implemented methods from the IDataSource
        */
    }
    abstract class 
    DatabaseDatasource implements IDataSource
    {
        protected 
    $resource null;
        protected 
    $connect null;
        public function 
    getConnect(); /* Should be implemented, ofcoure */
        /*
         Implemented methods from the IDataSource
        */
    }
    class 
    MySQLDatabaseDatasource extends DatabaseDatasouce
    {
        
    /*
         Implemented methods from the IDataSource and DatabaseDatasource
        */
    }
    ?>
    Now the problem I see here is first the nameing of the IDataSource::connect()-method, while yes - you connect to database you do *not* connect to files. Example:

    PHP Code:
    <?php
    $file 
    = new FilesystemReader('file.txt');
    $file->connect(); // This just looks wrong to me.
    ?>
    Imho, disconnect/connect should be called close/open instead. As you can *open* a connection to a database.


    Another thing is the DatabaseDatasource::$resource-field, which I just think you missplaced as the IDataSource has a getResource() but no $resource? I for one belive that all DataSources must have a resource to get that data from?

    One more thing is the whole initialize-method, what is it used for? As you already have connect(or as I would like to call it, open).
    Last edited by thr; Oct 12, 2005 at 21:44.

  21. #71
    SitePoint Guru thr's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    664
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One more thing, about the datastructure::Chain and datastructure::Stack. About the datastructure::Chain dont you think there should be an interface called something like Chainable?

    About the datastructure::Stack, well - I guess this is mostly personal perference but the nameing of addEntry should imho be push, and getLastEntry should be pop and getSize should either be size or count. And from a stack you should not be able to remove elements w/o poping them or getting the whole array of ellements back, as this is not a stacks purpose, and if you need that functionallty just use an Array/Hashmap. So imho, a stack should look like this:

    PHP Code:
    <?php
    class Stack
    {
        
        protected 
    $stack;
        
        public function 
    __construct($values=null)
        {
            
    $this->stack = array();
            if(
    is_array($values)){
                
    $this->stack $values;
            }else{
                
    $this->push($values);
            }
        }
        
        public function 
    push($value)
        {
            
    // Same as array_push($this->stack,$value);
            
    $this->stack[] = $value;
        }
        
        public function 
    pop()
        {
            return 
    array_pop($this->stack);
        }
        
        public function 
    size()
        {
            return 
    count($this->stack);
        }
        
    }
    ?>

  22. #72
    SitePoint Guru thr's Avatar
    Join Date
    Jun 2003
    Location
    Sweden
    Posts
    664
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a rundown of what my XMLIterator/Reader did:

    Basicly, it took any type of iterator or reader(not sure about the reader part, have not worked with the source in about 8months or so) in a manner like this:


    PHP Code:
    <?php
    $xmlIt
    = new XMLRecursiveIteratorIterator(new RecursiveDirectoryITerator);
    while(
    $xmlIt= ->hasNext())
    {

        for(
    $i=0;$i<$xmlIt->depth();$i++){
            echo 
    "\t"// just to get some identation
        
    }
        if(
    $this->isNode()){
            
    // If we got a node, in this case a node == directory, cos we are reading a directory.
        
    }
        if(
    $this->isElement()){
            
    // If we got a file
        
    }

    }
    ?>
    And you could then out of this create an XML heriarchy out of any class that implemented the SPL::Iterator interface.

  23. #73
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by thr

    Illusina, I read the thread bout the Datareaders, and I actually have some old php5-beta code lying around from when I was messing with SPL. It's built ontop of SPL(which imho is something realy sweat) which takes any type of SPLReader(i think) and converts it into an DOMXML Heriarchy. Quite like the FileReader/Tokenizer example. (Just gotta get the code from an old server that's offline atm).

    Edit: Another crucial point imho. is configuration files. Everyone hate them, and it is possible to go (almost) without them (not completly w/o them, but the amount that mojavi2-3 has atm. is just insane imho.).

    Edit #2: To comment on Mojavi 4 directly, or well - your UML diagrams. While they look incredibly well thought out there's one (of possibly many things) thing that bugs me, let me point it out: http://www.javiwerks.com/images/moja...datasource.JPG This is the diargram over the datasource, and if you look at IDataSource, FilesystemDatasource and (one of the database) MySqlDatabaseSource - in code they would look something like this:

    ......

    PHP Code:
    <?php
      $file 
    = new FilesystemReader('file.txt');
      
    $file->connect(); // This just looks wrong to me.
      
    ?>
    Imho, disconnect/connect should be called close/open instead. As you can *open* a connection to a database.


    Another thing is the DatabaseDatasource::$resource-field, which I just think you missplaced as the IDataSource has a getResource() but no $resource? I for one belive that all DataSources must have a resource to get that data from?

    One more thing is the whole initialize-method, what is it used for? As you already have connect(or as I would like to call it, open).
    thr,

    Wow, lots of stuff to comment on.

    Ok, addressing the Datasource:

    I agree with you on this one, the words used with regards to something like a FilesystemDatasource just sound clunky. However, on that now, I'm still considering whether it's really worth it to factor files into the Datasource layer or not. This is definately something I need to think about, however, I think that the method renamings connect() -> open() are reasonable either way.

    As for comments regarding the SPLReader -- I'm interested, but I don't know how heavy said format is, and how much runtime cost it will cause. This is something I'd like to see a diagram or some proof of concept code for before accepting/declining.

    Regarding confiration files -- Configuration files are tricky creatures. People want them, people hate them, people disagree about the standards, people want them more flexible, and people want them simple all at the same time. So, here's my thoughts on configuration files: The plan for m4 was to use Xml configuration files soley, with heavy caching. Almost all of Mojavi 3's ini configuration files are being consolidated into settings.xml, which will be cached as, basically, a series of nested containers. However, at this moment configurations are nothing something I'm thinking about. At least, configurations that are in a format other than php. Something I've learned about trying to start writing a framework is that leaving configuration 'til the end is a great idea due to 1) added flexibility/agility when you really need it. There's no sense in having a configuration compile class that you're going to have to change 20 times at this stage in the game when you can just use a more ad-hoc proof-of-concept type php-configuration.

    And lastly the $resource field in the interface. Well, I would have added this, but I'm under the impression that PHP5 doesn't allow member variables in interfaces . If I'm wrong, please correct me, and a few diagrams will be updated accordingly.

    Regards,

  24. #74
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by thr
    One more thing, about the datastructure::Chain and datastructure::Stack. About the datastructure::Chain dont you think there should be an interface called something like Chainable?
    thr,

    Yes, in fact I think there should be a Stack class. That's why I added it about 3 days ago , though I don't have the exact same interface as you. Here's the current class:

    PHP Code:
    <?php

    class Stack 
    {

        protected
            
    $stack = array();

        public function 
    push(&$el)
        {
        
            
    $retval array_push($this->stack$el);
            
            return 
    $retval;
            
        }
        
        public function & 
    pop()
        {
            
            
    $retval array_pop($this->stack);
            
            return 
    $retval;
            
        }
        
    }
    ?>
    As far as Chainable is concerned -- yes, I'd like to have this, but I don't know if it's reasonable and/or possible to do on a generic chainable interface. This is because, as far as I can tell, the Chain datastructure interfers that it has a pointer of some sort to the next link in the chain, while requires a dependency on a link in the chain. Well, I may have just solved my problem, how does the following sound?

    PHP Code:
    <?php

    class Chainable
    {

        public function 
    execute(Chainable $link)
        {
        
            
    // ........
        
        
    }

    }

    ?>
    This is definately an area to investigate.

    I've been discussing this issue with thr, and it appears we're going to have something like Chain and Chainable. Chain to handle firing the Chain, and the Chainables to be part of the Chain.

    Regards,

  25. #75
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by thr
    Just a rundown of what my XMLIterator/Reader did:

    Basicly, it took any type of iterator or reader(not sure about the reader part, have not worked with the source in about 8months or so) in a manner like this:


    PHP Code:
    <?php
     $xmlIt
    = new XMLRecursiveIteratorIterator(new RecursiveDirectoryITerator);
     while(
    $xmlIt= ->hasNext())
     {
     
         for(
    $i=0;$i<$xmlIt->depth();$i++){
             echo 
    "\t"// just to get some identation
         
    }
         if(
    $this->isNode()){
             
    // If we got a node, in this case a node == directory, cos we are reading a directory.
         
    }
         if(
    $this->isElement()){
             
    // If we got a file
         
    }
     
     }
     
    ?>
    And you could then out of this create an XML heriarchy out of any class that implemented the SPL::Iterator interface.
    thr,

    Looks interesting, though perhaps unnecessary? From what I can see, each class that wants to do be usable needs to be implementing not only the Iterator, but also RecursiveIterator. Is this really required? I'm not sure. I have been making pretty extensive use of (as relative to my other projects at least) the SPL recently and I find a number of things that it does very useful. An example of this is it's decoration capabilities with Iterators, which is being used in multiples places thusfar in m4. However, implementing those two interfaces for traversing the configuration tree may work. I think we're on the same line of thought, as I posted this earlier: http://forum.mojavi.org/index.php?sh...indpost&p=7086

    Thoughts?

    Regards,


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
  •