#SOLID Principles with ruby examples
##SRP - Single responsibility principle A class should have only a single responsibility.
Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.
##OCP - Open/closed principle Software entities should be open for extension, but closed for modification.
###1. *
* { margin: 0; padding: 0; }
Let’s knock the obvious ones out, for the beginners, before we move onto the more advanced selectors. The star symbol will target every single element on the page. Many developers will use this trick to zero out the margins and padding. While this is certainly fine for quick tests, I’d advise you to never use this in production code. It adds too much weight on the browser, and is unnecessary.
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
For last night's UW Advanced Rails last class I put together my short list for staying up to date with Ruby, Rails, and the Web Development community. Here's the list:
- Ruby Weekly, HTML 5 Weekly, and Peter Cooper's other great e-newsletters
- Ruby 5 podcast. Short, and perfect for commuting.
- Ruby Rogues - a longer form podcast that has ruby rock-stars on it
- Prismatic - something about their filtering / aggregation algorithm is the best. Friend me there to get started: Ivan Storck on Prismatic
- Seattle.rb - The US's oldest Ruby group meets every week and has presentations 1x a month. Great networking and code help.
Railscasts videos all in one: | |
http://media.railscasts.com/assets/episodes/videos/001-caching-with-instance-variables.mp4 | |
http://media.railscasts.com/assets/episodes/videos/002-dynamic-find-by-methods.mp4 | |
http://media.railscasts.com/assets/episodes/videos/003-find-through-association.mp4 | |
http://media.railscasts.com/assets/episodes/videos/004-move-find-into-model.mp4 | |
http://media.railscasts.com/assets/episodes/videos/005-using-with-scope.mp4 | |
http://media.railscasts.com/assets/episodes/videos/006-shortcut-blocks-with-symbol-to-proc.mp4 | |
http://media.railscasts.com/assets/episodes/videos/007-all-about-layouts.mp4 | |
http://media.railscasts.com/assets/episodes/videos/008-layouts-and-content-for.mp4 |