[buddypress-trac] [BuddyPress] #1479: Universal Component Class Concept
buddypress-trac at lists.automattic.com
buddypress-trac at lists.automattic.com
Sat Dec 19 21:30:35 UTC 2009
#1479: Universal Component Class Concept
----------------------------+-----------------------------------------------
Reporter: johnjamesjacoby | Owner:
Type: enhancement | Status: new
Priority: minor | Milestone: Future Release
Keywords: needs-feedback |
----------------------------+-----------------------------------------------
Comment(by MrMaz):
I think this is a good start. I would want to take it much further and get
all crazy OO, and stick really tight to a pattern like Template Method
that can be used to introduce a lot more control over data
formatting/filtering/security.
That would look more something like this:
{{{
// in base component class
function get_slug() {
if ( preg_match('/[a-z0-9]/', $this->my_slug() ) ) {
return $this->my_slug();
} else {
die('your slug is no good');
}
}
// in child component class
function my_slug() {
return 'appname';
}
}}}
All of the base component methods would only call get_slug(), so it would
not be possible for anyone to mess things up. Notice there are no
variables used, so it wouldn't be possible for someone to modify the slug
from the outside.
And just in general, I think global data is crazy bad, so any opportunity
to do away with it should be taken advantage of.
Most of this flies in the face of how WP handles just about everything, so
I am not expecting anyone to warm up to this very much. I will say though,
that it would be smart to use this overhaul to implement some
encapsulation of the core functionality and global data, because right now
anyone can fark with any data they want to. They can just up and change
the slug for a component!
--
Ticket URL: <http://trac.buddypress.org/ticket/1479#comment:5>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list