Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Try Vanilla Forums Cloud product

hbf · wiki guy? · MVP


Last Active
Member, Developer
  • Re: How to modify an old plugin for 2.1

    @hgtonight said:
    Themehooks traditionally implement the IPlugin interface. Like Todd said in that post, there are times when it is needed.

    If a class has a parent class that doesn't extend the plugin class, it will have to implement the interface (due to PHP language construct restraints).

    it's not really a PHP language construct constraint the requires you to implement the interface when declaring an extension class of a parent class which does not implement the interface you need... it's OOP by definition. you just cant implicitly cast an object from one class to another without some declaration and member implementation. Otherwise you'd end up with all sorts of null references and bad pointers.

    From a software design perspective, you can get around the extends/implements construct if you wanted to brute force everything as objects. Every class extends object so you can always cast back to object and use reflection to get at the properties and methods that you want. This is a form of late binding that can be useful when you dont have a shared interface contract or cant really know what you are going to get before runtime. but it costs a lot in terms of performance and robustness.

    there's a time and a place for everything.

  • Re: How to modify an old plugin for 2.1

    im not aware of any oop language that allows multiple inheritance (it may exist, i just dont understand how it would work from a CS perspective). you can only really have one parent type, then you can implement as many interfaces you want. the adding of new interfaces is one way to extend the parent class.

  • Re: How to modify an old plugin for 2.1

    @vrijvlinder said:
    It still is a bit confusing to me... but thanks for correcting me :)

    basically the difference is between inheritance and implementation

    in laymans terms:

    implementation means there is a class [Class Gdn_IPlugin] that describes a set of interfaces (in this case an interface refers to public methods or properties that can be accessed by any consumer). This class is referred to as an interface, and generally uses the naming practice of beginning with i or I. Any new class which implements this interface MUST explicitly declare and expose all public methods and properties described in the interface. By doing this and by declaring implements ixxxx in the class declaration, you have told the world that they can cast you to this known interface, and the the public properties defined by the interface will always be present.

    the idea of extends means that you are inheriting the behaviors and properties of some parent class. In this case, if the parent class already implements the Gdn_IPlugin then you are golden, since that is the critical interface. However if you extend a parent class which does not implement Gdn_IPlugin, you will need to implement it yourself. Now, with most plugins you will extend a base class Gdn_Plugin which by definition is the most fundamental implementation of IPlugin, but sometimes that won't be the case, and therefore the plugin framework can't cast your object to the interface and thus you dont actually have a plugin.

    The inheritance and implementation concepts are pretty fundamental to object oriented programming. I'd suggest doing a lot of reading on them as they are really fun ideas that provide tremendous amounts of power to modern programming.

    IMHO PHP does not make these concepts very accessible to the novice, if you are learning OOP you are better off in a managed, tightly constructed and well templated language like C#. you can download the Express version for free from Microsoft. it's pretty killer.

  • Re: POLL: Which do you think is better? Removing or Banning users?

    remove to get rid of the user profile, add info to stop forum spam and internal ban list.

  • Re: Adding meta description to the forum home page.

    all of my plugins start as a copy paste from the most similar thing i can find. i never hit file->new