Question on programming style

  • Thread starter Thread starter Dom
  • Start date Start date
D

Dom

Sometimes I need only a single method in a class. And since I like to
be nice and neat, I find myself writing things like this:

int Index = new MyClass().GetIndex();

Is this considered bad form?
 
Sometimes I need only a single method in a class. And since I like to
be nice and neat, I find myself writing things like this:

int Index = new MyClass().GetIndex();

Is this considered bad form?

Not necessarily, but it is more likely to end up with an error in some
cases.

If the method is simply a "helper" method, you are better to use static
routines:

public static int GetIndex()
{
}

if possible. There are some potential downsides here, but it is fairly
useful when the method is truly a "helper" method.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

My vacation and childhood cancer awareness site:
http://www.crazycancertour.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top