Results 1 to 6 of 6

Thread: Property or Public Variable

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Location
    india
    Posts
    95

    Property or Public Variable

    hi,

    in my 3 tier project i want to set some values in another layer( ex :Business layer). which is best method to assign values. GET SET property or creating public variable(s) in Business layer for holding the values?

  2. #2
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Property or Public Variable

    Property's are more natural in use than member functions, and considered better programming practice than public variables.

    Public variables are a no-no.
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Property or Public Variable

    Obviously, a public property, because you can place some logic in your get/set blocks at any time.

  4. #4
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: Property or Public Variable

    And by logic, that usually means validation logic; as in: "is this value appropriate?"
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Location
    india
    Posts
    95

    Re: Property or Public Variable

    yes
    Property's are more natural in use than member functions, if i want to assign more values to bussiness layer member i should create more property is it correct. suppose i have 20 values to assign for business layer, then there should be 20 property members in my Bussiness layer? is this is applicatble?

  6. #6
    Member CommanderEl's Avatar
    Join Date
    Feb 2005
    Location
    Adelaide, Australia
    Posts
    40

    Re: Property or Public Variable

    by applicatble im going to assume you mean a mixture of acceptable/applicable.
    yes, perfectly acceptable
    more readable than public variables and better programming practice.
    it makes sense to add these to the business layer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width