Choosing between template files and custom module I wanted to add some custom functionality in my Drupal website, so I read some  tutorials (first, second ) and  decided to create custom template files for specific forms &amp; exposed filters I wanted to change. And it worked perfectly!

But when I had to pass the changes to the original site I had to change the code a bit, so I tried with a custom module this time (not using template files) and it also worked like a charm!

I'm confused because both templating and custom modules can be used for providing the same functionality. But which is better - in terms of stability, performance, code reuse etc. ?
That depends on what you would like to accomplish.
When it is just pure templating (markup, styling, theming) you can do this with template files just fine.

But when you want to include custom logic (programming), it is better to create a custom module where you put the hook() implementations and/or preprocess functions etc...and then define a temaplate file there.

Does this offer some clarification for you?