0

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.

1

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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