Skip to content

diegosanchez/bob-2021--combining-clojure-spec-with-design-recipes

Repository files navigation

CI status

Combining clojure.spec with design recipes

Index

Agenda for the activity

  1. (10 min) - Presentation
  2. (5 min.) - Problem statement
  3. (40 min.) - Playing with the code
  4. (2 min.) - New feature statement
  5. (20 min.) - Playing with the code
  6. (13 min.) - Retrospective

Context

Combining clojure.spec with design recipes

Presentation PDF with closed-captioned

Presentation video

Workshop

IMPORTANT

  • The ``mainbranch may suffer changes after publication day, until just before the beginning of the workshop. In that case, you will havo to perform agit pull -r`. We let you know about this at the beginning of the workshop.

Prerequisites

Get ready for the activity

Clone the repository

git clone [email protected]:diegosanchez/bob-2021--combining-clojure-spec-with-design-recipes.git bob-2021

Change directory

cd bob-2021

Run test (verification)

clojure -M:test:runner

Expected output:

Running tests in #{"test"}

Testing ws.prepaid-test

Ran 1 tests containing 1 assertions.
0 failures, 0 errors.

Invoke library (verification)

    clojure -X:use-case

Expected output:

Entry point for testing the use case from CLI...
Args: {:key-simple 1, :key-map-value {:v1 "a", :v2 "b"}}
Calling use case...
1 {:v1 "a", :v2 "b"}

The Problem Statement

It's common to see the usage of a prepaid card to pay for a public transport ride. This prepaid card allows users to pay for a public transport ride.

When a user first buys a prepaid card she/he pays an initial amount of money named initial-balance. Every time a user pays for a ride, her/him consumes money from the prepaid card. A user can increase the card balance by depositing money.

The card can be used in two different modes:

  • Standard: If the card balance is B and the user has to pay R, the payment successes whether R <= B.

Finally, every transaction has to be record into the contactless card.

Some considerations:

For the sake of simplicity:

  • Money amounts are represented as integers.
  • the Transaction record can only have one amount per transaction.
  • we have published a plausible solution (definitely, not the only possible one!) on branchsolution/aPossibleOne.

Possible use cases include:

  • If the user has to pay 10, and his/her card balance is 100, then the payment is accomplished. Then, the card has a new record with -10 and the balance is 90.

  • If the user has to pay 20, and his/her card balance is 10, then the payment is not accomplished. There is neither a new record nor a balance change.

Helpful tasks

Some common tasks below.

Task Command
Run all tests clojure -M:test:runner
Run unstable tests clojure -M:test:runner -i, --include unstable
Run stable tests clojure -M:test:runner -e, --exclude unstable
Run the use case clojure -X:use-case

Expected Results

Read more...

Concepts to Explore

Read more...

Misc

License

Copyright © 2021, Diego Sánchez and Leandro Doctors.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Additional permission under GNU AGPL version 3 section 7:

If you modify this Program, or any covered work, by linking or combining it with Clojure (or a modified version of that library), containing parts covered under the same terms as Clojure (currently, the Eclipse Public License version 1.0), the licensors of this Program grant you additional permission to convey the resulting work. Corresponding Source for a non-source form of such a combination shall include the source code for the parts of Clojure used as well as that of the covered work.

About

Combining clojure.spec with design recipes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published