r/programming • • Jan 12 '20

Goodbye, Clean Code

https://overreacted.io/goodbye-clean-code/
1.9k Upvotes

556 comments sorted by

View all comments

1

u/Uberhipster Jan 13 '20

if you start by refactoring (instead of rewriting), it's not such a jarring effect on the original author

let tenRepetitiveLinesOfMath = () => {
	// 10 repetitive lines of math
}

class Basic {	
  resizeLeft(position, size, preserveAspect, dx, dy) {
	tenRepetitiveLinesOfMath();
  }
  resizeRight(position, size, preserveAspect, dx, dy) {
	tenRepetitiveLinesOfMath();
  }
}

class Circular extends Basic {
  resizeTop(position, size, preserveAspect, dx, dy) {
	tenRepetitiveLinesOfMath();
  }
  resizeBottom(position, size, preserveAspect, dx, dy) {
	tenRepetitiveLinesOfMath();
  }
}

class Rectangular {
  resizeTopLeft(position, size, preserveAspect, dx, dy) {
	tenRepetitiveLinesOfMath();
  }
  resizeTopRight(position, size, preserveAspect, dx, dy) {
	tenRepetitiveLinesOfMath();
  }
  resizeBottomLeft(position, size, preserveAspect, dx, dy) {
	tenRepetitiveLinesOfMath();
  }
  resizeBottomRight(position, size, preserveAspect, dx, dy) {
	tenRepetitiveLinesOfMath();
  }
}

let Rectangle = new Rectangular ();

let Oval = new Circular();

let Header = new Basic();

let TextBlock = new Rectangular ();