June 30, 2024, 03:58:22 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


method, event, properties

Started by kryton9, August 16, 2006, 09:20:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kryton9

Looking at other OOP information about what classes are, I have been running across these:
events
methods
properties

I know that methods are functions that class uses to do things with it's variables.

What would be an event in Aurora?

Are properties just the variables of the class?

Ionic Wind Support Team

Pretty much.  An event is a handler like OnSize.   ActiveX interfaces have properties which a similar to member variables.
Ionic Wind Support Team

kryton9

Can we generate events in Aurora in our functions?

And would properties have a get and set function, is that what makes them a property?

Ionic Wind Support Team

Use the SendMessageA API call to send a message to a window.    The OnXXX handlers are messages handlers, when your window receives a WM_CLOSE then OnClose in your class is called.

Quote
And would properties have a get and set function, is that what makes them a property?

Design it anyway you wish.   The word 'property' is usually given to an object you really don't have direct access to.  Such as a COM control or ActiveX object.  With lots of member variables that they don't want to create direct interfaces for.

If your reading a reference that keeps calling things 'properties' then your probably just going to confuse yourself.  Don't overcomplicate the simple and elegant nature of Aurora with terminology from other bloated languages.

If you have a memebr variable like m_float and you don't want to access it directly then feel free to make an accessor function.

MyObject::GetMFloat(),float
{
     return m_float;
}

MyObject::SetMFloat(float f)
{
    m_float = f;
}

Personally I don't like generic functions that use a string to property representation.

Set("Something", f);
f = Get("Something");

But to each their own.
Ionic Wind Support Team

kryton9

OK thanks I get a better understanding now.

Kale

Quote from: Paul Turley on August 16, 2006, 10:08:26 PM
Don't overcomplicate the simple and elegant nature of Aurora with terminology from other bloated languages.

LOL! :D

Parker

In C# properties look like this:
int stuff
{
  get
  {
    return _stuff;
  }
}


You can also have a "set" section, where you would assign to the variable. My example is called a read-only property. Because there is no set section, you can't write to it, only use it in an expression like x = MyClass.stuff;. You can do anything you want in that handler though, just like a function. They're actually pretty cool in my opinion, and I would love to have them show up in Aurora.