SitePoint Sponsor

User Tag List

Page 7 of 10 FirstFirst ... 345678910 LastLast
Results 151 to 175 of 230
  1. #151
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nacho
    However, take an application controller, or an error handler, for example. How many instances would you think you need, despite of the application getting larger? I can only see the need for one of them.
    You may only see the need for one of them, but you can still program as if you might may eventually need more than one of them. The cost of doing so is minor compared to the cost of having to reprogram chunks of your application when it turns out you were wrong.

  2. #152
    SitePoint Wizard Ren's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    1,060
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nacho
    Mmmm, I have to say I didn't expect that one coming from you
    So you mean you have two instances of your error handler running at the same time ... for development and production?
    I'm developing an idea atm, where both error handers, development and production, will be used on the same site at the same time, but for different groups of people.

  3. #153
    SitePoint Enthusiast Silverhawk's Avatar
    Join Date
    Sep 2003
    Location
    Malaysia
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    Yes and yes. Although PHP4 is really quirky when it comes to objects.
    How is it quirky? What are the things i should look out for when attempting to go OOP in PHP4?

    Quote Originally Posted by kyberfabrikken
    Actually that would be $http->GET['offset'] or simply $http['offset'] because of SPL's ArrayAccess interface. The reason - as already discussed - is to put the variables in a scope.
    Besides being a proper design, what benefits do we get by doing this?

  4. #154
    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 Silverhawk
    How is it quirky? What are the things i should look out for when attempting to go OOP in PHP4?
    In particular PHP4 implicitly clones objects on assignment. To avoid this, you need to pass by reference. It can be quite a nightmare to debug. Besides, this means that functions which takes an object as argument or return an object, must do so by reference. Since PHP4.4 this implies that you need to create a temp variable when returning an object.

    PHP5 also introduce a lot of constructs inspired by java. Most of them aren't strictly needed, but are just nice to have. Especially if you know OO from a java background.
    Quote Originally Posted by Silverhawk
    Besides being a proper design, what benefits do we get by doing this?
    Avoiding globals is a bit like signing an insurance. It won't make much difference here and now, but when it does, you'll be in trouble if you didn't do the right thing.
    Wrapping the superglobals in an object means that they won't get polluted by misbehaving code, and it means that if your code misbehaves, it won't affect other applications. It's about isolating things as much as possible, which makes it easier to debug you code.
    If you use unit testing, it's a lot easier to create a new http-request wrapper than accessing the superglobals.

  5. #155
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    You may only see the need for one of them, but you can still program as if you might may eventually need more than one of them. The cost of doing so is minor compared to the cost of having to reprogram chunks of your application when it turns out you were wrong.
    I still fail to see how would I need more than one instance of my application since that would mean two applications, but maybe you could give an example of what you have in mind. Furthermore, it's not only I would be using just one instance of the application controller, I would want to make sure there is only one.
    There’s more than one way to skin a cat.

  6. #156
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ren
    I'm developing an idea atm, where both error handers, development and production, will be used on the same site at the same time, but for different groups of people.
    Ok, I see more or less what you mean, but wouldn't that make two different objects instead of two instances of the same object? Of course I don't know what you have in mind exactly, but I'm guessing you would decorate one of them to obtain the other one, or would have one derivating from the other one or would use a factory to create both ...

    Could you maybe explain how would you exactly implement those error handlers in order to have to deal with two instances instead of two different objects? Wouldn't that violate the principle of single responsability?
    There’s more than one way to skin a cat.

  7. #157
    Non-Member
    Join Date
    Apr 2006
    Posts
    337
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You must be a very good coder to call phpBB crap. I looked at their code and it did not look crap to me.
    Maybe you have too high of a standard.

  8. #158
    SitePoint Wizard Ren's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    1,060
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nacho
    Ok, I see more or less what you mean, but wouldn't that make two different objects instead of two instances of the same object? Of course I don't know what you have in mind exactly, but I'm guessing you would decorate one of them to obtain the other one, or would have one derivating from the other one or would use a factory to create both ...

    Could you maybe explain how would you exactly implement those error handlers in order to have to deal with two instances instead of two different objects? Wouldn't that violate the principle of single responsability?
    Using an error handling class, you can chain them together, as set_error_handler() returns the previously installed handler (which can be called with call_user_func()), so if the current error handling class does not know how to deal with the error, it can be handed to the next error handler. CoR style.

  9. #159
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ren
    Using an error handling class, you can chain them together, as set_error_handler() returns the previously installed handler (which can be called with call_user_func()), so if the current error handling class does not know how to deal with the error, it can be handed to the next error handler. CoR style.
    I must admit I would have never come up with such an idea. Furthermore, I fail to see the need of such a complex setup and the possible advantages of it, although that doesn't mean anything of course.
    Would you care to explain what the background of that situation is? What do you try to achieve by having two different error handlers implementing different behaviours?

    EDIT.- What I do see is that you're actually changing the "singleton" of your error handler with a "singleton" of your error handling class or would you also expect to have two different instances of your error handler class?
    There’s more than one way to skin a cat.

  10. #160
    SitePoint Wizard Ren's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    1,060
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nacho
    I must admit I would have never come up with such an idea. Furthermore, I fail to see the need of such a complex setup and the possible advantages of it, although that doesn't mean anything of course.
    Would you care to explain what the background of that situation is? What do you try to achieve by having two different error handlers implementing different behaviours?
    Well I have what would be a normal style error handler. Now if a developer logs into the application an additional error handler is installed to listen in and provide http://www.sitepoint.com/blogs/2006/...y-blue-screen/ style error page.

    Other uses I've had is to capture <xsl:message /> warnings from XSL Transforms, and perform different processing on.

  11. #161
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ren
    Well I have what would be a normal style error handler. Now if a developer logs into the application an additional error handler is installed to listen in and provide http://www.sitepoint.com/blogs/2006/...y-blue-screen/ style error page.

    Other uses I've had is to capture <xsl:message /> warnings from XSL Transforms, and perform different processing on.
    Interesting. Didn't know the article, thanks for the reference. I'll give it a thought.
    Is it all about styling the exceptions then? (Plus the additional info provided to developers I mean). The thing is I implement it somehow different but the result is kind of the same. My error handler is common and independent of the role of the active account, but it loads error messages which depend upon that role, so some would contain more info than others.
    There’s more than one way to skin a cat.

  12. #162
    SitePoint Wizard Ren's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    1,060
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nacho
    Interesting. Didn't know the article, thanks for the reference. I'll give it a thought.
    Is it all about styling the exceptions then? (Plus the additional info provided to developers I mean). The thing is I implement it somehow different but the result is kind of the same. My error handler is common and independent of the role of the active account, but it loads error messages which depend upon that role, so some would contain more info than others.
    Essentially yes. Not sure there is much else you can do with alot of errors.

    In PHP4 had a error handler which reports errors over jabber, so can see them realtime with a IM client, without messing too much with logs, or screwing about with the layout.

  13. #163
    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 nacho
    Ok, I see more or less what you mean, but wouldn't that make two different objects instead of two instances of the same object?
    It seems you're confusing classes with objects.

    You don't have instances of objects -- you have instances of classes, which are objects. So two instances of a single class are "two different objects" of the same class -- just like you and I are two instances of the class HumanBeing (well, I can only assume for you... ).

    That's why checking for equality can be very complex. E.g. you can have two instances of the same class with exactly same attribute values -- i.e. the same state -- but they would still be different objects. Or you can have two different variables that point to a single object, which is a completely different thing.

  14. #164
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nacho
    I still fail to see how would I need more than one instance of my application since that would mean two applications, but maybe you could give an example of what you have in mind. Furthermore, it's not only I would be using just one instance of the application controller, I would want to make sure there is only one.
    I can think of a big one; testing. Testing is, in fact, a very good reason never to use singletons or global vars. In any case, the point I was trying to make is that all interactions between objects should take place via their interfaces, which is the net result of never assuming you will only every need one instance of an object.

  15. #165
    SitePoint Guru Majglow's Avatar
    Join Date
    Aug 1999
    Location
    B-Town
    Posts
    645
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I noticed the good words about vanilla and decided to check it out. Now, I'm no database expert, so somebody correct me if I'm wrong, however as I glanced around the code, I didn't see any indexes in the database besides the primary index and I noticed that the search was implented as:

    Code:
       function DefineSearch() {
          $this->GetPhrase();
          $this->BreakKeywords();
          $SearchFieldCount = count($this->SearchFields);
    		$KeywordCount = count($this->Keywords);
    		$CurrentKeyword = "";
    		$CurrentPhrase = 0;
    		$CurrentOperator = "";
    		
    		if ($KeywordCount > 0 && $SearchFieldCount > 0) {
    			if ($this->Wheres != "") $this->Wheres .= " and ";
    			$this->StartWhereGroup();
    			for ($i = 0; $i < $KeywordCount; $i++) {
    				$CurrentKeyword = $this->Keywords[$i]["Keyword"];
    				if ($CurrentKeyword == "[#phrase#]" && count($this->Phrases) > $CurrentPhrase) {
    					$CurrentKeyword = $this->Phrases[$CurrentPhrase];
    					$CurrentPhrase++;
    				}
    				for ($j = 0; $j < $SearchFieldCount; $j++) {
    					// Need to manipulate the operator to allow the different fields being searched to return results.
                   // So if this is the beginning of the search for this keyword, use the assigned operator, otherwise use "or".
    					$CurrentOperator = ($j == 0)?$this->Keywords[$i]["Operator"]:"or";
    					$this->AddWhere($this->SearchFields[$j], "%".$CurrentKeyword."%", "like", $CurrentOperator, "", "1", ($j == 0));
    				}
    				$this->EndWhereGroup();
    			}
    			$this->EndWhereGroup();
    		}
       }
    It seems to me that this software wouldn't be able to handle a community of any substantial size.
    Ohai!

  16. #166
    SitePoint Guru Majglow's Avatar
    Join Date
    Aug 1999
    Location
    B-Town
    Posts
    645
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ablaye
    You must be a very good coder to call phpBB crap. I looked at their code and it did not look crap to me.
    Maybe you have too high of a standard.
    I just downloaded phpBB2 since I was curious. I opened index.php and I loled.

    yep... it's quite horrible. Database calls, logic, HTML, hundreds of lines of nested if/elses, etc...
    Ohai!

  17. #167
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Location
    TechArena.IN
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    very interesting read..

  18. #168
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ren
    Essentially yes. Not sure there is much else you can do with alot of errors.

    In PHP4 had a error handler which reports errors over jabber, so can see them realtime with a IM client, without messing too much with logs, or screwing about with the layout.
    Ok. Thanks for explaining. I like also the idea of forwarding them to a IM client. Thought myself of SMS in case of critical applications, but never really got to build one of them
    There’s more than one way to skin a cat.

  19. #169
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    It seems you're confusing classes with objects.

    You don't have instances of objects -- you have instances of classes, which are objects. So two instances of a single class are "two different objects" of the same class -- just like you and I are two instances of the class HumanBeing (well, I can only assume for you... ).
    Yes Berislav, I'm a flesh and blood son of a ...

    I see you're still as picky, but nevertheless somehow right; although I'm not confusing, but rather not expressing myself properly. I wasn't for me a question of whether the objects where identical, but whether there was room to use a singleton or not (thus having two instances of the same class running at the same time).

    Thanks for explaining anyway
    There’s more than one way to skin a cat.

  20. #170
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    I can think of a big one; testing. Testing is, in fact, a very good reason never to use singletons or global vars. In any case, the point I was trying to make is that all interactions between objects should take place via their interfaces, which is the net result of never assuming you will only every need one instance of an object.
    Fair enough ... I don't do TDD ... Still it sounds to me kind of strange that because of testing a design pattern becomes somehow invalid ... it doesn't fit the bill, as far as I'm concern, but that would get us to yet a whole different discussion. I'll let it rest ... Enough OT
    There’s more than one way to skin a cat.

  21. #171
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You really think other enterprise software is better? have you seen some of that code?

  22. #172
    SitePoint Enthusiast Silverhawk's Avatar
    Join Date
    Sep 2003
    Location
    Malaysia
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    In particular PHP4 implicitly clones objects on assignment. To avoid this, you need to pass by reference. It can be quite a nightmare to debug. Besides, this means that functions which takes an object as argument or return an object, must do so by reference. Since PHP4.4 this implies that you need to create a temp variable when returning an object.
    If i understand OOP correctly, objects are considered unique so if a function needs to operate on an object it should be operating on that object. So naturally passing by reference makes sense and cloning does not. Am i getting this right?

    However i can't seem to figure out why a temp variable will be required when returning an object. If an object is already passed into the function by reference there is no need to return the object. If the object is created within the function wouldn't it only exist within the scope of the function? Cloning it then makes sense.

    I'm probably not understanding something :P So some examples would help

    Quote Originally Posted by ablaye
    You must be a very good coder to call phpBB crap. I looked at their code and it did not look crap to me.
    Maybe you have too high of a standard.
    Actually, it is pretty decent... just not as good as it can/should be. I can't say its absolutely horrible, but once you start learning more you start realising that the code isn't actually that good.'

    In PHP4 had a error handler which reports errors over jabber, so can see them realtime with a IM client, without messing too much with logs, or screwing about with the layout.
    It does!? Where/how can i implement this? I googled around and didn't quite find much info.

  23. #173
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ablaye
    You must be a very good coder to call phpBB crap. I looked at their code and it did not look crap to me.
    Maybe you have too high of a standard.
    Or perhaps you have a very low standard?

    Its terrible.

  24. #174
    SitePoint Member madt's Avatar
    Join Date
    Nov 2004
    Location
    South Africa
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Phorum?

    Has anyone tried http://www.phorum.org/?

    Doesn't look as neat as the other "more popular" forums, but it's easy to create your own templates.
    madt

  25. #175
    SitePoint Zealot Michel Merlin's Avatar
    Join Date
    Mar 2005
    Location
    Versailles (France)
    Posts
    169
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by agoossens
    However, I do recall Invision Power Board being a very nice piece of software.
    We must have not seen the same Invision... The one I saw was on InfoWorld Electronic forums, where Invision was just a catastrophic aggravation of an earlier catastrophe, which eventually brought those renamed IWE forums to collapse. Even among the fanatic crowds then phagocyting InfoWorld (some still living in IWeThey), there was not one to support Invision.

    Now this was around 1998-2000 (i.e. Middle-Age Internet), so Invision may have improved...

    Paris, Thu 11 May 2006 12:47:45 +0200, edited 12:54:40


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
  •