TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Simple Blog Project (http://www.talkphp.com/absolute-beginners/4291-simple-blog-project.html)

baseballplayr 05-15-2009 11:30 PM

Simple Blog Project
 
Based on feedback for simple projects to learn OOP, I think I will try a blog app. I figure this is a way for me and anyone else who wants to pitch in, to learn OOP php better. For starters, what all do I need for this blog?
Database class
Post class
Login class (maybe a session class to go along with it?)
Validation class
Exception class

Most of this was taken from another post in this section from allworknoplay. Which class should I write first? The database class? Will give it a try this weekend :)
Thanks for all the help in advance!

allworknoplay 05-16-2009 12:14 AM

Quote:

Originally Posted by baseballplayr (Post 24120)
Based on feedback for simple projects to learn OOP, I think I will try a blog app. I figure this is a way for me and anyone else who wants to pitch in, to learn OOP php better. For starters, what all do I need for this blog?
Database class
Post class
Login class (maybe a session class to go along with it?)
Validation class
Exception class

Most of this was taken from another post in this section from allworknoplay. Which class should I write first? The database class? Will give it a try this weekend :)
Thanks for all the help in advance!


Sounds good, I will try to join in if I can...

the post class can use methods from the validation class, as well as the login class....

Also, let's go with lazy loading ( autoload ), I think that's the correct terminology...

Village Idiot 05-16-2009 04:09 AM

Don't use objects for the sake of using them, objects are only useful if you understand object oriented design (this takes a long time to grasp well). So here's my question: Why do each of those items need to be in a class? What do you gain by using objects opposed to coding them without?

I have found (though both observance and personal experience) that projects made for the sake of using objects are bad. All they teach is how objects work, which is done fine with small useless programs. The nasty side effect that they give is that you get into the thought process of using objects for anything you can manage to create one for. This is not how good design works, objects should only be used when there is a clear advantage to use them.

What I am saying is that you should learn how OOP works with small applications, read up on object oriented design and then start building a larger application. When you build this larger app, use OOP as a tool opposed to the base of the entire project.

baseballplayr 05-16-2009 05:09 AM

So you don't think building a blog would be a beneficial small app?
I know there are times when using OOP isn't the best bet, but merely want to make something OOP from start to finish, just to make sure I have it down. What would you consider a large application?

Village Idiot 05-16-2009 02:46 PM

I understand your want to complete a project using object oriented concept, but I think it would be far more beneficial to you if you to do smaller projects, learn proper object oriented design then do a larger project.

And there is no solid definition of a large project, especially with lone programmers. I consider large projects (when I am alone) anything over 1,500 lines, but I am used to programming large applications (the ASP one I maintain is about 100k lines). Back when I was a newer programmer, large was over a few hundred lines. A blog would certainly run into this, so I wouldn't consider it a small project for you.

allworknoplay 05-16-2009 03:12 PM

All I say is I can't wait to have enough hours of OO under my belt. It's going to be great being able to quickly look at a class and get a good idea of what the programmer is trying to do, what design pattern he's following, how it can be better, what flaws are in it...(having the urge to build your own framework out of curiosity)

When you can do that, I'd say you are in a good place in the OO world....

Tanax 05-18-2009 11:40 AM

Ehh.. you could do a blog app with 1 class. I would however recomend having the database as an own class. Then all you need is a blog class, with functions for post a new entry, post comment on an entry, fetch an entry(along with its comments), fetch all entries(for the blog frontpage - possibly with a limit of 10 so it only displays the 10 latest entries), login as a user, etc.

All of that goes into 1 class. Then in the future you can expand this to have multiple classes handle several things, for example an own login class. The thing is that you mentioned it was supposed to be easy, and making a class for every "function"(basicly) is not needed. Not at this point anyhow.


All times are GMT. The time now is 01:44 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0