This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Iterator; | |
public class FibonacciSequence implements Iterator<Long> { | |
private long n = 0; | |
private long a = 0; | |
private long b = 1; | |
public boolean hasNext() { return a + b > 0; } | |
public Long next() { | |
long fib; | |
if(n == 0 || n == 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fj.F2; | |
import fj.data.List; | |
import fj.data.Stream; | |
public class FunctionalJavaFibonacci { | |
public static final Stream<Long> fibonacciSequence = new F2<Long, Long, Stream<Long>>() { | |
public Stream<Long> f(final Long a, final Long b) { | |
return Stream.cons(a, curry().f(b).lazy().f(a + b)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static com.googlecode.totallylazy.Callables.first; | |
import static com.googlecode.totallylazy.Computation.computation; | |
import static com.googlecode.totallylazy.Pair.reduceLeftShift; | |
import com.googlecode.totallylazy.Pair; | |
import com.googlecode.totallylazy.Sequence; | |
import com.googlecode.totallylazy.numbers.Sum; | |
public class TotallyLazyFibonacci { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller | |
class TarefasController { | |
//restante omitido - mas não remova! | |
@RequestMapping("tarefa/listaAjax") | |
public @ResponseBody List<Tarefa> listaAjax() { | |
JdbcTarefaDao dao = new JdbcTarefaDao(); | |
return dao.lista(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>br.com.caelum</groupId> | |
<artifactId>projetao</artifactId> | |
<packaging>war</packaging> | |
<version>1.0-SNAPSHOT</version> | |
<name>Projetao Spring MVC</name> | |
<dependencies> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- no diretorio de instalacao do Tomcat --> | |
<Resource name="jdbc/dataSource" auth="Container" type="javax.sql.DataSource" | |
maxActive="100" maxIdle="30" maxWait="10000" | |
username="root" password="" | |
driverClassName="com.mysql.jdbc.Driver" | |
url="jdbc:mysql://localhost/fj21"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dependência é o principal problema em desenvolvimento de software. Duplicação é o sintoma. | |
Mas, ao contrário da maioria dos problemas na vida, nos quais eliminar os sintomas faz com que um problema mais grave apareça em outro lugar, eliminar duplicação nos programas elimina dependência. | |
Kent Beck, em TDD by Example | |
http://alexandreaquiles.com.br/2010/08/17/63/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hora; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.TimeZone; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServlet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hora; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.TimeZone; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServlet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hora; | |
import java.io.IOException; | |
import java.io.PrintWriter; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.TimeZone; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServlet; |