jackpf Posted March 22, 2009 Share Posted March 22, 2009 Hey all, I've just got the hang of object oriented programming, and am considering switching my site over to using classes. But then I thought...is there any real benefit of doing this? Is there really anything a class offers that a simple function can't do? So I thought I'd ask here for some advice Any pointers are greatly appreciated, Jack. Quote Link to comment https://forums.phpfreaks.com/topic/150634-functions-vs-classes/ Share on other sites More sharing options...
.josh Posted March 22, 2009 Share Posted March 22, 2009 If you're asking yourself these questions, then you probably don't need to go OOP. You go OOP for the same reason you went to putting things into functions: re-usability. Quote Link to comment https://forums.phpfreaks.com/topic/150634-functions-vs-classes/#findComment-791297 Share on other sites More sharing options...
colbyg Posted March 22, 2009 Share Posted March 22, 2009 i would only use a class for some kind of add-on to a website. like a template engine, a class to access and edit a database, etc. not for the actual website. Quote Link to comment https://forums.phpfreaks.com/topic/150634-functions-vs-classes/#findComment-791298 Share on other sites More sharing options...
trq Posted March 22, 2009 Share Posted March 22, 2009 Just because your using classes does not mean your programming proper OOP. If you think the only benifit to classes is to group functions together you have a long way to go before getting the 'hang of object oriented programming'. Quote Link to comment https://forums.phpfreaks.com/topic/150634-functions-vs-classes/#findComment-791300 Share on other sites More sharing options...
jackpf Posted March 22, 2009 Author Share Posted March 22, 2009 That's what I thought...but then I hear people bragging about how they can code "object oriented" etc... But in the end, you just end up with heaps more code, and apparently they're slower. Yeah...this has deterred me from using them slightly... And thorpe, that's what the purpose of this topic is for; to help understand more about object oriented coding. What's the point in using OOP? I'm just interested. Quote Link to comment https://forums.phpfreaks.com/topic/150634-functions-vs-classes/#findComment-791304 Share on other sites More sharing options...
trq Posted March 22, 2009 Share Posted March 22, 2009 But in the end, you just end up with heaps more code, and apparently they're slower. You may end up with more code, but likely better designed and easier to maintain. You should take a look at one of the bigger frameworks. Zend. Even just doing the quickstart tutorial will give you a good overview of some of the benefits of good design. Quote Link to comment https://forums.phpfreaks.com/topic/150634-functions-vs-classes/#findComment-791311 Share on other sites More sharing options...
bluejay002 Posted March 23, 2009 Share Posted March 23, 2009 Yes... I agree with thorpe. It is easier to manage and maintain if it is in a class. Well maybe I did understood a bit about OOP since I started doing it with Java. In PHP, I do use some classes but not to all part, some part where I think it would be better for a class they I make a class for it, if not, I won't. IMHO Quote Link to comment https://forums.phpfreaks.com/topic/150634-functions-vs-classes/#findComment-791387 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.