O quanto você está satisfeito com o código que produz? Mais ainda: o quanto você está satisfeito como profissional? Na busca pela melhoria de nossas aplicações, caímos num grande desafio: melhorar a nós mesmos!
Numa conversa franca e descontraída, Samuel e Victor tentarão apresentar idéias sobre como você pode melhorar seu próprio trabalho e sentir orgulho do que faz.
7. /* I realize that this program is a messy
compilation of inefficient coding, and
perhaps even stands as
something blasphemous in your eyes.
Coming midterms forced me to write the
program as is because this format required
the least amount of thinking as well as the
least amount of time. Therefore, I only ask
one thing of you: Be gentle. */
http://www.thedailywtf.com
8. Public static int getTestcell()
{
int i, neighbor, male, female, empty, value, num;
male = 0;
female = 0;
empty = 0;
value = 0;
num = 0;
if (spotvalue[n] == 0)
{
neighbor = n;
if (n == 0)
{
if (spotvalue[neighbor + 1] == 0)
empty = empty + 1;
else
{
if (spotvalue[neighbor + 1] == 1)
male = male + 1;
if (spotvalue[neighbor + 1] == 2)
female = female + 1;
}
if (spotvalue[neighbor + 20] == 0)
empty = empty + 1;
else
{
9. if (spotvalue[neighbor + 20] == 1)
male = male + 1;
if (spotvalue[neighbor + 20] == 2)
female = female + 1;
}
if (spotvalue[neighbor + 21] == 0)
empty = empty + 1;
else
{
if (spotvalue[neighbor + 21] == 1)
male = male + 1;
if (spotvalue[neighbor + 21] == 2)
female = female + 1;
}
if (male >= 1 && male <=2)
{
if (male == female)
{
num = rand.nextInt(2);
value = num + 1;
return value;
}
else
{
value = 0;
10. }
}
else
{
value = 0;
return value;
}
}
if (n == 19)
{
if (spotvalue[neighbor - 1] == 0)
empty = empty + 1;
else
{
if (spotvalue[neighbor - 1] == 1)
male = male + 1;
if (spotvalue[neighbor - 1] == 2)
female = female + 1;
}
if (spotvalue[neighbor + 20] == 0)
empty = empty + 1;
else
{
if (spotvalue[neighbor + 20] == 1)
male = male + 1;
if (spotvalue[neighbor + 20] == 2)
11. female = female + 1;
}
if (spotvalue[neighbor + 19] == 0)
empty = empty + 1;
else
{
if (spotvalue[neighbor + 19] == 1)
male = male + 1;
if (spotvalue[neighbor + 19] == 2)
female = female + 1;
}
if (male >= 1 && male <=2)
{
if (male == female)
{
num = rand.nextInt(2);
value = num + 1;
return value;
}
else
{
value = 0;
return value;
}
}
else
12. value = 0;
return value;
}
}
if (n == 380)
{
if (spotvalue[neighbor + 1] == 0)
empty = empty + 1;
else
{
if (spotvalue[neighbor + 1] == 1)
male = male + 1;
if (spotvalue[neighbor + 1] == 2)
female = female + 1;
}
if (spotvalue[neighbor - 20] == 0)
empty = empty + 1;
else
{
if (spotvalue[neighbor - 20] == 1)
male = male + 1;
if (spotvalue[neighbor - 20] == 2)
female = female + 1;
}
if (spotvalue[neighbor - 19] == 0)
empty = empty + 1;
49. class Email {
public Email() { ... }
public void setFrom(String from) { ... }
public void setTo(String to) { ... }
public void send() {
// YOUR HOT CODE HERE
}
}
http://guilherme.pro/2009/04/05/why-i-dont-write-code-comments/
51. new EmailMessage( )
.from("teste@localhost.net")
.to("destination@address.com")
.withSubject("Fluent Mail Example")
.withBody("What a nice code!")
.send();
http://guilherme.pro/2009/04/05/why-i-dont-write-code-comments/
53. O que este código faz?
java.util.Calendar c =
java.util.Calendar.getInstance();
c.set(2005, java.util.Calendar.NOVEMBER, 20);
long time = c.getTime();
http://www.slideshare.net/gvespucci/refactoring-an-introduction
54. long time = october(20, 2008);
http://www.flickr.com/photos/schoeband/3861094589/sizes/l/ http://www.slideshare.net/gvespucci/refactoring-an-introduction
55. What is a Clean Code?
“Quando você olha para o código, percebe que
ele faz exatamente o que você esperava”
Howard Cunningham
http://railsconf.blip.tv/file/2089545/
58. // create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", _smtpHost);
Session session = Session.getDefaultInstance(props, null);
// create a message
Address replyToList[] = { new InternetAddress(replyTo) };
Message newMessage = new MimeMessage(session);
if (_fromName != null)
newMessage.setFrom(new InternetAddress(from,
_fromName + " on behalf of " + replyTo));
else
newMessage.setFrom(new InternetAddress(from));
newMessage.setReplyTo(replyToList);
newMessage.setRecipients(Message.RecipientType.BCC,
_toList);
newMessage.setSubject(subject);
newMessage.setSentDate(sentDate);
// send newMessage
Transport transport = session.getTransport(SMTP_MAIL);
transport.connect(_smtpHost, _user, _password);
transport.sendMessage(newMessage, _toList);
59. // create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", _smtpHost); WTF?!
Session session = Session.getDefaultInstance(props, null);
// create a message
Address replyToList[] = { new InternetAddress(replyTo) };
Message newMessage = new MimeMessage(session);
if (_fromName != null)
newMessage.setFrom(new InternetAddress(from,
_fromName + " on behalf of " + replyTo));
else
newMessage.setFrom(new InternetAddress(from));
newMessage.setReplyTo(replyToList);
newMessage.setRecipients(Message.RecipientType.BCC,
_toList);
newMessage.setSubject(subject);
newMessage.setSentDate(sentDate);
// send newMessage
Transport transport = session.getTransport(SMTP_MAIL);
transport.connect(_smtpHost, _user, _password);
transport.sendMessage(newMessage, _toList);
60. // create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", _smtpHost); WTF?!
Session session = Session.getDefaultInstance(props, null);
// create a message
Address replyToList[] = { new InternetAddress(replyTo) };
Message newMessage = new MimeMessage(session);
if (_fromName != null)
newMessage.setFrom(new InternetAddress(from,
else
_fromName + " on behalf of " + replyTo));
WTF?!
newMessage.setFrom(new InternetAddress(from));
newMessage.setReplyTo(replyToList);
newMessage.setRecipients(Message.RecipientType.BCC,
_toList);
newMessage.setSubject(subject);
newMessage.setSentDate(sentDate);
// send newMessage
Transport transport = session.getTransport(SMTP_MAIL);
transport.connect(_smtpHost, _user, _password);
transport.sendMessage(newMessage, _toList);
61. // create some properties and get the default Session
Properties props = new Properties();
props.put("mail.smtp.host", _smtpHost); WTF?!
Session session = Session.getDefaultInstance(props, null);
// create a message
Address replyToList[] = { new InternetAddress(replyTo) };
Message newMessage = new MimeMessage(session);
if (_fromName != null)
newMessage.setFrom(new InternetAddress(from,
else
_fromName + " on behalf of " + replyTo));
WTF?!
newMessage.setFrom(new InternetAddress(from));
newMessage.setReplyTo(replyToList);
newMessage.setRecipients(Message.RecipientType.BCC,
_toList);
newMessage.setSubject(subject);
newMessage.setSentDate(sentDate);
// send newMessage WTF?!
Transport transport = session.getTransport(SMTP_MAIL);
transport.connect(_smtpHost, _user, _password);
transport.sendMessage(newMessage, _toList);
62. new EmailMessage( )
.from("teste@localhost.net")
.to("destination@address.com")
.withSubject("Fluent Mail Example")
.withBody("What a nice code!")
.send();
http://guilherme.pro/2009/04/05/why-i-dont-write-code-comments/