Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing an MVC framework. I have a folder full of library classes, each are self contained, and could be ripped out of the framework and used by themselves. The only problem is that a few of these libraries (benchmarking, unit testing) display HTML to report results.

I am wondering, do I display this HTML in a view file, or hard code it into the class? If I use view files, these modules will no longer be able to be used by themselves, and will require the print_view() method found in another class. If I hard code this HTML into the library class however, the class becomes difficult to read, as well as makes it harder to modify the design aspects of the reports.

Any suggestions/thoughts?

share|improve this question

A testing/benchmarking reporting tool should use its own output framework and not rely on that of the main site/application.

So, absolutely don't use your "print_view" method (as you call it) from the main site to output library analysis HTML (this would be a reverse/circular dependency), but absolutely do embed some kind of view/output engine into the libraries that provide output. You are correct to want to avoid embedding HTML into your benchmarking/testing libraries.

This embedded output engine could be:

  • Something quick and dirty (inside a function, extract template var array + include PHP template file)
  • A lightweight MVC framework
  • A copy of your website framework (though being different in purpose it's probably not ideal).
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.