bdd workshop for javascript developers

24
BDD for RIAs with JavaScript 2013 Workshop Tour Carlos Ble carlosble.com @carlosble

Upload: carlos-ble

Post on 18-Feb-2017

1.150 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: BDD workshop for JavaScript developers

BDD for RIAs with JavaScript

2013 Workshop Tour

Carlos Ble carlosble.com

@carlosble

Page 2: BDD workshop for JavaScript developers

Warning

This workshop is very demanding so please:

● Ask anything you need.● Give me feedback.● Take notes.● Pay attention.● Be responsible.● Get ready to share code with others.

Page 3: BDD workshop for JavaScript developers

Effective communication

Your only goal when communicating should be

to … Communicate!Don't talk or write to...

● Demonstrate how smart you are● Convince others ● Fight others ● Avoid the uncomfortable silence● Think out loud

No one is more important than you, and you are not more important than anyone else. What others think about you, is

not your business.

Page 4: BDD workshop for JavaScript developers

The seven rules of Angel Lafuente

1ª. Nunca la palabra antes que el pensamiento. 2ª. No interrumpir la frase o idea. 3ª. Frase breve. 4ª. Mirada interpelante. 5ª. Gesto libre. 6ª. Silencios. 7ª. Velocidad posible y adecuada

Those who master silence, master spoken word.

http://www.ulpgc.es/hege/almacen/download/48/48279/manual_del_curso.pdf

Page 5: BDD workshop for JavaScript developers

Listen to yourself: use your common senseBe honest to yourself because your intuition and feelings are telling you all the time what is

more appropriate in every situation.

Pay attention to your gut feelings because they don't cheat you.

Listen carefully to others to be empathetic to them.

Do what you know you ought to do.

Page 6: BDD workshop for JavaScript developers

Where are you standing?

Is everything OK with you and your environment?

● Breath● Sleep well

● Eat well● Work out

● Workplace environment must have good conditions● Try to learn about yourself

There are several techniques to help you practice self-control and self-discovery :

● Meditation● Yoga

● Martial arts● Team sports

● Extreme sports● And much more!

Page 7: BDD workshop for JavaScript developers

Where are you standing?

Is everything OK with you and your environment?

● Breath● Sleep well

● Eat well● Work out

● Workplace environment must have good conditions● Try to learn about yourself

There are several techniques to help you practice self-control and self-discovery :

● Meditation● Yoga

● Martial arts● Team sports

● Extreme sports● And much more!

Page 8: BDD workshop for JavaScript developers

Be a good team player

Don't make assumptions

Don't take it personally

Do your best

Be precise and specific with your words

See also the Core Protocols

Page 9: BDD workshop for JavaScript developers

BDD is a set of values and practices

Build the thing right

dannorth.net/introducing-bdd/

dannorth.net/whats-in-a-story/

chrismdp.com/2013/01/bdd-is-not-cucumber/

[Over]simplification: specification by example + outside-in TDD

Page 10: BDD workshop for JavaScript developers

Lean development and Impact Mapping

Build the right thing, avoid waste

en.wikipedia.org/wiki/Lean_software_development

impactmapping.org/drawing.php

Page 11: BDD workshop for JavaScript developers

What, not how: the amazing happens when you just write the minimum code

Case Study: LiveTeamApp.com

● No password or registration required.● Group chat and individual chat rooms.● GUI tailored to users according to their feedback.● Pomodoro integrated with team monitor and and chat.● New features are delivered in a matter of hours.● Everything is covered by tests.

Remember: Just make your acceptance tests pass deferring any other decision as much as

possible.

Page 12: BDD workshop for JavaScript developers

LiveTeamApp

Page 13: BDD workshop for JavaScript developers

The specifications workshop

50-70% of the defects are in the requirements...

● Focus on what, not how● Avoid GUI details in the examples● All the roles together in the workshop:

● Facilitator● Stakeholders● Business Analysts● Product Owners● Testers● Developers

● Face to face conversation● Time, an important investment:

● 2 hours for a week sprint seems reasonable

Page 14: BDD workshop for JavaScript developers

Good books out there

● Bridging the communication gap● Specification by Example

● Impact Mapping● ATDD by Example

● The cucumber book

Page 15: BDD workshop for JavaScript developers

Starting with the user story

Title (one line describing the story)

Narrative:As a [role]

I want [feature]So that [benefit]

Acceptance Criteria: (presented as Scenarios)

Scenario 1: TitleGiven [context]

And [some more context]...When [event]

Then [outcome] And [another outcome]...

Page 16: BDD workshop for JavaScript developers

Exercise

The specification workshop

Page 17: BDD workshop for JavaScript developers

Wait a moment:Three types of JavaScript

➢ With TDD➢ Without TDD

➢ For Frameworks

Page 18: BDD workshop for JavaScript developers

BDD for RIAs: the process

A Rich Internet Application is very different from a Website!

Page 19: BDD workshop for JavaScript developers

App core: Passive View pattern

Outside-in: Blue: test-driven with unit tests, using test doubles.

Green: test-driven with unit tests, using test doubles.Pink: test-driven with integration tests.

Page 20: BDD workshop for JavaScript developers

Outside-in development

Good understanding of test doubles:● Stubs: programmed to return answers.● Spies: will remember calls.● Mocks: will fail on unexpected calls.● Fakes: almost like the real system, just faster or repeatable.

How to write scenarios where some objects don't exists already? Remember the UML :-)

Key rules: ● Do not mock artifacts you don't own.● Use stubs for queries and mocks/spies for actions.

Page 21: BDD workshop for JavaScript developers

Exercise: the flow

1. Connecting the Business API with the service. 2.Connecting the UI with the service.3.Implementing the service.4.Implementing the interactor.5.Implementing the databinder.

All of them are UNIT TESTS

Page 22: BDD workshop for JavaScript developers

Advice: let the team follow code changes

● Initialize a code repository for the exercises (Git, Mercurial, or whatever you prefer).

● Make commits small enough that just by looking at the “diff” anyone can understand what the change is.

● This usually means, no more than 10 lines of code.

● Try to commit on red, on green, and eventually on refactor.

● This is a great way to document code changes.

Page 23: BDD workshop for JavaScript developers

Exercise: the integration

●TextBox Widget Implementation

●Storage implementation

Page 24: BDD workshop for JavaScript developers

Architecture review

Patterns:● Passive View

● Factory● Wrapper● Observer● Pub/sub

● Singleton

Non-emergent architecture:I18n, fault tolerance, security,

scalability, SEO, routing, contents...