try {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("ad...@example.com", "Example.com Admin"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress("us...@example.com", "Mr. User"));
msg.setSubject("Your Example.com account has been activated");
msg.setText(msgBody);
Transport.send(msg);
} catch (AddressException e) {
// ...
} catch (MessagingException e) {
// ...
}
Now I suddenly have two Exceptions I have to deal with. I don't like those exceptions to leak into my application, which means I have to catch and handle them here. I did never write any logic in my TDD cycles to cause these error situations, so the catches will not be covered by my tests. Is this wrong? Validation for the e-mailaddress (causing the AddressException) is already implemented in my application before starting the send use-case of the e-mail. The AddressException therefore should not be able to occur. It feels dangerous not to do anything with the exceptions, however.--
The only way to go fast is to go well.
---
You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discu...@googlegroups.com.
To post to this group, send email to clean-code...@googlegroups.com.
Visit this group at http://groups.google.com/group/clean-code-discussion.
Roy Osherove always says that the best way to learn a third-party library is by writing tests to it.Juan
2013/9/11 Caio Fernando Bertoldi Paes de Andrade <caio...@gmail.com>
Hi guys,Testing third-parties can be done very healthily via learning tests. I searched like crazy here but I couldn’t find where I read about this. It basically consists of writing key tests for a library while you learn how it works. This way you make sure the library works as you expect and when a new version is available, you just run your learning tests to check if it’s still compatible.About the implications a third-party library can have in your application’s design: Just write an adapter for it, exposing only the usage (and therefore the design) that makes sense for your application. The third-party will then turn into a plugin. Yes, the adapter will have to deal with stuff (e.g. exceptions) you don’t want to, but the adapter is an implementation detail outside of your application design. The interface (e.g. EmailGateway) is what has to be very clean.
Hope this helps,Caio
On 11 Sep 2013, at 07:30, Carlos Ble <ble.j...@gmail.com> wrote:
Hi,The benefit from writing tests first is that you get the chance to think of the design. You choose a design and then implement it the best way you know.However, when using third party tools the design is already done and you don't have margin to make design decisions. In this case I do write the tests after.You can use a "fake" object for "Transport.send" and test everything else with an integration test.Cheers :-)
El martes, 10 de septiembre de 2013 07:23:29 UTC+1, Jop van Raaij escribió:Thank you for the suggestions, I agree.
I do feel a bit confused about adding code which is not driven by my tests. The only way I can think of to 'approve' this external force which is writing tests and code, is by accepting the guys who build javax.mail did a good job and have dealt with more error/exception situation to handle as I've done until now. Eventually I probably come to the same solution as they did, but it'll cost me a lot of time and effort.
On Wednesday, September 4, 2013 6:15:22 PM UTC+2, Uncle Bob wrote:I'm with featurefabrik on this one. I'll add that you can likely bury the javax exceptions in side your specific exceptions so that when you find yourself debugging, you'll have the stack traces you need.--
The only way to go fast is to go well.
---
You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discussion+unsub...@googlegroups.com.
To post to this group, send email to clean-code...@googlegroups.com.
Visit this group at http://groups.google.com/group/clean-code-discussion.
--
The only way to go fast is to go well.
---
You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clean-code-discussion+unsub...@googlegroups.com.