Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Final version of presentation #43

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added defensive-programming-reversim-2013.key
Binary file not shown.
Binary file added defensive_programming/1108864_o.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions defensive_programming/always_safeguard_from_exception.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@current_user ||= User.find(session[:user_id]) rescue nil

@current_user ||= User.find(session[:user_id]) if session[:user_id].present?
Binary file added defensive_programming/always_validate_input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions defensive_programming/always_validate_your_input.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class Foo
def Bar(num, str)
if str.isA(String)
puts "Stringify Bar"
act_on_string(str)
elsif num.isA(Fixnum)
puts "Fixnumy Bar"
act_on_integer(num)
else
do_something_else(num, str)
puts "I don't know what this is"
end
end

private
def act_on_string(str)
if str.isA(String)
# do some action
else
raise Exception
end
end

def act_on_integer(str)
if str.isA(Number)
# do some action
else
raise Exception
end
end

def do_something_else(num, str)
if str.isA(String)
# do some action
elsif num.isA(Fixnum)
# do something else
else
raise Exception
end
end

end
Binary file added defensive_programming/be_aware.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/design-patterns.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/every_rule.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/exceptions_alternative.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/exceptions_dangerous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/friend.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/happy_coder.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/less.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/naming.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions defensive_programming/naming.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class class_name

def take_and_send(queue, msg)
end

end
Binary file added defensive_programming/patterns.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/psychology.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/remember-fear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/ruby.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added defensive_programming/work_done.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.