Reputation: 14897
I'm programming in an ASP.NET environment and Im thinking of separating my utility functions into 3 classes - Presentation.cs, Business.cs, Data.cs. What do you think? How do you organize your utility functions?
Upvotes: 3
Views: 676
Reputation: 296
Normally my class composition is decided by looking at the type of data used or the relationships between the methods I have to organize.
I then wrap my utility classes in a .Utilities namespace and separate them physically into a folder with the same name.
This usually implies that anything contained is used for utility purposes.
Upvotes: 0
Reputation: 17022
That depends on what they do. Largely, I group my utility functions into classes based on what they operate on. I tend to ignore the guideline that specifies a minimum number of methods per class; if it makes sense for a method to belong to a class because it operates on a specific type of data, then it goes into a class, number of methods be damned.
However, these days, utility methods are typically prime candidates for extension methods. So that factors in quite frequently.
Upvotes: 3
Reputation: 755141
I organize my utility functions based on the type of data they process. I also give the class and file name the Util suffix to distinguish it as a general purpose utility class. For instance
Upvotes: 4