Join the forums now, and start posting to receive access to our Scripts Vault!
Have you considered maybe using a memory table or memcache?For my own chat, I also use this idea of multiple channels. I use javascript push to push chat messages directly from user to users. The chat messages are not stored on my server at all.
Performance wise you'll probably be better off with a separate table
QuotePerformance wise you'll probably be better off with a separate tableCitation needed.
Hey, I dunno how your codebase is setup, but if I were implementing a chat system using my codebase (Kohana+Doctrine+Win) I'd implement the single table system as suggested by chrisjenkinson with a channel id to segment the data.Now because I use an ORM(Doctrine) I can just create a concrete class for each of the channels that I want within my game, each of these channel classes will extend from the ORM base class, and set their channel id, I can also preform message specific validation, say I don't want people posting links in the global chat, but amongst friends links are fine.What this does it allow me to quickly create new messages for specific channels, for example:<?php Global_Chat_Message::factory('Hello, world!'); ?>and<?php Private_Chat_Message:factory('chrisjenkinson', 'Hows it going?'); ?>And as a subtle plus if over time I realise that my user base is using the private chat feature a lot, and its causing an adverse affect on the rest of the messaging system I can then duplicate the message table, give it a new name like 'messages_private_chat' update the models used table, within the orm and boom added performance with minimal work
Quote from: chrisjenkinson on March 10, 2011, 04:20:10 AMQuotePerformance wise you'll probably be better off with a separate tableCitation needed.Because the DB won't have to differentiate on channel ID. I can't offer you a citation because it seems self-evident to me. I have a feeling you're about to tell me why I'm wrong, though.
And to chris, i 'could' do that but then as stated, how would i make sure to be able to effeciently handled the more annoying of people. I need a way to be able to use and just get it. And a cache table, sounds to me like a pure memory table, since otherwise, what's the point of using that instead of a table that actually stores said data?
There's an opportunity cost to opening the various files needed to access another table, the index, etc..
I mostly have it setup as such. Base PHP Functions + built in functions in 'ext', and then a pbkdf2 function that i found on the PHP page's documentation for something, i cannot remember the exact page right now but it's there. Everything else is written up by hand. The reasoning behind it is that i find OO code to look ugly and haphazardly put together. That and i dislike pointless abstractions. I use methods from jquery because that's the only way to deal with javascript to get it done. And i also use the buillt in methods but no code i write implements new methods. The chat function would most likely be something like, sendmessage($message,$channel);and that to me looks cleaner than sendmessage::something($message,$channel);. The :: and the idea of using methods just makes the code feel dirtier along with the fact that it doesn't translate back into as little opcodes i've been completely against it.
Take a note that in chat you have only 1 channel open at a time. So the need to access multiple tables will never emerge.
Overly_Awesome_Chat_Manager::create() ->getChannel('global') ->getChannel('private') ->getChannel('region-my-awesome-farm') ->execute();
I think this depends on the way the UI is implemented
Besides, your OOP heavy UI still sux because it does not send SMS notification when someone write your name
[snipped to terseness]Thats cool, not everyone has the same taste in everything, the thing I really like about OOP is how it lets you do the same thing in multitude of different ways. From an OOP developers perspective simply calling a sendmessage('message', 'channel'); feels wrong, because you then have to remember which channel is what. And for me personally I'd be constantly putting the wrong channel id into the overly generic message sender. Whereas with a nice self documenting static function call, it either works because you remembered the name correctly, or gets picked up as an error when your testing it. With your broad parameter list approach, I find that errors often slips though the gaps, more so because I never worked out how to unit test functional code :S
The OO way of programming was pretty neat when i first heard about it, i was like, oh this is an interesting way of doing things. But then I realized that it was another abstraction layer and slowly but surely my focus on performance on the resulting application took over and i've never looked back.
I dislike extra abstractions that i need to. I'm all for the abstractions that C provided since that was well amazing once i got into that, but going out further just feels weird and hte idea of it sits with me wrong.
That and the knowledge that objects have to take up more memory than a simple string for example and will take up those precious op codes and bytes of ram, makes me cringe when i think about implementing them.
int x = 4;int y = 7;
class Coordinate { public: Coordinate(x,y) : _x (x), _y (y) {} private: const int _x; const int _y;}Coordinate location = new Coordinate(4,7);
Edit: Wow, that was rather fast lolninja, i wouldn't have expected you to come up with an api to send out text messages via OOP PHP so quickly. It must be some sort of black magic or some similar mysterious force that you have tapped into.
They don't take up more memory! They take up the amount of memory equal to the amount necessary for their properties. The OOP just places related properties into a convenient wrapper for the developer to use!
class Coordinate { private $_x; private $_y; function Coordinate($x,$y) { $this->_x = $x; $this->_y = $y; }}$location = new Coordinate(4,7);echo memory_get_usage() . "\n";
$coordinate = array(4, 7);echo memory_get_usage() . "\n";
$x = 4;$y = 7;echo memory_get_usage() . "\n";
wrappers are NOT free
As far as the example of adding the z plane, i don't know how it'd be terribly different to do something such as a function which handles all movements. And then i'd just add that function that moves the players around. Since there'd need to be a collision detection anyway. The function is going to have to be there anyway in the future.
The very last thing, is that it is a lot easier for OO programmers to find code online since almost everyone is using it(for rather obvious reasons) so it's hard to find code that is purely procedural or at the very least isn't overly OO.
$var = 'my string';$words = $var->explode(' ');
I'm not using any framework because first off, I'm more interested in learning PHP rather than some framework's way of working in php. Secondly, because they're all overly OO and their security practices are laughable at best.
My 'most important' things are performance stability and security, then comes usability for end users since if any of the first three is not possible then i doubt anyone would even want to use the thing. After that it's all about modularity, and finally ease of use on the other coders.