Coined by consultants
Scrum & Kanban are not bad or irrelevant; they provide frameworks for organizations
Not a requirement for developing with agility
Agile is not a noun. You can't do agile.
No mention of sprints, backlog, etc
Our consultants did not mention the manifesto 18 months ago
Single Responsibility Principle
Open/Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
Inheritance is not a prerequisite for Object-oriented design
Behavioral Subtyping
Classes & methods should be focused on one thing
public async Task<byte[]> DownloadFile(){
var invoice = await _mediator.Send(new InvoiceQuery(carrier));
var orderData = await _mediator.Send(new CustomerData(invoice.Id));
var transformedInvoice = _invoiceService.Manipulate(invoiceData, orderData);
var file = _invoiceService.CreateCsv(transformedInvoice);
return file;
}
Mathematically, a function is defined as "A special relationship where each input has a single output"
Testable code allows us to write tests
Tests allow us to be confident in our code integrity in the face of change
Confidence in our code integrity in the face of change enables us to Develop with Agility
Pass in dependencies!
New is Glue - Steve Smith 2011
Quick Demo
"After having written nice, decoupled code throughout your code base, the Composition Root is where you finally couple everything, from data access to (user) interfaces." - Mark Seemann Composition Root Reuse
Doug McIlroy (Bell System Technical Journal 1978)
And a couple other principles that I don't think apply to developing with agility... https://en.wikipedia.org/wiki/Unix_philosophy
Our methods should be able to stand on their own and be obvious.
Shared Mutable State is the Root of All Evil - Henrik Eichenhardt
Don't use mutable global variables
Basic control structure
Bread & Butter
Should be avoided
const numbers = [0,1,2,3,4,5,6,7,8,9,10]
const isEven = input => input % 2 === 0
const square = input => input * input
const getSum = (input1, input2) =>
input1 + input2
let squaredEvens = [];
numbers.forEach(x => {
if (isEven(x)) {
squaredEvens.push(square(x))
}
})
let sumSquaredEvens = 0
squaredEvens.forEach(x =>
sumSquaredEvens = getSum(sumSquaredEvens, x))
const numbers = [0,1,2,3,4,5,6,7,8,9,10]
const isEven = input => input % 2 === 0
const square = input => input * input
const getSum = (input1, input2) =>
input1 + input2
const sumSquaredEvens = numbers
.filter(isEven)
.map(square)
.reduce(getSum, 0)
const otherFunc = (input1: string, input2: string) => input1 + " " + input1
const yeetFunc = input => "yeet! " + input
const coolFunc = (input1: string, input2: string) => {
let str = ""
if (input == "case1") {
str = otherFunc(input1, input2)
} else if (input === "case2") {
str = otherFunc(input2, input1)
} else {
str = yeetFunc(input1)
}
console.log(str)
}
const coolFunc = (input1: string, input2: string) => {
const behavior = behaviorFactory.create(input1, input2)
const str = behavior.execute()
console.log(str)
}
class OtherBehavior implements IBehavior {
input1: string
input2: string
constructor(input1, input2) {
this.input1 = input1
this.input2 = input2
}
execute = () => input1 + " " + input2
}
class YeetBehavior implements IBehavior {
input: string
constructor(input) {
this.input = input
}
execute = () => "yeet! " + input
}
class BehaviorFactory {
static create(input1, input2): IBehavior {
if (input1 == "case1") {
return new OtherBehavior(input1, input2)
} else if (input1 == "case2") {
return new OtherBehavior(input2, input1)
} else {
return new YeetBehavior(input1)
}
}
}
interface IBehavior {
execute(): string
}
Brian Kernighan - The Elements of Programming Style
"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?"
Ben Hunt 2018
If you're concerned with performance but not measuring it, you're just guessing
Is the speed worth the cost?
Use someone else's solution if it's appropriate
Dapper, mediator, serialization tools, standard http verbs & response codes, logging, etc