Injection, Modularity, and Testing

Similar documents
SAP Fiori - Take Order

Activity 10. Coffee Break. Introduction. Equipment Required. Collecting the Data

Innovations for a better world. Ingredient Handling For bakeries and other food processing facilities

DOWNLOAD OR READ : SMART SOLUTIONS FOR BUSY FAMILIES PDF EBOOK EPUB MOBI

Step 1: Prepare To Use the System

Roux Bot Home Cooker. UC Santa Cruz, Baskin Engineering Senior Design Project 2015

Barista at a Glance BASIS International Ltd.

ENGI E1006 Percolation Handout

Environmental Monitoring for Optimized Production in Wineries

DOC / KEURIG COFFEE MAKER NOT WORKING ARCHIVE

ARM4 Advances: Genetic Algorithm Improvements. Ed Downs & Gianluca Paganoni

WineScan All-in-one wine analysis including free and total SO2. Dedicated Analytical Solutions

GEA Plug & Win. Triple win centrifuge skids for craft brewers

ZPM Mixer. Continuous mixing system

Responsibilities I choose what to cook every day. I personally cook the main dishes in the kitchen. I check on the dishes in our

US FOODS E-COMMERCE AND TECHNOLOGY OFFERINGS

For Beer with Character

The basic ingredient. We know how.

STACKING CUPS STEM CATEGORY TOPIC OVERVIEW STEM LESSON FOCUS OBJECTIVES MATERIALS. Math. Linear Equations

Table of Contents. Toast Inc. 2

IT tool training. Biocides Day. 25 th of October :30-11:15 IUCLID 11:30-13:00 SPC Editor 14:00-16:00 R4BP 3

-- Final exam logistics -- Please fill out course evaluation forms (THANKS!!!)

Recursion. John Perry. Spring 2016

Restaurant reservation system thesis documentation. Restaurant reservation system thesis documentation.zip

COMSTRAT 310 Semester-Long Project Part Three

Chesapeake Bay Seafoods Industries Association (CBSIA)

Brewhouse technology

Moving Molecules The Kinetic Molecular Theory of Heat

Cleaning the La Marzocco Espresso Machine, Linea FB 70

Virginia Western Community College HRI 225 Menu Planning & Dining Room Service

Rice Paddy in a Bucket

For Beer with Character

Ideas for group discussion / exercises - Section 3 Applying food hygiene principles to the coffee chain

MDD. High Speed Mixer. Member of the

1. Continuing the development and validation of mobile sensors. 3. Identifying and establishing variable rate management field trials

John Perry. Fall 2009

Software engineering process. Literature on UML. Modeling as a Design Technique. Use-case modelling. UML - Unified Modeling Language

Promote and support advanced computing to further Tier-One research and education at the University of Houston

Noun-Verb Decomposition

THE APPLICATION OF NATIONAL SINGLE WINDOW SYSTEM (KENYA TRADENET) IN PROCESSING OF CERTIFICATES OF ORIGIN. A case study of AFA-Coffee Directorate

Alberta Safety Codes Authority (ASCA)

Operating the Rancilio Silvia after PID kit modification Version 1.1

MyPlate The New Generation Food Icon

How Many of Each Kind?

CS420: Operating Systems. Classic Problems of Synchronization

Tamanend Wine Consulting

Maximizing Efficiency In The Production Of Coffee

Industrial standard barcodes on Tray Packaging

Algorithms. How data is processed. Popescu

Proposal for Instruction Manual/Feasibility Study /Rewrite of Manual on Starbucks Barista Espresso Machine

OPERATING MANUAL. Sample PRO 100 Series. Electric Heating. Applies to Versions: SPE1*, SPE2, SPE4, SPE6

A BOOK DISCUSSION Guide

AWRI Refrigeration Demand Calculator

Decolorisation of Cashew Leaves Extract by Activated Carbon in Tea Bag System for Using in Cosmetics

A La Carte Review Guide

Resident manager. The ticket to success set up for future of Dining in senior care

OenoFoss Instant Quality Control made easy

Slow Rot or Not! By Jennifer Goldstein

Is Fair Trade Fair? ARKANSAS C3 TEACHERS HUB. 9-12th Grade Economics Inquiry. Supporting Questions

PRODUCTION SOFTWARE FOR WINEMAKERS. Wine Operations and Laboratory Analyses

TRUSTED RELIABLE QUALITY

WINE MANAGAMENT PLATFORM FOR WAREHOUSES

industrial baking systems TRAVELLING TUNNEL OVEN BKR S BKR G Made in Italy

think process! INSTORE BAKING As individual as your branch store

Please sign and date here to indicate that you have read and agree to abide by the above mentioned stipulations. Student Name #4

User Studies for 3-Sweep

THE 900 DAYS - THE SIEGE OF LENINGRAD "SALISBURY BY HARRISON E." 14.8

Streamlining Food Safety: Preventive Controls Brings Industry Closer to SQF Certification. One world. One standard.

openlca case study: Conventional vs Organic Viticulture

Pete s Burger Palace Activity Packet

F O R T H E T A S T E A L O N E

Assess the impact of food inequity on themselves, their family, and their community one s local community.

Chapter 3. Labor Productivity and Comparative Advantage: The Ricardian Model. Pearson Education Limited All rights reserved.

FOOD CONSISTENCY To successfully create or establish a brand, your product MUST be consistent.

Application Note CL0311. Introduction

Product Presentation. C-series Rack Ovens

Cell Biology: Is Yeast Alive?

Search Engine Rankings Report

Predicting Fruitset Model Philip Schwallier, Amy Irish- Brown, Michigan State University

PLANTING SEEDS. Episode 3. our heroes find themselves chained to the floor of a cygnusian prison cruiser.

Calibrate grill heat zones Monthly GR 1 M1

GLOBUS WINES. Wine Investment & Cellar Management. India London New York Hong Kong Tokyo

TEST PROJECT. Server Side B. Submitted by: WorldSkills International Manuel Schaffner CH. Competition Time: 3 hours. Assessment Browser: Google Chrome

Instructions for Use. Fixing hook

CMC-se News. Pavel Kessler. UM Karlsruhe 2016

Alcohol Meter for Wine. Alcolyzer Wine

Jure Leskovec, Computer Science Dept., Stanford

Issue No. 7 SPOTLIGHT THE PHILIPPINES

Case Study 8. Topic. Basic Concepts. Team Activity. Develop conceptual design of a coffee maker. Perform the following:

Given a realistic scenario depicting a new site install, the learner will be able to install and setup the brewer for retail turnover without error.

benefits of electronic menu boards: for your business and your customers

F R E S H C U P. Single Serve Automatic Eject Pod System by:

Coffee zone updating: contribution to the Agricultural Sector

2004 PICKLING LINE MARKET STUDY

SESSION 606 Tuesday, November 3, 2:45pm - 3:45pm Track: Framework Fusion

Managing Multiple Ontologies in Protégé

Kiosks: An Easy and Effective Nutrition Labeling Solution for Grocery Stores

MXS without Freescale tools

CUSTOM CRUSHPAD SOLUTIONS

Transcription:

Injection, Modularity, and Testing An Architecturally Interesting Intersection SATURN 2015 George Fairbanks Rhino Research http://rhinoresearch.com http://georgefairbanks.com

Talk summary Dependency injection Improves testability Without modularity, becomes too complex Great example of boiling the frog When do mundane concerns become architecturally relevant? Daily rational decisions still have trouble Partial solutions Overcome cultural obstacles Overcome process obstacles

Story of a coffee maker class CoffeeMaker { Pump pump = new StandardPump(); Heater heater = new StandardHeater(); Looks fine? Great, let s test it. void brew() { heater.on(); pump.pump(); wait(100); print( Enjoy your coffee ); heater.off();

Test the coffee maker class CoffeeMakerTest { CoffeeMaker coffeemaker; void setup() { Pump pump = new FakePump(); Heater heater = new FakeHeater(); coffeemaker = new CoffeeMaker(); To isolate dependencies, we ll use a fake pump and heater and Oops, those are hardwired into the coffee maker. Let s fix that. void testbrew() { coffeemaker.brew(); assert(...);

Coffee maker, try 2 class CoffeeMaker { Pump pump; Heater heater; Ok, now the pump and heater are passed in during construction. CoffeeMaker(Pump pump, Heater heater) { this.pump = pump; this.heater = heater; void brew() {...

Test the coffee maker, try 2 class CoffeeMakerTest { CoffeeMaker coffeemaker; void setup() { coffeemaker = new CoffeeMaker( new FakePump(), new FakeHeater()); Yay! But now who knows how to create a CoffeeMaker? void testbrew() { coffeemaker.brew(); assert(...);

Coffee maker, try 3 class CoffeeMaker { Pump pump; Heater heater; @Inject CoffeeMaker(Pump pump, Heater heater) { this.pump = pump; this.heater = heater; void brew() {... Now the dependency injection container injects the parameters as needed. JSR-330 defines: @Inject Provider.get() Problem solved?

Test the coffee maker, try 2 class CoffeeMakerTest { CoffeeMaker coffeemaker; The pump needs a water source! void setup() { coffeemaker = new CoffeeMaker( new FakePump(), What about new FakeHeater()); their dependencies? void testbrew() { coffeemaker.brew(); assert(...); The heater needs an energy source! The dependencies are not one-level -- they are a graph!

Test the coffee maker, try 3 class CoffeeMakerTest { CoffeeMaker coffeemaker; void setup() { Injector injector = magic(); injector.add(fakepump.class); injector.add(fakeheater.class); // and their dependencies, etc. coffeemaker = injector.create(coffeemaker.class); void testbrew() {... Use the injector to create the CoffeeMaker. Must populate the injector s graph of objects, so it can inject the Pump and Heater. Ugh, setting up the injector s graph is tedious. Let s make a helper method!

Test the coffee maker, try 4 class CoffeeMakerTest { CoffeeMaker coffeemaker; void setup() { Injector injector = magic(); mytestsetup(injector); coffeemaker = injector.create(coffeemaker.class); void testbrew() { coffeemaker.brew(); assert(...); Good Shared test setup Handles recursive dependencies Bad Test setup is complex -- do you trust it? mytestsetup() becomes a dumping ground Big app = lots of dependencies

Parts only (no assembly instructions)

Parts and assembly instructions

Modular assembly

Injection, Modularity, Testing Dependency Injection Big graph of dependencies that change daily Package Modularity Injection granularity: classes, facades, modules? Usually: classes Testing Fussy: many mock/fake dependencies Inertia: Test case LOC > application LOC Many fine-grained dependencies changing daily Forest-through-the-trees: which configurations are legal? Hard to get intellectual control

Photocopier example Single legal configuration of photocopier Input: Manual-feed Engine: 30 copies per minute Output: stapling BNF: All legal configurations <photocopier> ::= <input> <engine> <output> <input> ::= manual-feed input auto-feed input <engine> ::= 15cpm 30cpm 60cpm <output> ::= output tray stapling output tray Compare with: all the screws and bolts

Architects want intellectual control Concerns about modules How is the system decomposed into modules? What are the dependencies between modules? What are the legal arrangements of modules? What is the granularity of the modules? Concerns about testing Is the system testable? Is the test infrastructure maintainable?

Missing abstraction: a System Configuration What is a system configuration? Group code into modules Describe legal arrangements of modules Abstractions yield intellectual control Zoom out: Save us from thinking of every last screw and bolt Type vs. instance: All legal system configurations vs. one Common configuration instances Run locally Run unit or integration tests Run in production Common configuration types <I never see these>

Hypothetical dependency injection timeline Start with simple system, simple dependency injection (fine-grained). Team grows, system gets bigger, refactors test setup into shared code. Shared test setup becomes complex in its own right. Rules for configuring a legal system are implicit and shared across developers. Shared test setup becomes a write-only dumping ground for bindings. When would you add architecture to the timeline?

This is old news DeRemer and Kron, 1975, Programming-in-the-Large Versus Programming-in-the-Small

You are the architect Steer the project Good luck

Imagine this timeline A software project starts. Feature-driven using short iterations. Project ramps up. More people. Improved support infrastructure including robust test harnesses, continuous integration, automated deployments. Continued growth. Some parts treated as legacy but well-tested and usable. Complexity is everywhere. Velocity slows. Significant new developer on-boarding time because of complexity. Developers propose refactoring of baked-in assumptions that would take many months/years, so it s hard to make a cost-benefit argument. Management chooses to rewrite the system. When did any concern become architecturally relevant?

Practicing architecture is hard today Document everything? We could go Documenting Software Architectures, but: Poor track record of keeping docs updated Poor track record of developers reading docs Debatable track record of Me architect. You developer. Architecture theory seems to be reasonably well-sorted Culture obstacles Increasing disdain for abstractions & delayed gratification (see: YAGNI) Process obstacles In practice, many teams seem to do better with iterative feature-driven sprints and refactoring Limited success reports of agile + architecture

What should we do? Culture of architecture Get architecture off the whiteboard and into the code Simon Brown s work on C4 Architecturally evident coding style Microservices movement No, it s not the only architectural style Architecture terms being used by agile / iterative teams Architecture in process Architecture within short iterations Michael Keeling s work (and upcoming book!) Better tooling, frameworks Today: great tooling to support iterations, continuous integration, automated deployments, etc Tomorrow: great tooling to make architecture abstractions visible (Structurizr)

Moral of the story Dependency Injection: Great example of boiling the frog When do mundane concerns become architecturally relevant? Daily rational decisions still have trouble Let s show how to do architecture We know how to think about it What is best practice for feature-driven iterative development?