Last post Feb 07, 2011 04:21 AM by sandy060583
Feb 04, 2011 06:51 AM|Studentno00|LINK
Feb 04, 2011 07:05 AMfirstname.lastname@example.org|LINK
From MSDN http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.80).aspx
"Static classes and class members are used to create data and functions that can be accessed without creating an instance of the class. Static class members can be
used to separate data and behavior that is independent of any object identity: the data and functions do not change regardless of what happens to the object. Static classes can be used when there is no data or behavior in the class that depends on object identity."
1) Well this depends on how you are really calling your methods, you can use static methods if you do not have any reason to create an instance of the class. There is nothing wrong with this approach.
2) Not a problem if the static methods are setup correctly. Each user whether the method is static or not will have the same affect on the underlying datasource (XML, DB etc)
Seems you are on the right track, hope this helps
Feb 04, 2011 09:00 AM|Studentno00|LINK
Thanks for the answer.
Feb 07, 2011 04:21 AM|sandy060583|LINK
Answer to Query 2 :
There's no particular effect on concurrency. The same rules are true: mutating shared data concurrently is bad. If you have instance methods but they don't mutate anything, you're fine.
There's a difference in general design though - static methods should almost always be thread-safe (i.e. you should
make them thread-safe) whereas instance methods don't generally have to be (although you should document your class's thread-safety).
Hope this will help !!!