To Build Extensions Or Not

I started this topic mainly because I was wondering if it would be a good idea to build all possible components/classes as Yii extensions. The reason behind this is since we are suppose to write modular/reusable code, writing extensions will encourage, to some degree, improved re-usability. Not only is it easy to plug into other projects, you can share them as open source projects. Such cases can be seen in the jQuery community.

So what are your opinions on this? Please state your for and against reasons.

I can’t agree with “all possible” part but generally writing part of code as an extension gives you a lot of pros:

  • Reusability.

  • More thought.

  • Can be shared with community to get feedback/testing/karma.

From my experience there is one con: time. To make code reusable you need more time. To share with community you need to document extension. That’s even more time.

From the other side, this extra time worth it since reusability and community feedback will give you more in a long term.


if (!similar_extension_exists())

    create_extension();

else if(!existing_extension_perfect() && !author_open_to_suggestions())

    create_extension();

else

    help_to_improve_existing_extension();