This is third in the series.
Don’t re use the same expressions over and over again
When it comes to XQuery writing we normal parses XML and reads data. There are lot of constructs in XQuery to be used so sometimes, we tend to evaluate the same expression again and again.
Let’s look at an example.
Below is an example where a discounted is applied if the game cost exceeding some amount.
In the above example as we see the XML is read again to read the value of the price two time. One for the condition and one for output. It is not a good practice. Another small thing to notice is that XML tag being repeated again. This also can be avoided.
Lets look at a better example now.
Doesn’t is look simpler and better now. Keep it Simple and Better!
Share your thoughts around the XQuery design principles or any specific pattern you want me to assess and I will be sharing my thoughts on that.
Lets do coding better! Subscribe for more!
shreya says
Yet another very informative post from your end. Really they do help a lot. Thank u for the share once more.