Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. WriteOnly

WriteOnly

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpjavadotnetvisual-studio
43 Posts 22 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T The Cake of Deceit

    Who would use it? A coding horror in VB. And if you use it, it turns your code into a coding horror. X|

    CLR: Removes tough Java-based stains fast!

    E Offline
    E Offline
    elektrowolf
    wrote on last edited by
    #28

    Alpha Nerd wrote:

    Who would use it? A coding horror in VB.

    In VB? In C#, too: class Foo { private int _val; public int Val { set { this._val = value; } } }

    1 Reply Last reply
    0
    • T The Cake of Deceit

      Did you know VB.NET has a WriteOnly property to make properties into /dev/nulls? :wtf: It even offers IntelliSense to remove the Get accessors!

      CLR: Removes tough Java-based stains fast!

      D Offline
      D Offline
      Dr Walt Fair PE
      wrote on last edited by
      #29

      The best use for write-only things, in general, is when you are dealing with real-time control interfaces. Some devices allow you to save data to a memory location or port and that sets control bits in an external device. As far as the external device is concerned, it is an input-only deal; from the program's viewpoint it's write-only and any attempt to read would be undefined or return garbage. One logical use for a write-only property would be to control interfaces with external hardware. You would define a class encapsulating the hardware access and anything that writes to the hardware without any chance of being able to read the real-time results back, would logically be marked as WriteOnly. This is fairly common when using some PIC chips, DSP chips and assorted other devices. In my DSP applications, marking output data as WriteOnly would make perfect sense, since once it is sent to the buffer, it goes out the sound interface and does not exist anywhere that is accessible to the software. (Note: I haven't done that, since I knew it was essentially write-only and never thought I might try to read it again.) To me, marking a property as WriteOnly in a VB, C, C# or any other language very clearly tells everyone not to even bother to read it back because the data no longer exists. Another use for WriteOnly properties would be when dealing with highly asychronous processes, but I won't go into that here. So, yeah, if you're dealing with stuff in your own application's memory, WriteOnly may not make much sense, but if you are dealing with control systems and external devices, it may well make perfect sense.

      The PetroNerd

      Walt Fair, Jr. Comport Computing Specializing in Technical Engineering Software

      1 Reply Last reply
      0
      • L Luc Pattyn

        Dave Kreskowiak wrote:

        it's pretty dark...

        are you sure? if it sucks everything in, and never lets go, it must be bloody light in there. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #30

        I think the light is processed into something else. I couldn't tell what though, because, like, there's no light! :-D

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        L 1 Reply Last reply
        0
        • D Dave Kreskowiak

          I think the light is processed into something else. I couldn't tell what though, because, like, there's no light! :-D

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #31

          Aha, I see. Or actually maybe I don't, lacking some light??

          Luc Pattyn [Forum Guidelines] [My Articles]


          This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


          1 Reply Last reply
          0
          • T The Cake of Deceit

            Did you know VB.NET has a WriteOnly property to make properties into /dev/nulls? :wtf: It even offers IntelliSense to remove the Get accessors!

            CLR: Removes tough Java-based stains fast!

            P Online
            P Online
            PIEBALDconsult
            wrote on last edited by
            #32

            I suppose a write-only property (in whatever language, but preferably C#) could be used when defining something like a queue (Enqueue) or a stack (Push). (Though not recommended.)

            1 Reply Last reply
            0
            • T The Cake of Deceit

              Yes, it's a good language, but I prefer C#. Besides, WriteOnly is so weirdly funny! :laugh:

              CLR: Removes tough Java-based stains fast!

              E Offline
              E Offline
              elektrowolf
              wrote on last edited by
              #33

              Full ACK. It's those little advantages of C# like anonymous delegates, lambda expressions without return value, automatic properties, a.s.o. that made me prefer C#. But one can't say VB is horrible! Basically, it has all features of C# and just an other syntax.

              1 Reply Last reply
              0
              • T The Cake of Deceit

                Robert Surtees wrote:

                Maybe the property is part of a quantum computer and so write only to spare the possible life of a cat.

                You would need 9 WriteOnly properties then. Remember; they have 9 lives! LOL. :laugh: (who would build a supercomputer in VB? the language is slightly crippled, but this WriteOnly thing gives a advantage over C# or the awful C++)

                CLR: Removes tough Java-based stains fast!

                R Offline
                R Offline
                Russell Jones
                wrote on last edited by
                #34

                writeonly properties are just as possible in c#, just create a property without an accessor. It's probably not great practice to use one but there may be times when it came in handy

                1 Reply Last reply
                0
                • T The Cake of Deceit

                  Did you know VB.NET has a WriteOnly property to make properties into /dev/nulls? :wtf: It even offers IntelliSense to remove the Get accessors!

                  CLR: Removes tough Java-based stains fast!

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #35

                  I quite often use write only properties in C# Consider this: Object A depends on an internal state and also needs an Object B for whatever it does. Object B inherits from a baseclass or interface, so there are many classes that may be used to create an instance to use as object B. Hardcoding it in A is not an option. Instead I use a write only property of A to pass a suitable object B at runtime. Object A then reinitializes it's internal state and prepares B for its use. I do not want to have access to object B anymore. It is not needed and indeed any tampering with B would have a bearing on A's state. With a write only property this problem cannot arise.

                  1 Reply Last reply
                  0
                  • M MarkB777

                    Did you also know VB is straight up just an ugly language? VB itself is a coding horror.

                    Mark Brock Click here to view my blog

                    M Offline
                    M Offline
                    Mr PoorEnglish
                    wrote on last edited by
                    #36

                    MarkBrock wrote:

                    VB itself is a coding horror.

                    maybe the greatest advantage to VB is that the programmers aren't as arrogant as C# programmers. (otherwise: the meaning of writeonly also is a secret for me.)

                    L 1 Reply Last reply
                    0
                    • W Werries

                      Hi all of you that think VB are such a horrible language to use for coding. I’ve notice some of you think a large project can’t be done in VB. Well, I’ve got news for you. I work for a company that develops Point of Sale software for the last 14 years, and we are currently working on a new version for the Point of Sale that has at least 2 million lines of source code in it! It is a full client-server application and can be used on a single PC and up to thousands of computers all with a breeze. Programming some parts of the application in C and other languages, VB still is the most organised and understandable code there is. Call a project with more than 2 million lines of source code small? The project contains about 121 dll’s written in VB6 and about 67 dll’s written in VB.Net. Currently we are converting all the VB6 dll’s to VB.Net dll’s. After all, it is not the language that makes an application what it is, but the programmer’s ability to develop good and reliable code, regardless of the language. ;)

                      A programmer's life is good... or is it?? Ek dink nie so nie!

                      M Offline
                      M Offline
                      MarkB777
                      wrote on last edited by
                      #37

                      haha I don't think any of the "anti-VB"'ers in here are really serious about what they say. I've worked on a very large VB.NET project as well - A customized CMS for our government. People are just taking the piss. ;)

                      Mark Brock Click here to view my blog

                      V 1 Reply Last reply
                      0
                      • M Mr PoorEnglish

                        MarkBrock wrote:

                        VB itself is a coding horror.

                        maybe the greatest advantage to VB is that the programmers aren't as arrogant as C# programmers. (otherwise: the meaning of writeonly also is a secret for me.)

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #38

                        Arrogance? Perhaps, but stereotypes usually do not come out of a void. Until .Net VB hardly was a candidate to do any serious work with. And those who tried often gave a picture of needlessly fighting windmills to overcome its shortcomings and proove that they were right. Also, the acronym 'BASIC' is still held high by advertising VB as the ideal language for beginners. Is it really a wonder that all diehard VB users are automatically percieved as such? Last, the syntax obviously is one of those love-or-hate things. So am I being arrogant if I don't want to be irritated by it the entire day? Or am I arrogant when I decide that I have better things to do than arguing with people who automatically put me into the 'annoying newbie' box?

                        M 1 Reply Last reply
                        0
                        • L Lost User

                          Arrogance? Perhaps, but stereotypes usually do not come out of a void. Until .Net VB hardly was a candidate to do any serious work with. And those who tried often gave a picture of needlessly fighting windmills to overcome its shortcomings and proove that they were right. Also, the acronym 'BASIC' is still held high by advertising VB as the ideal language for beginners. Is it really a wonder that all diehard VB users are automatically percieved as such? Last, the syntax obviously is one of those love-or-hate things. So am I being arrogant if I don't want to be irritated by it the entire day? Or am I arrogant when I decide that I have better things to do than arguing with people who automatically put me into the 'annoying newbie' box?

                          M Offline
                          M Offline
                          Mr PoorEnglish
                          wrote on last edited by
                          #39

                          CDP1802 wrote:

                          but stereotypes usually do not come out of a void.

                          That may be right, but then its a question of character, whether you want to take stereotypes for your opinion, and wether you want to reproduce stereotypes on and on. To have preferences cannot be called arrogance, neither criticizing some VB concepts. (I've lots of criticism myself, for example the mixing up of "=" and "==" in one operator - gruesome, isn't it?) But to me it's the IDE, which keeps me staying in VB, because of the background-compiling, because contextmenu "go to definition" leads directly to the objectbrowser, and the objectbrowser displays the return-types of functions already in the overview.

                          1 Reply Last reply
                          0
                          • M MarkB777

                            haha I don't think any of the "anti-VB"'ers in here are really serious about what they say. I've worked on a very large VB.NET project as well - A customized CMS for our government. People are just taking the piss. ;)

                            Mark Brock Click here to view my blog

                            V Offline
                            V Offline
                            VentsyV
                            wrote on last edited by
                            #40

                            MarkBrock wrote:

                            I've worked on a very large VB.NET project as well - A customized CMS for our government.

                            Not the one for the FBI that failed miserably and waisted $100 mil taxpayer's money by any chance is it ?

                            M 1 Reply Last reply
                            0
                            • V VentsyV

                              MarkBrock wrote:

                              I've worked on a very large VB.NET project as well - A customized CMS for our government.

                              Not the one for the FBI that failed miserably and waisted $100 mil taxpayer's money by any chance is it ?

                              M Offline
                              M Offline
                              MarkB777
                              wrote on last edited by
                              #41

                              haha... that's classified :).

                              Mark Brock Click here to view my blog

                              1 Reply Last reply
                              0
                              • B Baixinho

                                This is the type of comment that only can be written by someone that doesnt know the language. I work on c# but i worked on VB.Net a few years before. The two main diferences i noticed on the transition was that intelisence is a lot better on VB, and on vb i don't have to compile the code to see errors.

                                J Offline
                                J Offline
                                Jorgen Sigvardsson
                                wrote on last edited by
                                #42

                                Member 2411327 wrote:

                                The two main diferences i noticed on the transition was that intelisence is a lot better on VB, and on vb i don't have to compile the code to see errors.

                                That's not a language difference, it's an IDE difference.

                                -- Kein Mitleid Für Die Mehrheit

                                1 Reply Last reply
                                0
                                • B Baixinho

                                  This is the type of comment that only can be written by someone that doesnt know the language. I work on c# but i worked on VB.Net a few years before. The two main diferences i noticed on the transition was that intelisence is a lot better on VB, and on vb i don't have to compile the code to see errors.

                                  J Offline
                                  J Offline
                                  Jonathan C Dickinson
                                  wrote on last edited by
                                  #43

                                  I am a 8yr VB (and generic BASIC) refugee and I must say that C# has given me a warm fuzzy feeling since I started using it. One word: keystrokes ;).

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups