Thursday 15 July 2010

.net - Returning interface without concrete class -



.net - Returning interface without concrete class -

i came across post said when returning interface, 1 should not homecoming concrete class implementing because makes programmers using function returns interface assume things according see returns. may cause code work on later versions may not. question. there way seperate interface homecoming type concrete class implementing it? can homecoming interface without farther metadata comes concrete , available others? thanks

the declaration of reference homecoming should interface type, not concrete class implements it. such class declared internal nobody can monkey , you're free alter implementation see fit without breaking client code.

at runtime, client programmer always going able see class implements interface. , can peek @ private parts. cannot stop this, debugger smart plenty figure out. that's debuggers do. of no concern, view debugger provides not mean client programmer can freely party on class. accessibility still enforced @ compile time. if he's trying grab plane heading home , you're not picking phone, yes, may utilize reflection poke himself out of trouble. you'll break q&d hack next release not surprise him :)

.net interface

No comments:

Post a Comment