SitePoint Sponsor

User Tag List

Results 1 to 25 of 25
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    First PHP OOP Application...

    Greetings All!!

    I have finally seen the wonderful world that is Object Oriented Programming. This past semester I took a VB.net course and Java course and finally got to know a bit about OOP. I know the basics.

    However, the classes only dealt with memory resident objects, there as no storage of them to a flat file or database. Basically, I don't know how to do OOP alongside a databse. But I want to learn.

    One of the projects I'm currently working on is a calendar/schedule for a sports team's website. I've got the DB scheme down (I'm really good with DB design). I've started off my migration to OOP by using a database class called ezSQL from Justin Vincent. It really has made the code simpler and smaller. I like that. I've also begun to take a look at some of the form classes, such as PEAR's HTML:Quick_Form. But how do I take my application a step further?

    The events/games would be an object. They would have various properties I would set as well as some methods for interacting with the object. My big question is: What is the proper way to store the object into the database? Do I write a method called 'storeInDatabase' or something like that? For some reason, my gut tells me that's not right. And what about functions such as 'displayScheduleTable' or 'displayEventDetails'? Those don't seem to belong in an 'Event' class.

    There's probably some great sites or posts about this very topic, I'm just not finding them. Everything I'm seeing so far is the basics of OOP, which I have a decent handle on. I need to learn how to develop a database application using OOP.

    BTW, my current enviroment is still PHP 4, so I can't use any of the fun and new things in PHP 5.

    Thanks alot, in advance, for any help you may provide me.

  2. #2
    SitePoint Guru
    Join Date
    Dec 2003
    Location
    oz
    Posts
    819
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ChrisHasenpflug
    Basically, I don't know how to do OOP alongside a databse. But I want to learn.
    Some links
    http://www.sitepoint.com/forums/showthread.php?t=175288
    http://www.sitepoint.com/forums/showthread.php?t=185352
    http://www.amazon.com/exec/obidos/tg...books&n=507846

    Quote Originally Posted by ChrisHasenpflug
    And what about functions such as 'displayScheduleTable' or 'displayEventDetails'? Those don't seem to belong in an 'Event' class.
    This would be appliction level code. Application code is code in a controller (or in an object that is called from the controller) that uses business objects to do the processing required. The business objects abstract the database so that the application sees only objects - some of which represent tables in the database.

    Code:
    GUI + Page Controller (may be combined with app layer)
    	|
    	V
    Application Layer
    	|
    	V
    Business Layer
    	|
    	V
    Data Access Layer 
    	|
    	V
    Persistent data store (eg DataBase)

    Regards,
    Eli

  3. #3
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you haven't read this already beg, steal or borrow a copy of Patterns of Enterprise Application Architecture (Martin Fowler).

    You'll find some short descriptions of the patterns on the catalogue page of the above site.

  4. #4
    SitePoint Guru
    Join Date
    Dec 2003
    Location
    oz
    Posts
    819
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by McGruff
    If you haven't read this already beg, steal or borrow a copy of Patterns of Enterprise Application Architecture (Martin Fowler).
    Yeh, that was the 3rd link I put in.

    <off topic>
    How do you put links in these forums without showing the link location.
    I tried this, but must be disabled:
    <a href="www.somedomain.com">somedomain</a>
    </off topic>

    Eli

  5. #5
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [ url =http://..etc ]foo[ /url ]

  6. #6
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is it with everyones fetish for PoEAA? It's a good book to read, but when you think things out, and get experience, you tend to discover those "patterns" yourself. I can't justify spend £40 on it, even with the £25 book voucher I was given by the school. Maybe I'm just too tight with my money.

    Still I can't say i don't recommend the book. I guess it's a good way for newbies to sort of fast track their learning a little. However, no matter how much you read, and how much you study/learn at university/college, nothing replaces having solid first hand experience in programming projects for the real world. It's certainly something I've learnt over short 6 months of my career.

  7. #7
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tend to refer back to Java World as a reference, but I'm not saying not to buy the book, or that the book is not a good buy, as it is

  8. #8
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    What is it with everyones fetish for PoEAA?
    ...nothing replaces having solid first hand experience in programming projects for the real world.
    That's exactly it: this book contains the distilled experience of a highly skilled programmer. It's a treasure trove worth its weight in gold (there's a copy lying on the table as I type). When you're ready for it it'll provide an enormous boost to your analytical skills and depth of understanding.

    In particular, the data source and object-relational patterns are very relevant to ChrisHasenpflug's original question.

    Fetish? Don't get me started

    "Our Fowler, which art in heaven
    Hello world be thy name.
    etc...

  9. #9
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well to me it seems like web programmers seem to use it as a substitute for the Karma sutra.

    It's a good book, but I think that practise makes perfect and in order to be good at something you need to go out there, make mistakes and learn from them, no matter how good a book is. However, at the same time people need something to guide them. I just get the impression that some people here seem to see PoEAA as the be all and end all piece of text.

    As I say though, I'm also a mega cheapskate type of person who won't spend money on books when you can learn so much from the web and from interacting with others on forums etc.

  10. #10
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree hands-on coding is important. Grappling away on your own helps you to understand theoretical solutions better but this book really is essential reading. Some books might have an interesting chapter here or there but in PoEAA thereís hardly a page which isnít oozing with intelligent analysis or practical advice.

    Iíve been learning to program for a while now in my spare time, mainly using free resources like youíve mentioned but this really is one book you have to buy IMO.

  11. #11
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nah, CBA to buy it. I know "Border's" round the corner from my office have a copy, so I can just pop down there during my lunch hour to read it :P

    However, looking at it, I have a few book vouchers I need to use, but I wanna get some non web programming books with them. At some point I plan to play about with making games in C++ (nothing, huge, just a old arcade style shoot'em up), and maybe get into some other C++ stuff. However, I just don't have the time to do anything in CPP atm, so for now I'm doomed to doing PHP coding for the next few months.

  12. #12
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now that is bizarre. Someone just subtracted from my reputation for recommending PoEAA.

    I'm sure I don't deserve any points anyway but this is the advanced forum, isn't it..?

  13. #13
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by McGruff
    Now that is bizarre. Someone just subtracted from my reputation for recommending PoEAA.
    I can't top you up again because I have to spread some around first.

    The reputation I get is often bizarre. I'll spend hours (or days if it's a persistence library) on a post and get just about zilch in reputation. I slag off you know who in posts even I am ashamed of, and I get bucket loads. Go figure.

    There really is no justice .

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  14. #14
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess you two are looking for a pattern of objectification that others may have have designs on, but no method to return the values you a looking for.

  15. #15
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lastcraft: We should be paying you in gold bars not reputation points. (Sorry I'm all out right now..).

    If I'm thinking of the same guy, I personally thought you were spot on. Knowledge is precious, blind arrogance is just a waste of time. Don't listen to all that stuff about Marston-baiting making you blind.

  16. #16
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm...

    Despite our never ending disagreements McGruff I'd give you reputation but it wasn't all that long ago I gave, and I need to spread it around before you can have more...

    But at the end of the day, what does it really matter? Hell, folks knock points of me left, right and centre and it ain't nothing, is it

  17. #17
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    netherlands
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    reputation points? I guess I'll probably should read a faq somewhere.

    About PoEAA, I don't found it spectacular either to be honest. It was a nice read, it covers some nice aspects, but I can recommend a couple of other, and in my opinion better, books for that price. And besides that, most of the usefull patterns in the book are covered in a wide range of topics in this forum, so I would advice the topicstarter to try and find those topics first.

  18. #18
    SitePoint Guru
    Join Date
    Dec 2003
    Location
    oz
    Posts
    819
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Manor
    About PoEAA, I don't found it spectacular either to be honest. It was a nice read, it covers some nice aspects, but I can recommend a couple of other, and in my opinion better, books for that price.
    Could you post the names of books you recommend please?

  19. #19
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    netherlands
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lazy_yogi
    Could you post the names of books you recommend please?
    I found "Object Design: Roles, Responsibilities andCollaborations" and "Domain Driven Design" very usefull.

  20. #20
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm waiting on getting the later from amazon myself, should get it either tomorrow or friday. As for the first book you've suggested I was just about to order that as well at the same time, though on second thoughts changed my mind after looking at my bank statement on line

    (It's on my wish list if anyone wants to buy it for me... hint hint )

    Can't wait to get the book, and hope to get the other one soon. Still digesting Test Driven Development I bought over christmas, of which comes highly recommended.

    The book makes it (appear) so simple to develop from nothing to something via unit testing. Remarkable really. Outstanding actually

  21. #21
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have searched poeaa of Martin Flower.but I haven't seen it or rather haven't read it.Is it cover oop of php with any example?will you guide some books regarding on that?
    I want to know the price of those book including poeaa in "INR"

  22. #22
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do a search for Martin Fowler in the books section of Amazon, there should be an Amazon locally to you?

    Doesn't really matter the cost as you'll benifit greatly from the book. Knowledge is power, remember

  23. #23
    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 ujjwal
    I have searched poeaa of Martin Flower
    PoEAA is an abreviation for Patterns of Enterprise Application Architecture

    lots o' links
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  24. #24
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's a link to a summary of the patterns in the third post to give you an idea of the content.

  25. #25
    SitePoint Zealot sanka69's Avatar
    Join Date
    Apr 2003
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For what it's worth, I found "Head First Design Patterns" quite a good book. The slightly juvenile demeanour about the book got a bit irritating, but it got to the point. In fact, the interruptions probably made it easier to read late at night after a hard day at work.

    Head First Design Patterns


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
  •