4 ms·
There’s a certain program size from which they start to make sense and further still the benefits are obvious - you have a computer to help solve puzzles for yo
by baq 4y ago
There’s a certain program size from which they start to make sense and further still the benefits are obvious - you have a computer to help solve puzzles for you, so why not use it if the puzzle is ‘will this peg fit into that hole?’ when you have thousands of pegs and holes.
- mharig 4y agoAnd so you end up writing climb_the_wooden_ladder(l: WoodenLadder) plus climb_the_aluminium_ladder(l: AluminiumLadder) or press all into an OO hierarchy instead of climb(thing): '''Climb a thing with steps''' # prevent run time crash: if not hasattr(thing, 'getSteps'): hitDeveloper()
- baq 4y agoNo, you define a Ladder (or Climbable if you’re feeling fancy today) Protocol and all remains good in the world.
- cfu28 4y agoNo need for OO hierarchy, just use a protocol
- mharig 4y agoOh, I missed the Protocol class of the typing module. Have to further investigate the usage of this. Thanks to you and baq!