29
Expressive Design phillip calçado http://fragmental.tw (in 20 minutes)

Expressive Design (in 20 minutes)

Embed Size (px)

Citation preview

ExpressiveDesign

phillip calçadohttp://fragmental.tw

(in 20 minutes)

javamail usage

I want this CSV report delivered

as an e-mailattachment

1st Try

public class Mail {

public void sendEmailWithCsvFile(String from, String to, String subject, String body, List<String> csvFileLines) {

Properties props = new Properties(); props.put("mail.smtp.host", "localhost");

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 + "\n"); part2.setContent(buffer.toString(), "text/csv"); part2.setFileName("file.csv");

Multipart mp = new MimeMultipart(); mp.addBodyPart(part1); mp.addBodyPart(part2);

msg.setContent(mp);

Transport.send(msg); }}

I want this CSV report delivered

as an e-mailattachment

InternetAddress

MimeMessage

Session Properties

Message.RecipientType

MimeBodyPart

Multipart

2nd Try

public class Mail {

public void sendEmailWithCsvFile(String from, String to, String subject, String body, List<String> csvFileLines) {

Properties props = new Properties(); props.put("mail.smtp.host", "localhost"); 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 + "\n"); Attachment csvFile = new Attachment("file.csv", buffer.toString()); message.attach(csvFile);

mailService.send(message); }}

I want this CSV report delivered

as an e-mailattachment

MailMessage

MailService Properties

Attachment

3rd Try

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 + "\n"); Properties props = new Properties(); props.put("mail.smtp.host", "localhost"); MailService mailService = new MailService(props); mailService.newMessage() .from(from) .to(to) .subject(subject) .body(body) .attachTextFile("file3.csv", buffer.toString()) .send(); }}

send_email do to '[email protected]' from '[email protected]' subject 'Testing via Ruby'

body %{ Hi, Please do not forget the milk. Bye! }

attachment('file4.csv') << linesend

I want this CSV report delivered

as an e-mailattachment

E-mail

Attachment

what just happened?

Noise Reduction

I want this CSV report delivered

as an e-mailattachment

E-mail

Attachment

Noisethe difference between

I want this CSV report delivered

as an e-mailattachment

E-mail

AttachmentThis

Noisethe difference between

I want this CSV report delivered

as an e-mailattachment

E-mail

AttachmentThis That

Noisethe difference between

This That

Noisethe difference between

Operation

Operation

Attribute

Attribute

Class Name

Operation

Operation

Attribute

Attribute

Class Name

Operation

Operation

Attribute

Attribute

Class Name

public class Something{

private String name;

public boolean doS(){

}

}

Business Analysis Design Implementation

the goal

I want this CSV report delivered

as an e-mailattachment

I want this CSV report delivered

as an e-mailattachment

E-mail

I want this CSV report delivered

as an e-mailattachment

E-mail

Attachment

the techniques

“Idiomatic”Java

Domain-Driven Design

Internal DSL

External DSL?

Noise

“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 extensible tool to model the domain.

External DSL: Language is created based on the domain.

:internal { DSL}

“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 extensible tool to model the domain.

External DSL: Language is created based on the domain.

:internal { DSL}

TODO:

Need a

better name

for that

Thanks

http://fragmental.tw