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. The black hole

The black hole

Scheduled Pinned Locked Moved The Weird and The Wonderful
question
20 Posts 14 Posters 0 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.
  • M Marcello Faga

    "Lasciate ogni speranza o voi ch'entrate" Dante Alighieri private double m_EdgeDim; public double EdgeDim { set { m_EdgeDim = value; } } Don't you really want to see what you have put?

    **************************** Strong congruence for strong people; with a compatible behaviour. For a semantical way of life.

    M Offline
    M Offline
    Megidolaon
    wrote on last edited by
    #8

    I understand the point of a write-only property, but I don't like the idea of really using it. It's only going to confuse you or anyone else working with the code. After all, the only one who really isn't supposed to know the value of the property is the user, so as long as it's not displayed to the user, it should be fine. Using a write-only property will only make debugging and refactoring harder. In my opinion, this is a bad practice.

    J C D 3 Replies Last reply
    0
    • M Megidolaon

      I understand the point of a write-only property, but I don't like the idea of really using it. It's only going to confuse you or anyone else working with the code. After all, the only one who really isn't supposed to know the value of the property is the user, so as long as it's not displayed to the user, it should be fine. Using a write-only property will only make debugging and refactoring harder. In my opinion, this is a bad practice.

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

      I am writing the code for my first (proper) CP article and I did have one write only property. I have a webcam class that I want to control to a T (via a VisionController class). On the webcam wizard the user selects the device and the wizard puts it in the class. I don't want ANY other portion of code interacting with it: so once the class is in I can get to it. It forces me to create proper interfaces, and now that I have completed them I put the get {} in there ;).

      J 1 Reply Last reply
      0
      • M Megidolaon

        I understand the point of a write-only property, but I don't like the idea of really using it. It's only going to confuse you or anyone else working with the code. After all, the only one who really isn't supposed to know the value of the property is the user, so as long as it's not displayed to the user, it should be fine. Using a write-only property will only make debugging and refactoring harder. In my opinion, this is a bad practice.

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #10

        Megidolaon wrote:

        Using a write-only property will only make debugging and refactoring harder.

        Why?

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        M A 2 Replies Last reply
        0
        • M Megidolaon

          I understand the point of a write-only property, but I don't like the idea of really using it. It's only going to confuse you or anyone else working with the code. After all, the only one who really isn't supposed to know the value of the property is the user, so as long as it's not displayed to the user, it should be fine. Using a write-only property will only make debugging and refactoring harder. In my opinion, this is a bad practice.

          D Offline
          D Offline
          David MacDermot
          wrote on last edited by
          #11

          I have several classes I use for instrumentation control and port access. I use the write only property as a means of passing instructions to the remote devices (reads easier in my opinion) and this suggests that the property value is not stored just passed along. Ex: remoteDevice.IO.Send = "SETVOLT 25"; If I wanted to set some kind of parameter value that is stored in the class but should not be read I would use the following method: serializer.SetInitialValue(103);

          P 1 Reply Last reply
          0
          • D David MacDermot

            I have several classes I use for instrumentation control and port access. I use the write only property as a means of passing instructions to the remote devices (reads easier in my opinion) and this suggests that the property value is not stored just passed along. Ex: remoteDevice.IO.Send = "SETVOLT 25"; If I wanted to set some kind of parameter value that is stored in the class but should not be read I would use the following method: serializer.SetInitialValue(103);

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #12

            Well I consider those to be backward, but it's really a matter of style.

            1 Reply Last reply
            0
            • J Jonathan C Dickinson

              I am writing the code for my first (proper) CP article and I did have one write only property. I have a webcam class that I want to control to a T (via a VisionController class). On the webcam wizard the user selects the device and the wizard puts it in the class. I don't want ANY other portion of code interacting with it: so once the class is in I can get to it. It forces me to create proper interfaces, and now that I have completed them I put the get {} in there ;).

              J Offline
              J Offline
              James Simpson
              wrote on last edited by
              #13

              What about putting it in the constructor? Or should it be modified? J

              James Simpson Web Developer imebgo@hotmail.com P S - This is what part of the alphabet would look like if Q and R were eliminated
              Mitch Hedberg

              J 1 Reply Last reply
              0
              • M Marcello Faga

                "Lasciate ogni speranza o voi ch'entrate" Dante Alighieri private double m_EdgeDim; public double EdgeDim { set { m_EdgeDim = value; } } Don't you really want to see what you have put?

                **************************** Strong congruence for strong people; with a compatible behaviour. For a semantical way of life.

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

                Don't you know about the black hole design pattern?? Looks like this..

                public class BlackHole
                {
                private T _hole;
                public T Hole {
                set {
                try {
                this._hole = value;
                }
                catch {
                throw new BlackHoleException();
                }
                }
                }
                }

                1 Reply Last reply
                0
                • J James Simpson

                  What about putting it in the constructor? Or should it be modified? J

                  James Simpson Web Developer imebgo@hotmail.com P S - This is what part of the alphabet would look like if Q and R were eliminated
                  Mitch Hedberg

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

                  Yeah I thought about putting it in the CTor, but the thing is that a wbcam wizard updates it, I am thinking I really should make a set method because it has a few side effects (rule of properties: if it doesn't have side effects make it a property, if it does make it a method).

                  He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Chineese Proverb] Jonathan C Dickinson (C# Software Engineer)

                  1 Reply Last reply
                  0
                  • C CPallini

                    Megidolaon wrote:

                    Using a write-only property will only make debugging and refactoring harder.

                    Why?

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                    M Offline
                    M Offline
                    Megidolaon
                    wrote on last edited by
                    #16

                    IMO, it's a bit of a hassle because you can only see the values while debugging and having them display in the Watch window. A examples was provided where it might be a good idea to use a write only properties but I simply don't like the idea. I haven't gotten into the situation where I'd need a write only property and if I ever got into such a situation, I'd re-think my design.

                    P 1 Reply Last reply
                    0
                    • C CPallini

                      Megidolaon wrote:

                      Using a write-only property will only make debugging and refactoring harder.

                      Why?

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                      A Offline
                      A Offline
                      AJMH
                      wrote on last edited by
                      #17

                      The only good example of a write-only property I've come across is with authentication. A class representing a user might have a username and a password. The password is required for authentication, but should not be generally accessible to the rest of an application. If you have a code-base which supports third-party plug-in authoring then you may not be able to guarantee all plug-in code is safe / responsible... In this case a write-only property for the class is a good plan if the user object is then shared. Otherwise I would tend to agree with the use of a setter method... Might be a background thing, though :cool: - I know a lot of the VB folks like properties for class field setters/getters.

                      AJ

                      1 Reply Last reply
                      0
                      • M Megidolaon

                        IMO, it's a bit of a hassle because you can only see the values while debugging and having them display in the Watch window. A examples was provided where it might be a good idea to use a write only properties but I simply don't like the idea. I haven't gotten into the situation where I'd need a write only property and if I ever got into such a situation, I'd re-think my design.

                        P Offline
                        P Offline
                        peterchen
                        wrote on last edited by
                        #18

                        Megidolaon wrote:

                        and if I ever got into such a situation, I'd re-think my design.

                        Absolutely, if you can't read it, it's not a property.

                        We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                        blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist

                        1 Reply Last reply
                        0
                        • M Marcello Faga

                          "Lasciate ogni speranza o voi ch'entrate" Dante Alighieri private double m_EdgeDim; public double EdgeDim { set { m_EdgeDim = value; } } Don't you really want to see what you have put?

                          **************************** Strong congruence for strong people; with a compatible behaviour. For a semantical way of life.

                          P Offline
                          P Offline
                          Paul Conrad
                          wrote on last edited by
                          #19

                          Marcello Faga wrote:

                          Don't you really want to see what you have put?

                          Not really, it could be a writeonly type of scenario.

                          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                          1 Reply Last reply
                          0
                          • M Marcello Faga

                            "Lasciate ogni speranza o voi ch'entrate" Dante Alighieri private double m_EdgeDim; public double EdgeDim { set { m_EdgeDim = value; } } Don't you really want to see what you have put?

                            **************************** Strong congruence for strong people; with a compatible behaviour. For a semantical way of life.

                            B Offline
                            B Offline
                            BillW33
                            wrote on last edited by
                            #20

                            I often use read only Properties, but write only properties, while useful in a few rare instances, are usually not what you want to do.

                            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