Is this a valid object design? I have a domain object where I insert the service and call the verification method to update the state of the object, and if everything goes well, send a confirmation message. The code looks like this:
class Foo { String bar Service emailService public boolean verify() { bar = "foo" if(this.save()) { emailService.sendConfirmation() } } } Foo.get(1).verify()
Is it allowed to call the email service in this case? Is there a design template that I can use for such a situation.
Thank. - Ken
. , . , - , .
- , , ( ).
, - .
' ( , ) . . :
class Foo { String bar public boolean verify(Service emailService) { bar = "foo" if(this.save()) { emailService.sendConfirmation() } } } Foo.get(1).verify(new Service(...))
( ) . Udi Dahan. , . .
,
, . , .
, . .
(?), . , , , Foo ConfirmationMessage ( ), . .
Foo
ConfirmationMessage
, Service , , - , . , , , () .
Service