Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"virtual public" vs "public virtual"

1 view
Skip to first unread message

Jon Shemitz

unread,
Feb 23, 2004, 10:26:37 PM2/23/04
to
Syntax seems to say "modifiers is modifiers" and either is valid, but
Google searches seem to show that "public virtual" is more common.

Is there any sort of (semi) official convention?

--

programmer, author http://www.midnightbeach.com
and father http://www.midnightbeach.com/hs

fbhcah

unread,
Feb 23, 2004, 10:51:05 PM2/23/04
to
The generally followed convention is:

<access specifier><override/virtual/abstract...><return-type><Method name> (<params>)

This convention is what I had seen almost always which may be considered as official :). But nevertheless, some ppl (though very rare) do use the other one too.

Regards,
fbhcah

Andreas Huber

unread,
Feb 24, 2004, 3:11:48 AM2/24/04
to
Jon Shemitz wrote:
> Syntax seems to say "modifiers is modifiers" and either is valid, but
> Google searches seem to show that "public virtual" is more common.
>
> Is there any sort of (semi) official convention?

I guess there isn't. However, many C#ers are coming from C++ where you had
to split the interface into public, protected and private *sections*:

class X
{
public:
void F();
void Y();
protected:
void Z();
private:
int x;
};

So having the access specifier first is more natural, to people coming from
C++, that is...

Regards,

Andreas

P.S. I'm unsure whether Java has any restrictions here...

Jon Skeet [C# MVP]

unread,
Feb 24, 2004, 3:39:20 AM2/24/04
to
Andreas Huber <ah2...@gmx.net> wrote:
> P.S. I'm unsure whether Java has any restrictions here...

Nope. So long as the return type is immediately before the method name,
the rest is fine.

The conventions are the same though.

--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Michael S

unread,
Feb 24, 2004, 3:51:06 AM2/24/04
to

"Andreas Huber" <ah2...@gmx.net> wrote in message
news:403b0738$1...@news.bluewin.ch...

> Jon Shemitz wrote:
> So having the access specifier first is more natural, to people coming
from
> C++, that is...
>
> Regards,
>
> Andreas
>
> P.S. I'm unsure whether Java has any restrictions here...

Java does not have any such restrictions (except virtual is not a keyword as
everything is virtual in Java).

However, as Java, Delphi, Visual Basic and just about every language there
is have as convention of specifying scope before modifiers and I would hate
to see 'virtual public' being used. For me, it simply looks wrong.

Programmers looking for modifiers will scan the second word first, why
confuse them. =)

- Michael S

0 new messages