keeping helper functions inside controller

I have following two helper kind of functions in my controller :

 private String snippetFilename(String title, String mode) {
        String filename = title.replaceAll("\\s", "_").replaceAll("\\W", "");
        String extension = metaData.getExtensions(mode);
        filename += "." + extension;
        return filename;

    private void parseHtml(Snippet snippet) {
        snippet.setText(StringUtils.replaceEach(snippet.getText(), new String[]{"&", "\"", "<", ">"}, new String[]{"&amp;", "&quot;", "&lt;", "&gt;"}));

Open in new window

My controller functions do make use of this ?
Is it fine to keep them in controller  ?

Rohit BajajAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't see the problem in keeping them in the controller.
A controller is after all just a java class like any other.
mccarlIT Business Systems Analyst / Software DeveloperCommented:
I agree too that it would be fine.

However, another possibility is to just move the "parseHtml" method to be a method within your Snippet class. This is because it only modifies Snippet's text field and it doesn't require any other input in order to do what it does. Or in other words, it only reads/writes to a field in the Snippet class and so it could belong there.

The only differences are that you would make it "public" so it can be called from outside the Snippet class, and it wouldn't take a Snippet parameter, because you call the method ON the snippet that you want to update.

Also, looking at what you are doing there, whether you move it or not, you either need to make VERY sure that you only ever call that method once, or you should enhance the method so that if it were to be called multiple times (by mistake) it doesn't screw it up. At the moment, if it were called twice on a String with an & you would get this situation...

Tom & Jerry   -->   Tom &amp; Jerry   -->   Tom &amp;amp; Jerry

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.