I have a selection of utility classes that I have written, one for each section of my web application. For the section on engineer reporting I have a reporting utility class, for the section on documentation I have a documentation utility class. These classes
contain the data access layer and do all of the database access.
I was about to add a section into one of my classes that will do image manipulation and this code is quite heavy in what it does. I was wondering, does it make sense to put this heavy image manipulation part in a utility class? Should I seperate this off
to another class or module for performance? I do not want to create thread blocking or simlary by having this class working on image manipulation for user A in such a way that user B cannot do anything until user A's action is complete.
My approach would be to put the new method where it logically belongs. In other words, I would put an image manipulation method into an image class. If I didn't have one, I'd create it.
I think your concerns about simulanteous use are unfounded. Each user will get their own instance of the class.
Marked as answer by UselessChimp on Jan 01, 2013 01:57 PM
That is a perfect idea. Thank you very much for pointing out that my image functions really belong in an image class, perfect!
I did not know each user gets their own instance of a shared class, this is useful information to know, but that said why is it sometimes said that shared classes are not thread safe if each use gets their own instance of it?
UselessChimp
Member
210 Points
110 Posts
ASP.Net Performance of Utility Classes
Dec 31, 2012 03:44 PM|LINK
Hello all,
I have a selection of utility classes that I have written, one for each section of my web application. For the section on engineer reporting I have a reporting utility class, for the section on documentation I have a documentation utility class. These classes contain the data access layer and do all of the database access.
I was about to add a section into one of my classes that will do image manipulation and this code is quite heavy in what it does. I was wondering, does it make sense to put this heavy image manipulation part in a utility class? Should I seperate this off to another class or module for performance? I do not want to create thread blocking or simlary by having this class working on image manipulation for user A in such a way that user B cannot do anything until user A's action is complete.
Dan Bracuk
Contributor
3970 Points
1096 Posts
Re: ASP.Net Performance of Utility Classes
Dec 31, 2012 04:19 PM|LINK
My approach would be to put the new method where it logically belongs. In other words, I would put an image manipulation method into an image class. If I didn't have one, I'd create it.
I think your concerns about simulanteous use are unfounded. Each user will get their own instance of the class.
UselessChimp
Member
210 Points
110 Posts
Re: ASP.Net Performance of Utility Classes
Jan 01, 2013 01:56 PM|LINK
That is a perfect idea. Thank you very much for pointing out that my image functions really belong in an image class, perfect!
I did not know each user gets their own instance of a shared class, this is useful information to know, but that said why is it sometimes said that shared classes are not thread safe if each use gets their own instance of it?