Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

So I'm reviewing a piece of code that is a perfect candidate to be abstracted away into a view helper. However at the moment, the piece of code uses two other view helpers to get the final display.

Now my question is, if a new view helper is created, is it recommended to inject the two helpers being used already, into the one created to get the final result needed?

I've not seen anything for or against, my initial feelings were that the code probably needs refactoring, but I don't think the dev will be willing to, so what I have outlined seemed like a nice middle ground.

share|improve this question
add comment

1 Answer

I don't particularly like the ideas of a) duplicating code, b) having a view helper that has a coupling dependency to two other view helpers. Either write code to handle the needs in the singular view helper, or refactor and extend an abstract view helper in each implementation so all three classes can access the same functions in their appropriate scopes and the next developer can follow the code without a non-best practices hacked up solution.

share|improve this answer
add comment

Your Answer

 
discard

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.