With - End with block in C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zeljko

    #16
    Re: With - End with block in C#

    Sure I do - but I still miss with when I want it and need it as in the
    previous example :) Anyhow - I already sound too picky - lack of with
    block is something I can live with :) Just wondered why they left it
    out. The article Jon posted pretty much explained their reasons

    Zeljko.


    On Tue, 28 Oct 2003 10:11:32 -0600, "Cowboy \(Gregory A. Beamer\)"
    <NoSpamMgbworld @comcast.netNoS pamM> wrote:
    [color=blue]
    >No! It would be an interesting addition, but it is not there. Overall, if
    >you start working with constructors, you will find that you do not need with
    >blocks anyway. ;->[/color]

    Comment

    • Zeljko

      #17
      Re: With - End with block in C#

      BTW, what did u mean by "It gets easier in the next version of .NET, "
      ?

      Zeljko
      On Tue, 28 Oct 2003 10:12:09 -0600, "Cowboy \(Gregory A. Beamer\)"
      <NoSpamMgbworld @comcast.netNoS pamM> wrote:
      [color=blue]
      >It gets easier in the next version of .NET, but C# will not ever be the same
      >as VB.NET. You have to make some language decisions.[/color]

      Comment

      • Kerry Sanders

        #18
        Re: With - End with block in C#

        >See http://www.gotdotnet.com/team/csharp.../ask.aspx#with[color=blue]
        >for the reasons it's not in C#.[/color]


        Good link. I had not seen that before now, Jon. Thanks for the post.

        Comment

        • Kerry Sanders

          #19
          Re: With - End with block in C#

          >Only if you don't value readability. I believe that "with" reduces[color=blue]
          >readability - and over the course of some code's lifetime, far more of
          >the time is likely to be spent reading it than typing it.[/color]


          Yes... over the code's lifetime, I would venture that far more time is going to
          be spent reading it by people other than the original coder. :)

          Been there, done that.

          Comment

          • ozbear

            #20
            Re: With - End with block in C#

            On Tue, 28 Oct 2003 16:21:49 +0100, Zeljko <trashbox4@yaho o.com>
            wrote:
            [color=blue]
            >Hi,
            >
            >I moved from VB6 to C# recently, and am very satisfied with the
            >result. However, I miss this one feature. The closest thing I could
            >find is "using" statement, but it requires object to implement
            >IDisposable interface, and it won't save me the trouble of typing the
            >variable name. What I want to do is something similar to this vb6
            >block of code:
            >
            > Dim a as class1
            > set a = new class1
            > with a
            > .dothis
            > .dothat
            > .propertyx = 1
            > end with
            >
            >Does the similar feature exist in C#, or no ?
            >
            >Best regards,
            >
            >Zeljko[/color]

            "With" is an abomination and should be cast into the pits of hell.

            It creates maintenance nightmares and no professional would ever
            use it in any language that supports it.

            Oz

            Comment

            • Jon Skeet [C# MVP]

              #21
              Re: With - End with block in C#

              ozbear <ozbear@no.bigp ond.spam.com> wrote:[color=blue]
              > "With" is an abomination and should be cast into the pits of hell.
              >
              > It creates maintenance nightmares and no professional would ever
              > use it in any language that supports it.[/color]

              I'm sure you're holding back... why don't you tell us what you really
              think? ;)

              --
              Jon Skeet - <skeet@pobox.co m>
              Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

              If replying to the group, please do not mail me too

              Comment

              • Steve Jorgensen

                #22
                Re: With - End with block in C#

                On Tue, 28 Oct 2003 10:18:59 -0600, "Cowboy \(Gregory A. Beamer\)"
                <NoSpamMgbworld @comcast.netNoS pamM> wrote:
                [color=blue]
                >This is a good point, but you have to ask yourself a couple of questions:
                >
                >1. Which methodology is more explicit? Overall, explicit code is less buggy
                >and easier to read.[/color]

                I disagree. Code that says more in fewer words is easier to read. A with
                block can be abused, but a reasonably short With block in ol' VB is a very
                good thing. It removes duplication which removes a chance of a
                hard-to-find typo, particularly when modifying code later.
                [color=blue]
                >2. Which methodology is easier to maintain? I find most people that heavily
                >use "with" in Visual Basic are pretty much being lazy.[/color]

                Most? I don't know. Almost any good feature can be abused by someone
                being lazy. Again, I'm not saying With should be added to C#, but I'd
                argue it was more of a good thing than a bad one in VB.
                [color=blue]
                >With the OleDb command params, I generally use one of the following
                >methodologie s:
                >
                >1. Create a code generator based on the stored procedure. A poor man's
                >version can be created with SQL Query Analyzer and Excel (or Access builder,
                >et al)
                >
                >2. Create a generic layer that matches sproc params with a list of some type
                >(dictionary, hashtable, et al) so I do not have to create the params
                >programaticall y.
                >
                >3. Use the Microsoft.Appli cationBlock.Dat a project, which gives some neat
                >overloads to set up params (and caches parameters).
                >
                >I find, more and more, that I am coding code generators that build the
                >repetitive code for me. Sure, there are times I have to hand code a few
                >params, but the coding is simple, so I am not too worried. With saves me
                >about three keystrokes each line in my coding standard, so it is not a big
                >deal. If you use less explicit code techniques, you may see a greater
                >keystroke savings.[/color]

                All sound like good suggestions to me.

                Comment

                • Shawn B.

                  #23
                  Re: With - End with block in C#

                  Its amazing how most C# programmers (in their humble opinion) view the
                  "with" as degrading or at least, not adding to, the readibility of code but
                  most VB programmers think it does. Therefore it doesn't technically work
                  either way, it's all in the perception of those who want/like/accept the
                  feature and those who don't want/like/accept the feature, but not a
                  technical one. It's a philisophical one.


                  Thanks,
                  Shawn


                  "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
                  news:MPG.1a08a0 66b1cca0cc98997 6@msnews.micros oft.com...[color=blue]
                  > Zeljko <trashbox4@yaho o.com> wrote:[color=green]
                  > > Right, they don't share anything, but the fact that a block of code is
                  > > somehow related to a particular object.[/color]
                  >
                  > Or objects - you can have multiple objects in a using construct.
                  >[color=green]
                  > > I miss it because I'm lazy -
                  > > typing . instead of typing first few letters and pressing ctrl+space
                  > > is a much faster thing to do. That's a great feature, if u ask me :)[/color]
                  >
                  > Only if you don't value readability. I believe that "with" reduces
                  > readability - and over the course of some code's lifetime, far more of
                  > the time is likely to be spent reading it than typing it.
                  >
                  > As Steve said - if you're doing a whole load of operations with a
                  > single object, chances are that functionality should be encapsulated
                  > within the object itself.
                  >
                  > --
                  > Jon Skeet - <skeet@pobox.co m>
                  > http://www.pobox.com/~skeet
                  > If replying to the group, please do not mail me too[/color]


                  Comment

                  • Shawn B.

                    #24
                    Re: With - End with block in C#

                    Why? I"ve never had a problem doing so. It's a great conveniece and have
                    never in 7 years working with VB suffered a single lost second of
                    productivity as a result of its presence. I never "rely" on it, but I do
                    take advantage of the features a tool offers as they are there for a reason.
                    I've never once in my memory suffered from not being able to read code that
                    used a "with".

                    I hear no end to the arguments of C# developers saying how difficult it is
                    to read. In my experience, I agree, I have worked with many C# and Java
                    developers who struggle to no end. My take? Adapt and move on. Most VB
                    programmers don't struggle as much as I've personally witnessed non VB
                    programmers struggle with it. I'm not making a blanket statement. This is
                    just an observation based on experience, is all.

                    Me? I'm primarily an Assembly and C++ programmer, who gets paid well to do
                    VB and C#. I enjoy all the features of all the languages and often pick the
                    best tool for the job when given the choice. When not given the choice, I
                    use the features available.


                    Thanks,
                    Shawn



                    "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld @comcast.netNoS pamM> wrote in
                    message news:%23KFIH9Wn DHA.392@TK2MSFT NGP11.phx.gbl.. .[color=blue]
                    >
                    > "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
                    > news:MPG.1a08a0 66b1cca0cc98997 6@msnews.micros oft.com...[color=green]
                    > >
                    > > As Steve said - if you're doing a whole load of operations with a
                    > > single object, chances are that functionality should be encapsulated
                    > > within the object itself.[/color]
                    >
                    >
                    > And, if these are properties you are setting, you should consider creating[/color]
                    a[color=blue]
                    > constructor that allows you to set the properties at instantiation rather
                    > than relying on a "with" construct.
                    >
                    > --
                    > Gregory A. Beamer
                    > MVP; MCP: +I, SE, SD, DBA
                    >
                    > *************** *************** *************** *************** **********
                    > Think Outside the Box!
                    > *************** *************** *************** *************** **********
                    >
                    >[/color]


                    Comment

                    • Shawn B.

                      #25
                      Re: With - End with block in C#

                      It won't because it's not the same language. That never stopped a language
                      designer from "borrowing" features of other languages. "With" is not unique
                      to VB. It also exists in JScript and JScript.NET. The syntax of it in
                      JScript can be improved, though. Nonetheless, that only proves its not a
                      VB only feature.


                      Thanks,
                      Shawn



                      "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld @comcast.netNoS pamM> wrote in
                      message news:OTSVE9WnDH A.392@TK2MSFTNG P11.phx.gbl...[color=blue]
                      > It gets easier in the next version of .NET, but C# will not ever be the[/color]
                      same[color=blue]
                      > as VB.NET. You have to make some language decisions.
                      >
                      > --
                      > Gregory A. Beamer
                      > MVP; MCP: +I, SE, SD, DBA
                      >
                      > *************** *************** *************** *************** **********
                      > Think Outside the Box!
                      > *************** *************** *************** *************** **********
                      > "Zeljko" <trashbox4@yaho o.com> wrote in message
                      > news:ai3tpvgkqs 7f4s2h4b0qpeer7 j0iog93k6@4ax.c om...[color=green]
                      > > Right, they don't share anything, but the fact that a block of code is
                      > > somehow related to a particular object. I miss it because I'm lazy -
                      > > typing . instead of typing first few letters and pressing ctrl+space
                      > > is a much faster thing to do. That's a great feature, if u ask me :)
                      > >
                      > > Thanks for the article,
                      > >
                      > > Zeljko
                      > >
                      > > On Tue, 28 Oct 2003 15:30:32 -0000, Jon Skeet [C# MVP]
                      > > <skeet@pobox.co m> wrote:
                      > >[color=darkred]
                      > > >Zeljko <trashbox4@yaho o.com> wrote:
                      > > >> I moved from VB6 to C# recently, and am very satisfied with the
                      > > >> result. However, I miss this one feature. The closest thing I could
                      > > >> find is "using" statement, but it requires object to implement
                      > > >> IDisposable interface, and it won't save me the trouble of typing the
                      > > >> variable name.
                      > > >
                      > > >In fact, "using" and "with" share basically no characteristics :)
                      > > >
                      > > >> What I want to do is something similar to this vb6
                      > > >> block of code:
                      > > >>
                      > > >> Dim a as class1
                      > > >> set a = new class1
                      > > >> with a
                      > > >> .dothis
                      > > >> .dothat
                      > > >> .propertyx = 1
                      > > >> end with
                      > > >>
                      > > >> Does the similar feature exist in C#, or no ?
                      > > >
                      > > >No, it doesn't. (Thanks goodness, in my view.)
                      > > >
                      > > >See http://www.gotdotnet.com/team/csharp.../ask.aspx#with
                      > > >for the reasons it's not in C#.[/color]
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • Shawn B.

                        #26
                        Re: With - End with block in C#

                        The C# syntax should be closer to:

                        with( a.parameters ) {
                        .add...
                        .add..
                        }


                        Thanks,
                        Shawn


                        "Zeljko" <trashbox4@yaho o.com> wrote in message
                        news:vn3tpvkipc dhvv25arnmdr0av v406su2sf@4ax.c om...[color=blue]
                        > Good point in some cases. Still, what to do with built-in, sealed
                        > classes ? E.g. :
                        >
                        > OleDbCommand a = new OleDbCommand ("DoThis" , conn);
                        > a.Parameters.Ad d ..(
                        > a.Parameters.Ad d ...
                        >
                        > instead of
                        >
                        > with a.parameters
                        > .add ...
                        > .add ...
                        > end with
                        >
                        > Zeljko
                        >
                        >
                        > On Tue, 28 Oct 2003 15:39:27 GMT, Steve Jorgensen
                        > <nospam@nospam. nospam> wrote:
                        >[color=green]
                        > >On Tue, 28 Oct 2003 16:21:49 +0100, Zeljko <trashbox4@yaho o.com> wrote:
                        > >[color=darkred]
                        > >>Hi,
                        > >>
                        > >>I moved from VB6 to C# recently, and am very satisfied with the
                        > >>result. However, I miss this one feature. The closest thing I could
                        > >>find is "using" statement, but it requires object to implement
                        > >>IDisposable interface, and it won't save me the trouble of typing the
                        > >>variable name. What I want to do is something similar to this vb6
                        > >>block of code:
                        > >>
                        > >> Dim a as class1
                        > >> set a = new class1
                        > >> with a
                        > >> .dothis
                        > >> .dothat
                        > >> .propertyx = 1
                        > >> end with
                        > >>
                        > >>Does the similar feature exist in C#, or no ?[/color]
                        > >
                        > >In the course of learning how to think more OOP, Ive figured out that[/color][/color]
                        With[color=blue][color=green]
                        > >.. End With is a good idea only in a language like the old VB with poor[/color][/color]
                        OOP[color=blue][color=green]
                        > >capabilities .
                        > >When you find yourself doing a series of operations on the same object,[/color][/color]
                        you[color=blue][color=green]
                        > >usually have a case for making this a method of that object's class or a
                        > >new inheriting class. Once the code is in the class that is being acted
                        > >on, the object reference becomes implicit, just as it would be in a With
                        > >block.[/color]
                        >[/color]


                        Comment

                        • Shawn B.

                          #27
                          Re: With - End with block in C#

                          See inline:

                          "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld @comcast.netNoS pamM> wrote in
                          message news:%23e66J9Wn DHA.392@TK2MSFT NGP11.phx.gbl.. .[color=blue]
                          > This is a good point, but you have to ask yourself a couple of questions:
                          >
                          > 1. Which methodology is more explicit? Overall, explicit code is less[/color]
                          buggy[color=blue]
                          > and easier to read.
                          > 2. Which methodology is easier to maintain? I find most people that[/color]
                          heavily[color=blue]
                          > use "with" in Visual Basic are pretty much being lazy.
                          >[/color]
                          And if they are, so? Work smarter, not harder. It helps get the project
                          done faster. I find that most people who use it use it because it's there
                          and because it requires less typing. That's certainly why I use it. But
                          overall, I'm more productive compared to many of my peers (not because of
                          the with statement) but the with statement helps. I don't over use it, I
                          use it when it makes sense.

                          [color=blue]
                          > With the OleDb command params, I generally use one of the following
                          > methodologies:
                          >
                          > 1. Create a code generator based on the stored procedure. A poor man's
                          > version can be created with SQL Query Analyzer and Excel (or Access[/color]
                          builder,[color=blue]
                          > et al)
                          >
                          > 2. Create a generic layer that matches sproc params with a list of some[/color]
                          type[color=blue]
                          > (dictionary, hashtable, et al) so I do not have to create the params
                          > programatically .
                          >
                          > 3. Use the Microsoft.Appli cationBlock.Dat a project, which gives some neat
                          > overloads to set up params (and caches parameters).
                          >
                          > I find, more and more, that I am coding code generators that build the
                          > repetitive code for me. Sure, there are times I have to hand code a few
                          > params, but the coding is simple, so I am not too worried. With saves me
                          > about three keystrokes each line in my coding standard, so it is not a big
                          > deal. If you use less explicit code techniques, you may see a greater
                          > keystroke savings.
                          >
                          > --
                          > Gregory A. Beamer
                          > MVP; MCP: +I, SE, SD, DBA
                          >
                          > *************** *************** *************** *************** **********
                          > Think Outside the Box!
                          > *************** *************** *************** *************** **********
                          > "Zeljko" <trashbox4@yaho o.com> wrote in message
                          > news:vn3tpvkipc dhvv25arnmdr0av v406su2sf@4ax.c om...[color=green]
                          > > Good point in some cases. Still, what to do with built-in, sealed
                          > > classes ? E.g. :
                          > >
                          > > OleDbCommand a = new OleDbCommand ("DoThis" , conn);
                          > > a.Parameters.Ad d ..(
                          > > a.Parameters.Ad d ...
                          > >
                          > > instead of
                          > >
                          > > with a.parameters
                          > > .add ...
                          > > .add ...
                          > > end with
                          > >
                          > > Zeljko
                          > >
                          > >
                          > > On Tue, 28 Oct 2003 15:39:27 GMT, Steve Jorgensen
                          > > <nospam@nospam. nospam> wrote:
                          > >[color=darkred]
                          > > >On Tue, 28 Oct 2003 16:21:49 +0100, Zeljko <trashbox4@yaho o.com> wrote:
                          > > >
                          > > >>Hi,
                          > > >>
                          > > >>I moved from VB6 to C# recently, and am very satisfied with the
                          > > >>result. However, I miss this one feature. The closest thing I could
                          > > >>find is "using" statement, but it requires object to implement
                          > > >>IDisposable interface, and it won't save me the trouble of typing the
                          > > >>variable name. What I want to do is something similar to this vb6
                          > > >>block of code:
                          > > >>
                          > > >> Dim a as class1
                          > > >> set a = new class1
                          > > >> with a
                          > > >> .dothis
                          > > >> .dothat
                          > > >> .propertyx = 1
                          > > >> end with
                          > > >>
                          > > >>Does the similar feature exist in C#, or no ?
                          > > >
                          > > >In the course of learning how to think more OOP, Ive figured out that[/color][/color]
                          > With[color=green][color=darkred]
                          > > >.. End With is a good idea only in a language like the old VB with poor[/color][/color]
                          > OOP[color=green][color=darkred]
                          > > >capabilities .
                          > > >When you find yourself doing a series of operations on the same object,[/color][/color]
                          > you[color=green][color=darkred]
                          > > >usually have a case for making this a method of that object's class or[/color][/color][/color]
                          a[color=blue][color=green][color=darkred]
                          > > >new inheriting class. Once the code is in the class that is being[/color][/color][/color]
                          acted[color=blue][color=green][color=darkred]
                          > > >on, the object reference becomes implicit, just as it would be in a[/color][/color][/color]
                          With[color=blue][color=green][color=darkred]
                          > > >block.[/color]
                          > >[/color]
                          >
                          >[/color]


                          Comment

                          • Shawn B.

                            #28
                            Re: With - End with block in C#

                            See inline:

                            "ozbear" <ozbear@no.bigp ond.spam.com> wrote in message
                            news:3f9f81a7.2 76717718@news-server...[color=blue]
                            > On Tue, 28 Oct 2003 16:21:49 +0100, Zeljko <trashbox4@yaho o.com>
                            > wrote:
                            >[color=green]
                            > >Hi,
                            > >
                            > >I moved from VB6 to C# recently, and am very satisfied with the
                            > >result. However, I miss this one feature. The closest thing I could
                            > >find is "using" statement, but it requires object to implement
                            > >IDisposable interface, and it won't save me the trouble of typing the
                            > >variable name. What I want to do is something similar to this vb6
                            > >block of code:
                            > >
                            > > Dim a as class1
                            > > set a = new class1
                            > > with a
                            > > .dothis
                            > > .dothat
                            > > .propertyx = 1
                            > > end with
                            > >
                            > >Does the similar feature exist in C#, or no ?
                            > >
                            > >Best regards,
                            > >
                            > >Zeljko[/color]
                            >
                            > "With" is an abomination and should be cast into the pits of hell.
                            >
                            > It creates maintenance nightmares and no professional would ever
                            > use it in any language that supports it.
                            >[/color]

                            I've never in 7 years experienced one second of lost time due to
                            "decipherin g" a with statement code block. Yes, I'm a professional, and I
                            do use it. I've never seen a VB programmer struggle or increase maintenance
                            issues due to the presence of a "With" block.

                            The only people I've ever witnessed struggle with it are C# and more so,
                            Java programmers who just can't seem to grasp it. Of course, they would
                            struggle with it. Of course, if it was a feature of the language they would
                            better understand it. If they were maintaining a VB app, there will be
                            increased maintenance because they are maintaining code in a language they
                            don't speak well.

                            I seem to find more C# programmers complain about how it decreases
                            readibility and increases maintainibility but I don't see too many VB
                            programmers (who use the feature) say the same thing. Sure it can be
                            abused, as can any number of features in C#. That doesn't make C# evil.

                            There are places in C# where I would greatly welcome it. I create custom
                            web controls, and in the Render methods, I have scores of lines of code that
                            repeat the same "HtmlTextWriter ..." that could easily save typing by using a
                            with. I actually did start the project over in VB for reasons of having to
                            type too much in C# and, even though I'm very profficient in C#, I get the
                            job done quicker in VB because I have to type less, my hands hurt less from
                            all the massive typing, and so on. Actually, I think it's the better
                            intellisense features of VB but I degress. I did not make that choice
                            because of the lack of a "with" but the point being, I'm going to type less
                            when I have more to do. Arguing with me that I'm "lazy" and less
                            "profession al" as a result wouldn't hold well if we were programming
                            together in the real world.

                            But we all have our opinions. In the opinion of many C# programmers, "with"
                            is to be abhorred. In the opinion of VB programmers, "with" is a welcome
                            feature. "With" also exists in JScript, by the way, but its syntax could be
                            improved.


                            Flame me for that if you wish. But I do use the language that's going to
                            help me get where I want to go the quickest. For other projects, I've used
                            C# because it makes more sense to do so. I enjoy both languages and get
                            paid to do so.


                            Thanks,
                            Shawn
                            [color=blue]
                            > Oz
                            >[/color]


                            Comment

                            • Daniel O'Connell

                              #29
                              Re: With - End with block in C#


                              "Shawn B." <leabre@html.co m> wrote in message
                              news:%23$$01X0n DHA.2064@TK2MSF TNGP11.phx.gbl. ..[color=blue]
                              > See inline:
                              >
                              > "ozbear" <ozbear@no.bigp ond.spam.com> wrote in message
                              > news:3f9f81a7.2 76717718@news-server...[color=green]
                              > > On Tue, 28 Oct 2003 16:21:49 +0100, Zeljko <trashbox4@yaho o.com>
                              > > wrote:
                              > >[color=darkred]
                              > > >Hi,
                              > > >
                              > > >I moved from VB6 to C# recently, and am very satisfied with the
                              > > >result. However, I miss this one feature. The closest thing I could
                              > > >find is "using" statement, but it requires object to implement
                              > > >IDisposable interface, and it won't save me the trouble of typing the
                              > > >variable name. What I want to do is something similar to this vb6
                              > > >block of code:
                              > > >
                              > > > Dim a as class1
                              > > > set a = new class1
                              > > > with a
                              > > > .dothis
                              > > > .dothat
                              > > > .propertyx = 1
                              > > > end with
                              > > >
                              > > >Does the similar feature exist in C#, or no ?
                              > > >
                              > > >Best regards,
                              > > >
                              > > >Zeljko[/color]
                              > >
                              > > "With" is an abomination and should be cast into the pits of hell.
                              > >
                              > > It creates maintenance nightmares and no professional would ever
                              > > use it in any language that supports it.
                              > >[/color]
                              >
                              > I've never in 7 years experienced one second of lost time due to
                              > "decipherin g" a with statement code block. Yes, I'm a professional, and I
                              > do use it. I've never seen a VB programmer struggle or increase[/color]
                              maintenance[color=blue]
                              > issues due to the presence of a "With" block.
                              >
                              > The only people I've ever witnessed struggle with it are C# and more so,
                              > Java programmers who just can't seem to grasp it. Of course, they would
                              > struggle with it. Of course, if it was a feature of the language they[/color]
                              would[color=blue]
                              > better understand it. If they were maintaining a VB app, there will be
                              > increased maintenance because they are maintaining code in a language they
                              > don't speak well.
                              >
                              > I seem to find more C# programmers complain about how it decreases
                              > readibility and increases maintainibility but I don't see too many VB
                              > programmers (who use the feature) say the same thing. Sure it can be
                              > abused, as can any number of features in C#. That doesn't make C# evil.
                              >
                              > There are places in C# where I would greatly welcome it. I create custom
                              > web controls, and in the Render methods, I have scores of lines of code[/color]
                              that[color=blue]
                              > repeat the same "HtmlTextWriter ..." that could easily save typing by using[/color]
                              a[color=blue]
                              > with. I actually did start the project over in VB for reasons of having[/color]
                              to[color=blue]
                              > type too much in C# and, even though I'm very profficient in C#, I get the
                              > job done quicker in VB because I have to type less, my hands hurt less[/color]
                              from[color=blue]
                              > all the massive typing, and so on. Actually, I think it's the better
                              > intellisense features of VB but I degress. I did not make that choice
                              > because of the lack of a "with" but the point being, I'm going to type[/color]
                              less[color=blue]
                              > when I have more to do. Arguing with me that I'm "lazy" and less
                              > "profession al" as a result wouldn't hold well if we were programming
                              > together in the real world.
                              >
                              > But we all have our opinions. In the opinion of many C# programmers,[/color]
                              "with"[color=blue]
                              > is to be abhorred. In the opinion of VB programmers, "with" is a welcome
                              > feature. "With" also exists in JScript, by the way, but its syntax could[/color]
                              be[color=blue]
                              > improved.
                              >
                              >
                              > Flame me for that if you wish. But I do use the language that's going to
                              > help me get where I want to go the quickest. For other projects, I've[/color]
                              used[color=blue]
                              > C# because it makes more sense to do so. I enjoy both languages and get
                              > paid to do so.
                              >[/color]

                              I used With in VB and don't regret it because I used it carefully, in only
                              some small circumstances. But I don't particularly care for it when coders
                              start writing long (or worse, nested) with statements to the point I cannot
                              determine what exactly is going on on a single screen

                              I simply don't think its something that C# needs, its not *THAT* important,
                              other features would be more valuable[color=blue]
                              >
                              > Thanks,
                              > Shawn
                              >[color=green]
                              > > Oz
                              > >[/color]
                              >
                              >[/color]


                              Comment

                              • Alvin Bruney

                                #30
                                Re: With - End with block in C#

                                Out of curiousity. What do you do that requires assembler?

                                I have a mental block to that language. It reminds me of D's and E's in
                                compsci. Forced to learn it to master the debugger, but still hate its guts.

                                --


                                -----------
                                Got TidBits?
                                Get it here: www.networkip.net/tidbits
                                "Shawn B." <leabre@html.co m> wrote in message
                                news:uPtwFN0nDH A.2964@tk2msftn gp13.phx.gbl...[color=blue]
                                > Why? I"ve never had a problem doing so. It's a great conveniece and have
                                > never in 7 years working with VB suffered a single lost second of
                                > productivity as a result of its presence. I never "rely" on it, but I do
                                > take advantage of the features a tool offers as they are there for a[/color]
                                reason.[color=blue]
                                > I've never once in my memory suffered from not being able to read code[/color]
                                that[color=blue]
                                > used a "with".
                                >
                                > I hear no end to the arguments of C# developers saying how difficult it is
                                > to read. In my experience, I agree, I have worked with many C# and Java
                                > developers who struggle to no end. My take? Adapt and move on. Most VB
                                > programmers don't struggle as much as I've personally witnessed non VB
                                > programmers struggle with it. I'm not making a blanket statement. This[/color]
                                is[color=blue]
                                > just an observation based on experience, is all.
                                >
                                > Me? I'm primarily an Assembly and C++ programmer, who gets paid well to[/color]
                                do[color=blue]
                                > VB and C#. I enjoy all the features of all the languages and often pick[/color]
                                the[color=blue]
                                > best tool for the job when given the choice. When not given the choice, I
                                > use the features available.
                                >
                                >
                                > Thanks,
                                > Shawn
                                >
                                >
                                >
                                > "Cowboy (Gregory A. Beamer)" <NoSpamMgbworld @comcast.netNoS pamM> wrote in
                                > message news:%23KFIH9Wn DHA.392@TK2MSFT NGP11.phx.gbl.. .[color=green]
                                > >
                                > > "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
                                > > news:MPG.1a08a0 66b1cca0cc98997 6@msnews.micros oft.com...[color=darkred]
                                > > >
                                > > > As Steve said - if you're doing a whole load of operations with a
                                > > > single object, chances are that functionality should be encapsulated
                                > > > within the object itself.[/color]
                                > >
                                > >
                                > > And, if these are properties you are setting, you should consider[/color][/color]
                                creating[color=blue]
                                > a[color=green]
                                > > constructor that allows you to set the properties at instantiation[/color][/color]
                                rather[color=blue][color=green]
                                > > than relying on a "with" construct.
                                > >
                                > > --
                                > > Gregory A. Beamer
                                > > MVP; MCP: +I, SE, SD, DBA
                                > >
                                > > *************** *************** *************** *************** **********
                                > > Think Outside the Box!
                                > > *************** *************** *************** *************** **********
                                > >
                                > >[/color]
                                >
                                >[/color]


                                Comment

                                Working...