Oct. 22, 2015
Spent time to look into
the note through the video, and then study more later:
How To Design A Good API and Why it Matters
(Julia's rating: A+)
https://www.youtube.com/watch?v=aAb7hSCtvGw
1. Watched again on 10/21/2015, notes taken to share:
54:40/1:00:18
Use Appropriate Parameter and Return Types
. Favor interface types over classes for input
- provides flexibility, performance
. Use most specific possible input parameter type
- Moves error from runtime to compile time (Julia's comment: Great tip, reduce time on debugging, fix things in compiling time!)
. Don't use string if a better type exists
- Strings are cumbersome, error-prone, and slow
. Don't use floating point for monetary values
- Binary floating point causes inexact results!
- Use double (64 bits) rather than float (32bits)
-Precision loss is real, performance loss negligible
2. watched again on 10/21/2015, notes taken to share:
49:19/1:00:18
Don't violate the Principle of Least Astonishment
Read more on this article:
http://programmers.stackexchange.com/questions/187457/what-is-the-principle-of-least-astonishment
3. watched again on 10/21/2015, notes taken to share:
https://www.youtube.com/watch?v=aAb7hSCtvGw
1. Watched again on 10/21/2015, notes taken to share:
54:40/1:00:18
Use Appropriate Parameter and Return Types
. Favor interface types over classes for input
- provides flexibility, performance
. Use most specific possible input parameter type
- Moves error from runtime to compile time (Julia's comment: Great tip, reduce time on debugging, fix things in compiling time!)
. Don't use string if a better type exists
- Strings are cumbersome, error-prone, and slow
. Don't use floating point for monetary values
- Binary floating point causes inexact results!
- Use double (64 bits) rather than float (32bits)
-Precision loss is real, performance loss negligible
2. watched again on 10/21/2015, notes taken to share:
49:19/1:00:18
Don't violate the Principle of Least Astonishment
Read more on this article:
http://programmers.stackexchange.com/questions/187457/what-is-the-principle-of-least-astonishment
3. watched again on 10/21/2015, notes taken to share:
42:31/1:00:18
Subclass only where it Makes Sense
. Subclassing implies substitutability (Liskov)
-- Subclass only when is-a relationship exists
-- Otherwise, use composition
. Public classes should not subclass other public
classes for ease of implementation
Bad: Properties extends Hashtable
Stack
extends Vector
Good: Set extends Collection
No comments:
Post a Comment