Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Community At long last, we're finally back

thesheeep

Arcane
Patron
Joined
Mar 16, 2007
Messages
10,098
Location
Tampere, Finland
Codex 2012 Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming! Serpent in the Staglands Dead State Divinity: Original Sin Torment: Tides of Numenera Codex USB, 2014 Shadorwun: Hong Kong Divinity: Original Sin 2 BattleTech Bubbles In Memoria A Beautifully Desolate Campaign Pillars of Eternity 2: Deadfire Pathfinder: Kingmaker Steve gets a Kidney but I don't even get a tag. Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
But I really have to ask.. how can one not get OO programming? There is a class, which has functionality that belongs to its "nature" (a soldier may attack() and have the getWeapon() function, etc.).
It really is easy as that... and now there are possibly dozens and hundreds of classes that work together.
Getting the "concept" of OO has never been the hard part. The hard part for me is first understanding the syntax, then trying to work out what I actually want to do and how to do it. And then trying to find that in one of 2,661 Files across 528 Folders, most of which are called things like "ControllerPublic" and are full of:

snip

Okay, the way I see it, you are still a bit struggling with typical OO structures. You'll get used to it. I'm doing this since some years and (except one hell of a nightmarish 3D engine) have a pretty easy time doing what you described, in any language that I can "read" (similarity to C++ helps). And not because I'm some kind of genius. It's practice. :)

Also, the code you showed is typical web-developer uncommented garbage. Maybe the concepts in there in how they use their classes is good, but as you noticed, you don't get anything thats going on there without having to look into each sub-function, class, etc. That is why good devs (good as in "other people will understand what I did there") use comments not only to describe a function, but also within the function.

By what you showed there, I have no doubt that the rest is equally hard to get. so kudos to you for managing it somehow anyway. Even if you had resort to the method that will force you to do it again ;)

Really, the code some web-devs produce gets me mad each time. And why? because they don't get that code is more often read than written, or worse, they don't care...
 

OSK

Arcane
Patron
Joined
Jan 24, 2007
Messages
8,115
Codex 2012 Codex 2013 Codex 2014 PC RPG Website of the Year, 2015 Codex 2016 - The Age of Grimoire Make the Codex Great Again! Serpent in the Staglands Dead State Divinity: Original Sin Project: Eternity Torment: Tides of Numenera Wasteland 2 Shadorwun: Hong Kong Divinity: Original Sin 2 BattleTech Pillars of Eternity 2: Deadfire
Seems like a marvelous pile of spaghetti code!

Looks fine to me.

Also, the code you showed is typical web-developer uncommented garbage.

Good code is self-evident. Shitty/obscure/irregular code needs comments. All code needs documentation. There's nothing wrong with the code that he posted as long as there's external documentation describing what things like responseView is and how it's used.

But I really have to ask.. how can one not get OO programming? There is a class, which has functionality that belongs to its "nature" (a soldier may attack() and have the getWeapon() function, etc.).
It really is easy as that... and now there are possibly dozens and hundreds of classes that work together.

Herp derp. If that's all there was to OOP, DU wouldn't be having the issues he's having.

Code:
 /**
* Shows a preview of the thread creation.
*
* @return XenForo_ControllerResponse_Abstract
*/
public function actionCreateThreadPreview()
{
$this->_assertPostOnly();
 
$forumId = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
$forumName = $this->_input->filterSingle('node_name', XenForo_Input::STRING);
 
$ftpHelper = $this->getHelper('ForumThreadPost');
$forum = $ftpHelper->assertForumValidAndViewable($forumId ? $forumId : $forumName);
 
$forumId = $forum['node_id'];
 
$this->_assertCanPostThreadInForum($forum);
 
$message = $this->getHelper('Editor')->getMessageText('message', $this->_input);
$message = XenForo_Helper_String::autoLinkBbCode($message);
 
$viewParams = array(
'forum' => $forum,
'message' => $message
);
 
return $this->responseView('XenForo_ViewPublic_Thread_CreatePreview', 'thread_create_preview', $viewParams);
}
What does responseView do and how do I use it? It appears in 103 files (and isn't in the file this piece of code is) - Which one do I want? "XenForo_ViewPublic_Thread_CreatePreview" is some parameter being passed to it, which itself is easily enough found (there are only two of them and the one in 'CreatePreview.php' seems likely) but then that has:

I can't tell you what responseView is but there should be documentation telling you what it is.

Don't know what a JFileChooser is in Java? http://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html
Don't know what an Event Source Object is in a random jQuery plugin? http://arshaw.com/fullcalendar/docs/event_data/Event_Source_Object/

If there is no documentation, then there's not much you can do other than read lots of code.

"XenForo_ViewPublic_Thread_CreatePreview" is an object.

Code:
class XenForo_ViewPublic_Thread_CreatePreview extends XenForo_ViewPublic_Base
{
public function renderHtml()
{
$bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
$this->_params['messageParsed'] = new XenForo_BbCode_TextWrapper($this->_params['message'], $bbCodeParser);
}
}
This is literally the only thing in that file (and there are hundreds of files where literally, there are empty _constructs or just one function with a few lines of code). This is easy enough to understand what it's doing (parsing bbcode) but how is it even being called? Obviously through responseView... but where was that again?

You're having trouble with this because of an OOP concept called inheritence. They're probably implementing the template pattern, but I can't tell if XenForo_ViewPublic_Base is abstract (if PHP even has abstract classes).

This is probably fairly basic shit to someone who's been coding PHP in an OO manner but I'm just not at that level of PHP coding to "get" what the hell is actually going on here and I'd often get lost in loops looking for that thing that started it all but finding files that called other files that seemed to call other files that had things like this in them:

Code:
public function __construct(Zend_Controller_Request_Http $request, Zend_Controller_Response_Http $response, XenForo_RouteMatch $routeMatch)
{
$this->_request = $request;
$this->_response = $response;
$this->_routeMatch = $routeMatch;
$this->_input = new XenForo_Input($this->_request);
}
I'm sure this is all great code and useful in some way but I have no idea how to actually /use/ any of it. In the end, it was a choice between simply going with what I knew and getting it done, or spending another year learning the ins and outs of OOP in PHP.

That's a constructor initializing some or all of an object's properties. This isn't PHP specific stuff you're having problems with. I've only used PHP a bit years ago for simple CRUD operations, but I can figure out what's going on. You're struggling with the OOP.



Don't let thesheeep bully you into feeling like an idiot for not understanding OOP. It's not simple. Especially not for someone with an existing background in procedural programming. OOP isn't just a few disjointed concepts, it's an entirely different mindset and way of approaching a problem. That said, If you're going to continue to maintain these forums using this software, it would probably be in your best interests to actually learn OOP.
 

DarkUnderlord

Professional Throne Sitter
Staff Member
Joined
Jun 18, 2002
Messages
28,544
That said, If you're going to continue to maintain these forums using this software, it would probably be in your best interests to actually learn OOP.
Yeah, that was pretty much the plan - only it meant committing time to it that I didn't really have and it was a greater mind-fuck than I had anticipated.
 
Self-Ejected

Kosmonaut

Lost in Space
Joined
Jul 11, 2008
Messages
4,741
Location
CCCP
... [snip] ...

Don't let thesheeep bully you into feeling like an idiot for not understanding OOP. It's not simple. Especially not for someone with an existing background in procedural programming. OOP isn't just a few disjointed concepts, it's an entirely different mindset and way of approaching a problem. That said, If you're going to continue to maintain these forums using this software, it would probably be in your best interests to actually learn OOP.

Is not only OOP, but looking at the code DU posted, the Xenforo programmers make an extensive use of other concepts, like HTTP requests/responses, Model View Controller architecture, and software patterns, that you need to be at least a little familiar with.

Moreover, and this is one of my biggest gripes with PHP: the lack of modules or namespaces support (at least in versions < 5.3) is the reason why all the objects and methods have those big-ass names.

I think that the types and variables are well named and give you the intent of what they do. It's just the Xenforo devs love for long-ass chains of indirection (objects instances calling other instances calling other instances...) and the long names that makes the code a little difficult to follow.
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom