On 6/27/06, <b class="gmail_sendername">Alan Gauld</b> <<a href="mailto:alan.gauld@freenet.co.uk">alan.gauld@freenet.co.uk</a>> 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;">
> Ok, that leads me to my next question. Currently, I have a class<br>> that I<br>> want to unit test, but it contains a semaphore from another class.<br>> Now, I<br>> could make the semaphore a global variable, or I bring in the other
<br>> class.<br>> One violates "good" programming principles and the other violates<br>> the unit<br>> testing principles. Is there another way?<br><br>Reconsider your definition of a "Unit" 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 "strongly" 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>