Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Expressive
Design
(in 20 minutes)
            phillip calçado
         http://fragmental.tw
javamail usage
I want this CSV
report delivered
  as an e-mail
  attachment
1st Try
public class Mail {

	   public void sendEmailWithCsvFile(String from, String to, String subject,
	   	    	   String body...
Message.RecipientType
I want this CSV
report delivered   InternetAddress      Multipart
  as an e-mail
  attachment
      ...
2nd Try
public class Mail {

	   public void sendEmailWithCsvFile(String from, String to, String subject,
	   	    	   String body...
I want this CSV    MailMessage   Attachment
report delivered
  as an e-mail
                   MailService   Properties
  ...
3rd Try
public class Mail {

	   public void sendEmailWithCsvFile(String from, String to, String subject,
	   	    	   String body...
send_email do
    to 'pcalcado@gmail.com'
    from 'bemaia@fragmental.tw'
    subject 'Testing via Ruby'

      body %{
  ...
I want this CSV      E-mail
report delivered
  as an e-mail
                   Attachment
  attachment
what just
happened?
Noise   Reduction
Noise
                   the difference between


I want this CSV                               E-mail
report delivered
  ...
Noise
                   the difference between


I want this CSV                               E-mail
report delivered
  ...
Noise
                   the difference between


I want this CSV                             E-mail
report delivered
    ...
Noise
           the difference between

Business      Analysis      Design                                       Implemen...
the goal
I want this CSV
report delivered
  as an e-mail
  attachment
I want this CSV
report delivered
  as an e-mail
         E-mail


  attachment
I want this CSV
report delivered
  as an e-mailE-mail


  attachment
     Attachment
the techniques
Noise




Idiomatic”
   Java



        Domain-Driven
            Design
                        Internal DSL

           ...
“Idiomatic”: Focus on how to use
              technical tools to solve the
              problem in an efficient way.

  ...
“Idiomatic”: TFocus on how to use
                              DO: a
                            O             e
        ...
Thanks




http://fragmental.tw
pics
•   http://www.flickr.com/photos/bitzi/293673587/


•   http://www.flickr.com/photos/sage/2143086954/

•   http://www...
Upcoming SlideShare
Loading in …5
×

Expressive Design (in 20 minutes)

12,700 views

Published on

Published in: Technology, Sports

Expressive Design (in 20 minutes)

  1. 1. Expressive Design (in 20 minutes) phillip calçado http://fragmental.tw
  2. 2. javamail usage
  3. 3. I want this CSV report delivered as an e-mail attachment
  4. 4. 1st Try
  5. 5. public class Mail { public void sendEmailWithCsvFile(String from, String to, String subject, String body, List<String> csvFileLines) { Properties props = new Properties(); props.put(quot;mail.smtp.hostquot;, quot;localhostquot;); Session session = Session.getDefaultInstance(props); MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(from)); InternetAddress[] address = { new InternetAddress(to) }; msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject(subject); msg.setSentDate(new Date()); MimeBodyPart part1 = new MimeBodyPart(); part1.setText(body); MimeBodyPart part2 = new MimeBodyPart(); StringBuffer buffer = new StringBuffer(); for (String line : csvFileLines) buffer.append(line + quot;nquot;); part2.setContent(buffer.toString(), quot;text/csvquot;); part2.setFileName(quot;file.csvquot;); Multipart mp = new MimeMultipart(); mp.addBodyPart(part1); mp.addBodyPart(part2); msg.setContent(mp); Transport.send(msg); } }
  6. 6. Message.RecipientType I want this CSV report delivered InternetAddress Multipart as an e-mail attachment MimeMessage MimeBodyPart Session Properties
  7. 7. 2nd Try
  8. 8. public class Mail { public void sendEmailWithCsvFile(String from, String to, String subject, String body, List<String> csvFileLines) { Properties props = new Properties(); props.put(quot;mail.smtp.hostquot;, quot;localhostquot;); MailService mailService = new MailService(props); MailMessage message = mailService.newMessage(); message.setFrom(from); message.setTo(to); message.setSubject(subject); message.setBody(body); StringBuffer buffer = new StringBuffer(); for (String line : csvFileLines) buffer.append(line + quot;nquot;); Attachment csvFile = new Attachment(quot;file.csvquot;, buffer.toString()); message.attach(csvFile); mailService.send(message); } }
  9. 9. I want this CSV MailMessage Attachment report delivered as an e-mail MailService Properties attachment
  10. 10. 3rd Try
  11. 11. public class Mail { public void sendEmailWithCsvFile(String from, String to, String subject, String body, List<String> csvFileLines) { StringBuffer buffer = new StringBuffer(); for (String line : csvFileLines) buffer.append(line + quot;nquot;); Properties props = new Properties(); props.put(quot;mail.smtp.hostquot;, quot;localhostquot;); MailService mailService = new MailService(props); mailService.newMessage() .from(from) .to(to) .subject(subject) .body(body) .attachTextFile(quot;file3.csvquot;, buffer.toString()) .send(); } }
  12. 12. send_email do to 'pcalcado@gmail.com' from 'bemaia@fragmental.tw' subject 'Testing via Ruby' body %{ Hi, Please do not forget the milk. Bye! } attachment('file4.csv') << lines end
  13. 13. I want this CSV E-mail report delivered as an e-mail Attachment attachment
  14. 14. what just happened?
  15. 15. Noise Reduction
  16. 16. Noise the difference between I want this CSV E-mail report delivered as an e-mail Attachment attachment
  17. 17. Noise the difference between I want this CSV E-mail report delivered This as an e-mail Attachment attachment
  18. 18. Noise the difference between I want this CSV E-mail report delivered This That as an e-mail Attachment attachment
  19. 19. Noise the difference between Business Analysis Design Implementation public class Something{ Class Name Class Name Attribute Attribute Attribute Attribute private String name; Operation Operation Operation Operation public boolean doS(){ } Class Name Attribute } Attribute Operation Operation This That
  20. 20. the goal
  21. 21. I want this CSV report delivered as an e-mail attachment
  22. 22. I want this CSV report delivered as an e-mail E-mail attachment
  23. 23. I want this CSV report delivered as an e-mailE-mail attachment Attachment
  24. 24. the techniques
  25. 25. Noise Idiomatic” Java Domain-Driven Design Internal DSL External DSL?
  26. 26. “Idiomatic”: Focus on how to use technical tools to solve the problem in an efficient way. Domain-Driven: Language is only a tool to model the domain. Internal DSL: Language is only an :internal { extensible tool to model the DSL domain. } External DSL: Language is created based on the domain.
  27. 27. “Idiomatic”: TFocus on how to use DO: a O e e d r n am technical toolsr thato solve the Ne te be t t fo problem in an efficient way. Domain-Driven: Language is only a tool to model the domain. Internal DSL: Language is only an :internal { extensible tool to model the DSL domain. } External DSL: Language is created based on the domain.
  28. 28. Thanks http://fragmental.tw
  29. 29. pics • http://www.flickr.com/photos/bitzi/293673587/ • http://www.flickr.com/photos/sage/2143086954/ • http://www.flickr.com/photos/brianmitchell/2113553867/ • http://www.flickr.com/photos/kamaski/186266747/ • http://www.flickr.com/photos/tosawyer/43691981/ • http://www.flickr.com/photos/helderfontenele/2134684620/ • http://www.flickr.com/photos/sotto1/808195510/

×