|
-
Aug 2nd, 2001, 06:37 AM
#1
Thread Starter
Hyperactive Member
methods and events in my own objects can someone help me clear the difference up
Hi
I sometimes get confused with methods and events
With a text box its easy to understand, there is a click event or a lost focus event etc , the methods are move refresh etc
I am wanting to create a reel object in my programs for work.
A reel is a reel of plastic film
so its properties would be length , id , color
its events would be ( and this is where I am slightly unclear ) things like dispatched , created , passed_inspection , is this the right path that I am on ?
Its methods would be ( again this is the area I get confused with )
assign_to_order , allocate_to_order , calculate_wieght.
If I have a event called passed_inspection would I have a method called inspection.
what would other methods of a reel be ? generally speaking
can someone help me clear this confusion up for me , I am new to objects and am waiting for a beginning objects book to arrive.#
Many thanks
Locutus
-
Aug 2nd, 2001, 07:06 AM
#2
I don't know much about the object your trying to create but I will try to clarify some things for you.
Actually I'm a bit surprised that you find methods and events unclear, most people mix up properties and methods.
But nevermind.
A method is a procedure (function or sub) that your object will execute itself. You want the object to do something, even if you don't know how it does it.
An event is what an object might raise if you want the user (in this case the programmer writing an application that uses this object) to do something (write some code) when something has happened.
As you said with a Command Button or a Text Box it's easy to understand events like Click or Change. But these events is only raised by the object and the object themself doesn't do anything more with them.
It's up to the user (the programmer) to do something when they happen.
You might want to use events to notify the application that uses the object that some work is done.
Let's say that you have an object that watches over a directory (or over a computer port, like COM1) and it will notify the application as soon as there has been a change in that directory (like a file has changed or been removed. Or a new file or subdirectory has been created) you would use an event and not a method.
If you use a method then it's up to the application to watch the directory and telling the class to do something when it's been changed.
I hope I haven't confused you even more by now 
Best regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|