software punk
TRANSCRIPT
Software Punk
Lior Bar-On, 2016
Controversial ideas in Software Development That just might work.
Source: songpop.wikia.com
Who is this Guy? (Lior Bar-On)
בלוג ארכיטקטורת תוכנה
Developer
Architect
Chief ArchitectBlogger
Inheritance is a bold violation of OO Principles!
1. Encapsulation (“הכמסה”)2. PolyMorphism (“ריבוי-צורות”)3. Inheritance (“הורשה”)
Violation
Composition > Inheritance
“... our second principle of object-oriented design:
Favor object composition over class inheritance.
”
Source: http://slidedeck.io/parnurzeal/why-opensource-slides Source: Addison wesley
Inheritance as tool for (poor?) abstractions
Black Cab → A, B, C, D
Yellow Cab → A, E, F
Green Cab → A, B, D, E
Scooter → C, E, G
PHV → B, C, F
Recap
Inheritance can cause “unexpected behavior” - but it is rare.
Inheritance (“is-a” delegation) is too limited to expressed real world domain objects. Use Inheritance only with dead-simple cases.
1
2
In some programming languages, Inheritance makes the code less expressive.3
HTTP Retry: The POST case
...IDEMPOTENT_METHODS = [“GET”, “PUT”]if method in IDEMPOTENT_METHODS { // http request retry}...
HTTP Retry: The POST case #2
...if can_retry { if _err == CONNECTION_ERROR { // http request retry }} ...
The Fallback cache Case
...if _err == CONNECTION_ERROR { // try to load response from fallback cache}...
Recap
Not only code Rots. Abstractions Rot too.It’s okay to occasionally favor Code Duplications and avoid non-meaningful abstraction.
When an Abstraction rots: Stop. do a reverse, and return the code duplication.
1
2
There are several ways to achievehigh quality....
Source: profiles.com.sg
Type B Codename “Bart”
Source: a presentation by Lior Bar-On
Example: Aggregating 11 model methods into a single test
Type C - Codename “Cat In The Hat”
Source: marocdeserttours.wordpress.com
Type C - Codename “Cat In The Hat”
Source: marocdeserttours.wordpress.com
Ideal Target: when covering 90%+ of the cases is not possible - or just too expensive
Recap
Unit Tests is great - but it has its costs.It fit perfectly for logical code units (if / for)
Integration / Unit-Integration tests are more broad - but more cost efficient.
1
2Sometimes, it worth monitoring things only on production.When done well - it can be cheap, otherwise - very expensive.
3