On 6/27/06, <b class="gmail_sendername">Alan Gauld</b> &lt;<a href="mailto:alan.gauld@freenet.co.uk">alan.gauld@freenet.co.uk</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&gt; Ok, that leads me to my next question.&nbsp;&nbsp;Currently, I have a class<br>&gt; that I<br>&gt; want to unit test, but it contains a semaphore from another class.<br>&gt; Now, I<br>&gt; could make the semaphore a global variable, or I bring in the other
<br>&gt; class.<br>&gt; One violates &quot;good&quot; programming principles and the other violates<br>&gt; the unit<br>&gt; testing principles. Is there another way?<br><br>Reconsider your definition of a &quot;Unit&quot; maybe?
<br>A Unit should stand alone, it is the smallest amount of code that can<br>stand alone.<br><br>If your class relies on another class maybe both classes need to be<br>considered as a single unit? Or maybe the classes need to be
<br>refactored to<br>make them less closely coupled?</blockquote><div><br>See that what makes this particular coding endevour so exciting. Instead of learning the mechanics of coding, I am starting to gain an understanding of style! I see that only two of my classes are &quot;strongly&quot; link because of a SocketServer call that I make. Other than that I can test all of the other classes independently. And there is one caveat, I will have to make a bunch of semaphores global instead of local to the classes. While I know that there is no hard and fast rule about using global variables, where can I find or can somebody tell me where I can find some guidelines about them (or is this a use common sense rule)? 
<br></div><br>-Thanks,<br>Tino<br><br></div>