Note that there are some explanatory texts on larger screens.

plurals
  1. POTDD : Any pattern for constant testing?
    primarykey
    data
    text
    <p>Constants are beautiful people - they can hold in a unique place a value that is used everywhere in your code. Changing that value requires only one simple modification.</p> <p>Life is cool.</p> <p>Well, this is the promise. Reality is sometime different :</p> <ul> <li>You change the <code>LogCompleteFileName</code> constant value from <code>L:\LOGS\MyApp.log</code> to <code>\\Traces\App208.txt</code> and you get two files : <code>\\traces\App208.txt</code> for the traces and <code>\\traces\App208.txt.log</code> for the logs...</li> <li>You change <code>TransactionTimeout</code> from 2 to 4 minutes and you still get a timeout after 2 minutes (after spending the day, you find out that you also have to change the timeout of the DBMS and the timeout of the transaction manager...).</li> <li>You replace <code>SleepTimeInMinutes</code> from <code>1</code> to <code>10</code> and you see no change (after an hour or so, you find out that the constant's name was misleading : the granularity is not the minute but the millisecond...).</li> <li>Even more subtle: you change <code>CompanyName</code> from, say <code>Yahoo</code> to <code>Microsoft</code> but automated mail alerts are still sent to <code>alert@yahoo.com</code>...</li> </ul> <p>Creating a constant is a contract. You are telling your readers that whenever they change the value, it will still works the way they think it should be.</p> <p>Nothing less. </p> <p>Of course, you need to test that you are not misleading your readers. You have to make sure that the implied contract is right.</p> <p>How do you achieve that with TDD? I'm just stuck with that. The only way I can test a change for a constant (!) value is to make that constant an application setting... Should I have to conclude that the <code>const</code> keyword should be avoided when I think that the value can and will change?</p> <p>How are you testing your (so called) constants using TDD?</p> <p>Many thanks in advance :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload