Menu

Only two statements ...

2004-03-01
2012-10-07
  • Andrey Loskutov

    Andrey Loskutov - 2004-03-01

    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);

     
    • Tom Copeland

      Tom Copeland - 2004-03-01

      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.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.