• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Forum prototype - Constructive criticism requested.

I'm really sorry, Dam1an, but please could you spend a few minutes posting some method names you'd expect to find in the model. I think this is why I went the OOP route, because I couldn't think of decent method names that made the least bit of sense. I'm in serious need of inspiration.

There are so many ways to go with Models, you could either just have the table fields as params, and then get, set, update and delete methods, and then wrap this with logic in a library, or you could have a model with getA, getB, getC etc, much like you have now in your object

If you still want me to give you how I would do it in MVC, just ask, or if you want to discuss it more in 'real time' PM me and I'll give you my MSN addy

Thanks for the thoughtful offer. I'll try and keep it in this forum for now, as I'm interested in everybody's opinions.

The dilemma I am facing, is coming up with meaningful method names. For example, get_post, get_thread - it's pretty obvious what those functions are going to do, but what would get_forum do? Theoretically, it should pass back the forum (in an object or an array), so what should I name the method that returns the list of child forums?

Oh... I've answered my own question. The obvious choice would be get_child_forums. Does this sound reasonable?

Its not all about names but also about parameters
for instance, would you have
function get_thread($thread_id);
function get_thread_by_id($thread_id);

You could also have the get_thread method return all threads in its current context (so all threads in that forum) if no arguments are specified

A method name needs to say as much as possible in as little as possible
so if get_forums (note: plural) is enough for you to know it will return multiple forums based on its context aka position in the forum hierachy) it would be preferable over get_child_forums

get_thread or get_thread_by_id? Now you're just trying to confuse me! Tongue

I think I would have to go with get_thread. I'd expect to get it by ID, and if the need arose, I could always add a get_thread_by_date, or whatever.

Wouldn't having a method like get_thread passing back more than a single thread complicate things? I don't mean to sound picky or anything, but this is one of the many thoughts that plague me, I never actually reached a definitive conclusion. I haven't really seen examples of code that answer this for me, and I spend a LOT of time sifting through other peoples code, to try and build on my own knowledge, and usually that only confuses the issue.

Have you tried looking through some of the PHP forums on SourceForge? Even if they're not MVC/PHP, you could get some ideas from them. It might help you finalize exactly what you want, and methods etc

Returning a collection of threads wouldn't complicate things (or where you thinking of having it in a seperate method to get threads in a forum?)

As for the get_thread($id) vs get_thread_by_id($id) I was just showing how some names can be unnecesserily long, as you correectly said you'd assume to fetch it given the ID

Building on my second from last post, I'd probably have a method named get_forum_threads($forum_id, $page_num), but that may not be the most obvious way to do it. What I'm getting at is that I'd like to keep everything simple and obvious. I would like to build upon this forum when it's done, and then release it into the public domain. If I'm going to go to all that effort, then it needs to be top-notch in order to get people using it - which is what I am striving for.

I'm going to dig through sourceforge now. Thanks for the suggestion. I'd just been using trusty ol' Google, sourceforge had never occurred to me (D'oh!).

Eek! I just searched sourceforge for "php forum" (without quotes) - 15648 found! I can't even count that high!

One thing about get_forum_threads($forum_id, $page_num)
To me, that seems to old fashioned, procedural way to do it
If you're doing OO, something like this would work better
(There are loads of alternative arguments you could you like offset and limit (like in SQL), starting thread number instead of page etc)

And I already suggested SF in your other thread on forums (obviously someone needs to catch up on their threads Tongue)

[quote author="TheFuzzy0ne" date="1241206577"]Eek! I just searched sourceforge for "php forum" (without quotes) - 15648 found! I can't even count that high![/quote]

go for a more specific query, like [URL=http://sourceforge.net/search/?words="php+forum"+mvc|oop]this[/URL], just 29 results

The problem with SF search, is you get all the results for php, plus all the results for forum, not just the ones which have both

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.