Stateless objects are objects that don't have to remember what state they are in, funny enough, between method calls.
What does this mean?
Lets look at some code
Code:
DIM x As Project1.Class1
Set x = New Project1.Class1
'step A Method1 does something. To do its job it needs 2 pieces of information
x.method1 sData, iData
.
.
.
'step B called 5 minutes later. To do its job it needs 2 different pieces of information and a piece from the first call
x.method2 sData2, dblData2, iData
Now those objects could be stateless in that everything method1 and method2 need to there jobs are passed to them at the time the method is called.
A non stateless object you might put those variables into properties and call the method without any parameters.
You might ask what the difference is. Well if Method1 and Method2 are called 5 minutes apart and they have to remember the properities between the calls then that is wasting RAM and possibly other resources on the server. Where the stateless object you send the method all the information it needs and when it is done the method can inform MTS/Component services and the object will be recycled.
What do I mean about being recycled. Well that object can be put in a pool and if another client requests a Project1.Class1 it can be given to them. You client still has a handle to a Project1.Class1 but the next time you call a method you may not actuall get the same one you had before. Since you are not relying on properties to still be set on the object you don't care.
Think of it like this.
You like pizza.
You want to go out on a night on the town but don't want to drive.
So you call the taxi company and say
"Can I a taxi at 123 Jones road going to 25 Center Street" <-Method call
the taxi company dispatches you a taxi.
Your out on the town for a few hours and ready to go home
So you call the taxi company and say
"Can I a taxi at 25 Center Street going to 123 Jones road " <-Method call2
You may or may not get the same taxi
During the time you are out that taxi was free to do other jobs for other people
your handle to the taxi company is the same (phone number)
It would be more expensive for you to hire a car and driver for the entire night.
Why pay for something when you don't really need it. That is what stateless objects
are about. A few object can service many clients just like a few taxi's can service
many people.
What do you loose? Well you can't just tell the taxi driver "Take me home" because
he/she does not know where your home is. In Just in Time Activation it would be like
even if you got the same taxi driver they have very bad memory and once they drop you
off they forget everything about you. So you must supply them with the info they
need to get you home, your address.
To make a object stateless you follow some guidelines.
1) no properties. Properties are soley for maintianing state.
2) no internat variables that must maintain value from one call to the next as this is maintaining state also
3) inform MTS/Component Services when you are done and the server can reuse the object. (This is like paying the taxi driver and letting them go)
Its a lot to take in an a big shift from conventional programming.