Giter VIP home page Giter VIP logo

atdd-bank-account's Introduction

The website and index of materials.

Find lecture notes and details on how to run the sessions.

Building the Site

Configured in site.sbt.

Run sbt site/makeMicrosite to create the site you're reading now. Find it in site/target/jekyll once built.

You should be able to preview the site using Jekyll to serve it.

$ cd site/target/jekyll
$ jekyll serve

If you're going to publish it (sbt site/publishMicrosite), make sure you site/makeMicrosite first (otherwise you'll see a commit on the gh-pages branch with 0 commits)

Initially Publishing the Site

This only needs to be done once.

We publish the site to Githubs gh-pages, setup the branch (one time) with the following:

# Using a fresh, temporary clone is safest for this procedure
$ mkdir temp
$ git clone [email protected]:youruser/yourproject.git
$ cd yourproject

# Create branch with no history or content
$ git checkout --orphan gh-pages
$ git rm -rf .

# Establish the branch
$ git commit --allow-empty -m "initialize gh-pages branch"
$ git push origin gh-pages

Then delete the temp folder, you have a new empty branch. When that branch has HTML in it (say, a jekyll site), when you push, Github will "deploy" the HTML to it's web servers. Visit the published site with https://xp-dojo.github.io/xp-dojo.

Domain Names

If you have a domain name (like we do), add it to a file called CNAME and the above will redirect to it. Setup that domain name server to point back to Github (just a A records is enough). This article goes into a little more depth around HTTPS (notably, the older 192.30.252.153 don't support HTTPS so you want to be using the 185.199.108.153 alternatives).

Then go enjoy https://xp-dojo.org

atdd-bank-account's People

Contributors

baldrick avatar lithgow avatar suggitpe avatar thankthemaker avatar tobyweston avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

atdd-bank-account's Issues

Purge binaries and rely on gradle and maven instead

As discussed in #3 lets remove the binaries and .idea project files and rely on gradle instead.

I still think this isn't the approach going forward - I'd prefer a zero deps thing that "just works".

I also think that maven is lower touch than gradle (built in plugin) so propose we keep both the pom.xml and gradle.build files in sync. Open to discussed this though (if we do, we really should setup travis or circeci to keep us honest).

Once the whole thing is developed and we prepare for delivery, I think we should remove the build files as previously discussed.

General test feedback for first iteration

Not really sure about some of the annotations from J5. @DisplayName and @Nested. Personally, I think it's a bit twee and shy away from annotations generally but realise it's subjective. For the pedagogical, I don't think it adds anything and may be distracting.

It's hard to make a call because if the audience is happy with the syntax, it'll feel natural but for noobs, it'll feel scary. My default when put in this position, is to simplify.

Figure out license

As for OSS, should we add copyright banners to all the files?

I'm keen to keep it open for people to use in classrooms but want to assert our rights at the same time

Maven/Gradle/No-deps

Merging the concordion branch has raised a few questions.

I don't think the project works out of the box as is, I couldn't open in IDEA from a clean clone. Wasgit rm --cached run on the bits to remove - was stuff removed at all? I'm a bit confused on it.

Anyway, the Concordion stuff, I brought in with Gradle and Maven support 😱 and now aren't sure what to do in the interest of gettings things cooking.

I may update the POM and build.gradle (for now) so its belts and braces, but let's use this issue to track our thoughts. Spoke to Suggs the other day who is 👨🐜(adam-ant) on gradle support...

Choose assertion library

Let's pick one (hamcrest/assertj) and make it consistent. They both seem pretty readable to me so I can't see a compelling reason to have both in there (and I don't mind which we settle on).

ConcordionResource fails with FileNotFound over concordion.css

See https://stackoverflow.com/questions/55250429/concordion-can-not-copy-resource-all-of-a-sudden

Concordion will try and create a file which if it contains relative paths, can fail with file not found errors.

For example:

ll /var/folders/wg/3nnv2yf90914pqpx69wmd9cc0000gn/T/concordion/org/xpdojo/bank/../../../concordion.css (No such file or directory

because only concordion above exists, it hasn't gotten around to creating the org/xpdojo/bank bit yet, so will fail.

Reproducible on Mac and Linux by deleting the temp folder.

Test folder structure tweaks

I propose we structure the test packages something like the following:

src
 ├───test
 │       ├───unit
 │       │       ├───java
 │       │       └───resources
 │       └───acceptance
 │               ├───java
 │               └───resources
 └─── ...

The point being to make it clearer for attendees what's an acceptance test and what's a "unit"-style test.

Trouble I'll have is setting up Gradle 😢

TiL: Reduce in Java has a terrible API

TiL: the combiner in the Stream#reduce method won't be used unless the stream is parallel.

This means the following line is technically incorrect, you can pass in nonsense for the last parameter and everything still works.

return transactions().reduce(ZERO, (money, transaction) -> transaction.against(money), (a, b) -> a);

A test to show the problem is below.

@Test
void generateBalanceForALargerSetOfTransactions() {
    Account account = accountWithBalance(amountOf(10), FIXED_CLOCK);
    final int numTransactions = 1000;
    LongStream.iterate(10, operand -> operand).limit(numTransactions).forEach(value -> account.deposit(amountOf(value)));
    assertThat(account.balance(), is(amountOf(10 + 10 * numTransactions)));
}

The "contract" for reduce should ensure the following - the combiner must be "compatible" with the accumulator for all values.

combiner.apply(u, accumulator.apply(identity, t)) == accumulator.apply(u, t)

So in terms of associativity;

combiner.apply(u, t) == combiner.apply(t, u)

A test to prove it:

@Test
void checkCombinerConformsToReduceSpecification() {
    // the "spec": combiner.apply(u, accumulator.apply(identity, t)) == accumulator.apply(u, t)

    BiFunction<Money, Money, Money> invalidCombiner = (a, b) -> a;
    BiFunction<Money, Money, Money> combiner = Money::plus;
    BiFunction<Money, Transaction, Money> accumulator = (money, transaction) -> transaction.against(money);

    Money u = amountOf(100);
    Transaction t = depositOf(amountOf(200), Instant.now());
    assertThat(invalidCombiner.apply(u, accumulator.apply(ZERO, t)), is(not(accumulator.apply(u, t))));
    assertThat(combiner.apply(u, accumulator.apply(ZERO, t)), is(accumulator.apply(u, t)));
}

To get the test to pass (forcing parallel stream):

 public Money balance() {
     return transactions().parallel().reduce(ZERO, (money, transaction) -> transaction.against(money), Money::plus);
 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.