But I don't know how I can bring methods from different classes to be used on the same object?
being able to use a rich set of methods without all methods defined in the same class, or without skipping between objects in the automation script
Todor Kolev wrote:
Now, when the user tries to code .myDslMethod() into the script, they only see SessionDsl methods suggested by the IDE, like so:
currentSession. <- IDE spews all applicable methods, which is a little spammy
currentSession.dsl(). <- IDE suggests only DSL methods - a nice time saving and reduction of error chance
I just don't like creating a new object just so I can link methods from its class into my "single point of service" class.
Please explain that part; there is something iffy about that. Are you allowing a this reference to escape a constructor?
Todor Kolev wrote:. . .. . .
That is called a default constructor. All other opinions are wrong
Todor Kolev wrote:. . . I later deemed those constructors redundant anyway and went with the "uncoded" constructor (lots of different opinions on the web about how to call the constructor created by the compiler when the class doesn't explicitly define a constructor with written code). . . .
The runtime can optimise execution in all sorts of ways, which can cause lines whose population of variables are disjoint to be taken in any order. If they apply to different variables, it must be all right to take the lines in a different order. The JVM might even run several threads itself, and distribute execution of your constructor between those threads.
Todor Kolev wrote:I am trying to understand how these lines could execute out of order.
1. Is it only a problem for multi-threaded design? . . .
Don't know. Could be any of those. Could be different from what happened yesterday.
2. What are the threads doing that can lead to this failure?
a) Are they "sharing" code lines, like:
Thread A: creates blank object, assigns fields Name and DoB
Thread B: assigns gender
Thread C: calls registerPupil
b) Or, is it a problem at the higher level, like:
Thread A: creates and starts to initialize fields
Thread B: school.getMaleFemaleRatio(); . . .
Threads don't pick up random code. The JVM must maintain correctness of all variables. If the gender variable is only used in line 5, then it can't be wrong to execute line 5 before line 4. Each thread will execute code using the gender variable so as to get the correct result.
How could one code ANYTHING when threads pick up random code?
That looks like a recursive definition to me. At least you can pretty well rely on suffering an exception if you get problems with that recursion.
Todor Kolev wrote:. . . 'this', in my constructor assigns the field of the current instance a reference to the instance. . . .
I wasn't selected to go to mars. This tiny ad got in ahead of me:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Appshttps://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous