Jump to content
Larry Ullman's Book Forums

JohnD

Members
  • Posts

    21
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by JohnD

  1. Larry,

     

    In ch 7 Design Patterns I am a little uncertain how to fit the UML diagram on p234 to the Strategy example. I realize that it is a generic conceptual model. I think the Context box could represent the intereface iSort, the Strategy box could represent Both Class MultiAlphaSort {} and Class MultiNumericSort {} and the ConcreteStrategyA{} ... C{} would be represented by Class StudentList{}, if fitted to the Strategy pattern example on pages 235 to 240. Is this correct?

     

    I do understand the implementation of the Strategy Pattern example. The reason I am bothering with the UML diagram here is that these diagrams have helped me a great deal when included with the oop chapters.

     

    Also, a slightly unrelated comment. If you ever decide to write the fourth edition of this book (which I would buy in a heart beat), I think it would be enhanced by an Appendix devoted to a listing of all the UML syntax. Of course keep the in-context examples of UML as well.

     

    Thanks,

    JohnD.

  2. This question regards application design and does not have a source code component.

     

    Is it common practice, or good practice, to use an abstract class and and multiple interfaces (small i) together in the same application? Consider the example of an abstract class automobile. This general class would enforce the "is a" constraints of all automobile types. Several different interface(s) would be defined and applied to the subclasses of automobile based on the type of automobile being defined.

     

    Does this seem reasonable? Or does defining an abstract class and multiple interfaces seem like over-kill?

  3. I just wanted to put this out there in case anyone is having similiar problems with XDebug running in Netbeans 8. When I was stepping through the code in register.php Netbeans running XDebug debugger was reporting a 'value not available' or some similiar message on the form validation pass, line 98, [First Name].

     

    When I chose Run File from Netbeans (without the debugger) everything worked fine. This appears to be a case of XDebug acting buggy. I was running it with the Debugger to resolve file locations, db name, passwords, etc., just to get the script working. Hope this saves someone some time.

  4. I was curious what instanceof would return here. It's strange because I can't do a print_r() or a var_dump() of $TEST. Also, I thought the whole point of the example was that in the "Singleton pattern is a creational pattern pattern that will restrict an application to creating only a single instance of a particular class type." (p216) I'm just trying to make sense of the models and see if there are cases where the php's behavior is counter-intuitive.

  5. When I user the instanceof keyword for the Singleton class in Ch07 page 218, it is returning true. See below.

    // Create a second object to confirm:
    $TEST = Config::getInstance();
    
    // see what instanceof thinks...
    if ($TEST instanceof Config) {
        echo '<pre>$TEST IS instance of Config</p>';
    }
    else
    {
        echo '<pre>$TEST IS NOT instance of Config</p>';
    }
    
    

    It is echoing that $TEST IS instance of Config. Am I doing something wrong?

  6. I think your code is ok. I believe you are stuck on a functional issue. When you click on the Logout link your session data (displayed on the screen) is deleted from the database - session destroyed. You need to close your browser without Logging out - session will still be active...in the database because you didn't Logout. Then run sessions.php script. You'll see 'sessions exists' because you didn't formally logout. I apologize if I'm telling you what you know already. I had to run the script a few times before I figured it out.  :lol:

    • Upvote 1
×
×
  • Create New...