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. The Lounge
  3. Is this an acceptable practice?

Is this an acceptable practice?

Scheduled Pinned Locked Moved The Lounge
jsonquestion
55 Posts 16 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.
  • F Fabio Franco

    Gates VP wrote:

    That stated, if you're mixing types on the "multi-declarations", it's time split them out.

    They are clearly separated by lines, if they were in the same line, then I would agree with you. As I said in my reply, it resembles a lot C++ declaration like:

    private:
    int x;
    double y;
    .
    .
    .

    The underscore even act as C++ semi-colon. It doesn't hurt readability as you can clearly see the types at the end of each line. I don't see any confusion, except that someone may be in doubt if the attribute applies only to the first variable or all of them.

    To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

    G Offline
    G Offline
    Gates VP
    wrote on last edited by
    #37

    If you have 35 or 40 of these grouped into one segment, they're going to flow off the screen. If you want to mark just one of them as "public", do you copy/paste this to some other part of the file entirely? How does this affect the attributes? Remember, after you copy/paste the private variable to the public section, the original attributes are on a completely different screen. And you're not instinctively moving the attribute along with the variable.

    Quote:

    I don't see any confusion, except that someone may be in doubt if the attribute applies only to the first variable or all of them.

    That's still confusion. And it's not really useful or purposeful confusion. You save a small number of characters and compile to the exact same IL code (hopefully) while introducing uncertainty for developers. This is the equivalent of doing C++ / C# if blocks without braces. You come back to this problem that actually caused real production issues on iOs: https://www.imperialviolet.org/2014/02/22/applebug.html[^]

    C 1 Reply Last reply
    0
    • D Duncan Edwards Jones

      As a general rule, explicit intent is better coding practice than implied intent.

      C Offline
      C Offline
      Colborne_Greg
      wrote on last edited by
      #38

      I rather have white space, but agreed.

      1 Reply Last reply
      0
      • F Fabio Franco

        Gates VP wrote:

        That stated, if you're mixing types on the "multi-declarations", it's time split them out.

        They are clearly separated by lines, if they were in the same line, then I would agree with you. As I said in my reply, it resembles a lot C++ declaration like:

        private:
        int x;
        double y;
        .
        .
        .

        The underscore even act as C++ semi-colon. It doesn't hurt readability as you can clearly see the types at the end of each line. I don't see any confusion, except that someone may be in doubt if the attribute applies only to the first variable or all of them.

        To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

        C Offline
        C Offline
        Colborne_Greg
        wrote on last edited by
        #39

        This is actually one line of code, but that is why I break it into multiple lines using the _ character to cheat a little bit, so I only have to write the serialization tag once.

        1 Reply Last reply
        0
        • G Gates VP

          If you have 35 or 40 of these grouped into one segment, they're going to flow off the screen. If you want to mark just one of them as "public", do you copy/paste this to some other part of the file entirely? How does this affect the attributes? Remember, after you copy/paste the private variable to the public section, the original attributes are on a completely different screen. And you're not instinctively moving the attribute along with the variable.

          Quote:

          I don't see any confusion, except that someone may be in doubt if the attribute applies only to the first variable or all of them.

          That's still confusion. And it's not really useful or purposeful confusion. You save a small number of characters and compile to the exact same IL code (hopefully) while introducing uncertainty for developers. This is the equivalent of doing C++ / C# if blocks without braces. You come back to this problem that actually caused real production issues on iOs: https://www.imperialviolet.org/2014/02/22/applebug.html[^]

          C Offline
          C Offline
          Colborne_Greg
          wrote on last edited by
          #40

          I write generics my classes are never more then 300 lines of code and if I need more then 4 or so data members I am doing something wrong Also I would never declare a member of a class public, I use properties to expose members. The only reason these are grouped together is so I do not have to write the serialization tag out for each, its cheating a bit.

          1 Reply Last reply
          0
          • C Colborne_Greg

            This is what it looked like before

            <System.Runtime.Serialization.DataMember>
            Private mLastUpdated As DateTime

                <System.Runtime.Serialization.DataMember>
                Private mLastUpdatedBy As String
            
                <System.Runtime.Serialization.DataMember>
                Private mClearanceRequired As Int64
            
                <System.Runtime.Serialization.DataMember>
                Private mClearanceIsRequired As Boolean
            

            The first example I wrote, stands on in the document, where writing datamember so many times with the word private seems to be a waste of space.

            G Offline
            G Offline
            Gates VP
            wrote on last edited by
            #41

            So to clarify, you're saying that "saving space" is more important than "providing clarity" and "avoiding bugs"? If you're trying to save space why are you: 1. Using Private at all? That's the default, just take it out. 2. Using that little "m" in the prefix. Why not just lower-case the first letter? ("lastUpdated") 3. Using full words when you could abbreviate everything? ("lstUpd") 4. Not importing the System.Runtime.Serialization on the file? Then you could just type ""! If "saving space" is really important, why aren't you doing it everywhere? And at the end of the day, all of this code is functionally equivalent, right? So it all compiles to the same IL. I'm just not understanding the "save space" argument here.

            C 1 Reply Last reply
            0
            • G Gates VP

              So to clarify, you're saying that "saving space" is more important than "providing clarity" and "avoiding bugs"? If you're trying to save space why are you: 1. Using Private at all? That's the default, just take it out. 2. Using that little "m" in the prefix. Why not just lower-case the first letter? ("lastUpdated") 3. Using full words when you could abbreviate everything? ("lstUpd") 4. Not importing the System.Runtime.Serialization on the file? Then you could just type ""! If "saving space" is really important, why aren't you doing it everywhere? And at the end of the day, all of this code is functionally equivalent, right? So it all compiles to the same IL. I'm just not understanding the "save space" argument here.

              C Offline
              C Offline
              Colborne_Greg
              wrote on last edited by
              #42

              The word Private indents the code for white space. The m stands for Member some companies use an underscore _ instead, each data member has a corresponding property that exposes the data member with extra code for validation, each of these properties implement an interface. The intent is white space and readability not saving space. Importing a class file is improper name resolution

              G 1 Reply Last reply
              0
              • C Colborne_Greg

                The word Private indents the code for white space. The m stands for Member some companies use an underscore _ instead, each data member has a corresponding property that exposes the data member with extra code for validation, each of these properties implement an interface. The intent is white space and readability not saving space. Importing a class file is improper name resolution

                G Offline
                G Offline
                Gates VP
                wrote on last edited by
                #43

                Quote:

                ...datamember so many times with the word private seems to be a waste of space.

                Your own words literally say that you are worried about "wasting space". Now you've changed it slightly:

                Quote:

                The intent is white space and readability not saving space.

                You're worried about "wasting space" but only for some very specific and narrow scope of "wasting". And in this particular case, you're worried about "small waste" vs. "absolute clarity" which seems like a pretty lame trade-off. The fact that anyone had to question whether or not the attribute applied to all the variables means that you failed the "readability" test. Your goal of "readability" actually resulted in this code being hard to read and possibly being "unclear" to people who were not experts in this very narrow language feature.

                C 2 Replies Last reply
                0
                • C Colborne_Greg

                  White space. It's more important to people. Also as a programmer if you do not understand how a compiler is going to handle your code, you might consider another profession.

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

                  Yes, it's a matter of knowing how the compiler is going to handle the code, but it's more about maintainability. The format of the code is not to please the compiler. It's there to convey, without a doubt, what you intended. It's better to be explicitly expressive than it is to assume functionality with a lack of expression. Think about what the next guy who has to maintain your code is going to think when he sees it. Again, you're not looking for opinions. You're shooting down everything everyone says about what you wrote in an attempt to justify it.

                  A guide to posting questions on CodeProject

                  How to debug small programs
                  Dave Kreskowiak

                  C 1 Reply Last reply
                  0
                  • C Colborne_Greg

                    This is what it looked like before

                    <System.Runtime.Serialization.DataMember>
                    Private mLastUpdated As DateTime

                        <System.Runtime.Serialization.DataMember>
                        Private mLastUpdatedBy As String
                    
                        <System.Runtime.Serialization.DataMember>
                        Private mClearanceRequired As Int64
                    
                        <System.Runtime.Serialization.DataMember>
                        Private mClearanceIsRequired As Boolean
                    

                    The first example I wrote, stands on in the document, where writing datamember so many times with the word private seems to be a waste of space.

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

                    If you're worried about space, why are you using one of the most verbose languages there is? :)

                    A guide to posting questions on CodeProject

                    How to debug small programs
                    Dave Kreskowiak

                    C 1 Reply Last reply
                    0
                    • C Colborne_Greg

                      I see yes the context of how someone takes a sentence is important. The code is flawless, again the question was about coding practices.

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

                      When I commented on this branch of the thread, it wasn't addressed to you.

                      A guide to posting questions on CodeProject

                      How to debug small programs
                      Dave Kreskowiak

                      1 Reply Last reply
                      0
                      • D Dave Kreskowiak

                        If you're worried about space, why are you using one of the most verbose languages there is? :)

                        A guide to posting questions on CodeProject

                        How to debug small programs
                        Dave Kreskowiak

                        C Offline
                        C Offline
                        Colborne_Greg
                        wrote on last edited by
                        #47

                        White space and readability It's like taking actual English practices and applying them to coding, so the point reading code is like reading a paragraph - when it's so elegant writing comments are redundant.

                        1 Reply Last reply
                        0
                        • G Gates VP

                          Quote:

                          ...datamember so many times with the word private seems to be a waste of space.

                          Your own words literally say that you are worried about "wasting space". Now you've changed it slightly:

                          Quote:

                          The intent is white space and readability not saving space.

                          You're worried about "wasting space" but only for some very specific and narrow scope of "wasting". And in this particular case, you're worried about "small waste" vs. "absolute clarity" which seems like a pretty lame trade-off. The fact that anyone had to question whether or not the attribute applied to all the variables means that you failed the "readability" test. Your goal of "readability" actually resulted in this code being hard to read and possibly being "unclear" to people who were not experts in this very narrow language feature.

                          C Offline
                          C Offline
                          Colborne_Greg
                          wrote on last edited by
                          #48

                          you are right I did say waste of space.

                          1 Reply Last reply
                          0
                          • D Dave Kreskowiak

                            Yes, it's a matter of knowing how the compiler is going to handle the code, but it's more about maintainability. The format of the code is not to please the compiler. It's there to convey, without a doubt, what you intended. It's better to be explicitly expressive than it is to assume functionality with a lack of expression. Think about what the next guy who has to maintain your code is going to think when he sees it. Again, you're not looking for opinions. You're shooting down everything everyone says about what you wrote in an attempt to justify it.

                            A guide to posting questions on CodeProject

                            How to debug small programs
                            Dave Kreskowiak

                            C Offline
                            C Offline
                            Colborne_Greg
                            wrote on last edited by
                            #49

                            You are not reading every comment. Maintainability is a good reply.

                            1 Reply Last reply
                            0
                            • G Gates VP

                              Quote:

                              ...datamember so many times with the word private seems to be a waste of space.

                              Your own words literally say that you are worried about "wasting space". Now you've changed it slightly:

                              Quote:

                              The intent is white space and readability not saving space.

                              You're worried about "wasting space" but only for some very specific and narrow scope of "wasting". And in this particular case, you're worried about "small waste" vs. "absolute clarity" which seems like a pretty lame trade-off. The fact that anyone had to question whether or not the attribute applied to all the variables means that you failed the "readability" test. Your goal of "readability" actually resulted in this code being hard to read and possibly being "unclear" to people who were not experts in this very narrow language feature.

                              C Offline
                              C Offline
                              Colborne_Greg
                              wrote on last edited by
                              #50

                              The reason indeed why I posted the acceptability is to hear what you think. I am way out to left field my own practices are just for myself as I am the owner of my software company. This is the whole thing, I already know how off standard this is.

                              Namespace Sinks
                              <System.Runtime.Serialization.DataContract(IsReference:=True)>
                              Public MustInherit Class Base
                              Inherits Validate
                              Implements iInterface

                                  <System.Runtime.Serialization.DataMember>
                                  Private mLastUpdated As DateTime, \_
                                          mLastUpdatedBy As String, \_
                                          mClearanceRequired As Int64, \_
                                          mClearanceIsRequired As Boolean
                              
                                  Public Sub New()
                                      MyBase.New()
                                  End Sub
                                  Public Sub New(Clearance As Int64)
                                      MyBase.New()
                                      ClearanceRequired = Clearance
                                  End Sub
                              
                                  Public Property LastUpdated As DateTime Implements iInterface.LastUpdated
                                      Get
                                          Return mLastUpdated
                                      End Get
                                      Set(value As DateTime)
                                          mLastUpdated = value
                                      End Set
                                  End Property
                                  Public Property LastUpdatedBy As String Implements iInterface.LastUpdatedBy
                                      Get
                                          Return mLastUpdatedBy
                                      End Get
                                      Set(value As String)
                                          mLastUpdatedBy = value
                                      End Set
                                  End Property
                                  Public Property ClearanceIsRequired As Boolean Implements iInterface.ClearanceIsRequired
                                      Get
                                          Return mClearanceIsRequired
                                      End Get
                                      Set(value As Boolean)
                                          mClearanceIsRequired = value
                                      End Set
                                  End Property
                                  Public Property ClearanceRequired As Long Implements iInterface.ClearanceRequired
                                      Get
                                          Return mClearanceRequired
                                      End Get
                                      Set(value As Long)
                                          mClearanceIsRequired = True
                                          mClearanceRequired = value
                                      End Set
                                  End Property
                              
                                  Public Overloads ReadOnly Property Value(User As Directory.iUser) As Object Implements iInterface.Value
                                      Get
                                          Select Case True
                                              Case User.Deny : Throw New Exception("User Denied!")
                                              Case ClearanceIsRequired And User.ClearanceReadLevel < ClearanceRequired : Throw New Exception("User clearance is lower then required!")
                                              Case Else : Return MyBase.Value
                                          En
                              
                              U 1 Reply Last reply
                              0
                              • C Colborne_Greg

                                I DO NOT NEED HELP Quit behaving like you know what the fook is going on. THE QUESTION IS - is this an acceptable practice, please learn to read English before getting on my case.

                                J Offline
                                J Offline
                                jibalt
                                wrote on last edited by
                                #51

                                I think you do need help not being a giant ahole.

                                C 1 Reply Last reply
                                0
                                • C Colborne_Greg

                                  The reason indeed why I posted the acceptability is to hear what you think. I am way out to left field my own practices are just for myself as I am the owner of my software company. This is the whole thing, I already know how off standard this is.

                                  Namespace Sinks
                                  <System.Runtime.Serialization.DataContract(IsReference:=True)>
                                  Public MustInherit Class Base
                                  Inherits Validate
                                  Implements iInterface

                                      <System.Runtime.Serialization.DataMember>
                                      Private mLastUpdated As DateTime, \_
                                              mLastUpdatedBy As String, \_
                                              mClearanceRequired As Int64, \_
                                              mClearanceIsRequired As Boolean
                                  
                                      Public Sub New()
                                          MyBase.New()
                                      End Sub
                                      Public Sub New(Clearance As Int64)
                                          MyBase.New()
                                          ClearanceRequired = Clearance
                                      End Sub
                                  
                                      Public Property LastUpdated As DateTime Implements iInterface.LastUpdated
                                          Get
                                              Return mLastUpdated
                                          End Get
                                          Set(value As DateTime)
                                              mLastUpdated = value
                                          End Set
                                      End Property
                                      Public Property LastUpdatedBy As String Implements iInterface.LastUpdatedBy
                                          Get
                                              Return mLastUpdatedBy
                                          End Get
                                          Set(value As String)
                                              mLastUpdatedBy = value
                                          End Set
                                      End Property
                                      Public Property ClearanceIsRequired As Boolean Implements iInterface.ClearanceIsRequired
                                          Get
                                              Return mClearanceIsRequired
                                          End Get
                                          Set(value As Boolean)
                                              mClearanceIsRequired = value
                                          End Set
                                      End Property
                                      Public Property ClearanceRequired As Long Implements iInterface.ClearanceRequired
                                          Get
                                              Return mClearanceRequired
                                          End Get
                                          Set(value As Long)
                                              mClearanceIsRequired = True
                                              mClearanceRequired = value
                                          End Set
                                      End Property
                                  
                                      Public Overloads ReadOnly Property Value(User As Directory.iUser) As Object Implements iInterface.Value
                                          Get
                                              Select Case True
                                                  Case User.Deny : Throw New Exception("User Denied!")
                                                  Case ClearanceIsRequired And User.ClearanceReadLevel < ClearanceRequired : Throw New Exception("User clearance is lower then required!")
                                                  Case Else : Return MyBase.Value
                                              En
                                  
                                  U Offline
                                  U Offline
                                  User 9249657
                                  wrote on last edited by
                                  #52

                                  I would prefer to write the attribute for each member, if you want to save lines of code you could write them inline.

                                  <System.Runtime.Serialization.DataMember> Private mLastUpdated As DateTime
                                  <System.Runtime.Serialization.DataMember> Private mLastUpdatedBy As String
                                  <System.Runtime.Serialization.DataMember> Private mClearanceRequired As Int64
                                  <System.Runtime.Serialization.DataMember> Private mClearanceIsRequired As Boolean

                                  And since you're saving lines of code, why could use auto-implemented properties por LastUpdated, LastUpdatedBy and ClearanceRequired.

                                  C 1 Reply Last reply
                                  0
                                  • U User 9249657

                                    I would prefer to write the attribute for each member, if you want to save lines of code you could write them inline.

                                    <System.Runtime.Serialization.DataMember> Private mLastUpdated As DateTime
                                    <System.Runtime.Serialization.DataMember> Private mLastUpdatedBy As String
                                    <System.Runtime.Serialization.DataMember> Private mClearanceRequired As Int64
                                    <System.Runtime.Serialization.DataMember> Private mClearanceIsRequired As Boolean

                                    And since you're saving lines of code, why could use auto-implemented properties por LastUpdated, LastUpdatedBy and ClearanceRequired.

                                    C Offline
                                    C Offline
                                    Colborne_Greg
                                    wrote on last edited by
                                    #53

                                    yeah I like that way too. It's not about saving lines of code, it's about creating white space

                                    1 Reply Last reply
                                    0
                                    • J jibalt

                                      I think you do need help not being a giant ahole.

                                      C Offline
                                      C Offline
                                      Colborne_Greg
                                      wrote on last edited by
                                      #54

                                      don't be a bully

                                      1 Reply Last reply
                                      0
                                      • J JimmyRopes

                                        Please ask in the proper forum.

                                        The report of my death was an exaggeration - Mark Twain
                                        Simply Elegant Designs JimmyRopes Designs
                                        I'm on-line therefore I am. JimmyRopes

                                        F Offline
                                        F Offline
                                        Fred McGalliard
                                        wrote on last edited by
                                        #55

                                        More satisfying to post in an "improper" forum. Stuffed Shirt proper? :laugh: :laugh:

                                        The fredster

                                        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