What do you think of repetitive method signatures?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

eg.

enum ButtonPress{Start, Stop, Pause};

void OnButtonPress(ButtonPress buttonPress) // <--- repetetive signature

It looks a bit ugly, and I know some programmers who would go ballistic at
the sight of this, but, in my experience, each of the three repetitions is
justified in itself, and overall, life is smoother if we just type it out,
and keep going without worrying about it.

btw. at the other end of the spectrum is the programmer who uses extreme
overloading. His approach would be...

void on(ButtonPress item);
 
Javaman59 said:
eg.

enum ButtonPress{Start, Stop, Pause};

void OnButtonPress(ButtonPress buttonPress) // <--- repetetive signature

If it works, and it's clear, retaining a sense of pragmatism is no bad
thing. The signature you've written seems perfectly readable. If it was a
small method, I'd be tempted to change it to

void OnButtonPress(ButtonPress bp)
It looks a bit ugly, and I know some programmers who would go ballistic at
the sight of this, but, in my experience, each of the three repetitions is
justified in itself, and overall, life is smoother if we just type it out,
and keep going without worrying about it.

btw. at the other end of the spectrum is the programmer who uses extreme
overloading. His approach would be...

void on(ButtonPress item);

There are only two things in life that I hate; people who are intolerant of
other people's programming styles, and people who use too much overloading.
;¬)

If your code is clear, there are usually bigger things to worry about.

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
 
according to MS's naming conventions you would have to name the class
"ButtonPressEventArgs".
 
thing. The signature you've written seems perfectly readable. If it was a
small method, I'd be tempted to change it to

void OnButtonPress(ButtonPress bp)

I've kept this suggestion in mind for the last few days, and I'm starting to
think that I like it. I notice that the System.EventHandler delegate has the
signature...

public delegate void EventHandler(
object sender,
EventArgs e
);

I've just written a procedure with this signature...

void Parse(char ch)

So, perhaps I would lean towards using an abbreviation for the parameter
name when the purpose of the parameter is obvious, or if it overall makes the
code look a bit cleaner.
 
Back
Top