When I came to an outsourcing company, I felt the pressure to survive. I often worked overtime and had no time to rest. Let alone reading books or doing other interesting things. The first thing to do is sacrifice.CodeQuality. I hope that I can keep my code requirements concise and powerful.
A bug was received last week to modify a message. For a business operation, if there is a receipt proof (receipnumber), the displayed message for the user will be all different, the simplest and most direct implementation:
If (string. isnullorempty (this. _ presenter. receiptnumber) {If (utility. showmessagebox (messages. tenancy. tnc059 ). equals (dialogresult. no) return;} else {If (utility. showmessagebox (messages. tenancy. tnc131 ). equals (dialogresult. no) return ;}
This snippets is not awkward. In the code, this snippets is also set in another if... That's ugly in else. I want to shorten the number of lines of code:
If (utility. showmessagebox (string. isnullorempty (this. _ presenter. receiptnumber )? Messages. tenancy. tnc131: messages. tenancy. tnc059). Equals (dialogresult. No) return;
However, this code is not expressive enough. I modified it again to enhance the expressiveness.
VaR message = string. isnullorempty (this. _ presenter. receiptnumber )? Messages. tenancy. tnc131: messages. tenancy. tnc059; If (utility. showmessagebox (Message). Equals (dialogresult. No) return;
Now, I am more satisfied.