This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BEFORE | |
class Person { | |
get courses() { | |
return this.courses; | |
} | |
set courses(courseList) { | |
this.courses = courseList; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BEFORE | |
const organization = { name: "Acme Goosberries", country: "GB" }; | |
// AFTER | |
class Organization { | |
constructor(data) { | |
this.name = data.name; | |
this.country = data.country; | |
} | |
get name() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
const orderData = orderString.split(/\s+/); | |
const productPrice = priceList[orderData[0].split("-")[1]]; | |
const orderPrice = parseInt(orderData[1]) * productPrice; | |
//AFTER | |
const orderRecord = parseOrder(order); | |
const orderPrice = price(orderRecord, priceList); | |
function parseOrder(order) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
function base(reading) {...} | |
function taxableCharge(reading) {...} | |
//AFTER | |
function base(reading) {...} | |
function taxableCharge(reading) {...} | |
function enrichReading(readingArgs) { | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
function base(reading) {...} | |
function taxableCharge(reading) {...} | |
function calculateBaseCharge(reading) {...} | |
//AFTER | |
class Reading { | |
base() {...} | |
taxableCharge() {...} | |
calculateBaseCharge() {...} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
function amountInvoiced(startDate, endDate) {...} | |
function amountReceived(startDate, endDate) {...} | |
function amountOverdue(startDate, endDate) {...} | |
//AFTER | |
function amountInvoiced(dateRage) {...} | |
function amountReceived(dateRage) {...} | |
function amountOverdue(dateRage) {...} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
const a = height * width; | |
//AFTER | |
const area = height * width; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
let defaultOwner = { firstName: "Martin", lastName: "Fowler" }; | |
function spaceshipOwner(spaceship) { | |
defaultOwner = {firstName: "Rebecca", lastName: "Parsons"}; | |
spaceship.owner = defaultOwner; | |
} | |
//AFTER | |
let defaultOwnerData = {firstName: "Martin", lastName: "Fowler"}; | |
export function defaultOwner() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
function circum(radius) { | |
return circumference(radius); | |
} | |
//AFTER | |
function circum(radius) { | |
return circumference(radius); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//BEFORE | |
function circum(radius) { | |
return 2 * Math.PI * radius; | |
} | |
//AFTER | |
function circumference(radius) { | |
return 2 * Math.PI * radius; | |
} |
NewerOlder