Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Programming

Introduction to Programming

«Introduction to Programming» Talk held at the RailsGirls Event in Berne (2017).

Brigitte Hulliger

November 25, 2017
Tweet

Transcript

  1. SPEAK UP! IF I DO NOT MAKE SENSE, PLEASE TELL

    ME, (NICELY)! MAKE SENSE! PLEASE :-) I’m a person too, you know...
  2. WE LIKE TO SOLVE PROBLEMS WE SWEAR A LOT... AS

    LONG AS THEY ARE SOLVABLE IN A LOGICAL WAY IT ACTUALLY HELPS! YOU’LL SEE...
  3. WE LIKE TO SOLVE PROBLEMS NOT ALL OF US ARE

    GOOD AT MATH... WE SWEAR A LOT... AS LONG AS THEY ARE SOLVABLE IN A LOGICAL WAY IT ACTUALLY HELPS! YOU’LL SEE... BUT MOST OF US STILL LIKE IT!
  4. WE LIKE TO SOLVE PROBLEMS NOT ALL OF US ARE

    GOOD AT MATH... WE SWEAR A LOT... AS LONG AS THEY ARE SOLVABLE IN A LOGICAL WAY IT ACTUALLY HELPS! YOU’LL SEE... BUT MOST OF US STILL LIKE IT! WE DON’T LIKE THINGS FUZZY... COMPUTERS WORK IN 0s AND 1s, WHY SHOULDN’T WE?
  5. WE LIKE TO SOLVE PROBLEMS WE ARE PEOPLE TOO NOT

    ALL OF US ARE GOOD AT MATH... WE SWEAR A LOT... AS LONG AS THEY ARE SOLVABLE IN A LOGICAL WAY IT ACTUALLY HELPS! YOU’LL SEE... BUT MOST OF US STILL LIKE IT! SERIOUSLY! WE DON’T LIKE THINGS FUZZY... COMPUTERS WORK IN 0s AND 1s, WHY SHOULDN’T WE?
  6. WE LIKE TO SOLVE PROBLEMS WE ARE PEOPLE TOO NOT

    ALL OF US ARE GOOD AT MATH... WE SWEAR A LOT... AS LONG AS THEY ARE SOLVABLE IN A LOGICAL WAY IT ACTUALLY HELPS! YOU’LL SEE... BUT MOST OF US STILL LIKE IT! SERIOUSLY! WE DON’T LIKE THINGS FUZZY... COMPUTERS WORK IN 0s AND 1s, WHY SHOULDN’T WE? WE ARE MOSTLY LAZY! WHEN IT COMES TO REPETITIVE WORK!
  7. WE LIKE TO SOLVE PROBLEMS WE ARE PEOPLE TOO WE

    LIKE JOKES NOT ALL OF US ARE GOOD AT MATH... WE SWEAR A LOT... AS LONG AS THEY ARE SOLVABLE IN A LOGICAL WAY IT ACTUALLY HELPS! YOU’LL SEE... BUT MOST OF US STILL LIKE IT! EVEN THOUGH, SOMETIMES ONLY WE UNDERSTAND THEM... SERIOUSLY! WE DON’T LIKE THINGS FUZZY... COMPUTERS WORK IN 0s AND 1s, WHY SHOULDN’T WE? WE ARE MOSTLY LAZY! WHEN IT COMES TO REPETITIVE WORK!
  8. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    THEY RUN IN A BROWSER THEY HAVE SOME CONTENT, WRITTEN IN HTML Hyper Text Markup Language
  9. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    THEY RUN IN A BROWSER THEY HAVE SOME CONTENT, WRITTEN IN HTML Hyper Text Markup Language HTML IS THE STANDARD MARKUP LANGUAGE FOR CREATING WEB PAGES. WEB BROWSERS RECEIVE HTML DOCUMENTS FROM A WEB SERVER AND RENDER THEM INTO MULTIMEDIA WEB PAGES. HTML ELEMENTS (HEADINGS, TEXT, IMAGES, BUTTONS, LINKS, …) ARE THE BUILDING BLOCKS OF HTML PAGES. FURTHERMORE HTML DOCUMENTS MAY INCLUDE META DATA DESCRIBING THE WEB PAGE (I.E. A DESCRIPTION OF THE PAGE OR USED LANGUAGE). SOURCE: https://en.wikipedia.org/wiki/Hypertext_Markup_Language
  10. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    THEY RUN IN A BROWSER THEY HAVE SOME CONTENT, WRITTEN IN HTML Hyper Text Markup Language LINKS TEXT META INFORMATION
  11. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    THEY RUN IN A BROWSER THEY HAVE SOME CONTENT, WRITTEN IN HTML Hyper Text Markup Language
  12. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    THEY RUN IN A BROWSER THEY HAVE SOME CONTENT, WRITTEN IN HTML Hyper Text Markup Language THEY HAVE SOME STYLES, WRITTEN IN CSS Cascading Style Sheets
  13. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    THEY RUN IN A BROWSER THEY HAVE SOME CONTENT, WRITTEN IN HTML Hyper Text Markup Language THEY HAVE SOME STYLES, WRITTEN IN CSS Cascading Style Sheets CSS IS A STYLE SHEET LANGUAGE USED FOR DESCRIBING THE PRESENTATION OF A DOCUMENT WRITTEN IN HTML. CSS IS DESIGNED PRIMARILY TO ENABLE THE SEPARATION OF PRESENTATION AND CONTENT, INCLUDING ASPECTS SUCH AS LAYOUT, COLORS AND FONTS. SOURCE: https://en.wikipedia.org/wiki/Cascading_Style_Sheets
  14. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    THEY RUN IN A BROWSER THEY HAVE SOME CONTENT, WRITTEN IN HTML Hyper Text Markup Language THEY HAVE SOME STYLES, WRITTEN IN CSS Cascading Style Sheets BACKGROUND COLOR OF THE WEBSITE TEXT COLOR DEFAULT SIZE OF THE FONT
  15. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    THEY RUN IN A BROWSER THEY HAVE SOME CONTENT, WRITTEN IN HTML Hyper Text Markup Language THEY HAVE SOME STYLES, WRITTEN IN CSS Cascading Style Sheets
  16. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    WHAT IF… • … I WANT TO ADD A SECOND PAGE?
  17. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    WHAT IF… • … I WANT TO ADD A SECOND PAGE? I HAVE TO COPY THE ENTIRE PAGE! REMEMBER: WE ARE MOSTLY LAZY! WHEN IT COMES TO REPETITIVE WORK!
  18. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    WHAT IF… • … I WANT TO ADD A SECOND PAGE? • … I WANT TO ADD SOME INTERACTION (NOT JUST READING CONTENT) I HAVE TO COPY THE ENTIRE PAGE! REMEMBER: WE ARE MOSTLY LAZY! WHEN IT COMES TO REPETITIVE WORK!
  19. WHAT ARE STATIC WEB PAGES? Static vs. Dynamic Web Pages

    WHAT IF… • … I WANT TO ADD A SECOND PAGE? • … I WANT TO ADD SOME INTERACTION (NOT JUST READING CONTENT) I HAVE TO COPY THE ENTIRE PAGE! I CAN’T! REMEMBER: WE ARE MOSTLY LAZY! WHEN IT COMES TO REPETITIVE WORK! AND WE SWEAR A LOT. SHIT!
  20. WHAT ARE DYNAMIC WEB PAGES? Static vs. Dynamic Web Pages

    THEY RUN IN A BROWSER THEY HAVE SOME CONTENT, WRITTEN IN HTML Hyper Text Markup Language THEY HAVE SOME STYLES, WRITTEN IN CSS Cascading Style Sheets THEY ADDITIONALLY INCLUDE SOME SCRIPTS, WRITTEN IN RUBY ON RAILS OR JAVASCRIPT OR ...
  21. WHAT ARE DYNAMIC WEB PAGES? Static vs. Dynamic Web Pages

    WITH DYNAMIC WEB APPS WE CAN... • … CODE FULL-BLOWN APPLICATIONS (LIKE FACEBOOK, TWITTER, …) • … REUSE COMPONENTS (LIKE HEADERS, …) ON MULTIPLE PAGES
  22. WHAT ARE DYNAMIC WEB PAGES? Static vs. Dynamic Web Pages

    WITH DYNAMIC WEB APPS WE CAN... • … CODE FULL-BLOWN APPLICATIONS (LIKE FACEBOOK, TWITTER, …) • … REUSE COMPONENTS (LIKE HEADERS, …) ON MULTIPLE PAGES HOW COOL IS THAT!?
  23. STATIC VS. DYNAMIC WEB PAGES GOT IT? HINT: A GOOD

    GUIDELINE FOR COMPARING STATIC VS. DYNAMIC WEB PAGES IS WHETHER THE WEBSITE COULD BE PRINTED OUT AND STILL FUNCTION PROPERLY
  24. WHAT IS RAILS? RUBY VS. RAILS RUBY IS A PROGRAMMING

    LANGUAGE RUBY ON RAILS (OR ROR) IS AN OPEN SOURCE FRAMEWORK BASED ON RUBY. WITHOUT KNOWING THE BASICS OF RUBY, YOU CANNOT PROGRAMM RUBY ON RAILS!
  25. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL!
  26. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL!
  27. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! OBJECT-ORIENTED everything is an object...
  28. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! INTERPRETED instructions are executed immediately • IN OBJECT ORIENTED PROGRAMMING (OOP), AND OBJECT MAY BE SEEN AS A CONTAINER OF DATA WITH ATTRIBUTES (DATA) AND A GROUP OF METHODS (PROCEDURES) DEFINED IN ITS CLASS. • AN OBJECT IS AN INSTANCE OF A CLASS IT IS ASSIGNED TO ALL THE ATTRIBUTES AND METHODS DEFINED IN ITS CLASS. • EVERYTHING IS AN OBJECT IN RUBY!
  29. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! INTERPRETED instructions are executed immediately CAR (OBJECT)
  30. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! INTERPRETED instructions are executed immediately CAR (OBJECT) 4 WHEELS (hopefully) (NUMBER OF WHEELS)
  31. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! INTERPRETED instructions are executed immediately CAR (OBJECT) 4 WHEELS (hopefully) (NUMBER OF WHEELS) TURQUOISE (COLOR OF CAR)
  32. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! INTERPRETED instructions are executed immediately CAR (OBJECT) 4 WHEELS (hopefully) (NUMBER OF WHEELS) ACCELERATE (SKILL: METHOD) TURQUOISE (COLOR OF CAR) FLASH (SKILL: METHOD)
  33. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! INTERPRETED instructions are executed immediately OBJECT-ORIENTED everything is an object... CAR (OBJECT) 4 WHEELS (hopefully) (NUMBER OF WHEELS) ACCELERATE (SKILL: METHOD) TURQUOISE (COLOR OF CAR) FLASH (SKILL: METHOD) DRIVER (OBJECT)
  34. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! INTERPRETED instructions are executed immediately WHAT ABOUT NOW? NAME SOME OBJECTS, ATTRIBUTES AND METHODS.
  35. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! INTERPRETED instructions are executed immediately CAR (OBJECT) 4 WHEELS (hopefully) (NUMBER OF WHEELS) ACCELERATE (SKILL: METHOD) PINK (COLOR OF CAR) DRIVER (OBJECT) ANOTHER CAR (OBJECT) ANOTHER DRIVER (OBJECT)
  36. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! OBJECT-ORIENTED everything is an object...
  37. INTRODUCTION TO RUBY INTRO TO RUBY YUKIHIRO MATSUMOTO HE FOUNDED

    OF RUBY IN 1993 OPEN SOURCE EVERYBODY CAN VIEW, CHANGE AND REDISTRIBUTE THE CODE AS YOU LIKE. THIS IS ACTUALLY VERY COOL! OBJECT-ORIENTED everything is an object... SIMPLE & INTUITIVE LET’S HAVE A LOOK...
  38. INTRODUCTION TO RUBY INTRO TO RUBY 5.times { print ‘Odelay!’

    } READ THIS OUT LOUD: WHAT DOES IT DO? ANY IDEAS?
  39. INTRODUCTION TO RUBY INTRO TO RUBY 5.times { print ‘Odelay!’

    } READ THIS OUT LOUD: WHAT DOES IT DO? ANY IDEAS? IN ENGLISH SENTENCES, PUNCTUATION (SUCH AS PERIODS, EXCLAMATIONS, PARENTHESES) ARE SILENT. PUNCTUATION ADDS MEANING TO WORDS, HELPS GIVE CUES AS TO WHAT THE AUTHOR INTENDED BY A SENTENCE.
  40. INTRODUCTION TO RUBY INTRO TO RUBY exit unless ‘restaurant’.include? ‘aura’

    LET’S TRY ANOTHER ONE. READ IT OUT LOUD ONCE MORE: AGAIN: WHAT DOES IT DO? ANY IDEAS?
  41. INTRODUCTION TO RUBY INTRO TO RUBY exit unless ‘restaurant’.include? ‘aura’

    LET’S TRY ANOTHER ONE. READ IT OUT LOUD ONCE MORE: AGAIN: WHAT DOES IT DO? ANY IDEAS? HERE WE’RE DOING A BASIC REALITY CHECK. OUR PROGRAM WILL EXIT (THE PROGRAM WILL END) UNLESS THE WORD RESTAURANT CONTAINS (OR INCLUDES) THE WORD AURA.
  42. INTRODUCTION TO RUBY INTRO TO RUBY [‘toast’, ‘cheese’, ‘wine’].each {|food|

    print food.capitalize } THIS ONE IS A BIT MORE TRICKY. TRY IT ANYWAY: WHAT DOES IT DO? HINT: SOMETIMES RUBY READS AS A «SHORTER» ENGLISH.
  43. INTRODUCTION TO RUBY INTRO TO RUBY [‘toast’, ‘cheese’, ‘wine’].each {|food|

    print food.capitalize } THIS ONE IS A BIT MORE TRICKY. TRY IT ANYWAY: WHAT DOES IT DO? HINT: SOMETIMES RUBY READS AS A «SHORTER» ENGLISH. SOLUTION: WITH THE WORDS ‘TOAST’, ‘CHEESE’ AND ‘WINE’: TAKE EACH FOOD AND PRINT IT CAPITALIZED.
  44. INTRODUCTION TO RUBY ON RAILS INTRO TO RAILS SIMPLE &

    INTUITIVE YOU’LL CONFIRM THAT YOURSELF TONIGHT, HOPEFULLY :-)
  45. INTRODUCTION TO RUBY ON RAILS INTRO TO RAILS SIMPLE &

    INTUITIVE YOU’LL CONFIRM THAT YOURSELF TONIGHT, HOPEFULLY :-) «CONVENTION OVER CONFIGURATION» REMOVES THE DULL PARTS OF CODING AND LETS US CONCENTRATE ON THE ESSENTIALS.
  46. INTRODUCTION TO RUBY ON RAILS INTRO TO RAILS SIMPLE &

    INTUITIVE YOU’LL CONFIRM THAT YOURSELF TONIGHT, HOPEFULLY :-) «CONVENTION OVER CONFIGURATION» REMOVES THE DULL PARTS OF CODING AND LETS US CONCENTRATE ON THE ESSENTIALS. FOLLOWS THE MVC PATTERN
  47. MVC

  48. MVC MODEL - maintains the connection between the objects and

    the database - access to data and the logic of the application - independent of view and controller MVC
  49. MVC MODEL - maintains the connection between the objects and

    the database - access to data and the logic of the application - independent of view and controller VIEW - presentation of the data and interaction with the user - only displays what is in the model MVC
  50. MVC MODEL - maintains the connection between the objects and

    the database - access to data and the logic of the application - independent of view and controller VIEW - presentation of the data and interaction with the user - only displays what is in the model CONTROLLER - the logic of the application - coordinates the interaction between the user, the view and the model - is in charge of what is happening MVC
  51. MVC MODEL - maintains the connection between the objects and

    the database - access to data and the logic of the application - independent of view and controller VIEW - presentation of the data and interaction with the user - only displays what is in the model CONTROLLER - the logic of the application - coordinates the interaction between the user, the view and the model - is in charge of what is happening MVC UPDATES FILLS WRITES NOTIFIES
  52. FILE STRUCTURE MVC • ALL APPLICATIONS DEVELOPED USING RUBY ON

    RAILS SHARE A COMMON FEATURE: THEY ARE ALL ORGANISED ACCORDING TO THE SAME STRUCTURE. • THIS HELPS UNDERSTANDING OTHER DEVELOPER’S CODE EASILY. THEREFORE: DON’T CHANGE IT! EVER!
  53. TEXT EDITOR TOOLS YOU CAN USE WHATEVER TEXT EDITOR YOU

    PREFER. • ATOM, VIM, NOTEPAD++, SUBLIME, … PERSONALLY, I LIKE SUBLIME THE BEST! AND IT IS AVAILABLE FOR ALL OPERATING SYSTEMS!
  54. TERMINAL aka COMMAND PROMPT (on windows) TOOLS THIS IS WHERE

    YOU START THE RAILS SERVER AND RUN COMMANDS • ON MAC: ◦ SEARCH FOR «TERMINAL» IN YOUR SPOTLIGHT • ON WINDOWS: ◦ SEARCH FOR «COMMAND PROMPT» OR «CMD» ON YOUR COMPUTER
  55. USE WHATEVER BROWSER YOU WANT... ALTHOUGH: I WOULDN’T USE INTERNET

    EXPLORER... BROWSER TOOLS OBVIOUSLY ;-) IT MIGHT DRIVE YOU CRAZY!