Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you store your helper classes in a separate assembly?

I just want to know if anyone stores their helper classes or methods in a separate assembly and why...just for clean management of them? I've seen so many posts about using a helper folder inside your MVC project and that brings me back to the messy old days in ASP.NET where people were using an App_code folder instead of cleanly separating things out physically like this into its own project.

And likewise nobody doing real architecture is going to put models in some folder in your MVC web assembly. They would go in MyApp.DataLayer assembly or MyApp.Models or something like this.

like image 846
PositiveGuy Avatar asked Feb 21 '10 03:02

PositiveGuy


People also ask

What is helper class in ASP net?

The HtmlHelper class renders HTML controls in the razor view. It binds the model object to HTML controls to display the value of model properties into those controls and also assigns the value of the controls to the model properties while submitting a web form.

What is helpers in c#?

A helper method is just a method that helps you do something else. For example, if you had to find the square root of a number multiple times within a method, you wouldn't write out the code to find the root each time you needed it, you'd separate it out into a method like Math.


3 Answers

Yes, but for reasons, which are common to other assemblies as well

  • Becomes easy to plug into any other project.(might need some editions).
  • Reusable
  • Easy to improve
  • Easy to refractor
  • As not part of a project, but project itself, it is easy to document and easy for developers to understand
  • Clears out some of the mess

But for all that above, your assembly, when ready, should be a "job well done", other wise, it is better to keep the helper classes to where they belong.

like image 110
Asad Avatar answered Oct 11 '22 10:10

Asad


We have some helpers in a separate project and some in the web project. I think you'll find that some of your helpers need to use abstractions that you've defined in your web project itself. And that will often force you to put those helpers into the web project, because it's not likely desirable to have some other project that has a reference to the web project. I don't consider it the same as using App_Code. These are files that are compiled at compile time inside your IDE, with no special "magic" that gets applied to App_Code.

like image 26
Charlie Flowers Avatar answered Oct 11 '22 11:10

Charlie Flowers


I use projects to separate out the different layers in my web or form apps. It allows me to respect the business rules better. Also I find it easier to track down where I need to go if I want to make a change.

But I have seen people use folders that label the layers in the solution but I think that is a little messy.

like image 25
JPJedi Avatar answered Oct 11 '22 11:10

JPJedi