How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ? 
Author Message
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?

Many developers know and use ! operator in VB6 and VB.Net.
It allow to access item of a collection in a compact form using col!Name
instead of col.Item("Name") or col("Name")
More abstractly, in terms of VB/COM, it allow to invoke method Item with
string argument for any object that implements method Item, so following
forms are equivalent:
1) Object.Item("SomeString")
2) Object!SomeString

If's useful only when you know keys of elements in a collection in advance
and hardcode those names in your code.
It happens and especially useful in database applications where you know
field names and want to access them in ADO objects.
So instead of using ds.Tables("tab1").Columns("col1") you can use
ds.Tables!tab1.Columns!col1

Another possible way of use is handling XML in VB where you simply use
Root!Node1!Node2!Node3 instead of ("Root")("Node1")("Node2")("Node3")

Of course operator ! is not applicable in 2 cases:
1) when you invoke method Item with variable as an argument.
2) when string argument contain spaces

I think it's a very attractive feature which actually increase readability,
allow to write more compact code and I would like to have it in C#.
But many developers think that it reduce readability of a code and against
having it in C#.

Main points for having ! are:
1) more compact code
2) more readable code
3) freedom to chose between having static members and dynamic members (named
elements of a collection)
   with almost same syntax
4) there is no syntax problem to reuse same operator ! as boolean and [""]
in C#

Main points against ! are:
1) less readable code
2) not obvious for C++/Java/C# developers
3) breaks C# consistency as a language
4) implicit invokation
  It is bad because method Item can be redefined with possibly any
implementation.
5) it interfere with ! boolean operator in C#

I would like to hear different opinions on that matter just to know common
opinion of developers community.



Tue, 01 Feb 2005 08:20:33 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?
Is there at least one person, who love ! in VB and would feel really bad
without it ?


Tue, 01 Feb 2005 08:26:59 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?


Quote:
> Is there at least one person, who love ! in VB and would feel really bad
> without it ?

I personally despise it. It's a throwback and completely inflexible.


Tue, 01 Feb 2005 08:45:00 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?
Never use it. I never use hard-coded field names. Even if the name is
supposedly fixed I define the name as a constant and refer to it that way.


Quote:
> Is there at least one person, who love ! in VB and would feel really bad
> without it ?



Tue, 01 Feb 2005 08:55:02 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?


Quote:



> > Is there at least one person, who love ! in VB and would feel really bad
> > without it ?

> I personally despise it. It's a throwback and completely inflexible.

Are you one of those who always say "I don't like VB and anything related" ?


Tue, 01 Feb 2005 08:51:37 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?

Quote:
> I never use hard-coded field names.

This leads to the assumption that you never use any early bound languages,
such as Java or C++.  Further, it leads to the assumption that the majority
of your code looks extremely awkward.

--

Remove "nodamnspam." to e-mail me for real.


Quote:
> Never use it. I never use hard-coded field names. Even if the name is
> supposedly fixed I define the name as a constant and refer to it that way.



> > Is there at least one person, who love ! in VB and would feel really bad
> > without it ?



Tue, 01 Feb 2005 09:35:59 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?
I'm with Jeff.  It sucks rocks - very ugly indeed.

Tom Shelton



Tue, 01 Feb 2005 09:49:35 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?

<cut>

Quote:
> 2) when string argument contain spaces

object![field name]

Quote:

> I think it's a very attractive feature which actually increase
> readability, allow to write more compact code and I would like to
> have it in C#. But many developers think that it reduce readability
> of a code and against having it in C#.

I don't think it affects readability significantly either way.  I don't use
it myself, primarily because I prefer using a consistent syntax and since I
can't use ! in all cases I don't use it in any.  I also prefer to explicitly
mention the .Item and other defaults rather than relying on others to know
what those defaults are when then read the code or worry about changes in
future versions of the object model involved.  OTOH, it doesn't bother me at
all when I see it in anybody else's code.  It's just not that important an
issue for me.


Tue, 01 Feb 2005 09:50:29 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?

Quote:
> I would like to hear different opinions on that matter just to know common
> opinion of developers community.

I think it's unnecessary, on the edge of pointless, suntactic sugar.  As
expected from a language bloated with convenicence methods.

--

Remove "nodamnspam." to e-mail me for real.


Quote:
> Many developers know and use ! operator in VB6 and VB.Net.
> It allow to access item of a collection in a compact form using col!Name
> instead of col.Item("Name") or col("Name")
> More abstractly, in terms of VB/COM, it allow to invoke method Item with
> string argument for any object that implements method Item, so following
> forms are equivalent:
> 1) Object.Item("SomeString")
> 2) Object!SomeString

> If's useful only when you know keys of elements in a collection in advance
> and hardcode those names in your code.
> It happens and especially useful in database applications where you know
> field names and want to access them in ADO objects.
> So instead of using ds.Tables("tab1").Columns("col1") you can use
> ds.Tables!tab1.Columns!col1

> Another possible way of use is handling XML in VB where you simply use
> Root!Node1!Node2!Node3 instead of ("Root")("Node1")("Node2")("Node3")

> Of course operator ! is not applicable in 2 cases:
> 1) when you invoke method Item with variable as an argument.
> 2) when string argument contain spaces

> I think it's a very attractive feature which actually increase
readability,
> allow to write more compact code and I would like to have it in C#.
> But many developers think that it reduce readability of a code and against
> having it in C#.

> Main points for having ! are:
> 1) more compact code
> 2) more readable code
> 3) freedom to chose between having static members and dynamic members
(named
> elements of a collection)
>    with almost same syntax
> 4) there is no syntax problem to reuse same operator ! as boolean and [""]
> in C#

> Main points against ! are:
> 1) less readable code
> 2) not obvious for C++/Java/C# developers
> 3) breaks C# consistency as a language
> 4) implicit invokation
>   It is bad because method Item can be redefined with possibly any
> implementation.
> 5) it interfere with ! boolean operator in C#

> I would like to hear different opinions on that matter just to know common
> opinion of developers community.



Tue, 01 Feb 2005 10:02:42 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?
Not at all

I prefer:
Const MyField = "XXX'
    :

value = rs(MyField)

to
value = rs!XXX

In practice, field names change over time. Keeping the names defined in one
spot makes maintenance much easier.


Quote:
> > I never use hard-coded field names.

> This leads to the assumption that you never use any early bound languages,
> such as Java or C++.  Further, it leads to the assumption that the
majority
> of your code looks extremely awkward.

> --

> Remove "nodamnspam." to e-mail me for real.



> > Never use it. I never use hard-coded field names. Even if the name is
> > supposedly fixed I define the name as a constant and refer to it that
way.



> > > Is there at least one person, who love ! in VB and would feel really
bad
> > > without it ?



Tue, 01 Feb 2005 10:23:37 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?

Quote:
> In practice, field names change over time.

On the contrary, in late-bound languages, they don't.  Code in general
changes over time as it evolves and matures; does this mean that you should
put everything in strings and evaluate it dynamically?

10 What about the identifiers that you use for the strings?
20 They change as often as the field names; does this mean that you should
put the names of them in strings?
30 Goto 10.

--

Remove "nodamnspam." to e-mail me for real.


Quote:
> Not at all

> I prefer:
> Const MyField = "XXX'
>     :

> value = rs(MyField)

> to
> value = rs!XXX

> In practice, field names change over time. Keeping the names defined in
one
> spot makes maintenance much easier.



> > > I never use hard-coded field names.

> > This leads to the assumption that you never use any early bound
languages,
> > such as Java or C++.  Further, it leads to the assumption that the
> majority
> > of your code looks extremely awkward.

> > --

> > Remove "nodamnspam." to e-mail me for real.



> > > Never use it. I never use hard-coded field names. Even if the name is
> > > supposedly fixed I define the name as a constant and refer to it that
> way.



> > > > Is there at least one person, who love ! in VB and would feel really
> bad
> > > > without it ?



Tue, 01 Feb 2005 10:31:37 GMT  
 How do you use ! in VB ? Do you like ! in VB ? Would you like to have it in C# ?


Quote:
> > In practice, field names change over time.

> On the contrary, in late-bound languages, they don't.  Code in
> general changes over time as it evolves and matures; does this
> mean that you should put everything in strings and evaluate it
> dynamically?

> 10 What about the identifiers that you use for the strings?
> 20 They change as often as the field names; does this mean that
> you should put the names of them in strings?
> 30 Goto 10.

ROTFL :-)))

Massimo



Tue, 01 Feb 2005 10:47:17 GMT  
 
 [ 36 post ]  Go to page: [1] [2] [3]

 Relevant Pages 

1. Visual Liking in .Net using TREE VIEW control

2. Copy read-only liked tables

3. DDE and the likes

4. Likes CAT and Sport Query

5. Doing a data search using VB 3.0?

6. Doing AbstractFactory using VB's Implements Keyword?

7. Noone likes newbies??

8. TOOLBAR LIKES IE3.0

9. Outlook liked form design

10. Structured storage - done it using VB?

11. Outlook liked form design

12. Outlook liked form design

 

 
Powered by phpBB® Forum Software