Personally, it all comes down to speed. However, if you are super green you dont know how fast is too fast.
When I get on on the fly, I will always look at the bolts on the wheel, if you can clearly see all three bolts rotating, usually safe enough to get on, depending on experience. I will always look down-track to make sure there arent any signals/signs/tunnels that will be in my way. I will always get on with my whole pack on my back leaving both hands/feet free. I get on alot of high wall gondolas, so there has to be at least 15 seconds of free space in front of you when you first grab the ladder.
Always catch with a ladder. Doing otherwise is fucking stupid.
Getting off....I will usually make sure the side track is clear visually for at least 30 seconds of movement. If the train is going too fast, I will throw my pack down first, then jump off, but i will usually wait till it slows down enough, and dismount with my pack on, using the previously mentioned methods.
If I am doubtful, I will dismount, and when i hit ballast, I will hang on for a portion of a second, and then push off hard from the train, sending myself far away from danger, and roll sideways on ballast down hill away from the train. Haven't hurt myself yet, but I'm sure it will happen