Germany, she prefers cats, earns 40k per year, she studied Economics • Mike is 27, he is from China, he prefers dogs, earns 40k per year, he studied Medicine • Svetla is 35, she is from Bulgaria, she prefers cats, earns 80k per year, she studied Electrical Engineering • Theo is 60, he is from Germany, he doesn’t like pets, earns 50k per year, he studied Law 1. Create appropriate data structures 2. Find all people who are from Europe 3. Find all people who earn between 45k and 70k per year 4. Find all people who don’t like pets
Module class • public by default • protected is barely used: any instance of a class can call a protected method on any other instance of the class • private is only callable from inside the class or subclasses -> won’t allow calls with an explicit receiver
Ruby code is executed inside an object called current object, symbolized by self • reference to the receiver that ruby holds when traversing the class hierarchy • only one object at a time can be self • when you call a method, the receiver becomes self • everything is an object -> in a class or a module, the role of self is take by the class or the module itself
• The app has an owner and zero or more lists • A list has an id, a name (mandatory) and zero or more items • An item has an id, a content (mandatory) and an expire date (not mandatory) • It should be possible to display all the expired items of a specific list • It should be possible to display all items of a list • It should be possible to display all lists • When an item has an expire date, that should also be displayed together with the name when listing the items • Lists can be added to and deleted from the app • Items can be added to and deleted from a list • Divide classes appropriately, make use of as many constructs we saw today
the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. I don't own the right to the images unless otherwise stated. If you feel you rights have been violated, please contact me at [email protected] To view a copy of this license visit http://creativecommons.org/licenses/by-nc-sa/4.0/ You can find the slides on speakerdeck.com/nirnaeth