Could you refactor this (production!) code... (without any comment in whole class!!!)
visitorText.append(subfill("Land", COL_1_WIDTH - 2)) .append(": ") .append(subfill((product.getCity().getCountry() != null) ? product.getCity().getCountry().getDisplayText(locale) : "", COL_2_WIDTH)) .append(subfill("Ziel", COL_3_WIDTH - 2)) .append(": ") .append((product.getCity().getRegion() != null) ? product.getCity().getRegion().getDisplayText(locale) : "") .append(CRLF); visitorText.append(subfill("Ziel", COL_1_WIDTH - 2)) .append(": ") .append(subfill((product.getCity() != null) ? product.getCity().getDisplayText(locale) : "", COL_2_WIDTH)) .append(CRLF) .append(subfill("Flug", COL_1_WIDTH - 2)) .append(": ") .append(product.getOutwardFlightData().getOriginAirport().getLC() + " " + product.getOutwardFlightData().getDestinationAirport().getLC() + ((product.getReturnFlightData().getOriginAirport() != null) ? ("/" + product.getReturnFlightData().getOriginAirport().getLC() + " " + product.getReturnFlightData().getDestinationAirport().getLC()) : "")) .append(CRLF) .append(subfill("Hotel", COL_1_WIDTH - 2)) .append(": ") .append(HTMLUtil.unmaskUmlauts(product.getProductName())) .append(CRLF) .append(subfill("Zimmer", COL_1_WIDTH - 2)) .append(": ") .append(roomDesc) .append(CRLF) .append(subfill("Verpflegung", COL_1_WIDTH - 2)) .append(": ") .append(subfill(boardingDesc, COL_2_WIDTH)) .append(subfill("Belegung", COL_3_WIDTH - 2)) .append(": ") .append(occupancy) .append(CRLF);
Ha! "COL_x_WIDTH-2" to account for the ": "... beauty.
On the other hand, the variable name has the word "visitor" in there, so it must be good!
Tom
Log in to post a comment.
Could you refactor this (production!) code...
(without any comment in whole class!!!)
visitorText.append(subfill("Land", COL_1_WIDTH - 2))
.append(": ")
.append(subfill((product.getCity().getCountry() != null)
? product.getCity().getCountry().getDisplayText(locale) : "",
COL_2_WIDTH))
.append(subfill("Ziel", COL_3_WIDTH - 2))
.append(": ")
.append((product.getCity().getRegion() != null)
? product.getCity().getRegion().getDisplayText(locale) : "")
.append(CRLF);
visitorText.append(subfill("Ziel", COL_1_WIDTH - 2))
.append(": ")
.append(subfill((product.getCity() != null)
? product.getCity().getDisplayText(locale)
: "", COL_2_WIDTH))
.append(CRLF)
.append(subfill("Flug", COL_1_WIDTH - 2))
.append(": ")
.append(product.getOutwardFlightData().getOriginAirport().getLC()
+ " "
+ product.getOutwardFlightData().getDestinationAirport().getLC()
+ ((product.getReturnFlightData().getOriginAirport() != null)
? ("/"
+ product.getReturnFlightData().getOriginAirport().getLC()
+ " "
+ product.getReturnFlightData().getDestinationAirport().getLC())
: ""))
.append(CRLF)
.append(subfill("Hotel", COL_1_WIDTH - 2))
.append(": ")
.append(HTMLUtil.unmaskUmlauts(product.getProductName()))
.append(CRLF)
.append(subfill("Zimmer", COL_1_WIDTH - 2))
.append(": ")
.append(roomDesc)
.append(CRLF)
.append(subfill("Verpflegung", COL_1_WIDTH - 2))
.append(": ")
.append(subfill(boardingDesc, COL_2_WIDTH))
.append(subfill("Belegung", COL_3_WIDTH - 2))
.append(": ")
.append(occupancy)
.append(CRLF);
Ha! "COL_x_WIDTH-2" to account for the ": "... beauty.
On the other hand, the variable name has the word "visitor" in there, so it must be good!
Tom