Monday, August 10, 2009

How Zip Codes can get complicated

[This was originally posted at http://timstall.dotnetdevelopersjournal.com/how_zip_codes_can_get_complicated.htm]

I mentioned in a previous post that while states (in an address) seem simple - indeed most developers have made a dropdown to "pick your state" - in legacy apps they can quickly get complicated. Same thing applies to zip codes. It sounds like a secondary afterthought - "Oh, just add a field to the application so we can store numbers like 20500." However, it can quickly snowball:

  • Do you store the 4 digits at the end, like "20500-0003".
  • If you remove the spaces and dashes, you're left with just numbers - which seems easier to store and search on. So do you store it as an integer (205000003)? This might work if you're only looking at cities in the midwest or west coast, but some east coast states use zip codes that start with a "0", which would get truncated if stored as a number. Personally, I prefer to store them as a varchar, and then have a UI validation (for new) and backend scrubbing process (for existing) to standardize the format in the database.
  • Do you enforce valid zip codes only? Not every 9-digit combination of numbers is a valid zip code - i.e. there are not 1 trillion distinct codes that actually are used.
  • Many applications assume that one zip code belongs to one state - but there are scenarios where a single zip code is shared by multiple states (seriously).
  • Do you allow your zip code field to store international postal codes? Many US applications start off small, and only worry about the US market. Then some business sponsor says "we're missing out on the Country XYZ market, quick, update the app to handle foreign cities". This often causes changes to an address screen, and the quickest way to change it may be providing an "Out-Of-Country" option for the state dropdown, and allow the zip code to store international postal codes.
  • And do you handle all this in the UI with a rich control, or just use a "flexible" 10-character textbox?

1 comment:

  1. Ngày nay trên thị trường nội thất có nhiều thương hiệu sản phẩm nội thất khác nhau như Hòa Phát, The City….với nhiều mẫu mã sản phẩm cũng như chất liệu nhằm đáp ứng tất cả nhu cầu của khách hàng. Nên khi bạn có nhu cầu mua bàn làm việc giá rẻ hay những sản phẩm nội thất khác bạn sẽ dễ dàng tìm được nhà cung cấp cho phù hợp với nhu cầu của bạn. Và hôm nay chúng tôi giúp bạn cách chọn mua được mẫu bàn làm việc cho văn phòng tốt nhất:
    Về hình thức, những mẫu ban van phong gia re tphcm hiện nay trên thị trường cần có kiểu dáng sang trọng, mẫu mã mới lạ, độc đáo kèm theo màu sắc đột phá dễ dàng tạo cảm giác thân thiện, thoải mái cho người dùng. Thiết kế kiểu dáng của bàn không cần cầu kỳ chỉ với thiết kế đơn giản, gọn gàng, chất liệu gỗ tiêu chuẩn mang lại sự an toàn cho người sử dụng.
    Giống như chất liệu làm các nội thất khác như bàn giám đốc cao cấp, vách ngăn di động. Về chất liệu, bàn được thiết kế với chất liệu cao cấp, chất lượng phù hợp với khí hậu nóng ẩm của Việt Nam, đồng thời một số loại bàn còn có khả năng chống cháy, chống mối mọt, ẩm mốc. Mặt bàn thường được làm từ chất liệu gỗ công nghiệp cao cấp như melamine, laminate, MDF… với nhiều tính năng bền đẹp, chắc. Cạnh bàn thiết kế kiểu uốn con tạo nên sự mềm mại cho người sử dụng và tránh bị tổn thương khi va chạm vào góc nhọn. Ngoài bàn ra thì ghe van phong tphcm cũng là thiết bị không thể thiếu trong văn phòng làm việc của bạn và cách chọn mẫu ghế như thế nào để có sự kết hợp hài hòa giữa bàn và ghế, không gian nội thất văn phòng. Tạo cảm giác thoải mái cho nhân viên trong thời gian ngồi làm việc tại công ty.

    ReplyDelete