bmcclure / CakePHP-Menu-Plugin

A CakePHP 2.0 plugin designed to help build menus in the controller and display them in the view
MIT License
17 stars 9 forks source link

Consider removing MenuItem classes #7

Open bmcclure opened 12 years ago

bmcclure commented 12 years ago

MenuItem might be overkill.

The Menu class serves a purpose in referencing a MenuRenderer, containing settings and meta information about a menu, and containing the menu items themselves.

The MenuItem classes, however, really only contain properties about a menu item and a reference to a MenuItemRenderer.

Perhaps it would be better for application performance if a MenuItem was simply an array of properties (containing at least a 'title' and 'url' property, an option 'renderer' property, and potentially others depending on the renderer you're using.).

The class doesn't do anything other than create an inheritance tree and allow MenuItemRenderers to only render certain types of MenuItems. This can be done just as easily with a check for a required property in the array.

But would the performance benefits of eliminating that entire class tree outweigh the potential clarity and extensibility of keeping them as classes serving a specific purpose instead of generic array items?

bmcclure commented 12 years ago

The way they are now feels more OO to me, but is it worth doing OO just for the sake of OO, or would array items work equally well in all cases?

I need to consider this...