SitePoint Sponsor

User Tag List

Page 1 of 4 1234 LastLast
Results 1 to 25 of 86

Thread: UML, PhP 5, MVC

  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2004
    Location
    Fort Lauderdale
    Posts
    522
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    UML, PhP 5, MVC

    I am creating an "on line personal training" application in PhP5. I am currently looking into UML and drawing up use cases, activity diagrams, classes, sequence diagrams and component diagrams.

    I have never used UML before and object oriented development is somewhat new to me from the php 5 perspective. ( coded in Java before ).

    I would like to use Smarty as the template engine.

    I haven't decided which php patterns I should use, but I know for sure I would like to focus on MVC ( Model View Controler ) and separate my objects into components.

    I wanted to get an opinion about how effective UML design will be in developing an application in PHP 5.

    I am not aware of any forward engineering tools for php currently, so I know that my classes will not be able to be generated by "Poseidon Community Edition" for example.

    I am also using the GRAPPLE approach to application development. Please give me some suggestions and feedback on how I should effectively spend my time to prepare for the coding..

    Thanks

  2. #2
    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 photo312
    I am also using the GRAPPLE approach to application development. Please give me some suggestions and feedback on how I should effectively spend my time to prepare for the coding..

    Thanks
    Personally I think you are wasting a lot of time drawing up lots and lots of diagrammes. Break your project down, do some rough planning and start coding as soon as possible. Test, code, refactor. Don't decide from the beginning that you are going to use x, y and z pattern. Start writing code and some appropriate patterns should reveal themselves to you. If you have decided you want to take an MVC approach thats fine, but don't get too hung up about it at this stage.

  3. #3
    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 photo312
    I would like to use Smarty as the template engine.
    Don't.

  4. #4
    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)
    If UML is new to you, I don't think it will add any value, but simply be overhead for you. The power of UML is in communication - you could say that it's a formal language for describing software amongst professionals. If you don't know UML, and you're not going to work with somebody who do, the language will just be a hindrance. Compare it to two people trying to communicate in a language in which none of them are profecient.

  5. #5
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    Toronto
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    Actually, that argument is hardly convincing, especially if you have untrusted templates or want to provide your users with cleaner syntax, named parameters and other niceties. The reason that every framework worth its salt either incorporates a template engine or integrates with one is that PHP is not such a hot template language all on its own -- despite its history.

  6. #6
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IMO, template languages are useful, but smarty gives you way too much power.

  7. #7
    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
    The reason that every framework worth its salt either incorporates a template engine or integrates with one is that PHP is not such a hot template language all on its own -- despite its history.
    Actually, many of those template engines are based on PHP, just like the one in the linked article. I especially eschew Smarty, as nearly all of its features are already available in PHP, so that it seems silly to use an interpreted templating language based on another interpreted templated language.

  8. #8
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    Toronto
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac
    Actually, many of those template engines are based on PHP, just like the one in the linked article. I especially eschew Smarty, as nearly all of its features are already available in PHP, so that it seems silly to use an interpreted templating language based on another interpreted templated language.
    Hi. Yes, and many others are not. In fact, show me one decent template engine that is pure PHP (other than PHP itself). There isn't any -- they are just conventions and framework around PHP as a template language. If, as 33degrees suggests, Smarty has too much power then surely that must imply that PHP is even more unsuitable to the task. At least Smarty provides a means to control the features exposed in the template while at the same time presents thoughtful tools for developers and a clear syntax for designers. I understand that a certain group of people don't favour Smarty but I for one find articles like Brian's really miss the point of using a system like Smarty.

    BTW: Smarty is not interpreted -- it compiles to PHP.

  9. #9
    SitePoint Evangelist
    Join Date
    Mar 2004
    Location
    Fort Lauderdale
    Posts
    522
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have used Smarty Extensively and I like it. I also must disagree with some of the UML critics. Good programming comes out from good preparation and from a "Bird view" of the classes and their connections. How am I supposed to learn the "Decorator Pattern" or the "Factory Pattern" unless I see its interaction with classes from this "Bird View" analogy.

    I am going to be posting my questions relating to the class design next. I am indeed dissapointed by the UML critics. I trully am.

  10. #10
    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 photo312
    I have used Smarty Extensively and I like it. I also must disagree with some of the UML critics. Good programming comes out from good preparation and from a "Bird view" of the classes and their connections. How am I supposed to learn the "Decorator Pattern" or the "Factory Pattern" unless I see its interaction with classes from this "Bird View" analogy.

    I am going to be posting my questions relating to the class design next. I am indeed dissapointed by the UML critics. I trully am.
    But what has learning patterns got to do with planning a project? UML makes good documentation. I don't think its especially useful for planning except for perhaps making a few sketches to make things clearer.

    People here aren't neccesarily UML critics, but I think you'll find a lot of people here prefer the TDD route over Big Up-front Design.

  11. #11
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    Toronto
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But what has learning patterns got to do with planning a project? UML makes good documentation. I don't think its especially useful for planning except for perhaps making a few sketches to make things clearer.

    I think you'll find a lot of people here prefer the TDD/only as much planning as needed route over Big Up-front Design.
    Documentation matters. Planning matters. For good projects they also tend to go hand-in-hand. Perhaps instead of "a lot of people" you mean a few busy posters? it should also be noted that several case tools and code generators make good use of UML.

    Maybe it is just me but something I noticed about sitepoint is that if something isn't used, appreciated or understood by a vocal minority, it gets shouted down and dismissed very quickly and without any thoughtful reflection. It is as if a few folks have deigned the perfect way of coding and are incapable of tolerating any mention of any other method. Yes, PHP has many newbies behind it but it seems inappropriate when it is assumed that everyone is a newbie just because they don't do things the way that the 'popular' kids do it. Or maybe I'm just in need of coffee

  12. #12
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jayboots
    If, as 33degrees suggests, Smarty has too much power then surely that must imply that PHP is even more unsuitable to the task.
    PHP is definitely a poor templating language, because it does absolutely nothing to seperate presentation from business logic. The difference is that PHP is the native language, if I'm going to bother using a second, templating language, then I want that language to enforce the seperation; if the templating language is basically php with a different syntax, why bother?

  13. #13
    SitePoint Evangelist
    Join Date
    Mar 2004
    Location
    Fort Lauderdale
    Posts
    522
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    Jayboots - I agree.

    There are so many ways to do things. I can just start coding away without planning and eventually get stuck. I have been there.

    I want to do this the right way. I came across a book "wrox - Professional PHP5" where they talk about:

    1. decorator pattern,
    2. factory pattern,
    3. database abstraction layers,
    4. GenericObject class that one can extend ( an abstract superclass that will never be instantiated directly but it will be extended / subclassed . It will allow for a neat and conscise representation as a class of a single row of a single table in a database...)
    5. MVC
    6. Observer pattern.

    SO - now I am supposed to come up with a good application without planning? You must be kidding me. If I am to write a good app and use the above mentioned techniques I need some serious planning and UML use cases, activity diagrams, sequence diagrams, class diagrams.

    I mean - come on - its time we all did it the right way.

    On top of this I want to use smarty for template rendering. It will get convoluted if I am to just start coding away.

  14. #14
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Lithuania, Europe
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    PHP is definitely a poor templating language, because it does absolutely nothing to seperate presentation from business logic.
    You separate. I do not see a SINGLE reason to use smarty instead of simple PHP templates (especially if you're working alone). PHP templates can be very neat with simple conditionals/echos/loops. That's all you need to display your data.

  15. #15
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    Toronto
    Posts
    300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    PHP is definitely a poor templating language, because it does absolutely nothing to seperate presentation from business logic. The difference is that PHP is the native language, if I'm going to bother using a second, templating language, then I want that language to enforce the seperation; if the templating language is basically php with a different syntax, why bother?
    How can you possibly say that Smarty is "basically php with a different syntax?". I guess Java is basically C++ with a different syntax? Ruby is basically perl/python with a different syntax? There are differences that go beyond syntax -- but then again, syntax is important. As an example, syntax underlay the long discussion on php-dev over the last week covering the pros and cons over named parameters; there exist a class of user to whom they make sense but PHP does not and will not cater to that. Smarty does -- after all, it is a convenience that HTML designers are used to.

    Never-the-less, maybe you've never turned on Smarty's security mode -- if you mean providing abstraction by providing fine-grained control over the environment, that's what that feature does. Smarty is hardly perfect (for example, I do think it could benefit from a standardized method of defining template interfaces) but what it does purport to do, it does well.

    Greetings.

  16. #16
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ReeD
    You separate. I do not see a SINGLE reason to use smarty instead of simple PHP templates (especially if you're working alone). PHP templates can be very neat with simple conditionals/echos/loops. That's all you need to display your data.
    The #1 most important feature of a templating language, to me, is strict seperation of presentation logic from business logic. PHP fails miserably at this. However, that doesn't mean PHP can't be used as a template language, it just means that it requires discipline and trust. If you're a sole developer or even a small team, then there's no problem; in a situation where you're letting untrusted users modify templates, it can be dangerous.

  17. #17
    SitePoint Guru Galo's Avatar
    Join Date
    May 2005
    Location
    Holland!
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by photo312
    I am creating an "on line personal training" application in PhP5. I am currently looking into UML and drawing up use cases, activity diagrams, classes, sequence diagrams and component diagrams.
    If your currently looking into it i have to say there's more to UML than a quick lookin but if that's what serves your needs then go for it, tried Microsoft Visio yet, awesome tool for UML and lot's of available training video's from Lydia's to get around it quick if you plan on investing....

    Quote Originally Posted by photo312
    I have never used UML before and object oriented development is somewhat new to me from the php 5 perspective. ( coded in Java before ).
    Why would you even use PHP then ?

    Quote Originally Posted by photo312
    I would like to use Smarty as the template engine.
    I'm not a big fan of templating systems but if you go for smartyt and are looking for a high-end system i would reccomend looking into Mojavi 3 http://www.mojavi.org/ which has a view setup for Smarty.

    Quote Originally Posted by photo312
    I haven't decided which php patterns I should use, but I know for sure I would like to focus on MVC ( Model View Controler ) and separate my objects into components.
    Whenever doing this concider that with one pattern comes another one, remember that a pattern has to create the context for another pattern otherwise it would not be functional to you in terms of re-use and maintanance.

    Quote Originally Posted by photo312
    I wanted to get an opinion about how effective UML design will be in developing an application in PHP 5.
    Just as effective as you would use it for Java, remember that URL is merly a tool to keep track of the Big-Picture and Small-Details at the same location.

    Quote Originally Posted by photo312
    I am not aware of any forward engineering tools for php currently, so I know that my classes will not be able to be generated by "Poseidon Community Edition" for example.
    Depends on what you mean with "forward engeneering"

    Quote Originally Posted by photo312
    I am also using the GRAPPLE approach to application development. Please give me some suggestions and feedback on how I should effectively spend my time to prepare for the coding..
    Grapple, hmmm reminds me of Quake2 CFT, man what a time...
    I'm not sure what you mean with "grapple approach" but i figure out it has to be something like a plugin-like method then keep in mind that a plug in is something that "could" adjust itself to fit the right shape if the context of that plugin is flexible enough, in other words, do all patterns u use in your app line up and make the circle round.

    With patterns the thing is, you can find a pattern for everything, but as long as your problems are not clear the patterns can never solve them.

    Hope this help a bit....

    Galo
    Business as usual is off the menu folks, ...

  18. #18
    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 jayboots
    Documentation matters. Planning matters. For good projects they also tend to go hand-in-hand. Perhaps instead of "a lot of people" you mean a few busy posters? it should also be noted that several case tools and code generators make good use of UML.
    You'll note I did not say "do not plan" or "do not document". Document where needed, do as much planning as neccesary, but the important thing is to start writing code. If you make a big up front plan then find things have changed half way through you would have wasted a lot of time.

  19. #19
    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 photo312
    Jayboots - I agree.

    There are so many ways to do things. I can just start coding away without planning and eventually get stuck. I have been there.

    I want to do this the right way. I came across a book "wrox - Professional PHP5" where they talk about:

    1. decorator pattern,
    2. factory pattern,
    3. database abstraction layers,
    4. GenericObject class that one can extend ( an abstract superclass that will never be instantiated directly but it will be extended / subclassed . It will allow for a neat and conscise representation as a class of a single row of a single table in a database...)
    5. MVC
    6. Observer pattern.

    SO - now I am supposed to come up with a good application without planning? You must be kidding me. If I am to write a good app and use the above mentioned techniques I need some serious planning and UML use cases, activity diagrams, sequence diagrams, class diagrams.

    I mean - come on - its time we all did it the right way.

    On top of this I want to use smarty for template rendering. It will get convoluted if I am to just start coding away.
    Your problem in my view is that you are trying to do much up front and are trying to make things too complicated from the start. It seems you are getting obsessed with patterns where in reality patterns tend to naturally expose themselves as you start coding. Perhaps you should have a read into agile methodologies and eXtreme programming for an alternate view to endless diagrammes and planning without getting much done.

    http://www.extremeprogramming.org/

  20. #20
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jayboots
    How can you possibly say that Smarty is "basically php with a different syntax?". I guess Java is basically C++ with a different syntax? Ruby is basically perl/python with a different syntax? There are differences that go beyond syntax -- but then again, syntax is important. As an example, syntax underlay the long discussion on php-dev over the last week covering the pros and cons over named parameters; there exist a class of user to whom they make sense but PHP does not and will not cater to that. Smarty does -- after all, it is a convenience that HTML designers are used to.

    Never-the-less, maybe you've never turned on Smarty's security mode -- if you mean providing abstraction by providing fine-grained control over the environment, that's what that feature does. Smarty is hardly perfect (for example, I do think it could benefit from a standardized method of defining template interfaces) but what it does purport to do, it does well.

    Greetings.
    Smarty has it's uses, and it may do what it purports to do well, but I simply feel it tries to do too much. Security mode helps for sure, but IMO a templating language should be secure to begin with. Put it down to a difference of opinion as to what the point of a templating language is, if you'd like.

  21. #21
    SitePoint Guru Galo's Avatar
    Join Date
    May 2005
    Location
    Holland!
    Posts
    852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by photo312
    Jayboots - I agree.

    There are so many ways to do things. I can just start coding away without planning and eventually get stuck. I have been there.
    BELIEVE ME, plan or fail.... i've been there to, many re-writes and eventualy end up with nothing...

    Quote Originally Posted by photo312
    I want to do this the right way. I came across a book "wrox - Professional PHP5" where they talk about:
    Good book, it's on my shelve and it'll teach you about patterns and PHP very well, but try to get a single system out of it and you'll still be trying in 10 years cause the examples in this book are written by seperated programmers who all have different approaches, see it more as a reference manual on the more advanced pattern/object oriented stuff that comes with PHP.

    Personaly i found the Core PHP and PHP 5 Power programming books to be more efficient in telling me about how to design AND develope instead of the development without the explenation of how it was designed.

    Also if you go into patterns try the "head first on design patterns" you'll love it since your a java programmer.

    Quote Originally Posted by photo312
    1. decorator pattern,
    2. factory pattern,
    3. database abstraction layers,
    4. GenericObject class that one can extend ( an abstract superclass that will never be instantiated directly but it will be extended / subclassed . It will allow for a neat and conscise representation as a class of a single row of a single table in a database...)
    5. MVC
    6. Observer pattern.
    As long as i do not know your requirements and problems i cant say if these patterns would solve them, it could be but that's all i can make from it....

    Quote Originally Posted by photo312
    SO - now I am supposed to come up with a good application without planning? You must be kidding me. If I am to write a good app and use the above mentioned techniques I need some serious planning and UML use cases, activity diagrams, sequence diagrams, class diagrams.
    You can't and please don't even try without a proper design...


    Quote Originally Posted by photo312
    On top of this I want to use smarty for template rendering. It will get convoluted if I am to just start coding away.
    [/QUOTE]

    Smarty is a template ENGINE not a RENDERER, there's a huge difference...
    Rendering is geting a native input and having a datailed output
    Engening is supporting an existing entity with utilities wich create an easyer application flow

    There you go... and dont mind the templating war b*tches, theire young and wild
    Business as usual is off the menu folks, ...

  22. #22
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rendering is geting a native input and having a datailed output
    Or an ouput of varied formats or content based on the input; Templating to me, just means that you are allowed the means to present your data more easily, again this may appear to be like rendering, but it isn't...

    You may just have the one template, but a variable number of renderers that use the one template, but only differently

  23. #23
    SitePoint Evangelist
    Join Date
    Mar 2005
    Posts
    421
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey, i loved these quotes:

    Quote Originally Posted by Galo
    do all patterns u use in your app line up and make the circle round
    Quote Originally Posted by Galo
    With patterns the thing is, you can find a pattern for everything, but as long as your problems are not clear the patterns can never solve them.
    Nice theoretical statements there, to keep oneself grounded. Thanks

  24. #24
    SitePoint Evangelist
    Join Date
    Mar 2004
    Location
    Fort Lauderdale
    Posts
    522
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do have the book " Head first design patterns" and I like it. I am going to take a look at the PhP5 power programming and see how things are done there.

    I have looked into the PhP-Architect Patterns book, which I got for christmass and it was very bad - They explain patterns by using a PHPUnit class for testing. Its very convoluted.

    As far as templating - I will stick to smarty. I have experience with it and, I will ad more DDR2 Ram to my box and that should take care of the extra processing that Smarty requires. Or I will get a faster Chip.

  25. #25
    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)
    Quote Originally Posted by photo312
    I have looked into the PhP-Architect Patterns book, which I got for christmass and it was very bad - They explain patterns by using a PHPUnit class for testing. Its very convoluted.
    Not "they" ... I . Perhaps following up on Luke's recomended link, and in particular the XP practice of Test Driven Development would be worth your while.

    Quote Originally Posted by Luke Redpath
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.


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
  •