473,473 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What do you think of repetitive method signatures?

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);

Nov 17 '05 #1
5 1106
"Javaman59" <Ja*******@discussions.microsoft.com> wrote in message
news:35**********************************@microsof t.com...
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
Nov 17 '05 #2
Thanks Tim, that settles it for me.
people who use too much overloading.


Yup! :))

- Stephen

Nov 17 '05 #3
Seems perfectly fine to me and perfectly readable.

Brian Delahunty
Ireland

"Javaman59" wrote:
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);

Nov 17 '05 #4
according to MS's naming conventions you would have to name the class
"ButtonPressEventArgs".
"Javaman59" <Ja*******@discussions.microsoft.com> schrieb im Newsbeitrag
news:35**********************************@microsof t.com...
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);

Nov 17 '05 #5
> 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.

"Tim Haughton" wrote:
"Javaman59" <Ja*******@discussions.microsoft.com> wrote in message
news:35**********************************@microsof t.com...
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

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

56
by: Xah Lee | last post by:
What are OOP's Jargons and Complexities Xah Lee, 20050128 The Rise of Classes, Methods, Objects In computer languages, often a function definition looks like this: subroutine f (x1, x2, ...)...
31
by: N.Davis | last post by:
I am very new to Python, but have done plenty of development in C++ and Java. One thing I find weird about python is the idea of a module. Why is this needed when there are already the ideas of...
2
by: Martin Høst Normark | last post by:
Hi everyone Has anyone got the least experience in integrating the Digital Signature with an ASP.NET Web Application? Here in Denmark, as I supose in many other countries, they're promoting...
19
by: Fernando Cacciola | last post by:
I'm puzzled, Why and how _exactly_ is this: void Foo<T>(T v ) where T : Interface/Value/Class/class any better than this void Foo( Interface/Value/Class/object v )
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
14
by: =?Utf-8?B?QUEyZTcyRQ==?= | last post by:
Am I correct in thinking that the <signatureof a function is its <syntax> i.e. the arguments and the order in which they are specified when calling the function?
9
by: Jonathan Wood | last post by:
I found the following class on the Web: public class LoginRewriter : IHttpModule { void IHttpModule.Dispose() { } void IHttpModule.Init(HttpApplication app) { app.AuthorizeRequest += new...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.