This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
It's not c because c calls a method in the assert. That method might change some state, or be needed to do some part of the methods algorithm. And if assertions are turned off, then your algorithm will not work in production.
Assertions should not be used for checking arguments of public methods. That's why option a) doesn't qualify.
Joined: Jul 19, 2004
The argument of the method is having only the method scope and also in the option b, the object s of Socket is having method scope. Then why not option b? Please explain me, i am not aware of this.
Joined: May 28, 2004
Assertions should not be used to validate information supplied by a client. A typical example is argument checking in public methods. Argument checking is part of such a method's contract, which could be violated if assertions were disabled. In choice a, actual value for port is provided when method is invoked. It could be information supplied by a client. [ March 12, 2005: Message edited by: Kedar Dravid ]