Designing functions independently of the data they operate on allows you to create more flexible functions with a wider range of applications. Learn how functional programming differs from object-oriented programming, which groups its data and functions in classes and objects.
- [Narrator] The second main concept … of functional programming … is something called functional purity. … In functional programming, … we aim to make all of our functions into pure functions. … And what this means is that the functions we write … should always return the same output, … given the same arguments. … And if this doesn't quite make sense to you yet, … let's take a look at what functions that … are not pure look like. … Basically functions are not pure … whenever they refer to some sort of internal … or external state that changes. … Now probably the most common example of this … in Java is when you have methods in a class they're referred … to a mutable member variable, … let's say that we have a person class … with a private age member variable, … and then we have a method called get age, … which simply returns the value of this age variable. … This get age function is probably not pure and here's why. … We can call it once and it might return some number like 34, … basically whatever the person's age is at that point, …
Skill Level Advanced
Java Design Patterns: Structuralwith Bethan Palmer1h 38m Intermediate
1. Introduction to Functional Programming
2. First-Class Functions
3. Working with Streams in Java
4. Advanced Concepts
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.