Bug? Properties

Discussion in 'Bugs & wishlist' started by LucaMs, Mar 2, 2015.

  1. LucaMs

    LucaMs Expert Licensed User

    It is not a real bug, but it is a ... uhm... "an incorrect behaviour".

    In a Class I have a property, setSomething(what as int).

    The editor, rightly, does not list setSomething as available method ("intellisense") although it is also a public routine but if you use it like a method (objMyClass.setSomething(12)) it works; instead, this should be an error reported by the compiler, I think.

    [P.S. or/and Syntax error]
    Last edited: Mar 2, 2015
  2. klaus

    klaus Expert Licensed User

    Without seeing your code it's impossible to know what happens.
  3. LucaMs

    LucaMs Expert Licensed User

    I was hoping to have explained well :( :)

    If you had a Class like:

    Sub Class_Globals
    Private mName As String
    End Sub

    Public Sub setName(Name As String)
        mName = Name
    End Sub

    Public Sub getName As String
    Return mName
    End Sub

    Name would be a Property, then you should set its value using:
    Dim Person As clsPerson
    Person.Name = 
    "Erel"' this should not work, and it should show an error.
  4. klaus

    klaus Expert Licensed User

    For me both are correct.
    Just two different ways of writing.
    I think that Person.setName("Erel") is also useful for compatibility with 'old' code written before the introduction of the propety routines.
  5. Erel

    Erel Administrator Staff Member Licensed User

    I agree with Klaus. This is good for compatibility with old code.

    There is another delicate point here. You must use setName inside the class to call the method (and it will show in the autocomplete list). So I don't see any harm if someone also uses this syntax from a different module.
  6. LucaMs

    LucaMs Expert Licensed User

    In fact, most likely this is not a problem.

    I happened to talk to a person about a method that from my point of view does not exist.

    However, inside the class you should not call the property but set the member variable associated with it.

    As for compatibility (somewhat dated) any methods whose name begins with "set" should simply become "Set ..." in the old projects (a replace would be enough).

    This is only a formal question, of course.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice