Recall & Review
beginner
What is the main idea behind Object-Oriented Programming (OOP)?
OOP organizes code by grouping data and behavior into objects, like how you organize tools in labeled boxes for easy use.
Click to reveal answer
beginner
What does functional programming focus on?
Functional programming focuses on using pure functions that don’t change data outside themselves, like a recipe that always makes the same cake without changing the ingredients.
Click to reveal answer
intermediate
How do functional patterns help improve OOP code?
Functional patterns help by making parts of the code simpler and safer, avoiding unexpected changes, just like double-checking your work to avoid mistakes.
Click to reveal answer
intermediate
Why is immutability important in functional programming?
Immutability means data doesn’t change once created, which helps avoid bugs, like writing with a pencil that can’t erase mistakes.
Click to reveal answer
intermediate
Give an example of how functional patterns complement OOP in Ruby.
In Ruby, you can use objects to model things and pure functions to process data safely, like using a calculator object with methods that don’t change the input numbers.
Click to reveal answer
What is a key benefit of combining functional patterns with OOP?
✗ Incorrect
Functional patterns help keep code predictable and easier to test, which complements OOP's structure.
In functional programming, what does 'pure function' mean?
✗ Incorrect
Pure functions always produce the same result for the same input and don’t cause side effects.
Why is immutability useful when combined with OOP?
✗ Incorrect
Immutability helps keep object data consistent and avoids bugs from unexpected changes.
Which Ruby feature supports functional programming?
✗ Incorrect
Blocks and Procs let you write functions that can be passed around and used like data.
How do functional patterns affect side effects in OOP?
✗ Incorrect
Functional patterns encourage pure functions, which reduce side effects and make code safer.
Explain how functional programming patterns can improve object-oriented code.
Think about how keeping data unchanged and using simple functions helps.
You got /4 concepts.
Describe a real-life example where combining OOP and functional patterns makes programming easier.
Imagine organizing tools and instructions separately but working together.
You got /4 concepts.