This file contains hidden or 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
////////////////////////////////////////////////// | |
// Step 1: Identify the change point and determine the sprouted class interface | |
export class QuarterlyReportGenerator { | |
public readonly beginDate: Date; | |
public readonly endDate: Date; | |
public readonly database: Database; | |
constructor() { | |
// constructor with multiple side effects |
This file contains hidden or 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
////////////////////////////////////////////////// | |
// Step 1: Identify the change point and determine the sprouted method signature (input/output) | |
export class BlogPostPublisher { | |
private blogActivityRecord: BlogActivityRecord; | |
private entriesRepository: EntriesRepository; | |
constructor(blogActivityRecord: BlogActivityRecord) { | |
this.blogActivityRecord = blogActivityRecord; | |
this.entriesRepository = new MySqlEntriesRepository(); |
This file contains hidden or 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
// After changing the code, Invoice should look like: | |
export class Invoice { | |
private readonly shippingPricer: ShippingPricer; | |
// ... | |
constructor( | |
billingDate: OurDate, | |
openingDate: OurDate, | |
originator: Originator, |
This file contains hidden or 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
export class Invoice { | |
//... | |
public getValue(): Money { | |
const total = this.itemsSum(); | |
if (this.billingDate.after(OurDate.yearEnd(this.openingDate))) { | |
if ( | |
this.originator.getState() === "FL" || | |
this.originator.getState() === "NY" | |
) { |
This file contains hidden or 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
export class Element { | |
private readonly name: string; | |
private text: string; | |
constructor(name: string) { | |
this.name = name; | |
this.text = ""; | |
} | |
addText(newText: string): void { |
This file contains hidden or 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
export class InMemoryDirectory { | |
private readonly elements: Element[]; | |
constructor() { | |
this.elements = []; | |
} | |
public addElement(newElement: Element): void { | |
this.elements.push(newElement); | |
} |
This file contains hidden or 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
export class CppClass { | |
private readonly name: string; | |
private readonly declarations: Declaration[]; | |
constructor(name: string, declarations: Declaration[]) { | |
this.name = name; | |
this.declarations = declarations; | |
} | |
public getDeclarationCount(): number { |
This file contains hidden or 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
export class Reservation { | |
private duration: number; | |
private dailyRate: number; | |
private readonly date: Date; | |
private readonly customer: Customer; | |
private readonly fees: FeeRider[]; | |
constructor(customer: Customer, duration: number, dailyRate: number, date: Date) { | |
this.fees = []; | |
this.customer = customer; |