Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
STATIC (shared) versus non static
Message
 
To
14/07/2014 01:41:09
General information
Forum:
ASP.NET
Category:
Class design
Environment versions
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01603606
Message ID:
01603749
Views:
37
Viv, Anatoly,Bill and Gregory thank you very much. I think I got it now. I was just surprised that in the literature, it is rare that you see examples implemented with static "things". So unless it slaps you in the face that "it"'s static, .... "it"'s not. (you can quote me :) ) is my conclusion.

>>I wonder what the best practice would be when it comes to declare classes (and more importantly methods) static. I have found that in most cases pundits declare non static classes and methods where it would be perfectly workable to have them static.
>>
>>The way I see it is that static is easier to test no?
>
>In addition to the rest of the replies
>
>Static means not related or specific to an instance
>
>eg: a Person class
>
>Instance properties/methods would be Name, BirthDate, address, etc since that are 'things' that belong to a specific Person ( or instance)
>We do not have the same name, do we ?
>A method like CalculateAge() or GetAge() would not be static since it would use the (instance) property DateOfBirth
>
>CalculateAge() could be static when it would accept dateOfBirth as a parameter
>
>Static means applicable to any instance, ie not needing instance properties
>
>Static does not necessarily mean that it is easier to test - the only difference is that you don't have to instantiate the class before using it

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Previous
Reply
Map
View

Click here to load this message in the networking platform