Difference: ProgrammingNotes (12 vs. 13)

Revision 1315 May 2003 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="TechTips"
(back to TechTips)
Line: 51 to 51
  In general, look for opportunities to eliminate duplicate data. It will pay off over time in clearer code that's easier to use.
Added:
>
>

Saying "No" vs. Saying Nothing

I've noticed that many systems seem to confuse the difference between "no" and saying nothing. For example, if you make a database query and it returns zero rows, can you tell the difference between that case and it not returning at all? This is especially important when you're working with external systems because it's very important to know whether the other system responded properly, but with an empty result set, or whether it crashed or timed out. This difference is rarely important to programmers but it's vitally important to the operations staffs that run online systems since they should be able to tell at a glance what part of the system to spend their time diagnosing.

My rule of thumb is that you shouldn't throw when you get empty responses. So if the database returns 0 rows for your query you should return an array or collection with zero elements, but there should be no exception since everything was processed properly. Save the exception for when things actually go wrong, such as timeouts, communications failures, etc.

A guy that I once worked with wrote a research paper that went into extreme detail about the differences between different types of uncertainty in software development, i.e. the difference between "I don't know" and "I know that there's no answer". Actually, I didn't understand much beyond the abstract but my co-worker spent some time explaining it to me.

A related topic is the difference in relational dbms terms between null and 0, but that's a different discussion.

View topic | History: r25 < r24 < r23 < r22 | More topic actions...
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback