Click here to Skip to main content
15,899,679 members
Home / Discussions / C#
   

C#

 
QuestionC# network transfer stream problem Pin
art_coding27-Mar-07 10:19
art_coding27-Mar-07 10:19 
QuestionClass "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme27-Mar-07 9:54
Edmundisme27-Mar-07 9:54 
AnswerRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Dave Kreskowiak27-Mar-07 10:11
mveDave Kreskowiak27-Mar-07 10:11 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Austin Harris27-Mar-07 10:25
Austin Harris27-Mar-07 10:25 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Dave Kreskowiak27-Mar-07 12:43
mveDave Kreskowiak27-Mar-07 12:43 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Leslie Sanford27-Mar-07 10:26
Leslie Sanford27-Mar-07 10:26 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme27-Mar-07 10:27
Edmundisme27-Mar-07 10:27 
AnswerRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Leslie Sanford27-Mar-07 10:22
Leslie Sanford27-Mar-07 10:22 
Edmundisme wrote:
I don't know if simply giving the child an IPlayable iterface and the Vet an IEuthanizable interface will be restrictive enough as Child could cast IPlayable to Dog and thereby access its "Euthanize" method.


This will sound trite, but the simple answer is to make sure that your Child code doesn't do that.

Interfaces are good for enforcing the kind of contraints you've described; they limit how the outside world views an object thereby constraining what actions you can perform on them. However, if someone (another programmer) is going to abuse the contract you've given them by only exposing your objects through a limited interface... well, they've broken the contract and all bets are off.

Other than that, you could have some type of key that has to be passed to the Euthanize method. Only a vet would posses such a key, so in theory only a vet could euthanize a pet. Just make sure that the key is hidden from the child. Smile | :)

I'm curious about this problem, however, and will enjoy reading other answers. Hopefully, they will be more helpful.
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme27-Mar-07 10:36
Edmundisme27-Mar-07 10:36 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Leslie Sanford27-Mar-07 10:47
Leslie Sanford27-Mar-07 10:47 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme27-Mar-07 11:49
Edmundisme27-Mar-07 11:49 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
led mike28-Mar-07 5:21
led mike28-Mar-07 5:21 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme28-Mar-07 6:15
Edmundisme28-Mar-07 6:15 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme28-Mar-07 6:30
Edmundisme28-Mar-07 6:30 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
led mike28-Mar-07 6:52
led mike28-Mar-07 6:52 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme28-Mar-07 7:21
Edmundisme28-Mar-07 7:21 
QuestionAppDomains & Loading Assemblies Pin
AJ12327-Mar-07 9:19
AJ12327-Mar-07 9:19 
AnswerRe: AppDomains & Loading Assemblies Pin
S. Senthil Kumar27-Mar-07 17:01
S. Senthil Kumar27-Mar-07 17:01 
Questionchange hue saturation Pin
samreengr827-Mar-07 9:03
samreengr827-Mar-07 9:03 
QuestionMultiplayer game Pin
Fco. Javier Marin27-Mar-07 8:50
Fco. Javier Marin27-Mar-07 8:50 
QuestionC# XmlReader Pin
lost in transition 27-Mar-07 8:20
lost in transition 27-Mar-07 8:20 
AnswerRe: C# XmlReader Pin
Not Active27-Mar-07 8:26
mentorNot Active27-Mar-07 8:26 
GeneralRe: C# XmlReader Pin
lost in transition 27-Mar-07 8:30
lost in transition 27-Mar-07 8:30 
AnswerRe: C# XmlReader Pin
Ennis Ray Lynch, Jr.27-Mar-07 8:48
Ennis Ray Lynch, Jr.27-Mar-07 8:48 
AnswerRe: C# XmlReader Pin
Austin Harris27-Mar-07 9:08
Austin Harris27-Mar-07 9:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.