Dialog
+ render()
Hard-wired new
1class Dialog {2 void render() {3 Button b = new WindowsButton(); // hard-coded concrete4 b.onClick();5 }6}
State
createsnew WindowsButton() 💥
Your free access ends in 7 days — and you haven’t tried it yet. Watch one algorithm run, start to finish. It takes about two minutes.
Try one problemDefine a method for creating an object, but let SUBCLASSES decide which concrete class to instantiate — so the creator code never names a product directly.
1class Dialog {2 void render() {3 Button b = new WindowsButton(); // hard-coded concrete4 b.onClick();5 }6}
Dialog.render() does `new WindowsButton()` directly — the layout class names a concrete widget.