Bladeren bron

convert to intellij

Nhu Nguyen 6 jaren geleden
commit
233bae8766
5 gewijzigde bestanden met toevoegingen van 118 en 0 verwijderingen
  1. 25
    0
      .gitignore
  2. 36
    0
      pom.xml
  3. 53
    0
      readme.md
  4. 2
    0
      src/main/java/FizzBuzz.java
  5. 2
    0
      src/test/java/FizzBuzzTest.java

+ 25
- 0
.gitignore Bestand weergeven

@@ -0,0 +1,25 @@
1
+/target/
2
+!.mvn/wrapper/maven-wrapper.jar
3
+
4
+### STS ###
5
+.apt_generated
6
+.classpath
7
+.factorypath
8
+.project
9
+.settings
10
+.springBeans
11
+.sts4-cache
12
+
13
+### IntelliJ IDEA ###
14
+.idea
15
+*.iws
16
+*.iml
17
+*.ipr
18
+
19
+### NetBeans ###
20
+/nbproject/private/
21
+/build/
22
+/nbbuild/
23
+/dist/
24
+/nbdist/
25
+/.nb-gradle/

+ 36
- 0
pom.xml Bestand weergeven

@@ -0,0 +1,36 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <modelVersion>4.0.0</modelVersion>
6
+
7
+    <groupId>com.zipcodewilmington</groupId>
8
+    <artifactId>gildedrose</artifactId>
9
+    <version>1.0-SNAPSHOT</version>
10
+    <properties>
11
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
13
+        <java.version>1.8</java.version>
14
+    </properties>
15
+    <build>
16
+        <plugins>
17
+            <plugin>
18
+                <groupId>org.apache.maven.plugins</groupId>
19
+                <artifactId>maven-compiler-plugin</artifactId>
20
+                <configuration>
21
+                    <source>1.8</source>
22
+                    <target>1.8</target>
23
+                </configuration>
24
+            </plugin>
25
+        </plugins>
26
+    </build>
27
+    <dependencies>
28
+        <dependency>
29
+            <groupId>junit</groupId>
30
+            <artifactId>junit</artifactId>
31
+            <version>4.12</version>
32
+            <scope>test</scope>
33
+        </dependency>
34
+    </dependencies>
35
+
36
+</project>

+ 53
- 0
readme.md Bestand weergeven

@@ -0,0 +1,53 @@
1
+## Objectives
2
+
3
+1. Understand test driven development process
4
+
5
+# What is Test Driven Development?
6
+
7
+Test Driven Development, or TDD, is a method for approaching a problem not through the implementation of the solution, but rather, through the expectations of a working solution. What that means is, instead of trying to write the code that solves the problem, you first define what the working code will do when it works, and then you write the implementation to make it work.
8
+
9
+# Test Driving FizzBuzz
10
+
11
+A classic programming problem is [FizzBuzz](http://c2.com/cgi/wiki?FizzBuzzTest). It is considered the [Stairway to Heaven](http://www.codinghorror.com/blog/2007/02/fizzbuzz-the-programmers-stairway-to-heaven.html) of programming because there are so many different ways to play it and everyone plays it.
12
+
13
+The goal of FizzBuzz is to build a program that can take a number:
14
+- if the number is evenly divisible by 3, it should return "Fizz"
15
+- if it's divisible by 5, it should return "Buzz"
16
+- if it's divisible by both 3 and 5, it should return "FizzBuzz"
17
+- otherwise it should print the number
18
+
19
+## Defining Our Expectations
20
+
21
+Let's approach solving this problem from a TDD approach. That means that we don't care about "how", but rather, we care about "what". What should the program do if it works correctly, not how it does it. We are going to write our expectations first, then our implementation.
22
+
23
+Before we look at the RSpec syntax, let's just express our tests in plain English (also sometimes referred to as "pseudo-code").
24
+
25
+1. We expect FizzBuzz.of(3) to return "Fizz"
26
+2. We expect FizzBuzz.of(5) to return "Buzz"
27
+3. We expect FizzBuzz.of(15) to return "FizzBuzz"
28
+4. Anything else will return the number FizzBuzz.of(2) returns "2"
29
+
30
+We don't care how that `#fizzbuzz` method works, nor how it's defined, *we are just stating our expectations*. And we're doing that first. When coding, it's important to have a target to shoot for; by writing your test first and stating your expectations of your code, you know your goal. You get to use your entire brain to think about just your goals, not how you'll get there, which adds clarity and focus to the problem.
31
+
32
+> The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility.
33
+>
34
+> — <cite>Edsger W. Dijkstra</cite>
35
+
36
+Test-Driven Development allows us to fully utilize our mental capacity to clearly state the problem we're solving and then to 100% focus on implementing a solution. When you are just coding, you're actually focusing on stating the problem and the solution at the same time. You are thereby splitting your thinking in two, making you less effective at both.
37
+
38
+> It's the exact same reason you make a todo list. Also testing is not for present you, it's for future you.
39
+>
40
+> — <cite>Joe M Burgess</cite>
41
+
42
+# Instruction
43
+Given a number, your method should return a string:
44
+- "Fizz" if it's divisible by 3
45
+- "Buzz" if it's divisible by 5
46
+- "FizzBuzz" if it's divisible by 15
47
+- the number in string format otherwise
48
+
49
+## Todo
50
+1. For this repo
51
+2. Clone your fork
52
+3. Solve the problem using TDD
53
+4. Create a pull request

+ 2
- 0
src/main/java/FizzBuzz.java Bestand weergeven

@@ -0,0 +1,2 @@
1
+public class FizzBuzz {
2
+}

+ 2
- 0
src/test/java/FizzBuzzTest.java Bestand weergeven

@@ -0,0 +1,2 @@
1
+public class FizzBuzzTest {
2
+}