Static function
-
hi everybody, I would like to ask a question here. Is Static function advantage or disadvantage ? How are they disadvantage ? Shuold I use many static function in a program ? Thank for answering my questions , Sincerely,
-
hi everybody, I would like to ask a question here. Is Static function advantage or disadvantage ? How are they disadvantage ? Shuold I use many static function in a program ? Thank for answering my questions , Sincerely,
dinh van hai wrote:
Is Static function advantage or disadvantage ?
Depends on the context. Static functions are useful for factory methods like Create, which create and return appropriate objects.
dinh van hai wrote:
How are they disadvantage ?
Static functions are like global functions, only that their scope is restricted to the class. So too many static functions and the class then becomes a dumping ground where you keep adding functions that don't fit elsewhere.
dinh van hai wrote:
Shuold I use many static function in a program ?
Of course you can. You can take the system defined static functions, like File.Create as a starting point. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
hi everybody, I would like to ask a question here. Is Static function advantage or disadvantage ? How are they disadvantage ? Shuold I use many static function in a program ? Thank for answering my questions , Sincerely,
how do static functions affect the performence and memory of our program ?
-
hi everybody, I would like to ask a question here. Is Static function advantage or disadvantage ? How are they disadvantage ? Shuold I use many static function in a program ? Thank for answering my questions , Sincerely,
If the function doesn't use any data from the instance of the class, it should be static, so that you don't have to create an object just to call the function. Declaring a function as static also supplies the information that the function is self-contained and doesn't need any data from an object. --- b { font-weight: normal; }