Explain the concept of priming read Java.
I was taught this expression and pattern way back in the day. Sure, the name comes from old pumps that needed to be filled with water before they could pump water, but who cares? We're talking about code here.
Some really good examples and an explanation of what the pattern accomplishes would be welcome. How is this pattern regarded today?
Priming can sometimes get a defective loop working but at the cost of DRY. So it may be a brief stop on the way to a better design. Is this considered an anti-pattern? Are there alternatives?
This metaphor almost certainly refers to the practice of establishing the first conditional check in a while loop. If you don't do this, the loop won't work. It is a well-established pattern, and it hasn't changed since the while loop was invented. The requirement for setting the initial condition in a while loop is not a defect.
int i = 0; // prime the pump
while (i < 10 xss=removed xss=removed xss=removed xss=removed xss=removed xss=removed>