Coders Campus Podcast

Coders Campus Podcast

Download on the App Store

Coders Campus Podcast episodes

  • EP56 – Fun Tricks and Analytics with IntStreams in Java

    GitHub link here: https://github.com/tp02ga/FunWithStreams

    In this episode we'll talk about IntStreams and why they're useful in Java.

    IntStreams can be used to replace a common looping mechanism as well as provide a very helpful utility for gathering analytics on data in a non-verbose way.

    Episode Transcript

    0:09

    Welcome to the coders campus podcast, where you'll learn how to code from one of the best teachers in the industry. Whether you're an absolute beginner or a seasoned pro, the coders campus podcast will teach you what you need to know, to master the art of programming. And now, your host, Trevor page.

    0:28

    All right, ladies and gentlemen, fellow coders. Welcome back to this next lesson in our series in the podcast where we are diving into streams in Java. So thanks so much for joining, as always, always a pleasure to be on this side of the microphone, and hoping to deliver lots and lots of useful tidbits to you. So today, we're talking about into streams, tricks and analytics within streams was the title I came up with, because it sounded neat, it rhymes. So deal with it. So anyway, what we're gonna be covering is essentially, what is an in stream? How is it different from a regular stream in Java? When would we use it? What are some, you know, nifty little tricks that we can use it for. And as well as you know, getting into more data analytic stuff, which is something that, you know, Python gets a lot of a lot of notoriety for, using, you know, data science and whatnot. But the, hey, there's some tools in Java for data science as well. And I'll be it this one is very simplistic, but helpful. I've used it before for, you know, analyzing data and giving reports and whatnot. So yeah, without further ado, let's dive into this topic, while I pull up my example. So as always, if you're following along with the examples that I'm posting, you can do so via coderscampus.com/56, that should redirect you to a little blog post where I will include the GitHub repository that I'm using, within within that GitHub repository, there should be a package called com.coderscampus.intStream. And there's a couple of files in there that you can look at that will, you know, represent the code that I'm going to be talking to you about right now. So yeah, you don't have to go there. Now. It's okay, if you're driving or something or doing dishes and or working out, you could just listen. But just remember, this code is available, if you want to go back and look at it for reference on your computer, to coderscampus.com/56. So basically, what is an entire stream, we'll start there. So in streams are a variation of a stream in Java. But more specifically, it is dealing with, as it says, In the name integers. So it allows you to do more specific operations, you know, chaining methods and whatnot, like we're used to doing with streams where you, you know, you do a dot filter, dot this dot that or whatever, with an industry that allows you to do it unlocks a couple of specific, you know, dot, essentially specific methods, specific functions that you can call that you can invoke that do some helpful things. So in in stream is just, hey, we're dealing with integers here. So the only valid object that you can be streaming over the only valid, you know, collection of things that you can be streaming over is an integer or an integer set of integers. Or I suppose I should say, a collection of integers to be more specific. So, yeah, if you're not using integers here, if you're not streaming over integers, then you can, you cannot use an int stream. Okay, that's the first thing to understand this int stream is just for integers. Streams are for any objects. So long as they're not, you know, primitives. Well, I guess I shouldn't say any objects. Streams are good for any collections. But into streams are specifically for integers. Okay. So having said that, the example that I have here is using sales data. So it's something very simple. There is no you know, this is how we do it the old way. And this is how we do it the new way. The old way of doing this is awful. If you had to code this out yourself, it would be tons of lines of code. The finished product here in front of me is is like what 24678, you know, about eight lines of code versus it would be, I don't know 50 or more, I don't know, off top my head. It would just be a lot of work to do this all yourself.

    4:43

    So yeah, we boil it down to eight lines of code here. But basically what we're doing here is we're looking at sales data. This could be any data, I just created a sales data object class, more specifically, and it's just a plain old Java object inside of it is just two properties. Restoring one is the date, the date of sales, and the other is the amount. So the number of sales made on a given date. Now it's an integer amount, it's not a it's not $1 amount. So it's not like a double or a big, you know, into big, double big. What does it anyway? Big decimal, it's not a big decimal or a double type. It's just integer. So this represents some hypothetical number of individual units sold on a given date. Okay, that's really what we're what we are working with here. But it's simple. It's a simple it has a date and an amount as an integer. The date is a local date type. So we're using Java, what is this Java eight? Yeah, Java eight type, sorry, my phone is making notification messages. If that was if you have an Android phone, and you're looking at your phone right now, that was my phone.

    5:52

    Okay, so just a date and an amount was get with getters and setters, that is what is inside of the sales data class. Very, very simple, just storing two things. So having said that, I also have a little method that I created to just populate a list of sales data. So I'm just populating an arbitrary number of sales data objects and putting them into a list. In my code here, I just have it generating 100. So all this is doing is randomly generating integers and randomly generating dates, popping them into new sales data, you know, objects, and throwing those into a list. It's just a list of sales data that has data inside of it. Now, getting into using an entire stream, we can start streaming over our data, which we just do the normal way we always stream which is we say sales data dot stream. Okay, so nothing, nothing earth shattering, here, we're just doing a regular old stream. So what this will return to us, when we do the sales data dot stream, is it is going to return a stream a normal stream of sales data objects, okay. But what we can do here is we want to turn this into an int stream, because we want to do some statistical analysis on the data. Okay, specifically on the int data, the integer data, so what we can do is we can do for a regular stream, you can perform a dot map to int, map to int. So we've talked about map before a couple of lessons or episodes ago, map is just where we take, you know, something coming upstream. So like, you know, like an object or whatever. And we are, you know, sort of narrowing down to a subset of properties for that, you know, those collection of objects that we're iterating over, okay, that we're streaming over. So, this allows you to narrow into, essentially a different it maps it to a different data type. Normally, we use it to narrow down to a specific property of the objects that we're streaming over. In other words, for this one, we want to narrow it down to just the amount the sales data amounts, because remember, I said the amount was stored as integer, the date in sales data was stored as a local date. So again, sales data has a date, and amount. But what we want to do is you want to narrow down to just the amount. Okay, so that's sort of what map can do map can narrow down to individual properties, or can can completely transform into something, you know, entirely different. It's up to you and how you want to use map. But that's map, we've already talked about map, I want to talk about map to int. So it does the exact same thing. The only difference is what the dot map, how dot map Dipper differs, not dippers, difference from dot map to int, is that map returns a stream of the objects again, and a while stream of the output of whatever it is that you're transport, mapping it to the map to int returns an int stream. Okay, it's not an int stream of anything, because it's we already know it's of integers, right? So it's not an int stream of something, it just returns a plain old in stream because we already know it's a stream of integers. So anyway, that's what we're dealing with here. So map to int, translates transforms the data coming upstream into an int stream. But then we need more data here. We can't just say map to into the magically it'll work. You need to tell it what property from the objects that we're streaming over. What property is the property that we want to use this industry for? How do we want to stream over these integers? So when you tell it what property we're streaming over here, data the individual property? So as I've alluded to before, the property that we want to stream over is the amount property because for sale data, the amount is an integer. Okay, so we can say dot map to int when we're streaming. And we pass in the, the get amount is the the getter method that exists for sales data. So you pass in get amount. And that is what we can use to stream to create our int stream from. Okay, so we pass in the get amount. So this you want to pass and get amount, you can either use the normal lambda function syntax where, you know, the left hand side is because it's the getter method, it will take nothing, I believe, I have it written out the other way. I'm using the double colon syntax. Let me just see if it works. If I use the double, double round brackets.

    10:46

    Oh, no, I need to pass it in, right, you need to pass in the I shouldn't say double round brackets, you're passing in the sales data from above. So you can call it S or something. And then you can say s dot get amount, right. So when you say dot map to enter, you're passing in a lambda function, it takes the input of the object that's being iterated over being streamed over, which is the sales data, you can call it whatever you like, called call it S. And then you can say s dot get amount on the other side of the arrow function. Alternatively, you can just say, sales data, the, the class name, so sales day with a capital S, double colon, is used to give you access to the methods, right, so you can say double colon get amount, right. So that way, you don't have to have the lambda function, you just sort of pass the pass the function. And it's another way to do the same thing. They both do the same thing. So in my example, I just use that double colon format. So again, sales data dot stream, dot map to int, and pass in the sales data's get amount function. Cool. So now what do we have downstream? What could what sort of dot operations can we do now that we've turned it into an entire stream? There's tons of there's, there's a tons of stuff, there's tons of stuff. One of which is called summary statistics. But I'll get there in a moment, you can do on an in stream, because we know we are streaming over integers, you can do a dot sum, because we simply know we're in there's integers here, we know we can sum up the integers, you can do dot sorted callback to the last episode, it will just know how to sort and insert an int stream because it's just integers. We can what else we can do a max or a min on it, which returns optional int, because Optionally, you know, what if there's not a maximum in there, what if it's empty, or I don't know, maybe there's two that are the same thing. Anyway, you can do max and the min, you can limit the number of, of entries you want to stream over if for some reason that is of use to you, maybe you can sort it and then limit to like, I don't know, the first 10s. Anyway, you can, you can do a bunch of stuff, you can count, you can get an average, you can also convert it to a double stream or a long stream. Okay, because there's not just an industry, there's also double stream and long stream. And pretty much all the stuff we're talking about with an inter stream applies to double stream and long stream as well. Okay. So having said that, there's tons of stuff you can do with an in stream that is specific to iterating over integers. And that's where my mind when I first learned about in streams, it just, it was too much. When I was learning about streams, I was like, well, to stream, there's in stream and double stream as long stream like, what are all these types. And these are all confusing. So don't be too overwhelmed or confused by these types that we're using here is just a stream of integers. And all the only reason why we have a different type there is so that we can unlock these additional functions that I just spoke about that apply specifically to integers that we know we can apply to integers. Okay, because if you're streaming over users, you can't do like stream over users and then say dot average, give me the average user. What the heck does that mean, right? There is no such thing as an average user. Like, you need to define that. And it doesn't make sense. Or give me the maximum user. It's like, what, what does that mean? Give me the maximum and minimum users? I don't know. That doesn't make sense. Conceptually speaking, you need to give me more context. I'm missing context. But if you say give me the maximum integer, and the minimum integer, right, or the average integer, that makes sense, you know how to how to find the maximum integer in a given list of integers, or the minimum integer in a given list of integers or the average value of all the list of integers, right? Those conceptually make sense. So that's what an int stream unlocks. Because we are iterating over a stream of integers. We can do all these extra things. Now, I want to dive into what I spoke about the very beginning there of the all the different functions that we can use on in stream and that was something called dot summer. Statistics. So what does dot summary statistics do? It returns another type called int, summary, statistics. What the heck is an int summary statistics type? Well, all this type is is just a class that allows you to get access to the Common Data Analytics. Remember, I promised I was gonna talk about analytics today, tricks and analytics, these this event summary statistics type, or class gives you access to the average account, the max, the min and the sum all in one place.

    15:39

    Okay, it gives you access to the average account, the max, the min and the sum. So it gives you access to five sort of aggregation type data, things, great for analytics, right? Great for reports and whatnot. So in three lines of code here, although it took me a long time to explain the three lines of code, in three lines of code, we can now get access to this event summary statistics object and get the count of the data, the max of the data, the min of the data, the average of data and the sum of the data. In other words, give me a count of all the sales that happened, give me the maximum sales, give me the minimum sales number, give me the average sales number, and give me the sum of all the sales figures together. Okay, so you can get all five of those things and print it out to a report. Cool. So that's sort of what inter stream allows you to do from a statistics or a analytics data standpoint, right? It allows you to do all that stuff, which is nice. It's very convenient. And like I said, to do all that statistics yourself to do all those number crunching things and processes and looping and if statements and, you know, switching out the maxes and the mins and trying to calculate a sum and get an average and account like doing all that it just is a lot of work. But we can boil it down to three lines of code now, stream it, map it to an int, get the summary statistics done. Cool. So that is the analytics or statistics point up or part of this conversation. The other part I said is you can do a trick, there's a trick that you can do with an industry that might, you know, impress your mom, or your friends. And that is you can use an input stream to generate, essentially a range of numbers that you can then iterate over. In other words, this is another way to do a for loop. Because you needed another way to do a for loop. You know, you can do a for loop with the old, you know, boilerplate way, which is, you know, for Indi equals zero, i is less than whatever i plus plus, there's that syntax for a for loop. There's also a for each loop, where you can do, you know, for, and then you have the data type, and then the individual object and the colon, and then you do the collection of objects. There's that concept of the for each loop. But then there was this idea of streams, regular streams, where you can do a dot stream, and then you can do a dot for each as well. Right, so you can do a dot for each but and that's fine. That's that's another way to do a for loop over a collection of objects as a stream. Cool, nothing wrong with that. Very helpful. But what if you want to do a different range, but you still want to do that same syntax, you want to have a range from instead of maybe doing all of them, you want to do from zero to 10, specifically, or zero to some number minus 10, I don't know whatever the whatever your little heart desires, you can use int stream to do that. So you can generate a range using int stream dot range, okay, into stream dot range allows you to have or gives you two inputs, so you have dot range, and it takes two inputs, the inclusive integer and the exclusive integer. Okay. In other words, this is from like zero to 10. You know, if you want to go from zero to 10. In other words, you want to iterate 10 times you go from zero to 10, exclusive, or zero is inclusive, 10 is exclusive, so you really only go from zero all the way to nine, and that you stop. That's what the int stream dot range will do for you. So you can do zero to whatever, there's also another one. Instead of range, it's called range closed. What that does is it allows you to do the instead of the end being exclusive, the end is inclusive, right? So instead of you want instead of wanting or having to do zero to nine, now you can have a choice to do one to 10, right, it's again, you could always do this with any other for loop structure. But it's just it gives you you know, you can do it with an in stream. So you'll see this in my code. I do Just to show off that I, you know that I know how to do this, you can do in stream dot range, you can see that the code when I'm generating my sales data with all the random numbers and stuff, I use an input stream to do that range. And then I do all the stuff to,

    20:14

    you know, go through, and you know, from zero to whatever, completely unnecessary. It's entirely unnecessary. But it's, it's just another way to do a for loop. In this case, we, I don't have a collection of objects to iterate over. All I'm given is as the input is just hey, the number of sales, you know, number of the total number of sales objects that I want our sales data objects that I want to create. That's the input to this generate sales data method that I'm talking about on my screen right now that you guys can't see. But the function that I use to generate sales data, the only input that it has is an is an integer, which is the number of sales. So you can't do like a stream, per se, on that you can't do a normal stream on that. Because it's not a collection, you can stream on a collection. But in this case, we don't have a collection. So we would have to write out a regular old for loop a for it, i equals zero, where i is less than number of sales, i plus plus. So because I would have been forced to write that instead, I'm using in stream dot range, zero comma number of sales. So that just allows me to save myself from typing out the boilerplate for for loop right. Now, having said that, do you always want to do that? I don't know, I don't think there's a huge reason to do this. Other than, like I said, it's, you know, it's potentially more readable. It's, it's using or utilizing the functional programming paradigm. So you do int stream dot range, and that dot range will return an int stream, which I then use dot boxed on. Because what dot box does is it returns a stream consisting of the elements of the int stream, each boxed into an integer. Okay, so what that means is, is we're just converting back to a normal stream, instead of an in stream, we're converting back to a normal stream. And each of the elements now that we're iterating over, are available as integers. That's all. So we're taking primitive INTZ, and boxing them into integer objects, and iterating over them as a collection. So if you have a range of zero to 100, or something, you will get a stream of numbers from zero all the way to 99. And then you can do whatever you want with those, right? So what I did was I just did a dot map, and I mapped the integer to something completely different. In other words, I completely ignore the integer, the I in this case, I completely ignored it and just mapped it to generate a new sales data object and they collected all those new sales data objects, 100 of them into a list and return that list. Okay, so that's how I generated my sales data. It wasn't, you know, again, I could have done all this in a for loop. But when you use an event stream, you get to use, you know, dot map and dot collect. And now this dot box thing, which just translates from an in stream back to a regular old stream. Cool. So, yeah, that is the gist of an event stream. And again, you can more or less copy, paste, everything I've talked about here, into a double stream or a long stream. Now, there's probably some operations that are specific to doubles, or specific long's that are, you know, useful and whatnot. So those will be available there. But that's a simple Google search. You don't need me to go over every single one of those individually. I'm sure you are fully capable of looking up what those types of streams are and what makes them different from an income stream. Okay. So having said that, I will spend very few moments here talking about the bootcamp to close things off again, this if you're listening to this point, all this is able to be sponsored by the coders campus boot camp, available at coderscampus.com/bootcamp. This again, this is how now I'm able to move forward with creating all this content getting back to what I love. I love creating content. I love doing these podcasts. I love doing YouTube videos. Shout out to the YouTube channel. If you don't know I have a YouTube channel. Oh, please go and check it out. It's just you probably, as I say Google, go to YouTube and search for coders campus on YouTube and you should find me there. I've got a bunch of content coming out on YouTube right now. That is wonderful. If you have time to sit in front your computer and watch videos. So anyway, shout out to the YouTube channel. Go there subscribe. I don't have enough subscribers I have like 11,000 or something at this point. I want to get to that coveted 100,000 mile marker milestone. So if you could please do me a favor and subscribe and then reach out to about you know what is that 80 88,500 of your friends and get that subscribe. I've as well, I will be in debt, I will be completely indebted to you. I will you know what I will give you a free ride through the boot camp, if you can bring in 88,000 subscribers to my YouTube channel, I will give you a free ride through the whole boot camp, I will personally

    25:16

    bow down and anyway, yeah. So check out the YouTube channel and check out the bootcamp as well. So if your goal is to get a job as coder, I won't say anything else. But that it's a very, very compelling product, the students in there absolutely love it. I absolutely love doing it and seeing the students and the success that they get and the jobs they get and how their lives change, and so on. So that I think in the next episode of this podcast, we'll have an interview with one of our students, where he you know, completely raw, unedited, unplanned, I just sort of pick his brain, about his experience in the boot camp and give and he gives his honest feedback and thoughts about his experience of the boot camp and the outcome. So I think I'll be releasing that as the next episode, if not the next one, it should be soon. Check out that interview with one of my students. And I'm gonna be doing a bunch more of those interviews because I'm terrible at marketing. And I need to get better at marketing and getting students to, you know, I have prospective students, I have people like you listening right now, who reach out to me and ask me questions. And they say, Trevor, you know, there's not, there's not a whole lot on your boot camp. Right now, there's not a whole lot of stuff I can learn. There's not a lot of, you know, marketing stuff. And I don't see a lot of testimonials like what is it? Like? Is it bad what's going on? And is there I can, there's tons of people, I can pick that everyone would sing praises, I should say the ones who graduate we have about an 80% graduation rate. The 20% who don't graduate usually drop out in the first like 14 or 30 days because they realize that they bid off way more than they could chew with their schedule. And that's never a good outcome. But anyway, it's not because of the product is because the time commitment, that's why I try to do my best to seek out people who have the ability to commit the time and the effort to doing this bootcamp. Anyway. There's tons of people out there that will sing the praises of the boot camp and will say all the right things that you want to hear that you you know, because all you want, normally what everything that you want is to just get a job to be to get a job and to feel confident in that job. And that's exactly what the output is for this boot camp. Okay, it's not an easy process. It's, it's, it's grueling. I won't lie to you. And but there's tons and tons and tons of support built into it. So anyway, people say, you know, it's just a scam, like, you don't have anything on and that's because I am terrible at marketing. I'm a programmer, guys. I love teaching coding. And I love actually coding, I hate, you know, sitting down and writing out testimonials from students and like trance transcribing them. And anyway, so that's why I'm just saying, Hey, I'm gonna do an interview with these people that I can do that sort of comfort, that's a comfort, comfortable thing for me to sit down and interview past students. So that's what I will do. I will sit down interview past students, and you'll have long form interviews, to listen to, for testimonials. So you can get their raw, unedited, honest opinions about their experience. So having said that, please do check out the boot camp, if your goal is to get a job as a coder, and you've been trying to do it for like, you know, if you've been trying to do this for years, please, please stop trying, like, just join the boot camp, it is so much faster. And it's such a better experience, and so much less frustrating than trying to do it completely on your own. And you'll end up making more money in the long run. Okay, the boot camps are cheaper than trying to do it self taught. If it takes you more than 12 months to learn on your own. It would have been cheaper to just do a boot camp, okay with the increase in salary that you're getting that you will get. Anyway, okay, I will stop. I promised I wouldn't talk a long time and I'm already starting talk a long time. Thank you so much for listening. Hopefully, I will see you in the next episode where we are going to be diving into hopefully, like I said, an interview with one of my past students. And hopefully you really enjoyed that and I look forward to seeing you there. So take care of yourself. As always, happy learning. And bye for now.

    29:02

    Thanks for listening to this episode of the coders campus podcast. But before you go, Trevor has a favorite ask you. In order to keep these episodes free, he'd love for you to leave a rating and review the podcast on iTunes. Just go to coderscampus.com/review to leave your own rating and review of the show. So if you have 30 seconds to spare right now, please help out by leaving a rating and review via coderscampus.com/review It will ensure that you continue to get these awesome free podcast episodes each and every week. So if you like free swag, head on over to coderscampus.com/review Happy Learning

     

    The post EP56 – Fun Tricks and Analytics with IntStreams in Java appeared first on Coders Campus.

    30 min
  • EP55 – How to Sort with Streams in Java

    GitHub link here: https://github.com/tp02ga/FunWithStreams

    In this episode we'll talk about how to sort a stream of objects using the “.sorted()” function.

    We'll also talk about the differences between using a stream to sort vs using something like Collections.sort(), which has been available since Java v1.2

     

    Episode Transcript

    0:09

    Welcome to the coders campus podcast, where you'll learn how to code from one of the best teachers in the industry. Whether you're an absolute beginner or a seasoned pro, the coders campus podcast will teach you what you need to know, to master the art of programming. And now, your host, Trevor page.

    0:28

    All right, ladies and gentlemen, welcome to this next episode of the podcast. It has hit episode number 55. Now, always a pleasure to have you in well in your earbuds and me sitting in front of this microphone in my office. So yes, always a pleasure. Let's dive into the topic for today, which will be a continuation of the theme that we've been working on, which is streams. In this one, I want to dive into sorting, which is not too crazy. There's not too much going on here with sorting in streams, but it's an important thing to know about. And that there's time. If it doesn't take too much, then we can dive on into the next topic, which you never know. I'll see how it looks once we get there. So as always, this lesson or episode of you will is brought to you by the coders campus boot camp. If you are looking to get a job as a coder, we are constantly improving the boot camp, we are constantly bringing in new talent and churning out really the next generation of great coders. And I couldn't be more proud of the students who are going through the curriculum right now. So to all you students who might be listening to this, because I know you are. If you're still in the boot camp, keep keep on truckin. I know, it's tough, I know it's hard. If you have come out the other end, congratulations. And I look forward to seeing you in your future career. So if you're interested, check it out. coaters campus.com/bootcamp to check out all of the details there. So let's go into streams with respect to sorting. So before we had streams, sorting was done or achieved via one of two means in the world of Java, you can either sort using comparable or a comparator. I never know how to pronounce that word, I like to pronounce the tour at the end. So in the world of streams and sorting, it's much the same. So if you're using comparable comparable is an interface that you can implement yourself if you have access to the other class that you want to be sorting. So if you have control over it, meaning if you have created an object, and you wish to sort those objects, you can implement comparable within your objects class, and implement the compare to method that it forces you to override. In our example, we could have done that, but I'm just doing a comparator instead. Because, well, it's it's you can see all the code in front of us. So it's just a little bit easier to get the point across when use a comparator. But this is really, you know, six of one half dozen, or the other is the expression meaning it doesn't really matter which one that you go with, because it's still sorting, sorting is still sorting. So yeah, and this one, we're gonna be using competitors. And that's just like, you can see the code in front of you. So when you did it, quote, unquote, the old way, meaning before you had streams, how did you accomplish sorting? Well, in this example, I'm going to be having I'm going to have a bunch of user objects, the users will have the common things that users always have username, password, but it's also going to have a, which call it

    3:36

    a last login date. Meaning that this particular class called user has a property called last login date, which is just a date that represents the last time that that user logged in. Now, we're not going to talk about how to implement that functionality that is outside the scope of this conversation, we're just going to assume that that is already done. And we are just handed the data. So we're just handed a collection of these users that has the data prefilled. Now if you're following along with the code that I am making available, you can check it out. Whereas it coderscampus.com/55, I guess will redirect you to this particular entry, or post or whatever you want to call it. And I will have a repo GitHub repo there, where you can check out the code that we're talking about. In any case, if you're following along with the code, then great. If you're not then no worries, I'll do my best as I always try to do to explain it. But yeah, we have a user and we will have or rather a collection of users and the users will have the data pre populated so the code that I will present you with. I just wrote some code to generate users, so it just will randomly generate users with a random username and a random password and random dates. That represent the last time that they've logged in. Basically, I just look at what today is, when you're writing the code, it looks at what today is, that's the maximum day that you can, you know, randomly generate. And the minimum day is like 90 days ago. So no matter when you run this code, whether it's you know, today when I'm recording this episode, or you know, sometime in the future, it should always work. Cool. So it'll generate dates. For last logins, it'll generate usernames and passwords and everything, and it'll generate a list of users. And how do we then go about, you know, accomplishing our sort? And how are we sorting? So for these ones, I want to sort the users by the last login date, so I want to see a list of the ones who, you know, just a list of the sorted users by when they last logged in. But I also want to filter out any users that haven't logged in, you know, in the last 30 days, or prior to 30 days ago, I should say. So what that means is anyone who's logged in 31 days, or are further out in the past, I just don't want to see them. Only the users that I want to see recently who've logged in, those are the ones I want to see. And I want to see them in the sorted list. Okay. Again, why? I don't know, I just sort of picked out of thin air. That's, you know, who knows, maybe there's a business requirement somewhere that says I want to see a sorted list of the most recently logged in users? I don't know, maybe that's useful to someone. So that's what we're going for here. But how do we accomplish it? Well, without streams, again, it's going to be more verbose, right? Without streams, you're first going to have to filter the list based on the getting rid of the people who have logged in more than 30 days ago. So I have some code there to filter lists. We've talked about filtering before. Without streams, you just have to iterate through them, you need to create a new collection. While you iterate through the existing collection, you will insert into the new collection, all of the entries that meet your filtering criteria. Okay, that's essentially how you get it done. I don't want to go into that we've already talked about that concept before. So we will filter our list create a new one, a new filtered list with just the ones who have logged in no more than 30 days ago. So now we have our filtered list. And how do we sort a list? Well, you can use collections dot sort, this is something that was has been available for a little while I forget when it was created since 1.2. So Java 1.2. So for quite a while you've been able to do collections dot sort. And collections dot sort takes an input of a list. So you pass in the list, but then it's not going to know how to sort that list. Because it's it's a, it's a custom type, right, we have created the user class, the user type, so it's not going to know how to sort it. So you need to tell it how to sort it either using comparable that we talked about before, or using comparator. So we can instantiate a new comparator, which is the way I'm going here, instantiate instantiate a new comparator, which forces you to override the Compare method. And then you can put the code in to compare the log in the last logon dates for all the users. Okay, I don't really want to go into all the code there that's needed. But suffice it to say, it's, I don't know, a few lines of code, right. So in total, we're talking about what 1234567 ish lines of code here to accomplish everything that I've talked about. And then you can output you know, your list your filtered list of users. So that's sort of the old way of doing it. Now, there's not there's not that there is anything wrong with that. It's just a little bit verbose. You just have to spell it all out. And it's not very sexy, it's not very, you know, it's just not easy to read, so to speak, right? That's, we've talked about this before, streams, makes code much easier to read, in my opinion. And in the opinion of like all the developers who've ever used streams. So yeah, that's how you accomplish that task. Now one side effect that happens with the collections dot sort method, which is the old way of sorting. Again, I keep I say old way, only to say that this is not using streams. So this is the non stream way to sort you can leverage collections dot sort. There are certainly other ways to sort this is just one of them. The side effects using collections dot sort is it will mutate the collection, mutate the list that you are giving to the collections dot sort function. So it will actually mutate that list, right? So this is a this is called side effects. This is where, if you're not aware that this is happening, it can cause some bugs, right, you can accidentally change a set of data that you didn't mean to change. Or you can change it from the outside, right. So if you change it inside a method, it has also been changed outside of the method or the file. function. So there's just, you know, there's that side effect that you need to be aware of. Now, if you're aware of it, then it's fine. Because you know, okay, cool. I know that when I do collections dot sort is going to mutate the list that I'm passing in. And am I okay with that? Am I okay with it, mutating that list, if I am, if I am the no problem, if I'm not, I should create a copy of that list first, okay. So that's just that little extra bit of knowledge that you need to have knowledge, you need to have that knowledge in order to move forward and avoid any bugs, right? For those of you in the know, no big deal. So that's more or less the only thing other than it being verbose that that is sort of different between, quote, unquote, sorting the old way. So now, if you talk about sorting the new way, which is leveraging streams, again, it's less verbose. So with the streams here with the new streams, what we can do is, you can take your collection that you're starting with, which is I just called it users is the name of the variable, which is the list of whatever number of users that's, you know, randomly generated. So users dot stream, that's how we kick things off. Dot stream is how we kick off all the streams. Now we want to filter right, so we can do dot filter. And you can do that.

    11:16

    What's called the predicate I think is the word it's been a little while since I've looked into all these Yes, predicate is what you pass in. So the predicate uses returns a true or false, it returns a Boolean, based on the you know, function that you give it. And function that we're doing is comparing to see hey, when is the last logon date more than 30 days ago. If it is, then you return false. And if it's not meaning, if it's more recent than that, if it's within the last 30 days, you can return true, again, how to do that doesn't matter. Just know that it's filtering based on that if you want to check it out, check it out in the code, coderscampus.com/55. So cool. Now in the again, the old way to filter, there was a bunch of steps there that was needed. And the new way, we're just, it's one line of code dot filter, you pass in the way you filter, and then you move on to the next chained method. In other words, we just put another dot after the filter, so say dot, then you can do something else. This one you can do dot sorted. Okay, so this is the this is the, you know, comparable, I shouldn't use the word comparable. This is the equivalent function to collections dot sort. Okay, so you can say dot sorted. So on a stream, on any stream of objects, you can say dot sorted. And what dot sorted takes as an input to this function takes as an input is a comparator. So allows you to pass in a comparator. And since we're using fancy schmancy, lambda syntax, we can use the lambda syntax for competitors, which is just you, you you know, put your on the left hand side of the arrow function, you have your two inputs, because it wants to objects, right? Object one, object two, or user one, user two, whatever you want to call it. Okay, this is what it's gonna be using to compare. So as it goes through the list, to compare all the elements and sort them, that's what it takes it constantly, you know, populates those two inputs, the object one, object two, or user one, user two, whatever you want to call it, that's the left hand side of the lambda arrow expression thingy for the dot sorted function. On the right hand side of the arrow, is the actual comparison. And again, we had to do this above, we had I say, above, because the code the old code is above, we had to do this the old way as well. So this is not new codes, not something different, is just more concise. So same comparison, we compare last login for the object one to compare to last login for object two, and then you close the parentheses. So that's sort of the sorted function that you pass in. So first you stream, then you filter, then you're sort, and then you collect, stream Filter, Sort collect, dot, dot, dot, dot, right, dot stream dot filter, dot sort dot collect. That is how the sort of more functional programming syntax boils down. It's very readable. Okay, I'm streaming users, that I'm filtering them somehow. And then I'm sorting the ones that have been filtered somehow. And I'm collecting them to a list to a new list. So dot collect and redo collectors.to list. That's how we again, we've talked about that before. So you assign this to a new list of users, right and call it filtered users or whatever you like. So the difference here now now we're done. That's it. Right? You had those four functions that you call dot stream dot filter, dot sorted dot collect. We're done. And the difference here is again, not not a earth shattering difference and you know, we're talking But four lines of code instead of seven now, so it's, it's not as verbose, but only by three lines of code. But it's much more readable, in my opinion, right, the other one will take you longer to understand. But this one's a lot more readable. And there's no side effect, meaning we are not mutating the input write users. When I say users dot stream, and the dot filter dot sorted collect users is that original list of 10 users? It we are not mutating that original list because streams, leveraging functional coding, the functional coding paradigm, is that it you know, it doesn't mutate stuff, everything is immutable, everything is final, right? Meaning you can't, you know, mess around with it. So it's just part of the functional programming, you know,

    15:51

    I don't know handbook or whatever you want to call it, they try to be as immutable as possible. So what that means is, when we are returning, we're collecting everything to a new list, we call it filtered, or I called it filtered users is the new list that we return, which means that we did not change the original list of users. So that's, you know, it take that for, you know, if you if you wanted to modify the original list of users, you can you can just assign it back to users. Least I think you can. Let me try to do that right now in my in my code and see if it gives me an error anything. Users go live coding on the podcast, ladies and gentlemen, let me just play this out and see does it break anything? Well, sort of it? Yeah. Cuz I mutated the original list. The second test was based but anyway, fundamentally speaking, no, I didn't break anything. So it's, you're able to do that. So the the, the benefit here, if you will, of using the new way using streams, to sort is that you have the choice. You can choose to not mutate. Or you can choose to mutate depending on which is what your preference, which one is your preference. There you go. I guess that's how you say it. Yeah, so you can make the choice yourself, you can choose to mutate or not, whatever tickles your fancy. So that's it for really for sorting right now. There could be other I don't know if there's any other sorting methods, I guess the only other sorted method is you can do just dot sorted without a comparator. If the object or the objects the class, that you're trying to sort the class that you're streaming, or gets the objects that you're streaming, if that implements Comparable, then you're good, then you don't have to pass in a comparator, right, a comparator. So if you had if you were streaming and sorting a list of like strings, well, strings, by default already have a way to sort themselves, it just sorts alphabetically, right? If you were streaming integers, or Long's or whatever, those already know how to sort themselves, right? Java has the people who program Java have already put that code in place to tell it how to sort itself. So you can just do dot sorted. And then you don't even need to pass in a comparator. But again, that's the same thing that you can do with the old way as well. You can do collections dot sort, and pass in a collection of strings, or a collection of integers, or a collection of Long's and it'll just sort itself, you don't have to pass in the comparator. So really, again, we have the same thing going on here. But it's I guess, good to know that you don't have to use a comparator. Like we did in this example, if you don't want to, if the objects that you are streaming, implement comparable, okay, so like I said, not a whole lot of, of fanciness going on here. Other than, like I said, that little bit of a note on mutability, and how with functional programming, it's more readable and immutable. It's just a little bit safer and a little bit more readable. So once you understand how to do this stuff, it just tends to be the go to way that I code myself, personally speaking.

    19:00

    I don't want to say that you have to do it that way. But it's just I just find once I got comfortable with it, which for me didn't take too too long. It was definitely a learning curve, and hence why I'm talking about here on the podcast. But once you learn how to do this stuff, it just becomes a little bit more second nature and a lot more nice to work with, in my opinion. So that is me on my quote unquote, high quote unquote, high horse that is me on my high horse saying, Hey, you guys should use streams if you're not already using them. And yeah, I mean, I could now we could go on and move on to another topic, but I guess, you know, I'm over already 20 minutes. And of course, I'm long winded. How do we not see that coming? I don't want this to turn into like a 45 minute podcast, but there was some code in there that I did. In my example. Again, if you go to coderscampus.com/55. And you go to the GitHub repository that I will link in the notes there. You'll see that I leveraged something called an int stream To do some loops, looping type code, and yeah, I want to talk about in streams and into meaning it streams. And how it is a does it extend the stream, I forget if it extends a stream or not extends base stream, which was that extends auto closable. I guess this is not extended stream, auto closable does not extends interesting, I thought I extended the stream anyway, an int stream is just a different type of stream that unlocks some new or different I should say functionalities. Maybe I'll I'll touch on that in the next episode of this podcast. We'll try get the next episode out really quickly now, because I'm already talking about int streams. But in streams are really fun. Because there's a lot of cool stuff that you can do with it, you know, you can use it to replace a typical for loop. And you can even use it to get some really cool statistics on any data set that you have. In this Yeah, it unlocks some pretty powerful stuff there. So we'll talk about that one in the next lesson. Again, I'll try to get that out ASAP. And hey, if you haven't already checked it out, again, I'm sure you have heard about it and but may not have checked it out. coderscampus.com/bootcamp, right? If your goal is to get a job as a coder, if you want to get paid, you know really a lot of money for doing something that if you're listening to these podcasts and enjoying them, then you get paid a lot of money to do something that's fun. Fun once you you get the hang of it, right? Always the learning curve is not that fun unless you figure it out. And then you have a lot of fun. Once you figure something out and make a breakthrough, then you feel great. But then it's just on to the next, you know thing to struggle on and have to make a breakthrough on then you get back into the hole. Oh my god, I'm not good enough for this. I'm not, you know, smart enough. I'm not this. I'm not that. Anyway, we've talked about this whole mindset thing around coding before on the podcast and how it is, in my opinion, one of the number one things that stops people from achieving their goal, right, they think they're not good enough. And really, every single coder thinks that they're not good enough, every single one, I have not met, I don't think I've ever met a coder who hasn't, at some point, hit the struggles and said like, Ooh, I don't know, like, I really want to do this. But this is really testing my resolve, right? Even Even people in my in my boot camp who I would have, I would have bet that they like one person in particular comes to mind where I would have bet that they would have sailed through the the podcast sale to the boot camp with very minimal hiccups. And then it turned out that whatever was halfway through or three quarters of the way through this particular individual really started to struggle, and then start to fall behind and then lose faith in their ability and start to, you know, stop showing up for the calls. And it was like oh, man, like I didn't. It's amazing how hard this is. That's the that's the message I want to get across. So the people who make it across the finish line are the ones who seek mentorship. I know I'm a broken record. I've said this before you've heard this before from me. But seeking mentorship and always asking questions and always asking for help is the way to achieve the goal. Okay, it is I have not yet met a student who has reached out and asked for help through the mentorship that they get in the boot camp throughout the entire thing. Who has not made it out the other end? Okay, not yet. Um, there might be one but I'm tired. I'm saying 99% of the time if you are someone who just keeps going, keeps asking questions, keeps showing up, keeps asking for help and keep getting that help from something like a bootcamp you are going to make it okay the job market is so hot right now, especially now in I'm recording this in 2022.

    23:55

    And again, this this this statement has never changed. Okay, my statement of the job market is so hot right now hasn't changed since I graduated university in 2006. Seven. Okay, the job market is ridiculous. Okay, but the job market for senior level programmers is ridiculous. Okay, the job market for entry level is still good. But it's not as good as senior level because students it's there's so many people who try to be qualified as and who who advertise themselves as qualified to be a junior level, right an entry level coder, but so many of them are not qualified. Right. And because of that, employers don't see the value in junior level as much as they do in senior level, but I'm shifting that on its head. I'm saying there's far far more value in a well educated entry level programmer than a senior senior level programmer, in my opinion. Okay, if someone has gone through a program like this boot camp on top About coderscampus.com/bootcamp, I am happy to hire my own boot camp students. Okay, I'm happy to hire my own boot camp students who show me that resolve that I was talking about before that drive that always showing up that always asking questions that you can't teach, I cannot teach you to take action, I cannot teach you to reach out and ask for help and ask questions I cannot teach you to not give up. That is something that you have to be good at yourself, okay, you have to have the resolve, you have to have the drive and the desire more than just the motivation to go forward. Okay, that I can't teach. But if you have that skill set, okay, if you've earned it, or learned it, or whatever, that kind of stuff. The rest is, is easy for me, I can teach you how to code, right? This is that that part's simple. Okay, that's just time. That's all that is. And once you get through the other end, I will hire the heck out of you if you know. So anyway, long story short. In my opinion, the coding boot camp is the solution. It is the path to employment, okay, to starting a new career, there are plenty of entry level jobs, for coders who are good enough, and you will be good enough if you go through the boot camp. And once you're beyond that, once you've had a year or two of experience, the world becomes your oyster. I know I've said this before, but it is so so true. as true today as it has ever been. There are just so many people, so many recruiters banging down my door banging down the doors of all senior programmers out there desperately trying to find people to, to fill the holes in the hiring process of other companies. So so many companies are looking for programmers who are qualified and they just can't find them fast enough. Okay, as myself as a business owner, as an employer, myself, I have felt this pain before I have felt the pain of Oh, no, I need more people. And I don't think I can find them. Or it's very, very difficult to find these people. Okay, I felt that pain before, not with programmers specifically with a different role. But now Now I understand the pain of Oh, no, like, where do I go to get these people? If I can't get these people? What am I going to do, I'm going to be in trouble. And that is the exact feeling that these employers have with respect to hiring programmers. So that's why I've taken it on myself my mission to train people on how to become the next generation of great coders. So we can fill those gaps, help those employers and help you at the same time. Okay, the university education and the university system, at least in North America, from what I've seen, falls very short of being able to fulfill this promise of allowing you to be job ready, and allowing you to go into one of these roles and understand what's going on. Okay, being able to hit the ground running. Okay? I haven't I just It still hasn't changed. Every every student I speak to every university student I speak to, they all repeat the same thing. I don't feel like I'm ready. Okay, and they're not I know, because I was one of them before. With a boot camp students, I just had a student last week, who's gone through the boot camp who is is pretty much graduate at this point. They're just waiting for their final review on their on their final project. They got a practice coding assignment that they needed to do. So they applied to a job. And they were given a practice coding assignment to fill out. And this student started to work on the practice coding assignment. They read through the requirements for the coding assignment, and they said, Oh, this looks exactly like assignment, I think nine or something in the curriculum in my boot camp. They're like, Oh, it's it's just assignment or assignment. 10, I think it was, they're like, Oh, this is just assignment 10 with different names, right? Different names, meaning different, different domain objects anyway.

    28:57

    But it was a, it was a simple assignment of, you know, you need to be able to do the CRUD operations on calling an API. And they were like, Oh, I've done that before. And they wrote able to code 95% of the project. And then they hit the last 5%, where it's at, okay, now, you did do that these XYZ things. And they were like, Ah, I'm, I haven't done that before. And that's always going to happen, right? I can only you can only know so much until there's that last 5% that you need to look up yourself. So guess what, they had the skill to be able to first reach out and ask for help. And I said, good question. Go google it. Right. And then they went in the Google that. And they're like, Oh, I think this is the way to do it. And I said, Yes, that's the way to do it. So this, you're learning. I'm teaching you guys on the podcast, as well as the bootcamp how to prepare for the real world. And I just see this every single time where students are like, Oh, they get their first you know, project on the job, or they get their first practice assignment. And they're like, Oh, that was assignment three here. That was assignment. 10. That was assignment six. So that was assignment and I say, Wow, imagine that shocking. Like, I keep saying a lot. I base my assignments off of the real world, but it doesn't really sink in. It sounds like marketing. But when you see it happening in the in in front of you when you are living the promise that the marketing talks about, you go, Oh, that's really helpful. Thank you, Trevor. And I'm like, okay, good. You're welcome. So anyway, I'm talking way too long than I meant to about this, but I just wanted to share some stories. And if you are someone who suffers from the I'm not good enough syndrome, and the I don't think I could ever make it syndrome, and everyone else can do it, but maybe not me, or I'm gonna be able to deserve this. I don't know, whatever you're struggling with. I've heard it all before. I've seen it all before. What it comes down to is the drive Do you want this or not? Okay, and do you want this soon? Do you want this in the next six to maybe nine months? Okay, or do you want to wait 18 or 24 or 36 months, I have, I cannot count the number of posts, I have seen on StackOverflow or not Stack Overflow on like Reddit, of people saying, oh my god, I got my first job, Yay, I'm a programmer. This is you know, I'm a self taught and I knew I can do it on my own. And that's great. I'm very, very happy for those people. I, I'm thrilled that they made it out. That's the goal. That's the dream. But then you read their story. And it's like, yeah, I started learning how to code, you know, 17 years ago, and it's like, Oh, my God, that's an exaggeration. But maybe they said, you know, three years ago, two years ago, and it's like, well, if you if you're okay, with waiting two years, great. But if you're in a situation where you want this, now, you want the salary, now you want the the outcome now, and you're ready to go. Now, boot camps are cheaper.

    31:45

    Okay, learning on your own might be free. But the opportunity cost that you give up, learning on your own and stumbling for two or three or four years, that has immense cost. So if you are ready to go now, if you want this stuff now, if you are more than motivated. Now, if you are driven. Now, if you will stop at nothing to unlock the career stability and an income, you know, now, if you want to, like, boot camps are the way to go. Okay, there's nothing I've seen that goes faster than boot camps. So I'm sorry, this is I did not mean to speak this long about this subject. But I just want to get that point across. So if you're still listening, and if this is actually, if you're listening on purpose, meaning if you're just doing the dishes, and your hands are wet, and you can't turn off the phone and skip what I'm saying, I'm very sorry, I will stop talking very, very soon. But if you're purposefully listening to this, if you're making the choice to listen to this, and you are considering it, and if this is striking a nerve with you, and making you feel like maybe I should check this thing out. I know it costs money, okay, it does cost money. But we're trying to structure it in such a way that you pay as absolutely the least amount of money as you possibly can to just cover the cost of the boot camp. Okay, just just my I don't take any profit at all, from this arrangement. And I'm saying this, I probably shouldn't be saying this out loud, because I don't know what this offer is going to be forever from now. But currently, as it stands right now, we're trying to make it so you can pay just the cost, meaning you only pay for the cost of the support that you're going to receive in the bootcamp and that's it. And the rest is could be potentially put into something called an income share agreement, where you don't pay that amount until you get a job as a coder making like $60,000 a year or more something right? Now, don't quote me on that I need to, I'm still ironing out the details. And I'm gonna get yelled at by my team for saying this out loud. But maybe they don't know they don't listen to the podcast. So I'm trying to structure it so that you pay the least amount of money as possible just to get the in, get in, get the education, and then you don't pay a cent until I get you out the other end and I help you to get that job. Once you have a job as a programmer, then you pay the rest of the balance. Right, that's sort of the deal that we're trying to structure. So that way I am I've always been motivated and incentivized to get jobs for my students that has never changed. But now I'm putting my money where my mouth is even more so by saying, Look, if you don't get a job as a coder, if you're if you don't get a job making less than 60k, then you don't pay back anything. And that's okay. There's no legal ramifications, that means I have failed. Okay, so long as you graduate, I should say that is the current stipulation, you need to graduate which means you need to do the work you need to show up you need to attend, you know, and do the assignments and follow my instructions, right if you choose to not follow my instructions and choose to not do any work and not show up and drop out, well, I can't help you. I'm not going to guarantee you a job and you're still gonna have to pay a penalty for that. Because that's you tapping out not me. This can be done as long as you're ready. As long as you're driven and you're willing to show up. I can I can extend that offer to you now you should also stay. Because I'm saying this out loud. The stipulation is for certain countries, for there are certain countries where even if you're the top developer, you're the best developer in on the planet, you're still not going to make $60,000 a year. That's just the way you know, global economics work. So this offer is limited to certain countries where, you know, your entry level salary is on average for a programmer. $60,000. Right. Yeah. So in other words, North America, some countries in Europe and whatnot. That's what this applies to. So I should make that that distinction now. But yeah, that's, that tends to be the majority of the people listening to the podcast, I'm very sorry, if you live in Pakistan, or India or something, and you're looking to get that kind of deal that education, I'm sorry, but it's just too expensive. And there's nothing I can do to solve global economic issues like that. Anyway, okay. I will stop talking. So coderscampus.com/bootcamp. If you are interested, now is the time to reach out. As soon as I release this podcast, reach out. You know, you go to the website, coders campus.com/boot camp and click to talk to us or whatever apply, send us a message, whatever, however you want to get in touch and say, Hey, I heard Trevor talking on the podcast about this offer where I only pay, you know, the cost of the bootcamp. I don't pay any anything else until I graduate and get a job and make $60,000 a year I want that offer. Right. So if that's you if that sounds good. Go now, coderscampus.com/bootcamp. And you know, fill out an application form. And make sure you have at least you know, 10 to 20 hours a week free. Because if you have less than 10 hours a week free, it's just gonna take too long. And then you might as well just learn on your own. Cool. Cool, I will stop talking. Thank you very much. Until next time again, I've promised you we will be learning about it streams i NT streams in the next lesson. So look forward to seeing you there. Take care of yourself as always, Happy learning. And bye for now.

    37:07

    Thanks for listening to this episode of the coders campus podcast. But before you go, Trevor has a favorite ask you. In order to keep these episodes free, he'd love for you to leave a rating and review the podcast on iTunes. Just go to coders campus.com/review to leave your own rating and review of the show. So if you have 30 seconds to spare right now, please help out by leaving a rating and review via coders campus.com/review It will ensure that you continue to get these awesome free podcast episodes each and every week. So if you like free swag, head on over to coders campus.com/review Happy Learning

     

    The post EP55 – How to Sort with Streams in Java appeared first on Coders Campus.

    38 min
  • EP54 – What is the Map Operation in Java Streams?

    GitHub link here: https://github.com/tp02ga/FunWithStreams

    In this episode we'll talk about:

    • How the .map() operation in Streams is completely different than a HashMap
    • The details of how .map() will transform your data from one type upstream, to a different type downstream
    • A real world example of how to use the .map() operation in your code
    •  

      Episode Transcript

      0:09

      Welcome to the coders campus podcast, where you'll learn how to code from one of the best teachers in the industry. Whether you're an absolute beginner or a seasoned pro, the coders campus podcast will teach you what you need to know to master the art of programming. And now, your host, Trevor page,

      0:28

      o k, my fellow coders, welcome to this 54th episode of the coach campus podcast. Thank you so much for joining. As always, if you're in your car, thank you for listening to me while you're driving, if you are on the treadmill or something at the gym, thank you for listening to me while you are working if you are doing dishes, or if you are just relaxing on a couch or in front of your computer. Thank you so much for listening. This is one of the most enjoyable activities that I do as a part of what I have been doing for the last 10 years, which is teaching people how to code. And in today's episode, we're going to be diving into as promised the topic of maps, specifically the mapping or the map operation inside of streams. Now, right up front, I want to say just like I did last time in the in at the end of that last episode, streams, maps, rather sorry, map as an operation within a stream has nothing to do with a HashMap or the map interface in the Java language. Okay, nothing to do with it. So anytime that you hear me say stream and map together dot map, don't think of HashMaps Okay, that's gonna be hard, don't think key value just throw that concept away okay. I wish there was a better fitted word here that we could use for this operation. But think of this as an operation this is you are executing a method the method is called dot map, okay, that's the function of the method or the procedure or whatever it is that you want to call it, they all mean the same thing okay. This is an operation that we are performing it is not a data structure. Maps as data structures are something different dot map is an operation is a function that we are calling that we are executing. Okay, so I will say that, first and foremost, at the top of this episode. Now, what the heck is a map dot map this operation within streams. So that's what I want to dive into today. But quick interlude, as I'm publishing this episode, it is Black Friday, in 2021. So it's November 26 2021, is when I'm publishing this, or at least I'm planning on publishing it. Obviously, if you are listening to this, and you might be listening to it on this day, but you know, you're probably listening to it at some point in the future. But why this day is important, this Black Friday, November 26 2021, is we are releasing a brand new product. It is a brand new

      3:00

      coding boot camp that I am very proud of, as you've heard me talk about in past episodes, I am very bullish on boot camps. I am a believer, I am a I am I've been converted to boot camps. Okay, I'm a believer in their efficacy, the efficiency and the outcomes that come from boot camps now. But, Trevor, you already have a boot camp? Why are you talking about releasing a boot camp? Well, let me tell you the last, you know, three years that we've been doing boot camps, I have had to turn away a significant portion of students, aspiring coders potentially just like yourself, because you guys don't, or at least most of the people who have applied to our boot camp. They don't have enough prior knowledge, enough prior experience with code. And that leads to them. Probably not having a very good outcome inside of our full boot camp that exists today as it is and as we've been running for the past three years. So I've always felt a little bit icky about that. I don't want to turn people away and say you're not ready yet. So that is why I am announcing today, as you know, Black Friday, November 26 2021, we have designed a boot camp that is fit for the complete beginner. So if you are a complete beginner, or if you just don't feel ready enough to jump into the you know, the big boy pool or whatever you want to call it. If you've been you know only doing this whole code thing for you know, maybe less than six months or something like that. You've been dipping your toes in the waters of coding for less than six months. This boot camp is for you. So and it is a coding boot camp. It is a 16 week program where we will teach you the fundamentals of coding. Of course we focus on the Java language while doing that. But let me tell you, this is the hardest part of learning to code, the fundamentals. Okay, what I'm talking about today streams and maps, those are beyond fundamentals. Okay, so if you if you're confused about streams and maps and or just streams in general. Yeah, that's good. That's probably means that you're you still need work on the fundamentals, you need this new boot camp. Okay, this I call it the core Java boot camp. Okay, because we've talked about core Java concepts. Core, Java is another way to just say the fundamentals of the Java language. And really, this is the fundamentals of any coding language at all. Okay, these concepts can be applied concepts can be applied to pretty much any object oriented language. Okay, that's what we're learning in this bootcamp. And let me tell you, like I said, this is the hardest part, this is where 90% of the people who start will stop, they can't get a grasp of the fundamentals. And they tap out, and they walk away. And I don't blame them. Because learning on your own learning without mentorship, learning without accountability, without community without direction, curriculum, and constant access to support. Without that stuff, you are so likely to fail, like 95% more likely to fail if you go that route on your own, okay, that's why I am big on boot camps, they really helped to bridge that gap. And they really helped to give you the confidence that you need, when you need it most. Okay, so I'm very proud and very excited to announce this, I want to call it the core Java boot camp. But really, like I said, it's just a boot camp to learn the fundamentals to get further than 90 some odd percent of people who've ever tried to learn how to code. So if this is you, if this is resonating, if you've tried before and quit, and if you're just sort of dabbling, or half in, but you really want to be all in, this is the way to do it. And And hey, if you're listening to this in 2021, on the in the Black Friday season, that hey, even better, there's a discount right now that we have, I haven't done a discount or a sale in like four years, because I haven't had time. But we're doing that here. And now. So you can get in and get access to this coding boot camp at 25% off. And in my opinion, this is very affordable. Okay, so this is not, because it's we're not teaching the five pillars of full stack development in this bootcamp, we're just focusing on the fundamentals for 16 weeks, we can make it more affordable. So as part of Black Friday, you can get in for 1500 US dollars, okay. 15 101 time gives you access to the entire 16 weeks of the bootcamp it gives you access to, like I said, all the support that you're going to need the live calls, we have like three live calls a week, with our lead instructor, we you get assignments. So there's four super challenging assignments, and you get code reviews for those assignments, you'll be able to get personalized feedback on the code that you write. There are plenty of like coding exercises in there that are smaller than the assignments. The assignments are where you're going to really struggle. But the exercises are a lot easier. Again, this is all making sure that you are absorbing and learning what it is that is being taught as part of this curriculum. So there's probably more that I didn't mention, but oh, yeah, there's a Slack channel. So the whole point, again, everything that we can do to help you get very comfortable with the fundamentals of coding, that's what we are doing this boot camp for 1500 bucks. Okay, that is an insanely good deal if you know and understand the power of what a boot camp delivers. Okay, my other coding boot camp is almost 10 times that price. So hopefully you understand the the impact and the severity of this offer and how big this is. So if you are a beginner, if you've been desperately needing help and wanting guidance from experts to be able to hang out with people just like yourself to be able to ask questions when they come up to be able to get help when you need it most. And to learn from experts about coding conventions, and all the things that you should be doing in order to be ready to take the next step, the next level, which is the next boot camp, do all that stuff, get that help in here, be ready for the next boot camp, and then we take all the money that you invested in this one, and we just apply it 100% As a credit towards the next boot camp. Okay, and then that next boot camp, then you're the big, you know, you're playing with the big boys, you're, you know, the big guns, if you will, whatever you want to call it. That's the fully comprehensive full stack boot camp that you've already heard me talk about this whole time. Okay, so every penny that you invest into this new one that I'm talking about the core Java boot camp, you can reinvest it 100% right back into the next one. Okay, so you can just take that and use it as a credit full credit, full discount, whatever you want to call it. So, really, this is like a if you're long on this process on education and getting a job as a coder, this is kind of like free. It's like a free boot camp that you can take right? Because you're just gonna get all that money back in the next one. So that's why I'm super excited about it's kind of like getting free access to me, my brain, my staff's brain, the all the content, everything that I've worked 10 years to create, you're essentially getting it for free. If you plan on going, going the route the whole way and doing the full full stack boot camp afterwards. Okay, so hopefully that makes sense.

      10:09

      Yeah, plus, like, I didn't say you're guaranteed admittance into the other boot camp. So if you finish this one, like the new one, you'll be guaranteed admittance into our full boot camp so I don't have to turn you away, which feels so much better. So cool, if that's of interest. And again, if it's Black Friday, and you're listening to this now, and it hasn't hit whatever, November 30, at midnight is when we're turning off the discount, go to coderscampus.com/beginner, pause the podcast right now, if that's resonating, if you're driving right now, if you're I don't know what pull over like if this is, if this is what you've been wanting for so long, it is right in front of you. All you need to do is go to the site sign up, it's as easy as typing in you know, your name, your email address, and whatever, you know, payment, you want to do credit card, PayPal, whatever you want, do it. Okay. And if you can't do a single payment of 1500, that's too much. We have the payment plan as well. It's like, you know, for payments of 597 or something like that, or three or four payments. I don't know, go there, you can do the paid plan as well. In any case, coderscampus.com/beginner. Okay. All right. So I'm taking so much time there to explain that. And even if you're in the future, and this is not the Black Friday sale, again, even without the 25% discount, like I said, you can take 100% of that and apply it towards the next boot camp. So it's it's worth it either way, whatever amount you're paying, you're getting it right back in the next boot camp, and then that next boot camp, the full stack boot camp, the one that's huge, the one that's, you know, 10 times the size, that one has a job offer guarantee, as you've heard me talk about so well worth it. Okay. Let's get back to the content of hand, which is streams. Let me take a sip of water to get down from that. Okay, I'm ready. Let's do this. So Java streams, specifically, an intermediary step called dot map, again, reiterating, not HashMap. If you're just thinking hash map again, throw it out. No, not not this isn't this is a function, there's a method, there's an operation dot map. So what is dot map? Do Trevor get to the point. So dot map is an intermediary step in part of a stream. So as you're streaming, a collection of objects, dot map allows you to take the object that you are currently streaming over, in other words, looping over. Okay, so takes the object that you are looping over and allows you to perform operations on a smaller set of its properties. Okay, so that's essentially what it does allows you to narrow in on a smaller set of properties or a single property, if you will. Okay, so, okay, fair enough. So it's all about zooming into a more specific property inside of the object that you're iterating over. How is that helpful? What does that mean? Can you be more specific? Can you give me an example? Sure. Absolutely. That's what I'm here for. So the example that I have in my code that I am hopefully have published is an example of using like, something like bank transactions, this could be anything, right? This could be any object, any object that you've created that has properties. For the one that I've created, the one that I'm using for the example is a bank transaction object. So the bank transaction class has three properties. So a bank trend transaction has a transaction ID, it has a created date, like when you created the transaction when the transaction was made. And it has an amount, okay, a monetary amount. So a bank transaction is three things transaction ID created date, and amount. That's it. That's what our bank transaction has, which again, think about the real world, when you perform a transaction, you have your debit card or something or you have a credit card, like you go to coderscampus.com/beginner and sign up for the bootcamp right. Course, camps.com, Ford, you'd like that, that was pretty good. I was smooth, I didn't plan I didn't plan on that. You go there and you create a new bank account transaction, you sign up with your credit card, with PayPal, inserts a new bank transaction. And you're now part of the bootcamp. Congratulations. So you do that and you have a bank transaction, right. And that transaction will have a unique ID, because that's how the world works. You need unique IDs to zoom in on the single thing that just happened just like when you have a you know, a driver's license number. It's unique to you and your state or your province or wherever you live your region.

      14:48

      You need some way to identify that single thing. So we have a transaction ID. We have a created date, which is boom, you don't happen just now or whatever it is that the the transaction gets created. We can put that into it. To date, and then we have an amount, right? It's just 1500 bucks for the boot camp. So that's the amount, right? Or 597? Because one of the whatever for payments that you that you can make to join the boot camp, right? There you go. That's your amount. So that's what a bank transaction is right? There you go. We just talked about a real world case. So with that bank transaction, let's think what can we do with that data? Right, let's say we have a bunch of bank transactions, let's say you log into your bank account, and you want to list out the past three months of transactions. Okay, so cool. You open up a report, you say, you know, show me the last three months of data, and then your bank, banks website, or whatever, lists out every single transaction that has happened in the last, whatever, 30 or 90 days or whatever, right? Ooh, cool. So you see all them listed there? Well, that's kind of like a collection of bank account transactions, right? That's your, that's your bank transactions. There's a whole bunch of them, there's a collection of them, there's like 90 days worth of the transactions. Right? Okay, with me so far. So let's say we have, we want to do an operation on that, we want to get a some of the most recent transactions. Okay, so of the last 90 days, or the transactions, let's say we want to get a some of the most, you know, recent, seven days of transactions. Let's say that's what you want to do. Okay? I don't know why, let's just say that that's something that you want, you want to get a sum of the last seven days of your transactions, because maybe you want to keep keep track of your weekly spending or something and you want to chart it or something. Fair enough. Cool. So how will we do that? Well, again, old way versus new way, there's an old way, which is without using streams, and I will be as brief as I can about this. So the old way, what would you do? Well, you'd have to get your you know, your list of bank transactions and pass it into a method, this method can be called, you know, get some of recent transactions, let's say, Cool, that's no different from using streams, we need a method, let's create a method get some of recent transactions. And we pass in our collection of bank transactions. In this case, we can use a list of bank transaction objects, and pass it into the method. Great. So how can we then get a sum of the most recent transactions? Well, we need to say, Okay, we want to get transactions between today and seven days ago. So you'll need a little operation to generate to the date range or whatever. Again, I don't want to get into the details of that, you'll have to do that either way. So cool. Now, specifically, in order to make this work, we need to iterate through every single one of the bank transactions. And we need to check and see if the created date for that transaction is between now and set, let's say seven days ago, right. So in other words, this is a filter step, we're not mapping yet, this is just a filter step. So we have to filter out and say, Okay, give me the transactions for the past seven days and add them to my to my list of recent transactions, because we will have created a list of recent transactions or something, a list of bank transactions called recent transactions, we add them to that list. Great done. So now we have a new ArrayList of recent transactions, meaning transactions that have happened within seven days ago. But now we want to get a sum of all of those transactions. So now we've collected them all. Got them all in a list, all the recent ones, just just the ones for the past seven days, we want to know add them up, right, so we need to get a sum. So we need to declare a variable called sum. And it's a double because I'm using a Double data type. We started at $0.00 0.0. And now we need to iterate through. So we do another for loop to iterate through the most recent transaction or so I should, I should say, the recent transactions list. This is a new list that we instantiate it as part of this method that we're talking about here. So we instantiate a new list. And now we say, hey, within that new list that we're iterating through recent transactions, each one of those is going to be assigned, I'm using a for each loop. So it gets assigned to a new variable called a recent transaction. So the singular version that's just good coding convention, singular versus plural plural for a collection. So we have a recent transaction. This recent transaction has an amount so we say recent transaction dot get amount, because we want to get that amount. And we want to add that into our sum. So we have to say sum equals the sum plus recent transaction dot get amount.

      19:39

      Okay, so that's what we're doing here. We're just saying hey, we have an object called a recent transaction, it is a bank transaction. The bank transaction has several properties, but we only care about one of those properties which is amount. So we need to say recent transaction get amount and then we take that amount and we add it to the value of some the previous values and reassign it back to sum. So in other words, we're going to do sum equals sum plus recent transaction dot get amount, which is what I just said. But hey, I wanted to just zoom in on the fact that we only care about one of the bank transactions properties, get them out, or sorry, amount, and we get that through the method called get amount. Okay? So we add up the sum, and then hey, we return the sum from this method, right? Because we want to get the sum of all the transactions so we can return that sum. And we are done. Okay, that's the old way of doing it. So to summarize, the old way of doing it, we need to instantiate a new list, we need to populate that new ArrayList with the most recent transactions, we need to initialize a some variable and initialize that 0.0. And then we need to iterate through the new list that we just created called recent transactions. And then we need to for each of those transactions, get the amount and add it to sum, and then we need to return some. Okay, that's sort of what we're doing in the old way. Okay, it's about what is this? 1-234-567-8910 1112 lines of code? Okay. So 12 lines of code, we can get her done? Well, in the new way, we only need 123456. So we need half as many lines of code. Cool, right? So how do we do it the new way, right? Okay, same thing, we have a method, the method can be called Get some recent transactions, we pass in our list of all the transactions from you know, whatever, the last 90 days, just like before, nothing changes here, all good. And we still have to define our window. So we have a variable that we create, called, I call it seven days is the name of the variable. Again, it's just what's our window of time that we're dealing with here. So we'll look at a seven day window. So we still need to declare that variable, that's still, that doesn't change just like we did in the old way, we have to do it in the new way as well, because that's part of our filter that we're going to use now. Where it changes is we can say bank account, or sorry, bank transactions, which is all of the bank transactions that we're passing in here, bank transactions dot stream. Okay, so we're going to stream our bank transactions. And then as you expect, as I alluded to, before, you need to filter this list of bank transactions, just like we talked about last episode, so I won't spend too much time here, we're filtering by created date. So we're saying, you know, dot filter, or we're having the lambda the lambda for filter is a predicate, the predicate takes one input. So the input that we're going to call it is just called bank transaction, you can call it whatever you like, as my followers know, I am partial to using the variable dog poop, to define a variable such that it can be named whatever the heck you want it to be named, the name doesn't matter. You could call it dog poop if you wanted to. But obviously, following good coding conventions, we give it a better, more meaningful name. So the meaningful name for the variable being passed into this predicate functional interface is going to be called bank transaction, because that's what it is, ladies and gentlemen, it's a bank transaction. So again, we're streaming we say dot filter, bank transaction is the name of the input variable to this lambda expression. We have our lamda arrow, and then to the right of the lambda arrow, we have the, the body right, so the body is just going to say bank transaction, which is the name of the variable, we just green dot get created. date.is, after seven days is the name of our variable. Now, I skipped over those details in the old example. But that's exactly what we had to do. In the old example, we just say, hey, is this bank transactions created date after seven days ago, then cool that included in this new list, but here in the new way, we just do a dot filter, we don't have to create a new list and populate it, we just use dot filter. Cool. So Dodd filter done now remember, dot filter returns, because it's an intermediary step, it returns another stream, specifically a stream of bank transaction objects. So dot filter still returns a stream? What can you do on a stream? Well, you can say dot map.

      24:15

      Okay, so you can do method chaining. I talked a little bit about method chaining. So we can do some method chaining here dot map. Well, what does dot map take in as a an input? It what does it take, you don't even know it takes in a function. So a function functional interface or whatever you whatever you want to call it. So it takes a type t, and it returns a Type R. Okay, whatever remember to return type is and it figures out what that return type will be based on what you give it, as well as the input type. So again, dot map takes an input type T. In this case, it's our bank transaction, because that's what's being passed to it from above from the filter above. So we have a bank transaction type. We'll call it bank transaction as part of this lambda function. Again, we could call it dog poop if we want it to be called X called Zed or whatever variable. But again, it's a bank transaction. So call it bank transaction, lambda arrow to the right of the lambda arrow, what are we doing? Well, again, dot map, takes an object bank transaction, and returns a specific like a subset of its properties, or, well, a single property, typically, in the real world use a single property. To return a subset of its properties, you'd need to have like a DTO, or something, but we won't go there. In this, in this example, we're just using a single property. And that's pretty much most of the time what you see with this operation. So we're gonna say bank transaction dot get amount. Okay, so just to reiterate, we had a filter, and then we have dot map, bank transaction on the left, lambda in the middle, bank transaction dot get amount on the right. So we're just going to say, hey, take the input of a, an actual bank transaction object and sort of coming in and spit out an amount as the output. Remember, the backing functional interface for dot map is function, function, input type T, output type R, okay, T R or generics. T in this case is bank transaction R in this case will be double, y is the output type double because we are telling it bank transaction dot get amount, what is the data type of get amount, the data type or the get amount data type, what's returned from that is of type double, because the amount is of type, double input type, bank transaction, output type double. So we've just translated if you will, in our stream, I like to say I like to use the expression upstream. In other words above this operation that we just did. I don't know if that's actually a thing, what they say makes a lot of sense if they call it upstream. But anyway, I say upstream. So upstream from the dot map operation, we were receiving bank transaction objects. But now downstream from the dot map operation, we've just changed that into double data types. So above map, we had bank transaction below map now downstream, we're going to have double. So that changes things. Alright, because we're no longer working with bank transaction as an object type anymore. We're now dealing with double. Okay, we have just mapped it to be something different, we've changed it, we transformed it, it's almost like dot transform, have you better name the dot map. But anyway, we've transformed it from one input to a different output from bank transaction as an input to double as the output. So now downstream below, with the next operation, we're dealing with double doubles. Now we're no longer dealing with bank transaction. As a type, we're dealing with the the amounts that belong to those bank transactions, downstream below dot map after dot map happens. So after the dot map, operation happens, picture each of the bank transactions for last seven days going in, think of your bank account and all that information you see on the screen, the last seven days, all the transactions, you know, credits and debits and from, you know, this grocery store, and here's your paycheck. And here's like all these transactions, all the details, you know, the dates that they happened, the name of the retailer, or whatever, the as well as the amounts in or out and all like there's all this information, but then we when we do dot map, which is like transforming it. Now just picture yourself zooming the screen in, specifically on the amount.

      28:55

      Column, all we're looking at now is the amount, okay, there's still a bunch of them still a bunch of amounts, and they are from all of those transactions on the screen, you're just throwing away all the other data around the screen, and you're just zooming in to the amount. That's what we're doing. We're zooming in on one property, one piece of data amount. We're throwing everything else away, so to speak. Okay, so we haven't changed anything, we haven't changed the underlying transactions at all, that the bank transaction objects are still sort of there. It's still those objects. But now all we can work with is just the amount in other words, just the double data types for amounts for those transactions. Okay, so that's important understand, downstream after we do the dot map, we're transforming it from one thing into something completely different. Okay. And that's where students often get mixed up. And they think, Oh, when I do a dot map, all of a sudden now I've lost my object. I don't know where the whole object went. All I have is like a piece of the object and I say exactly That's what you're telling it to do. That's what dot map does. You're, you're sort of throwing away the rest of the data. You're just zooming in on that one property. Okay? Cool. Let me take a sip. So hopefully I've over explained that hopefully you make it makes some sense to you, you and your mind. But remember, I should say, remember, let me tell you, what is dot map return. Remember, dot filter returns a stream of the object that we're iterating over right? The stream of Well, in this case, it was the stream of bank transaction objects. But what is the dot map return? Any guesses as to what dot map returns? Again, the two hints are it's an intermediary operation. And it underlying it, it has the function with T as an input and R as an output. So because dot map is an intermediary operation, it returns another stream. Okay, that's what intermediary operations do they just return another stream of something? So because it's an intermediary step, we have a stream of something. But what is the of something? What is the something I should say? Right, the something is now different, we don't have the object anymore, the Shinsei object, we don't have the original object, which is bank transaction. Remember, the underlying functional interface here is a function which takes a type T the bank transaction, and the output type OMA output type R, which in this case is double. Remember, we're doing an amount we're outputting an amount bank transaction dot get amount. So because we're doing get amount and amount as a double, the output now is a stream of double objects. It's no longer a stream of bank transaction objects, we have mapped it, we have transformed it to be a stream of double objects. And that has, I guess, consequences. I don't I don't wanna say consequences that has implications. Okay, we are no longer dealing with the bank transaction objects, we are now dealing with a native data type to Java, Java knows doubles. And because Java knows doubles, we can do something with that. Okay, there's special operations that we can do with double. So let's talk about that. What can we do with it? Well, the next step, we're going to do a terminating operation, a terminal operation, we're going to do dot collect. So we're going to collect all of those double amounts, right, all those bank transaction amounts, not all those bank transactions, are collecting all the bank transaction amounts that were from the last seven days, that's what this these steps have done. We filter get the last seven days we map, turn it from a drip bank transaction into the bank transit transactions amount, and then collect it. So we're collecting the last seven days worth of bank transaction amounts. Okay, what are we doing with collect? Well, we're gonna do something special ladies, gentlemen, we're going to do collectors dot, summarizing double. Now this I'm pulling out of my butt, this I did have to Google. But there's a special collector called summarizing. And then there's a bunch of different summarizing operations, you can do summarizing int, I think you can do you can do summarizing in summarizing double and summarizing the long. Okay, so this is a, this is a method that we're invoking. And you can pass in the amount so it just takes in summarizing double takes in

      33:37

      a what's called a to double function, but it's just like a function where you pass in a mount. So in other words, the summarising double just, you pass it into the mount and then you just on the on the left of the lambda and on the right of lambda, you just have a mount, you're not going to change it, you're not doing anything crazy with it, I just have a MT arrow amount, which looks kind of weird, but that's what you're doing. You're just saying don't do anything special with it, just take the double that's coming in from upstream from dot map, and just use it right. So summarizing double, returns something special, it returns something called Double summary statistics object. And this double summary statistics object which is returned its as opposed to collecting it to like a list. In the past example we said collectors.to list to take everything and turn it into a list. Now we're turning the bank transaction amounts into something called a double summary statistics object. Why are we doing this? Well, because the double summary statistics object which I just called the summary statistics object, gives us access to some really cool methods we can do dot get average get max get min get some we can do and then to do more, we can do a bunch of stuff with it. Okay. So, the the the important things to note there is that You can do get average get max get min get some average max min, some. Okay, those are for Super you oh and count. So I forgot count, average max min sum count. That's what this thing this summary statistics thing does for us. Okay, it unlocks a bunch of cool mathematical stuff for us to work with. Okay, so that's what the summary Summary Statistics does. And we were able to do that because we did the dot map step where we returned a double amount from the list of transactions that we're dealing with. And then we collected it into something called summarizing double what we use, collectors dot summarizing double, which returns a double summary statistics object. I know there's a lot of words going around there. But the point is, we can have this summary statistics summary statistics object and say dot get some, in other words, we can return dot get some. And that's it, we've now collected the sum of bank transactions, the bank transaction amounts from the last seven days, we return the sum, and we're done. Now the beauty with with this is we could also return the min and the max, the average and the count. If for some reason those were helpful, we could have done those as well imagine the old way what you would the work that you'd have to go through and the code that you have to type out to get the min, the max, the average sum and the count, right, that would be like that would take you all day, potentially, I don't know who knows. And now we just have it all in this one beautiful little operation called collectors dot summarizing double. So it's beautiful. No, just kiss to this. Streams stuff brought to you by dot map, being able to take an input type and trance, transform it into a different output type. Okay, that's what dot map does, again, not a great name, I prefer dot transform. I don't know what a better name would be then than that. But anyway, nothing to do with a hash map. That's something completely different. This transforms inputs into a different output. So that downstream, you can do something with it, like we saw here. Now when we take we zoom in on the bank transaction amounts,

      37:14

      we can do something with that. Now. caveat to everything I just said, you could probably get away with not using dot map, you could probably just done collectors dot summarizing double the input would be bank transaction, and the output probably could have been bank transaction get amount. So I'm kind of cheating here because I wanted to show you the dot map and explain dot map step. But that's a great way to explain the dot map step just goes to show you can make this five lines of code instead of six if you really wanted to stream to the best. That's me dunking on the old way of for loops, and while loops. And I hope you've learned something valuable here today. So hopefully, this was fun. Again, if you're listening at any realm close to 2021 and 2022. And you are a fairly new beginner to this whole coding thing. And your end goal is eventually to get a job as a coder, I really strongly suggest you check out our brand new Java fundamentals core Java boot camp that I just introduced as of today, as of the recording of this lesson or this episode. coderscampus.com/beginner will get you into you don't even have to like apply for it. Okay, there's no application process. We are accepting everyone. Okay, so Well, I should say so long as you have about 20 hours a week. Maybe we shouldn't accept everyone if you don't feel if you can only put in like four hours a week here. Yeah, then you're not committed. So yeah, you should have 20 hours a week to get to this. But as of right now, the recording we actually don't have an application process. So yeah, join coderscampus.com/beginner. And I look forward to seeing you on the inside of this 16 week, Java or core Java coding boot camp where you are going to learn the fundamentals of the Java language and you are going to do for crazy hard challenging assignments. For someone who's a beginner, you're going to get four beautiful code reviews, explaining everything that you've done, right, everything needs improvement, any conventions that you're not following, picking up on any bad habits and correcting them right there. And then it's beautiful process. With this, the code reviews are the best, I love them. Plus, you're also gonna be able to hang out possibly with me three days a week, most likely with one of my lead instructors. But hey, I often pop into those calls every once in a while and say hi to my coders and private Slack channel, you'll be able to get access to me there pretty much every single day seven days a week. As long as I'm awake and my wife is not within earshot or when I look I will respond to messages unless I need to be a dad and do family time then I will put my phone down but other than that I am responding to Slack messages and helping you guys out to achieve your goal of ultimately getting a job as a coder. So this is this is the best place to start if you are a beginner coderscampus.com/beginner Check it out. I'm super excited about it 25% off today until Monday, all was it November. What is Monday, November 29. My Calendar. Yeah, until the end of day, Monday, November 29, which is pretty pretty much like the morning of Tuesday, November 30 2021, you can get 25% off. But like I said, even if you don't get that discount, before time expires, 100% of what you've paid will go as a credit towards the next bootcamp, which is the full bootcamp which is the one that guarantees you that job. Okay, so it's pretty much like you're getting a free boot camp for 16 weeks, and you get to hang out with cool, cool people, just like yourself, and hey, me, too. So hopefully, I will see you there. I think it's one of the most amazing deals I've ever put out. And I'm truly proud to say that I'm able to release this bootcamp. So can we see on the inside coderscampus.com/beginner, and I can't wait to see you in the next episode. Take care of yourself. Happy learning. And bye for now.

      41:03

      Thanks for listening to this episode of the coders campus podcast. But before you go, Trevor has a favorite ask you. In order to keep these episodes free, he'd love for you to leave a rating and review the podcast on iTunes. Just go to coders campus.com/review to leave your own rating and review of the show. So if you have 30 seconds to spare right now, please help out by leaving a rating and review via coders campus.com/review It will ensure that you continue to get these awesome free podcast episodes each and every week. So if you like free swag, head on over to coders campus.com/review Happy Learning

       

      The post EP54 – What is the Map Operation in Java Streams? appeared first on Coders Campus.

      42 min
    • EP53 – Intro to Streams in Java

      GitHub link here: https://github.com/tp02ga/FunWithStreams

      In this episode we'll talk about:

      • What are streams and why you should care about them
      • Comparing a simple Stream example to a Looping example
      • Intermediate vs Terminal operations
      •  

        Episode Transcript

        0:09

        Welcome to the coders campus podcast, where you'll learn how to code from one of the best teachers in the industry. Whether you're an absolute beginner or a seasoned pro, the coders campus podcast will teach you what you need to know to master the art of programming. And now, your host, Trevor page.

        0:28

        Oh right, ladies and gentlemen, fellow coders. Welcome back to this next episode of the coders campus podcast, we have hit episode 53. And in this one, as promised, we are going to dive into the topic of streams, which is, I have to say, it's one of my favorite topics. Because of the features that we get to leverage here that again, come from Java eight, we get to, you know, leverage lambdas. And the behaviors that we get out of this code, the things that we can do with streams, the way the code is written, it's just, it's just so much more elegant, it's just so much more beautiful, more readable. Although it takes there's a bit of a learning curve that goes along with it. Once you understand streaming, it's just so wonderful to use. And it, it's a game changer, in my opinion in terms of readability, right and simplicity, right. So but again, all of that is, you know, important to understand that before you can do all that you need to learn this stuff first. So there is a learning curve involved here.

        1:38

        But my God, guys, it's so much it's so worth it, it's so worth the pain in the struggle to fully understand how to use streams. Because, you know, in my opinion, I never want to go back. So now, obviously, what do I mean by that? What do I mean by going back? And what is a stream? And how, how, why should we care about them? And you know, how do we compare a stream example to something else? And you know, what are the some of the commonly used methods and whatnot that we have with respect to streams, that's sort of what we're gonna be diving into, in today's 53rd episode of this coders campus podcast. So, as always, this podcast is brought to you by V coders campus boot camp. So I'm sure at this point, you've probably heard of it. If not, hey, there's always a first time for everyone. So the coders campus boot camp provides you with all the education that you need to get a job as a coder. And it's not just the education, it's all the copious amounts, the insane amounts of support that goes along with education because education by itself, in my opinion, I know this is a little controversial, is useless. So if you are someone who is fairly new to coding, education alone is in my opinion, useless. Because going from zero, like on a scale of zero to 100, if you're going from zero to like one as a coder, where 100 is job ready, so to speak, and zero is completely not job ready, going from zero to one is so, so hard, right? That's what this this whole podcast is driving towards is just the education alone, it takes so much time and effort to go from like zero to one, as a coder, there's so much so much fundamental stuff that you need to understand and that needs to click, and you probably need to hear it in 10 different ways. And it's just so difficult, right? Unless you are naturally gifted, in which case, it's a lot less difficult. But for the average person, it's very difficult. So that's where this bootcamp helps, right? We take you from we try our best to go from zero to one, I prefer to have someone who already is at one out of 100 with respect to their coding abilities, meaning you already have been exposed to variables and you've already written small console applications. And and maybe you're you've written some methods to take in inputs and give outputs and you understand the basics of methods and variables and whatnot and some data types. Once you're there, once you have all that knowledge, that's where we can take you from one to like 100 Right. In other words, we can get you the job ready in a short period of time in the boot camp by short period of time, I mean six months, okay, that is a short period of time when you know compared with anything else. So that's what the bootcamp is all about. We give you not only the education, but all the support that you need to get from essentially hypothetically speaking, zero to 100 Ideally from one to 100. So, we take you from where you are to being job a job ready coder. So that's what the bootcamp is all about. And that is what allows me to help produce this content. So if you are interested in that if your goal is to get a job as a coder, please check out coderscampus.com/bootcamp. Okay. coderscampus.com/bootcamp that will allow you to learn more about the boot camp, the program itself, what is expected of you in terms of time commitments and whatnot. It is a part time commitment, but it's still a commitment. So if you don't have at least 20 hours a week in your schedule, then don't even think about it. It this is, you know, we have to do a lot of work in six months. So you can check that out coderscampus.com/bootcamp, it is of interest to you feel free to apply. And you can ask all the questions you like, once you've applied, you are able to book a phone call with us. And we can hop on, you know, a phone call or zoom or something. And you can ask all the questions to see, you know, make sure it's a good fit for you and vice versa, make sure that you're a good fit for the bootcamp. So at a 90 96% job placement rate for graduates within six months, this is a very successful program. So for those of my students who graduate yet 96% of them are placed within six months, most are placed within like a month or two, I would say 80% are placed within like a month or two. And that is just because of the the curriculum that we provide, as well as the level of support that you get inside of the boot camp. It is, in my opinion, top class top rated. So we pride ourselves on that education and that support. And we pride ourselves on that 96% outcome number. So like I said, if your goal is to get a job as a coder, check it out coderscampus.com/bootcamp. Okay. Sweet. So let's get into streams, because like I said, my favorite topic, or at least one of my favorite topics. So first, we will dive into what streams are and why you should care about them. So streams were introduced in Java eight, just like lambdas were introduced in Java eight, which we've been talking about in the past few episodes here on the podcast, and

        6:55

        what are they? Well, they are essentially another way to iterate through collections. Okay, so what that means in plain English is usually you loop through some sort of a data structure that you may have in your typical, you know, workflow when you when you are writing programs when you're writing code. So in Java, a collection is something like a list or a set or a map, or you know, who knows any combination of those or variation of those.

        7:28

        A collection is just a bunch of objects crammed into one data structure. And typically, you iterate through them. So typically, it's a for loop, where you you loop through each and every one of the items in a list are the items in a set or the items in a map, you iterate through them so that you can perform some sort of action, right? So for example, let's say, you know, you have a typical example I would go to is user login, right. So if you have a list of users, so you got a bunch of users, and you want to, you know, validate that the user credentials that you've been given, in other words, credentials being username and password, you want to iterate through all the users to see if this, this username password matches with what you have in your database, right in your collection, your list of users or something, or maybe a map, you know, where the key value, I don't know, whatever. This is very common, right? Or maybe you're iterating through a list of bank transactions, you want to go through all your recent bank transactions, so that you can, you know, add up the totals or something, you know, this is very common, right, you do it in a for loop it for each loop type thing. So start with the first transaction, start with the first user, go through each and every one and do something as you are iterating. And going through each one of those objects, each one of those elements in the collection. So in the list or the set or the map, or the whatever collection is just another word for a data structure that holds many other objects inside of it. Right? Go back to your episode on data structures, if you don't know what data structure is, if you don't know what a data structure is, yeah, you're definitely maybe too advanced. This episode may be too advanced. But yeah, so that's what we used to do. That was sort of the old way, we would just iterate using a for loop or something. Could be a while loop as well, any loop you would iterate through, right? Well, what streams allows us to do is more or less the same thing. We can instead of you know, doing using a for loop, we can now use a stream to iterate through our collections. Okay, now, a stream is a lot more advanced than a standard for loop. There's a lot of optim optimizations inside of it. There's a lot of, you know, stuff, low level stuff that I don't want to cover in this podcast because in my opinion, you don't really need to know that stuff to be a great coder. Those are all like interview type questions. And again, I talked once before interview questions are so disconnected with the day to day reality of the coding that you need to do. It's so silly To me, and it's so annoying to me, because anyway, that's a whole nother soapbox I can get on. There's a huge disconnect between what is expected of you in an interview and what is expected of you in the real world. And that's really unfortunate. So anyway, the low level inner workings and you know, bits and pieces of how streams work. Those are interview questions, you're not going to need to know that stuff on a day to day basis. So I want to talk about the real world stuff. That's what I focus on in this podcast. So yeah, a stream the way I summarize a stream in plain English, I say it's a fancy for loop. That's essentially what I what I say. It's a fancy way to loop through a collection. Okay, that is the gist of what a stream is. Obviously, there's a lot more to it. But that's the gist. So considering the fact that a stream is just a fancy for loop or a fancy loop in general, why don't we dive into what makes it different, what makes a stream different from an actual loop? Right. So let's go let's go into an example. Now I have a I've created a repository, a GitHub repo that I will link in the show notes. Let me just make a note to do that here. I'll put it near the top of the episode. So GitHub link here, there, I made a note to put that in there. So if you go to coderscampus.com/53, you will be able to go to the show notes quickly, coders coderscampus.com/53. And you'll be able to see the GitHub link to the repos and you'll be able to see the shownotes should take to the repo singular. So you'll be able to see the code that I'm about to explain verbally to you right now. So if you're not driving, and you're able to you can pull up coderscampus.com/53, click on the GitHub link, and you'll be able to see the code that I'm talking about. So let's compare a simple example of an old way to do things meaning using a loop, and the new way to do things meaning using streams. So for our first example, we're just doing a simple filtering. Okay, we just want to filter a bigger list into a subset of that list meaning whittle down the elements in a list to be fewer elements based on some criteria. In this case, to give a concrete concrete example, I want to talk about a list of names. So we have a bunch of names in a list. A name starting with a going all the way to j. So we have Andrew Betty, Charlie, Darla Eddie Franca, George Hannah, Ivan Juliet. So what does that 10 names ABCDE, F, G, H, I, J. Yeah, 10 names. Look at that. I magically landed on 10. Nice, round number. So yeah, we have all those names in a list. Again, it doesn't matter what the names are, it doesn't matter that they're ABCDEFG. That's just I need to generate some names. And I just did it that way. So the content here doesn't really matter. Other than it's a, it's a bunch of strings. Okay. In this case, it's names because that's more meaningful. So you want to filter this list of names. Okay, this is something that you might want to do in the real world. Here's a bunch of data. And we want to filter that data based on some criteria. In this case, we have a list of names, and I want to filter it based on names that contain a R, T, okay, I don't know why I'd want to do that. That's just a random example that I came up with and chose to put in here. But I want to filter my list by names that contain the string AR, together. Okay, so, given Andrew Betty, Charlie, Darla Eddie Franca, George, Hannah, Ivan, Juliette, can you imagine which of those names contain the combination of letters AR together? Probably not off the top of your head, you might be able to pick one up. But anyway, that's why filtering using you know, code is helpful. So we want to filter the names by names that contain AR. So how do you do that the old way? How do you filter names by a given, you know, given parameter or given criteria? Well, the way you would do it is you would start with the filtered list, you would instantiate it as an array list. In other words, you'd have an empty list, I called it filtered list. And this empty, empty list, specifically ArrayList is waiting to be populated with the matching subset of data here that we're working with that we want to filter down towards, right. So we have we start with an empty list, we pass in our full list the names we pass in the parameter that we want to use. In this case, we want to filter by AR. And then we have our initialized filtered list or initialized empty list. And we want to start iterating through the full list of names. Right, so the full list of names, other words, all 10 names, you want to start iterating through them each one at a time. How do you do that? Well, we use a for loop before each loop to be specific. So we use a string name in names. So as you go through each of the names, you assign it to the variable name. And then we have a variable name in our for loop that we can then use, right, so name is just a string. So then inside of our for loop, we use that name variable. And we say name dot contains are, you know, filter parameters are criteria, because named contains is sort of the the filter. In this case, again, it doesn't necessarily matter what the filter is, and what the parameters are to that are the criteria are.

        15:33

        What just matters is how do we accomplish this task, right, so we start with an empty list, we have to do a for loop to iterate through all of our collection. In other words, we're iterating through all of our names. And then we say, hey, if this particular name contains our parameters, in other words, contains, you know, ar, is the filter that we're using, in this case, then cool, we have a match this name contains AR, so added to our filtered list. So our filtered list was the array list that was empty at the beginning, we want to populate this new empty list with every matching name that matches the AR, you know, filter. So we add that to the filtered list. And then at the end, once we get through all of our names in the for loop, at the end, we should have a filter to list a subset of the full list that contains our matching names, right? And then we want to return that. So that's it. I mean, that's how you do that with a for loop. Okay, start with an empty list. For each name, find out when the name contains the filter parameter, add it to the filter list. And then at the end, you return that filtered list, which will be a subset of the full list. Okay, so it makes sense. That's, that's fairly straightforward. It's 1234, you know, 567 ish lines of code. Not too bad, not too crazy. So how do we do this in the quote unquote, new way? How do we do this with the streams? Right? Let's talk about it. So in my code, I have a class called old way and new way. So these are two classes, again, not the greatest names for classes. But the old way is what I was just talking about, it was doing this filtering, there was a method in there, I omitted the fact that there was a method doing all this, but it was a method called the filter results. That took two inputs, all the names and the filter parameter. So this same code exists in the new way, class file. So the new the old way, the new way, have the same method that we're invoking here to return the filtered list of names. So we have that same method here, but in a new way, we do not do a for loop. Okay, we're using a stream. So how do you stream things? Well, the stream is based off of the collection. So all pretty much all of the Java, the existing Java collections, have a way to stream, okay, with a list. In this case, we're using a list. The list interface has a dot stream method now. So you're able to do names dot stream. So that starts the process of streaming. And again, what is a stream a stream is just another way to loop. Okay, as we did before, we created a for loop, right? In this case, we don't have to do the for loop, because that's kind of like what the stream is doing. It's allowing us to iterate so to speak. Okay, cool. So we do names dot stream. But then, well, what do we do? Now? Remember, we want to filter these results. How do you do like an if statement to see if a name matches another, you know, matches or contains this filter parameter or whatever, right? So the way streams works, is when you do dot stream, it returns that method returns a stream type.

        18:58

        And that type has a generic type that it accepts type T or whatever, right? So we have a stream of type t, but what is type T here? We have a stream of something. So what are we streaming? Well, remember, we have a list a collection of what we're dealing with names right now, it's a collection of what it's a collection of string data types, right? That is what our, our collection is, it's a it's a list of string. So when we're doing names dot stream, we're streaming what we are streaming string type. So that that of the keyword there that I use list of string, the of is what's important here. That's what I use in my brain. If the collection it's a collection of something, so that's what the stream is, is iterating over right? It's a stream of string. Unfortunately, those two words are very similar sounding does translate well with audio. So list of string, what's the same thing, same thing. List of string it now it is a stream of string objects. Okay, so we're streaming strings. So when we say names dot stream, which is the new method, dot stream is the fancy method that starts this whole streaming, it returns a stream of strings. Okay, now what can we do with that data type stream of whatever stream of type t, there's a whole bunch of stuff that we can do. So if you do if you do a.on, that stream, there's a whole bunch of other methods that you can do on a stream of whatever type. Okay, well, what can we do? Well, guess what, when you do that on your screen on your screen, and you hit the dot, after the stream method, because getting stream returns a stream of whatever T type, right? When you do a.it shows you all the other methods that you can do on a stream of something. And there are quite a few. There's, there's a bunch of beautiful things that we can do. The one that we want to focus on is we want to focus on the filter. And guess what? Filter takes a predicate? Hey, do you remember what the predicate is? We talked about that in the past episode, I think the last episode, so on 52, we talked about what a predicate is, a predicate takes a generic type t, and returns what it returns a Boolean. Okay, so, predicate takes type t, returns a Boolean, what type T are we talking about here? Well guess what the type is String, because we're streaming strings. So this type here, the the generic type that we're working with, sort of gets filtered through with each one of these steps that we want to do each one of these methods that we are changing, because what we're doing here is we're chaining, we're chaining methods, dot stream, dot filter, is what we're going to be doing dot stream dot filter, so we can chain methods on top of each other. If you want to, you can assign dot stream to a new variable, and then take that new variable name and then on that new variable name, do dot filter. But that's just an extra bunch of noise that you're adding in there. That's, that's okay, if you want to debug in terms of like outputting stuff to the console, or to the system out print line, or whatever. If you want to do it step by step and really have a strong understanding of each one of these steps and have it be very verbose, which defeats the purpose of using streams. But if you want it to be very verbose, so that you can understand it, by all means, go for it. But really the way streams are meant to be used and consumed is using this method chaining concept. So dot stream dot filter, and dot filter is a method that takes a predicate. So the predicate takes type t, remember, it takes type T and returns Boolean, the type in this case is going to be a string. So the filter takes a string as an input in this case, and returns a Boolean. So what is filter do? filter will return true it sorry, I should say IF filter returns true on a stream, that it keeps that particular

        23:25

        item that you're streaming through, it keeps that particular item in the stream, so to speak, downstream, if you will, it keeps that particular item. And you can do more with it. If If the filter returns false, it throws away that item, it does not care about it. It does not pass it down to the next step. Right. So filtering allows us to keep the things we want and throw away the things that we don't want, which is essentially what we were doing the old way, which was to say, hey, you know, for loop a for each loop, if the name matches our criteria, then add it to a new list. Right? So that's sort of what we're doing here. We're not necessarily Well, we can add it to a new list. But anyway, we're we're keeping going we're considering we're moving forward with anything that returns true here with this predicate with this filter predicate. Okay, so stream dot filter, and then how to use a predicate. Remember, it's just a functional interface that takes in that one, it's one method, I think the film predicates, I forget what the method is called. But it doesn't even matter. You don't need to know the name of the method. Because you can just use the lambda syntax here. So remember our lambda syntax arrows in the middle, to the left of the arrow is the input parameter name, and to the right is the body where we can return something. So dot filter takes the predicate dot filter, we're going to put in name as the name of our variable on the left hand side of the arrow function or the the arrow lambda syntax, because that's essentially what we're filtering here we're filtering a name, because it's a list of names. So really, the way my brain works is whatever we're streaming, whatever we are iterating, over, probably has an S on, it's probably a pluralized, the version of whatever. So names is the plural name, plural variable name here. So names has the s, well, what are we streaming, we're streaming the individual name. So you just cut the s off of the variable name. That's sort of how I typically set up. Streaming makes it very simple and straightforward and easy to understand and read. So we're iterating. we're iterating over names of via a stream. So again, I'm just I keep saying the same code over and over again, by the way, this code is three lines that I keep talking about here with this new way, it's three lines of code, as opposed to like seven before, so it's much more succinct, to get names dot stream,

        25:59

        dot filter. And then filter is a method that takes in a lambda A predicate. So to do that, we have name on the left hand side of the of the arrow. And then what is on the right hand side, well, remember, the right hand side has to return a boolean value. So what is this boolean value body function, whatever that we need to create here? Well, it's the same as we did in the old way, we just said if name dot contains the parameter, the criteria then return true, right, so we can just do that here, the short form, we don't even need to add body, we don't have to add, sorry, the curly brackets, we can just say, name, because that's the variable name that we chose to name it on the left hand side of the lambda, we can say on the right hand side name dot contains the filter parameter, right, the criteria that we're passing in, and that's it. Right, that's name is on the left, and then name contains the filter parameter on the right. Because named contains will return true if the name contains that filter parameter, right? In this case, AR is a string that we're filtering by. Cool. So we did names dot stream, which returned a string stream of string, then we did dot filter. And we put in our filter parameters, well, what is filter return filter returns another stream of string. Okay, same thing, but the difference here is, it's going to return a subset from the stream above, because we're filtering out some stuff. So if the name contains a our, the filter will return it as a stream of strings in this case, but for our example, it's actually gonna be two names. So I should probably have said that before. So the two names that is going to return here are Charlie and Darla Charlie contains contains AR, ch, ar, right for Charlie. So AR is in there. So boom, we have a match. So it's going to return that in a stream of strings. And it's also going to return Darla, because Darla has D A AR AR, right, we're always looking for the AR is in the names. So we're going to below the filter when we chain another method onto dot filter, because that's what this whole thing can do. We can chain methods onto each other filter returns a stream of strings, but in this case, it's only two string strings, right. It's only it's a stream of two strings, because to match the filter criteria, Charlie and Darla, whereas before and the step above, if we say names, dot stream, names dot stream, we'll have all 10 names. Because we haven't filtered anything, this is just, I want to stream all of the names, right. So names dot stream, will be a stream of 10 strings, right 10 names, but then dot filter will return a stream of strings, but it's only going to be two string strings in that stream. Sorry, again, stream string stream strings. I'm trying to enunciate as best as I can. So yeah, dot filter will give us a subset, right? They'll give us two strings in a single stream. Cool. So now what do we do? Well, we can do another.in. This case, we're doing something called dot collect. And we're saying collectors.to list. I went over that really quickly. Because there's there's more on your talk about about dot collect. So where the heck did that come from? Trevor, you probably are saying I was with you with a dot stream that sort of makes sense. You know, you're iterating over all of the, you know, items in the collection. we're iterating all over all 10 names. And then you said dot filter, and that got a bit more confusing. We're filtering, but you know, true means keep it false means throw it away and send it downstream. Okay, I think I understand what you mean. But then what the heck does collect mean so before I dive into what I collected means you need to understand that when you're streaming, there are, I think a couple of maybe more than a couple. But there are a couple types of methods that we can that we can use here. There, I should say couple of categories of methods when streaming. So there are a couple of categories, or at least a couple of important categories of methods. When we're talking about streams, the first category is

        30:31

        called an intermediate operation. So filter is an intermediate operation, you can categorize, filter as an intermediate operation. Okay? What that means is, you can perform a bunch of different intermediate operations on a stream, if you like, you can perform one you can perform none or you can perform many intermediate operations on a stream. In other words, these intermediate operations allow you to mess with the stream, change it in some way, or, or shape or form, right. In this case, we're filtering so we are removing elements from our stream. There are other intermediate operations that you can do that modify the stream. We'll talk about another one in well, can we talk about it in this episode, How long, I've been talking for 30 minutes. Okay, so maybe we'll talk about that in the next episode, another oper, another intermediate operation that you can do. So you start a stream, that's like the start of the whole thing, you can perform zero or sort of, I don't wanna say Unlimited, but zero or more intermediate operations on the stream, and then you can perform one terminal operation. Okay, a terminal operation is an operation that you can do once at the very end. Okay, so typically, the way a stream goes is the stream starts. And then on the stream, you do zero or more intermediary, intermediate operations, and then you perform one terminal operation. That is the generic and common blueprint for streams. Okay, so a terminal operation is what you do at the end. And the terminal operations typically take in some sort of, I think it's a supplier is the is that right supplier, does a supplier return? I can't remember anymore. We just talked about this, I think a supplier just returned something, as it takes something in, it returns a result. I forget if it takes, if it takes no, it doesn't take a parameter. At least I don't think it has to, because it already knows from above what what it has access to. So I believe the supplier just returns something back. So in this case, dot collect, has picked a supplier and the supplier in this case is called, we use something called collector.to list, or sorry, collectors with an S collectors is a special sort of helper method that allows us to do a bunch of stuff. So collector.to list allows us to take in the items that are coming from upstream, and then just says, Take everything that we have at this point and turn it into a list. Okay, so I know that was a bit confusing, I didn't do a great job explaining it. I got mixed up there with supplier versus consumer. Right, those are the two I just talked about this, you can see you can hopefully take some

        33:59

        some solace take feel good about the fact that I'm even still confused about this stuff, right? So and I've been doing this for like, I don't know, how long but using Java eight stuff, I don't know years, it's been two years that I've been doing this. So it just goes to show you don't need to know I'm trying to get into the inner workings of how everything and you don't need to know the inner workings all i All I think about and all I know is that I can do dot collect, which is a terminal operation which you need to have a terminal operation with a stream to do anything with it, do anything useful with it. So dot collect is a terminal operation and it allows us to take what items we have left in the stream and then turn them into something useful like a list or a set or a map or whatever, right. So there's a bunch of things that you can do with a collector. So you can say collect dot collect as the as the method. So dot collector is the method which is called a terminal operation. And then you pass in collectors dot something. So collectors.to list will turn whatever items we have left into a list. Okay, so that's it. That was a lot of explaining. But really all that explaining was for three lines of code, right? Names dot stream stream is a method for invoking it. So we have round brackets, names dot stream with round brackets, dot filter. With round brackets, what are we putting in the filter, we're putting a lambda name on the left arrow named contains filter params. On the right, that's how we filter out all the names that don't have AR in them. And then chaining another method dot collect, get, it's a method we're invoking. So we have to the open close parentheses here. And then we pass in collectors.to. List, collectors is the utility type object that we use here. That allows us to yeah, do all sorts of different ways to collect stuff, in this case, collectors.to list takes whatever we have upstream and turns it into a list. So then we can return that. So that's what we do to return a list of names that are filtered by a certain result. That's how we do it, we stream we filter, we collect done three lines of code. Cool. So that's what streams are, they are a different way to do a loop. And streams are composed of typically the initial dot stream to get started, then it has zero or more intermediary options. In this case, one of the intermediary options or operations that we did was filter, which reduces the number of items because we're filtering out stuff. And then we collect the terminal operation. So stream it, zero or more intermediary operations. And then collect is the terminal operation. So a terminal operation. So another example of a terminal operations do a for each. So which is you know, instead of saying collect, I could have said dot for each. And the difference there is dot collect allows us to put all that stuff into a variable, right? In this case, we're putting it all into a list. So we're taking the filtered results and putting it into a list, which is cool, because you want we want to return that list, right? We could have also alternatively use dot for each. So instead of just returning those last two names that we filtered, instead of just having those two names and returning them to a new list, we could have just said dot for each and done something with them, right? That's another terminal operation. In this case, we want to be able to return that list so that we can do something with it. But hey, if all we needed to do was like print out those names, we could have done done a dot for each and just printed them out. Right, that would have been another way to do it. So apologies for being long winded here. But I guess that's the whole point of this podcast is to be long winded. My hope was I could talk about another intermediate intermediary step. But yeah, we will all let your brain digest everything that we just talked about about streams. And in the next episode, we will dive into another really cool intermediary option called Map, which is probably the single most confused, that's right word confusing, intermediary operation that exists, because it shares the name of the data structure, right? In Java, there's a data structure called Map. And whenever my students learn about streams, and they hear about dot map, they immediately think it means convert it to a hash map. And it's like no, it does not mean that. So we will dive into the complexities of what dot map is as an intermediary operation. And obviously, we'll dive into some more stuff probably in the next

        38:48

        episode of the podcast, because there's more obviously to talk about with respect to streams. But to sum up, streams are less verbose way to do operations on a collection of objects. If I zoomed out to the 10,000 foot view, or whatever, 50,000 foot view, that is the gist of what streams do, because in our daily lives as coders, we do crud, all day long. crud, creating, reading, updating, deleting data, create, read, update, delete, see our UD crud, right, that's what we do on a day to day basis, we do crud, and as a part of crud, with reading data with the R step. Typically, we read data from the database. And when we read the data from a database, or a file or whatever your you know, your what's the what's the, your persistence thing, if it's a database, if it's a file, if it's a, an API, whatever your you know, data stream coming in is, typically we read it into a collection of some sort, and then typically We take that collection, and then we do something with it, we modify it, we enhance it, we tweak it, we do something with that collection that we've read from a database or an API or a file or what have you. We do something with that data, we modify it, and then we send it to the front end. And vice versa, we take it from the front end, we modify it, and we send it to the backend, right? That intermediary step there not to use the same word that exists in streams, that middle step that we do with respect to either pulling it from the database and putting it the front end, or taking it from the front end and putting it in the database. There's that middle step, where we typically iterate over a collection of items and do something with it, right. That's where streams shine. And there's obviously more streams and what we've talked about. But this is where this is something we do all the time, we see a lot of for loops, iterating over things and modifying things. And what happens is the statements, these blocks of code of for loops, can get really long and verbose. And really be difficult to understand. And you'll be amazed at how much more easily you can understand code when it is not in a for loop. And rather when it is inside of a stream. That is where streams shine. They are so much more readable. You can look at it and understand a more complex stream of operations in seconds when compared to probably upwards of hours with a for loop, maybe not hours, maybe that's a bit, too, you know, going too far. But minutes, I would say seconds versus minutes when it comes to understanding code and reading it. So that's the beauty of streams. And having said that, like I said at the top of this episode, the boot camp is something that I would highly recommend you checking out if you haven't already done so coderscampus.com/bootcamp allows you to Yeah, dip your toes in those waters, check out with the boot campers about learn more about it, see if it'd be a good fit for you. Like I said, if your goal is to get a job as a coder, oh my goodness, this is what I shine that and this is what I've dedicated my now career two is helping people transition from where they are to being job ready in as short a period as possible with as least amount of pain as possible. That's the point of the bootcamp. In my opinion. Like I said before, it is not only the fastest way to do it, it is also the cheapest way to do it. And there's data to back that up when it comes to completely self taught versus doing something like a boot camp versus doing something like a college degree. So it is the sweet spot in my opinion with respect to achieving the goal of getting a job in the real world. So if you are at you know, one out of 100 in terms of job readiness, I'd highly recommend applying to the boot camp coderscampus.com/bootcamp. I will see you there. Hopefully I will talk to you soon. Otherwise, I will see you in the next episode of the podcast. Take care everyone. Happy learning and bye for now.

        42:58

        Thanks for listening to this episode of the coders campus podcast. But before you go, Trevor has a favorite ask you. In order to keep these episodes free, he'd love for you to leave a rating and review the podcast on iTunes. Just go to coders campus.com/review to leave your own rating and review of the show. So if you have 30 seconds to spare right now, please help out by leaving a rating and review via coders campus.com/review It will ensure that you continue to get these awesome free podcast episodes each and every week. So if you like free swag, head on over to coders campus.com/review Happy Learning

         

        The post EP53 – Intro to Streams in Java appeared first on Coders Campus.

        44 min
      • EP52 – Most Common Functional Interfaces in Java

        In this episode we'll talk about 7 common Functional Interfaces that Java provides to us.

        UnaryOperator, BinaryOperator, Supplier, Consumer, Function, Predicate and BiPredicate

         

        Episode Transcript

        0:09

        Welcome to the coders campus podcast, where you'll learn how to code from one of the best teachers in the industry. Whether you're an absolute beginner or a seasoned pro, the coders campus podcast will teach you what you need to know to master the art of programming.

        0:24

        And now, your host, Trevor page. All right, ladies and gentlemen, fellow coders. Welcome to Episode 52 of the coders campus podcast. As always a pleasure to be here, again, bringing you the knowledge that you need to succeed as a coder. So on that vein, as per last episode, just want to preface this by saying, if you haven't checked out the boot camp, yet, we have cohorts launching every single month. And if your goal is to get a job as a coder in as little time as possible, within reason, we're not talking about, hey, do this little thing. And in two months, you'll be getting a job with 100,000 notes. So we're a lot more realistic here at coders campus. So yeah, our boot camps are about six months in duration, we have a very high success rate. But yeah, we'll talk more about that at the end of the episode. So if you haven't already checked it out, coderscampus.com/bootcamp if you're interested in launching your career as a coder. Alright, so now into the content. For today's episode, we are continuing our talk on functional interfaces. We mentioned in the last episode that there were some popular functional interfaces that are provided to us by the good folks at Java at I guess Oracle owns it currently. And these functional interfaces that are provided to us are quite useful. So much so that like I had alluded to in the previous episode, we don't tend to create our own functional interfaces, we only tend to leverage the existing ones. So obviously, let's talk about the existing ones that are out there, in no particular order. But these are the popular ones, there are many more than the sort of five that we're going to be talking about today. But the the, the the other ones are sort of variations of these five that we're going to talk about. So once you know and understand these five, the rest of them tend to be

        2:27

        fairly straightforward to understand. You'll see them and say, Oh, that's a variation of one of the five that Trevor taught me and I get it right. So let's start with the first with the five. Let me see is it 512345667? Sorry, I've been saying five, seven.

        2:45

        Although anyway, we'll dive into the popular ones. So again, just a recap, in case you Well, if you missed the last episode, go back and listen to it. Because if you don't want to functional interfaces, you're going to be entirely lost with this conversation right now. So highly recommend going back to the previous episode to listen up and learn about functional interfaces. But the first functional interface that we will talk about

        3:11

        is one called the predicate. Now these names are terrible, in my opinion, I hear the word predicate, and I'm sure maybe some people it clicks and make sense, it still hasn't clicked in my brain yet. But predicate is the name of this functional interface anyway, and it takes one generic type T. Okay, so this is a throwback to generics, hopefully you understand what generics are. Very quick recap of generics, you can think of these single capital letters that are known as generics usually encased in the angle brackets. For example, if you see a list, so give a list of something like a list of strings. The other is usually I say, of, but I you write out the angle brackets, so less than and greater than symbol. And in between those less than greater than symbols, you put the type. So in this case, if you have a list of strings, you would say list, open angle bracket, and you would put string as a data type, and then you close the angle bracket. And then you could instantiate that list with as an array list of strings or, or it could be a list of, you know, any object can be a list of double, it could be a list of user, it could be a list of anything. The point is the of their the word of typically means generic, right? It's a list of something. And that could be anything therefore that anything can be generic. Previously, you would use just the object type. Okay, object would be what you would throw in there, but then you need to cast it all the time, you'd have to cast object to your desired type. And casting can be a little bit wonky at times it can cause issues and it's just a it's just more mess. So Java introduced generics in, I think, version five or something. I've done an episode on generics. So if you don't know what generics are, I would obviously recommend brushing up on that as well. Now

        5:00

        That's all I will say about generics getting back to these functional interfaces, specifically the predicate functional interface. predicate takes one type T. Okay, so it uses generics a generic type. So it takes a single parameter, okay with this single type,

        5:21

        and it returns a Boolean.

        5:25

        So it has one input to its method.

        5:29

        And it has a return value of Boolean, so it returns a Boolean.

        5:35

        Okay, so this is like a framework, this is a very generic function, right? That's so you can think of these functional interfaces as as like, sort of templates for functions that are generic that you can just use. Because think of any function that you've written in the past, have you ever written a function that took in a single parameter and then returned to Boolean? I'm sure you have written a function that does that, for example, I've written one called validate user before in some of my projects, right? You want to validate a user. So you take in a user object, and inside of that user object, which has a type, there's a, you know, a username and a password or something. And then you take the username and password and you compare it against your database to see if this user exists in the database. If it does, does the passwords match exactly. If they do, then you return true. This is a valid user, or you return false. This is not a valid user. Right? So that's single

        6:31

        example of validate user as a as a method of function. That could be classified as a predicate. That's what predicate is all about. That's the generic, you know, functional interface that Java gives to us this generic template that we can leverage

        6:49

        in a bunch of places. One common place that you would use a predicate is in something called filter. So filter is something that comes with streams, we'll talk about streams, after we've done with this lesson, most likely.

        7:04

        filter allows us to filter out items from a collection. So if you have a list of users, and let's say in that list of users, you only want to be you only want to consider users that are active or something as an example, you only want to look at active users, active users can be defined as anything, but let's define them as you know, users that have paid their bill, right. So they're not, they haven't failed payments, or something like that, I don't know. So that the users in your system are active, and you only want to look at the active users, how you would do that is you would you would get a collection of all users. This is one way of doing it. You can have a collection of all users and then you can filter out the ones that are not active. So what filter does is it takes a predicate filter is a function that takes a predicate as its input. Okay, this is where in the past episode, I was talking about how the concept of functional interfaces and the introduction of functional interfaces here allows us to treat functions as parameters. Right? This we couldn't do this before. In the world of Java, you couldn't pass a function as a parameter to another function. Right? That's just it couldn't be done. You couldn't you can't do that. Now that became popular in JavaScript. And I'm sure other languages as well, other functional languages. And then Java, like I said, before, copied it shamelessly copied it and said, Hey, look at this great new feature that we have, are we the best? So yeah, this is what's happening here. The filter function takes another function in this case, functional interface as a parameter, and more specifically, it takes the predicate functional interface as a parameter, okay? Because the predicate takes in a type and returns a Boolean, right? So you filter out users that are that are not active, the filter method would take in a predicate, and the predicate would be you pass in a user, as, you know, part of your collection of users that you have, like, say, you have a list of users, you take in the user, that's your input. You type input type is user and the individual users in the collection, the list of users are what is being fed in one at a time, and the output is true or false. So in this case, you would sit you you know, write some code to see is this user active or not. So you would return true if the user is active, you would return false if the user is not active, that's a predicate right and that allows us to use this lambda syntax with the filter function. You know dot filter is a function, the input to the filter is this predicate and remember predicate is a functional interface. Therefore, you can use the lambda

        9:56

        which call it syntax. So filter can take

        10:00

        In a function so to speak, you type in the lambda syntax. So filter would, you know, you pass in a user, so user would be on the left, because it's your single

        10:09

        input value, you don't even need round brackets around that, believe it or not, when you have more than one input type with the lambda syntax. If you have more than one input type to the method, then you have to use your round brackets. But believe it or not, you can drop the round bracket. So you can just have dot filter, open up the round bracket for the filter function. And then just type in the single word user. Now you can call that word, whatever you like, it's just the name of the variable that's going into the input, the methods input, the method being the predicates, method, whatever that's called I forget, if it's like apply or might not be apply, I forget what it's called in there. But it doesn't matter, you don't have to know the name of it. There's a single public abstract method inside of the predicate functional interface. And it doesn't matter what the name is, because there's only one method and we Java knows, that's the method that we are executing here. And that method takes in one parameter of type t, and it returns a Boolean, that's what the predicate does, that's what the I should say, that's what the method inside of the predicate functional interface does.

        11:14

        Okay, so going back to dot filter, so you have dot filter, and then you're using the open bracket for the dot filter method, and then you pass in whatever parameter you want, whatever name of variable you want, since we are talking about iterating, through users here, again, this is I'm talking about it from a streams perspective. So if you haven't learned about spring streams, yet, there's a, there's gonna be a void, there's gonna be a gap in your knowledge as to what I'm talking about. But don't worry about that. Let's just focus on the filter here. And let's assume that we can have an input in here, and it's going to be a user. So you put in the word user, because that's what we have as an input. And then you have your arrow, minus sign greater than symbol. So on the on the right hand side is the body of the method that's going to return something returned, specifically a Boolean. So you can write whatever code that you know, you can just write user.is active, maybe you already have a method that's associated to finding out whether or not a user is active or not. And maybe that function is called user.is. Active, maybe it's, you know, a method in the user class. Okay. So that's all there is, you'd have on the left hand side, you have user and then you have the arrow, and on the right hand side, you'd say user.is. Active. And that's it. That's all the code you write, and then boom, the filter just works. Okay, because we're leveraging the predicate functional interface. And the filter takes the predicate functional interface

        12:31

        as its input, right filter takes that functional interface as its input, and how do we use functional interfaces? In Java? Well, we can use this great lambda syntax, this very non verbose, this very succinct

        12:46

        syntax, right user on the left arrow, and then user dot get, or user is active on the right of the arrow, and then that's it. You close your whatever, filters, round bracket, and you're done. Okay.

        13:00

        So that's where it's good. You can you can give this sort of this functionality, this filter functionality could have been anything. It could be any predicate, it could be any function that takes a single parameters input and returns any Boolean as output. That's it, it you can put whatever you like, in there, right? So it's a very, very flexible, that's the whole point of this stuff is it's flexible, and synced. If you've ever used JavaScript, I know I keep harping on this. If you've ever used JavaScript, you will you will be familiar with this, because it's just a very quick and easy and once you understand it, it's like yeah, why? Why? How would you ever not use that syntax? Right? So it just, it's just really good. I really like it. Okay. So predicate, that is one of the most common functional interfaces that Java provides to us.

        13:50

        Okay, now, here's its partner a little bit less common, but will take me two seconds, hopefully to explain to you there's something called by predicate

        14:01

        by predicate what is a by predicate, less common than predicate, but it's very easy to explain because it just takes two arguments, and returns a Boolean.

        14:13

        Okay, the two arguments it takes in I believe, are just type t, I think they have to be of type T. And that's it. unless I'm mistaken. But I again, I don't use my credit a lot. But yeah, it's less common. But it's very easy to understand instead of taking one argument, in other words, instead, instead of taking in like one user, and then checking to see whether or not the user is active or not, this one could take in to the by predicate takes two. So pain, it could be, you know, takes two users and you're doing something else instead of filtering out your I don't know you're doing something else for taking in two users and doing something with those two users.

        14:46

        Yeah, by predicate, less common, but there you go. Pretty simple to understand. When would you need to take in two arguments and return a Boolean? I don't know. That's you. I'm sure you can spend it. You can probably look through existing

        15:00

        code and find some use case for that. Right? So it's there, it's there if you need it. Now the question is, actually, I'm gonna pause because I haven't done any research on on the by predicate to see if it extends predicate or if it's some sort of maybe I can do it on the fly here.

        15:16

        Okay, sorry. So the by predicate takes in two different types, my apologies. That is my misunderstanding. So I was thinking about that when I was saying it out loud. I was like, it takes in two, two parameters, but they have to be the same type. It didn't feel right to me, which is why I may want to double check this. So no, it takes in two different types. T is the first type and you as the second type for the second argument. Okay, it's just there generics, right. You could take, you could pass in the same two types, I guess. But yeah, there you can, it gives you the flexibility of having two completely different inputs. But the point is, it returns a Boolean back. Now the other question I was thinking is, is this some sort of

        15:58

        extension of predicate does it extend predicate, and I don't see anything on the screen at the moment, as I'm going through here, to see that it does extend predicate. So my assumption then is that the by predicate has its use cases outside of something like the dot filter. So for dot filter, I don't believe you would be able to use by predicate. And I could code that out in front of myself to check that but I'm pretty sure it's, it's a completely different type.

        16:32

        Because I don't see anything in the documentation as I'm going through it.

        16:36

        That indicates that it is a

        16:40

        an extension of predicate so okay.

        16:43

        This is this is the to, to mid to mid specialization and predicate, whatever that means to arity is that I've never heard that word before. Anyway, these these

        16:57

        Oracle documentation words, this is why these podcasts exists, right? Because it's so hard to understand the the documentation. So if you have problems understanding, Docs, you're not alone. Okay? Back to it. So that's predicate by predicate. So the next one is called the unary, or unary. Operator. Okay, so the unary operator takes one parameter of type T. Okay, so just like the predicate, so we're very close here in terms of similarity, right, where they both take in one parameter of type t, but this one returns a value of that same type T.

        17:37

        So that's the difference, the predicate will return a boolean, this one returns a value of that same type generic type T.

        17:47

        Okay, so can you think of any method that you've ever created any function I'm using the word function and method to be mean that the exact same thing? I, I'm in the habit of using method because I came one of my most,

        18:00

        not most, what's the word I'm looking for? One of my first languages I worked with, and was most in depth into knew the most about was Visual Basic, and they call the methods.

        18:10

        That's the one I more or less started with was Visual Basic. So yeah, that's where this this terminology of methods comes from. When I say method, I'm trying to save function more often. So

        18:23

        the unary operator takes one parameter of type T and returns a value of that same type. So can you think of a function that takes in a parameter of whatever single type generic type t, and will then return that same type?

        18:39

        There's tons and there's tons and tons and maybe if you can't think of one off the top of your head right now, it's because there's so many I scoured I look for a really common one, a common one is replace all. So it's part of, if you have, I guess, a collection of strings or something along those lines, or a string, you can use a dot replace all. And in one of the iterations of Java, you can use Replace All that takes in a unary operator functional interface as its input for the method.

        19:10

        Okay, so the dot replace all takes in

        19:15

        a type A single type t, which in this case is a string,

        19:20

        and then returns that same string again.

        19:24

        Right, so it returns the same type does it return true or false? It returns the same type that was inputted inputted into it. So if the string comes in as input, the string goes out as input. If it's an integer that comes in as input, the integer goes out as input. If it's a double that comes in as input, it's a double that goes out as input. If it's a user that comes in as input, it's a user that goes out as input, you get the idea, right? That's what the unary operator is unary meaning one, singular, you know, one type T goes in one type T goes out. Okay? So, if you've ever tried to do a replace all on a string, you want to replace all the you know,

        20:00

        commas with spaces or you want to replace all the line breaks with tabs, or you want to replace all the tabs with line breaks, or you want to replace all the tabs with comma, right, whatever the case may be, whatever you want to replace.

        20:15

        You, you take the string as an input, and then you can send the string back as an output. Same thing, right. So that's the unary operator. Now, along the same line, just like before,

        20:27

        there's something called the binary operator unary, or unary, whatever operator, binary operator,

        20:37

        any ideas, any any thoughts as to what's going on here?

        20:43

        It represents, let me just go back to my notes here, I want to make sure I get this right, I don't want to make a mistake, it takes two parameters of a single type, and returns a value with that same type. So it's not two different types here, the binary operator I just double checked. So it's not like by predicate the by predicate allows you to pass in types T and type u, which is two different types. The binary operator

        21:09

        gives you Sorry, I'm going back gives you one single type that you can work with.

        21:14

        Okay, so

        21:17

        it's all type t, here. I'm trying to think do I have a an example? Let's see. Okay, so if you go back to, I don't wanna say this is a common example, this just happens to be an example that we did in the last episode, where we were talking about taking two strings and sort of concatenate them concatenating them together, right. So in this case, that's sort of what the binary operator does, the binary operator functional interface takes a single type t, but it takes two parameters of that single type T and returns that same type back, which is exactly what we're doing with concatenating strings, right, we, we could have essentially leveraged the binary operator in our code, if we did already, that's great. If we didn't, we could have where we took in two strings, string one, string two, s one, S two is what we had in the previous example, both of type string and returns a string as well, right, where t equals string, right? So t is the type T equals string. In this case, in this particular example, again, that example could have been anything, right. But in this example, we did

        22:23

        get strings. So S one S two takes in two strings, and then it concatenates them together and returns one string, which is the two strings concatenated together with a space. Right? Okay? It could have been integers, right, you could take in two integers, in this case, t equals integer, right takes in two integers, and returns one integer. So an example of that could be more or less any, you know, simple mathematical operation, taking integer one and integer two, and then maybe sum them together, that could be the which call it, the operation that we're performing is a sum operation, right? So take in, you know, and want an end to which number one and number two, add them together and return a single integer. Okay, or it can be n one, n two and subtract them and return that single integer. That's what the binary operator does takes in two arguments of the same type and returns that same type back binary operator. So predicate by predicate unary, operator, binary operator.

        23:27

        What's another one? Well, to be very generic, and that almost the most generic is the function, functional interface, there's actually a functional interface called function. Right? This one's like super, super, super common, it's so common, I couldn't even think of an example to use for it, because it's just so so common. Some of the previous examples that we used could extend the function functional interface here. That's what common it is. So the function functional interface takes a parameter a single parameter of type t, and returns a result of Type R. In other words, it could be a different result, a different type, as a result, doesn't mean that it has to be different. It could even be the same, right? It could be, it could be the same if you wanted to, in which case, that would just be a unary operator, right? The unary unary operator takes one parameter of type T and returns that same type. But that could also be a function but a function where it is just

        24:31

        the

        24:34

        the type and the return type are just the same. In fact, I would, I would guess that the unary operator, let me double check this unary operator. Java is my Google I would imagine this extends function. This function whose functional method is function dot apply. Yeah, so it must extend

        24:56

        the function.

        24:58

        Yeah, super interface.

        25:00

        So that's what they call it. The Super interface of the unary operator is function, but it's just passing in T and T.

        25:08

        T as type one and t as the return type as well, but also the type. So, yeah, the unary operator just extends function.

        25:17

        Right?

        25:19

        Oh, here we go the binary operator that was talking about struggling with earlier to explain to you the super interface of binary operator is by function that makes sense. And the by predicate does that have a super interface? No, does not okay, by predicate does not have a super interface. Okay, cool. Now I'm starting to notice some stuff in the documentation. So focus, okay. function, like I said, is so generic that many things sort of extended, right function just takes any type t, any sir, I should say any argument or any parameter of type t, and returns a result that could be of a different type. Okay, that's it. And again, all of these things, all of these

        26:03

        functional interfaces have a single public abstract method defined inside of it. Right. So each one of these might be called something different, it can be done, you know, dot apply, the by predicate Can I see what is called the by predicate has done test, which I assume the predicate has test is its method, the binary operator has, what is the name of the single abstract method that it has inside of it.

        26:32

        That it's been by Max pi, I actually don't know I guess it is super interfacial. By function. So by function has apply. So by function has apply. Same with function has apply.

        26:45

        binary operator leverages by function, but extends it by adding in some additional helper methods that I don't want, I don't want to get distracted with those right now, I just want to talk about the basics of these guys. But just know that some of these

        27:00

        functional interfaces provide other sort of helper methods that allow us to do fun things with it, maybe I'll dive into one of them for the function, functional interface, since I'm supposed to be talking about the function, functional interface right now.

        27:19

        Java and sort of typing it in so I can get that prepped. So the function functional interface is, like I said, very generic, it can take in any type t and return any result are. So this one is used

        27:35

        a lot everywhere, right? Think of any function you've ever written in your life in Java that would fall under this flag that under this not flag weather, this template, okay, pretty much, almost all of your code that you've written, except for the exception of when you have two inputs into the method, or three inputs, or four inputs, right function is just for one input. And then a different result. Type I should say, by function takes into so you see how generic these are you see why these,

        28:13

        these interfaces were supplied to us by Java, because they're so so common, and you can use them everywhere. Okay, that's what makes this stuff so powerful. And that's what allows us to leverage the beautiful, non verbose syntax of the

        28:33

        lambda syntax, right? The lambda syntax is super, super easy. In terms of easy on the eyes, a lot going on under underneath the hood, which is why we're talking about it, but super easy on the eyes. Okay. So

        28:46

        next up is one called supplier. Okay, another functional interface. supplier is also fairly common. Supplier doesn't take any parameters at all. It just produces a result of type T. Okay, so no inputs, just produces a result. So an example of when you might use this is, if you just want to have a function that just quickly produces any result, right? So an example might be, hey, give me a random number. Like there's no the you don't need to give it an input. You don't there's no input to a function that just returns a random number. It's just hey, give me a random number. I don't need to give you anything, you just need to give me a random number. So that's, that's an example of a supplier it supplies a result without having to take anything in as an input. But the type that it returns as a result is of type T. So take that for what it's worth you need to have, you need to specify that type. Now the this one gets tricky because it can confuse people with the syntax. So I want to dive in to specifically the syntax of a supplier functional interface.

        30:00

        When it comes to typing out the lambda syntax, so again, lambda syntax calling back to the previous episode, lambda syntax is when you have that arrow, right, the minus sign with the greater than symbol together. That's the arrow. That means lambda in my brain, that's what I do. There is something to the left of lambda something to the right of the lamda. To the left of the lambda is the method signature to the right of the lambda is the body of the method. That's how this works. Now, what is the method signature of a method that takes no inputs?

        30:34

        Okay, I'll say that, again, what is the method signature of a method that takes no inputs? So the method signatures is the name of the method and then an empty, open and close bracket, or opening close parentheses, I should say. So it's the it's just the name of the method, and then boom, boom, open bracket, close bracket. But remember, in the lambda syntax, we don't need the name of the method, because you already have a method that we are using and leveraging that as a single public abstract method inside of the functional interface. Right.

        31:04

        So what is the syntax, the syntax is just an empty opening, close parentheses, that's it, there's no name that goes in there. It's just an empty, open, close, and then the arrow, and then there's the stuff on the right of the arrow, which you know, should return something if you don't define the body with the curly brackets, if you just want it to return, you can omit the body, if you can do it all in one line, you can omit the body and just say, you know, for this example, returning a random number, it could be just be, you know, the open close parentheses, arrow, and then math dot random, done. Right, math dot random, it'll automatically return that. And great. There's our an example of a supplier method that we have implemented with a lambda syntax. Okay, so that's the tricky, the tricky part of this supplier syntax is there's no inputs. So just have to remember that the empty brackets are needed, it needs something, even if it's empty, because hey, that exists in the real world, too. We can have methods that take no inputs, how do you properly write out the syntax of a method that takes no inputs? It's just an open and close parentheses with nothing in between. Okay, same goes for the lambda syntax. Cool. Cool. Sorry, if the clap was loud. So next up is Consumer functional interface is the last of our sort of seven that we're talking about. The Consumer functional interface.

        32:28

        Also pretty common.

        32:30

        It's kind of the the, the polar opposite of the supplier. So there's supplier and a consumer, a consumer, if you had to guess if it's what is the opposite of a supplier? If a supplier takes no inputs, and rather just returns an output of type t, a result of type T? What is the opposite of that? Well, it's the consumer, which takes a parameter of type T but doesn't return any results.

        32:57

        Okay. So you might be thinking, Wait, a consumer takes a parameter, a single parameter of type t, but doesn't return anything? Well, how is that useful? Have you ever written a method that takes inputs but doesn't have any outputs whatsoever? Well, possibly, what about logging, logging is a very common example of this, right? When you are logging something, you're taking some sort of input, which is typically a message or something, and you're printing it to the log, but you're not returning anything, it doesn't need to return anything, it's just a void method. Right, that's what a consumer is a consumer will take an input to consumes an input and just doesn't return anything back. Has it doesn't need to so again, a common example this might be logging something or or it's just like a system out print line type thing. Good example of leveraging consumer and whatnot. So, those are the seven common types really five are common and then there was two in there that I threw in there that were you know,

        34:00

        variations of the common ones the common ones are predicate which takes a parameter returns a Boolean

        34:09

        unary operator takes a parameter and then returns a parameter of that same type t okay. So predicate unary operator function which is super common takes any type t returns any type our supplier

        34:26

        takes in nothing but returns something consumer takes in something but returns nothing.

        34:33

        Okay. And then there are variations of them right. So predicate has by predicate unary operator has binary operator function has by function supplier might even have by supplier I don't even know if I typed in

        34:45

        by supplier.

        34:48

        Java, would that would that exist? Maybe it looks like it might by supplier.

        34:55

        I've seen by consumer by predicate by function but not by supplier. The concept to me

        35:00

        function predicate different in supplier blah, blah, blah. Anyway, it looks like there is no by supplier.

        35:05

        A by supplier simply wouldn't make sense a method returns a value of a single type in Java. It's true. That's good point. Yeah. Okay. So the supplier supplies a result of type t, which is the return statement. In Java, you can't return two types, so to speak. That's just not how Java works. So a by supplier wouldn't actually make sense. You can't return two different types, unless they are concatenated inside of one type, right? Then you just return the one type. So that's my bad. So yeah, there's a by predicate a binary operator a buy function, a by consumer, but not a by supplier, because that wouldn't make sense. But, you know, there you go, you learn something. I'm literally just learning something new in front of you, which makes total sense. But there you go.

        35:50

        And there are variations on all those as well. There are some that specifically deal with specific types and whatnot. But yeah, I don't want to get into those because you know, we could we could be here all day talking about it. But those are the important ones that you need to fundamentally understand. I mean, you don't have to fundamentally understand them. But understanding them really helps to demystify all of the stuff that we're about to talk about, which is streams in the next episode. So having this foundational knowledge really helps to clear stuff up, when we're talking about streams, just helps to live some of the fog and some of the gaps in the knowledge that might lead to confusion and head scratching. So those are the popular functional interfaces. One thing to mention, is that the function functional interface, so the function, functional interface in Java, let me just pull up the doc on that guy. Where is it? Here it is. So the function functional interface has other methods inside of it, that are that are called default methods. So one of the caveats to functional interfaces is that yes, there can be only one public abstract method inside of a functional interface. If you try to add any more than one public abstract method, it will fail, but you are allowed to have as many default methods in there as you like, because default methods you are forced to supply a body. In other words, they are not abstract. Okay, so you can add other non abstract methods inside of functional interfaces. And this is what Java does provide to us, in many of these functional interfaces that I've already talked about. So for the function functional interface, to give you an example of one of these, there's a default method called and then

        37:42

        I'll say that, again, there is a default method included in the function functional interface. There's a default method called and then, and that default method called and then takes another function.

        37:59

        Okay, so what this allows us to do is we can run or execute one functional one function, functional interface, lambda method, right, we could supply a method that does something, and then we can chain another one, we can chain another function after it with the dot, and then you can pass it another functional interface. And guess what we do that another function functional interface, that one can then be chained with dot and then

        38:30

        okay, so you can have this method chaining of do this, and then that, and then that, and then that, and then that and that and then stop, right. So

        38:39

        really super powerful stuff. And this is highly leveraged inside of streams, as we will talk about in the next lesson, such as one example of one default

        38:50

        method that is, you know, identifier used inside of just one of the super common functional interfaces. Just to give you an example, and just let you know, there's more to these functional interfaces than just the single public abstract method. There's also some default methods in there that are super helpful, that allow us to unlock a lot of additional functionality. So cool. Having said that, the important topic outside of this that I want to chat about, which I'm sure you see coming is the Java bootcamp. Again, we run these every single month. If you love this content, if you'd love to learn this stuff, if you're passionate about it, if all you want to do is get paid to be a coder, but you just haven't gotten there yet. You've been struggling with it, you need help. If you've been trying to do it on your own.

        39:35

        It's time to consider bringing on some help right. So inside of my boot camp, I forget I've talked about this I've probably talked about this before if I have forgive me, but it's important to say a lot of people think that boot camps are

        39:51

        only for someone who's already wealthy and they're super expensive and you know, I could never afford a boot camp. And while that is true, there's a lot of X there's a lot of support.

        40:00

        Along with boot camp, right? It's not just an online course. Again, I've said this in the past, if I wish I could just run my business with online courses, they are so much easier, I could do what I'm doing right now, all day long. I could talk to a microphone all day long and send it out to millions of people. I could record a video series a bunch of lectures and put them out and sell them to people all around the globe and not have to worry about it. Boot Camps are so much more work for me, I've had to hire a team, I've got a team of like five people working for me now. There's so much more of my time goes into running a boot camp than anything else I've ever had to do my entire life. I should say, in my professional career, boot camps are so exhaustedly involved, but they produce results. And that's why I'm running a boot camp again, I would much rather I actively tried not to do a boot camp. Guys, I, I didn't want to do it. But I couldn't argue with the math and the numbers. The purpose of my business is to help create the next generation of great coders. Okay, I want to I want to empower you guys to have the knowledge and the confidence and the abilities to go out there and get a job as a coder and literally change the world and change your life. I know that's a bit it sounds, you know, a bit HYPEE. But it's true. If you're someone who has an average salary and average middle class salary, becoming a coder multiplies that by like a factor of two to four, two, sometimes like 10. Yeah, it depends on where you live, it can be 10, though.

        41:39

        It is a very lucrative career, as I'm sure you already know. But there's a reason why it's so lucrative. There is a huge lack of coders out there a huge lack of capable coders out there. And you know why there's a huge lack of capable coders. Because it's so, so difficult to learn this stuff. Okay. So if you have been trying to learn this on your own, if you've been trying to learn it from books, from podcasts, from YouTube videos, and series, and, and some courses, some online courses that you've purchased for, you know, anywhere from $1, to like $50 to $100, and you still don't seem to be getting it and there still seems to be a lot of frustration and gaps in your knowledge and you still stare at your screen blankly when you come up to like a project that you need to do or an assignment and you're like, I don't even know where to begin. There's a reason for that. This stuff is hard. Every single bootcamp student I've ever taught goes through that.

        42:37

        Okay, learning how to code is extremely difficult. You wouldn't think it, you wouldn't believe it, when you hear the people out there on the street, so to speak, and on the internet, touting that they are self taught. And I you know, don't take a boot camp, they're scams and don't, don't go to college, it's a scam, that kind of thing. Well, that's a very vocal minority. In my experience, I want I don't know, it's like Survivor bias is sort of what's happening there. It's like this one guy was able to do it on their own. And this one girl was able to do it on her own, and do it self taught without having to, you know, spend a bunch of money, etc, etc. Yes, it can be done. But in my experience, that is the vast minority of people, but they tend to be the loudest, right? I think in our society today, we're very familiar with the vocal minorities. So that is, what's happening here. If, if that's what's in your head, if you believe that? Well, it's entirely possible to do it on my own. Yes, it's just highly unlikely. And if you could do it on your own great, my work here is done. I wish, I wish that 100% of the people could do it on their own. Because then I could have a great business just doing what it is, that's so much easier, which is just recording podcast episodes, YouTube videos, and online courses. And that's it. That's not the reality of the situation that we are faced with in today's world. So that's why boot camps exist. Boot Camps exist, to kick your butts to hold you accountable to give you a deadline, and to enforce that deadline and and get you past these roadblocks, that you hit these mental roadblocks that stop you from moving forward and make it so easy to quit. Right? But when you've invested in a boot camp, it's a lot less easy to quit, because you've got a lot of money on the line, so to speak. So getting back to my original point of, you know, boot camps are expensive. Yes, but that's why we have a lot of financing options available. If you live in the US right now. And you're listening to this and you have decent credit. There's tons of financing options available, so much so that you might even be able to do the Bootcamp for $0 and you don't pay until after you have graduated. Okay, maybe even three months after you graduated from the boot camp. So think about that. You can literally pay nothing now. And then you don't pay until after you graduate and once you have employment which

        45:00

        Most of our coders that graduate have a job within a month or two, I think 80% Get a job within the first month or two after the bootcamp. Okay, it's a six month bootcamp. So if you if you're someone that we don't see this a lot, because normally the people who are most interested in taking this career track, maybe don't have the greatest credit, because they've been working in a job that doesn't pay them, well, they haven't been able to pay all their bills, and they, there are some collections, and there are some issues with their credit. But hey, if you're someone who has decent credit, you know, decent being, you know, above 650 credit score, you could probably get approved for $0, down to go into the bootcamp. Right. So then that's not an excuse anymore, you don't have the excuse of I can't afford it. You can't afford $0. So then it's just a matter of you don't believe that it's worth it. You don't believe that this can be done?

        45:48

        And I would say that if you come at it with that attitude, then you're probably right. Right? The beliefs that we hold, tend to become reality with time, right? If we truly believe that we are incapable, then guess what's going to happen?

        46:06

        Right. But if we truly believe that we can do something, guess what's going to happen?

        46:12

        Right? There's a very popular quote, I forget who it was it said it. It's whether whether you believe you can or whether you believe you cannot. You're correct.

        46:22

        Okay, I forget, I should know who that is. I think I was like, I think Henry Ford is the one who's quoted as saying, and I forget if it's Henry Ford, but it's very true. Mindset is so important, which is one of the main aspects inside the boot camp, this reassurance that you can do it, this reassurance that I've seen it hundreds of times, if not 1000s of times before, what you're going through right now. I've seen that play out time and time again. And all it takes is to realize, Oh, I'm not alone. Okay, I'm not stupid. Oh, I'm not an idiot. Oh, this is very hard. And oh, all I need to do is just stick to it and listen to my mentor, listen to Trevor, listen to his staff, follow the curriculum, do the proven system that leads to the amazing outcome of getting a job as a coder. Right? So anyway, there's plenty of options in terms of financing. Again, if you have decent credit, and you are someone who lives in the US lots of options. If you're in Canada or the UK, we do have options for something called an income share agreement, our income share agreement, if you've heard about that before, and you have a lot of negative connotations in your mind. Our income share agreement is not a pret a predatory practice. Okay, there's a lot of predatory income share agreements out there that take a huge chunk of your paycheck, some take up like 50% of your paycheck every month to pay, but it's just ridiculous. So ours is like 9.8%. So anyway, there's an income share agreement whereby you put some money down before the bootcamp is not $0. But you do put some money down before the boot camp, usually, it's like 10 to 20% of the cost. And then that the first all the rest until after you graduated. And once you have a job, right, so there are those options to these become very affordable as well, in contrast to paying off the entire balance of the bootcamp upfront. So just to let you know, just to sort of SWAT down some of the objections that you might have in your head, it is possible, okay, it's very possible to afford it, it's very possible to get into it. It does cost money, yes. Because this is the most intensive

        48:28

        program that you're ever going to enroll into with respect to achieving your goal of getting a job as a coder. So if you want to get a job as a coder,

        48:38

        I'm obviously a big believer in boot camps in general now, because I've been doing this for 10 years, and I see that the boot camps are the most effective way, and the fastest. And believe it or not the cheapest way to get a job call back to another episode I've done on explaining the financials, of being self taught versus boot camp versus going to school, the post secondary through university or college, whatever. Boot Camps are actually the cheapest. When you look at the data and laid out in front of you, on average, boot camps are the cheapest route. So there's no excuse. The only excuse in the book, in my opinion is if you don't live inside of you know, US, Canada, UK, or some you know, quote, unquote, wealthy country, if you are in a country that is not wealthy, that is unfortunate. I don't have a financial solution for you. I'm so sorry. I wish there was a way that I can literally help every human being on planet Earth. But the the economics of it just don't work. If you don't live inside of a quote, unquote, you know, wealthy country, you know, somewhere in Europe or you know, North America,

        49:43

        or Australia or something like that. It just unfortunately doesn't work financially. So, for that there are online courses, and then you have to force yourself to be one of those 5% I'm so sorry. If you're outside of the wealthy countries, I just haven't found a way to solve that problem yet. Hey, good business.

        50:00

        unity there, if anyone's listening who wants to solve that problem, I'm all ears. I've been trying to solve that figure out a way to solve that problem for like a decade. Let me know if you have any solutions. Anyway, I'm rambling. That is the college campus boot camp, I probably should have said a long time ago where to go to get it, coders campus.com/bootcamp, you can apply to see if you meet our criteria to enroll. Because we are looking for people who have a little bit of prior experience. If you're listening to this podcast, you're probably good.

        50:31

        But yeah, you may need some prior coding experience, you do need some decent credit, if you're looking for financing if you don't have decent credit, but you can pay for all upfront Great, then you no problem there. If you

        50:45

        are not looking to get a job, then you might not qualify for financing. Because the whole usually the whole financing thing is based off of getting a job. So if you don't want to get a job as a coder, might not be a good fit. But hey, you might as well still apply to see if you get through. We have the whole point is to apply coderscampus.com/bootcamp applied to the boot camp and book call with one of our admissions advisors to have a chat and like I said, make sure that you're a good fit. That's what that call is about. We're going to talk about the boot camp, the specifics of it all the inner workings, we're going to figure out what the best way forward is for you. On this call, we're going to give you the plan the curriculum, we're going to show you the path. And if you want to take that journey with us in the boot camp, and you meet our qualifications. Great, we're happy to accept you into the boot camp and get started. Like I said, we have new ones starting every single month. If you don't meet our criteria, it might just be because you need to brush up on your fundamentals, in which case, we will send you to one of our free courses. You can do the free course once you've completed it, let us know we'll have a look at your code. And then guess what you can get entry into the next boot camp. So

        51:57

        sound good coderscampus.com/bootcamp. Looking forward to seeing you there. Thank you so much for listening to me talk through all this. If you're still listening, you are incredible, I love you. I can't wait to continue to bring out these episodes, and hopefully Hey, even to see you potentially in the boot camp. But just listening to this is an amazing form of support. And I'm very grateful to have your ears for this conversation right now. And I look forward to the next conversation where we will hopefully be diving into streams. I don't see why we wouldn't be diving into streams in the next episode, but you never know what the future holds. So I'm going to assume that we'll talk about streams next. And I can't wait to see you there. So take care of yourself as always happy learning. And bye for now. Thanks for listening to this episode of the coders campus podcast. But before you go, Trevor has a favorite ask you. In order to keep these episodes free, he'd love for you to leave a rating and review the podcast on iTunes. Just go to coaters campus.com/review to leave your own rating and review of the show. So if you have 30 seconds to spare right now, please help out by leaving a rating and review via coders campus.com/review It will ensure that you continue to get these awesome free podcast episodes each and every week. So if you like free swag, head on over to coders campus.com/review Happy Learning

         

        The post EP52 – Most Common Functional Interfaces in Java appeared first on Coders Campus.

        54 min
      • EP51 – Let’s Talk Lambdas in Java

        In this episode we'll talk about a super useful feature that was introduced back in Java version 8, known as Lambdas.

        The Lambda feature is something you didn't know you desperately wanted or needed until you understood it.

        The Lambda syntax allows you to write much cleaner and more readable code, while also empowering you to get more done with less code.

        In this lecture, I'll be referring to some code that you can download via this github repository.

        Episode Transcript

        0:00

        Hey fellow coder before we rolled into the episode today this one is sponsored by brought to you by the Coders Campus Bootcamp. If you haven't already checked it out, you can check it out via coders campus.com forward slash boot camp. So if you're looking to get a job as a coder, and you've been struggling to achieve that on your own, you are struggling to learn how to code on your own. You're not alone. And that's what that's why these boot camps are so popular. So we'll talk more about that at the end of this episode. But yeah, please do check it out coderscampus.com/bootcamp, you can apply to see if you'd be a good fit. So having said that, let's roll into today's content

        0:48

        Welcome to the coders campus podcast, where you'll learn how to code from one of the best teachers in the industry. Whether you're an absolute beginner or a seasoned pro, the coders campus podcast will teach you what you need to know to master the art of programming.

        1:03

        And now, your host, Trevor page.

        1:07

        Ladies and gentlemen, boys and girls, children of all ages. Welcome back to this 51st episode, I think of the coders campus podcast. Thank you so much for joining always a pleasure to be here in the hot seat and bringing you the important information curated by none other than the No. Okay, so let's focus. So yeah, welcome to the podcast. Great to be back. And I want to kick things off by talking about sort of what I alluded to in a past episode, I forget when I alluded to it. But yeah, I want to get to talking about streams eventually. But before I can talk about streams, I want to talk about lambdas. So today's episode is always good, it's going to be I should say always going to be the full episode will be about lambdas and lambda expressions and lambda, this lambda that you will be by the end of this episode, a lambda expert. So let's dive right in to it. I'll open up my notes here. So I guess the first thing we can start off with is what the heck is a lambda? Why is Trevor talking about this subject? When is it used? Why is it important? Why should I know about it, that kind of thing. So we'll start off by obviously talking about what a lambda is. So it's essentially a syntax that is used to cut down on the code that you have to write essentially, reduce the verbosity is the professional term, if you will reduce the verbosity of the code. So what that means is, you'll have to write less code in order to do the same thing. Okay, that's really, you know, there's a lot more than it can do. But that's, I mean, you know, fundamentally, why would you choose to use a lambda over not a lambda, it's, it's really to reduce the verbosity of the code. And that should tend to lead to more readability case, your code becomes shorter, more succinct, and more readable. Now, the it's a double edged sword. Because when you do this, when you reduce the verbosity, when you abstract away some details, when you hide the inner workings of what's happening through shorter code, although it's more readable, it's only readable if you understand it. So what this this tends to lead to is more confusion if you do not understand it, hence, me talking about lambdas. Today in this podcast episode, so lambdas are very powerful. They were a feature that was added to the Java language as a version eight. So Java, version eight at the time of this recording, is, you know, one of the most, if not the most popular version of Java being used out in the wild. And no, some you know, there's no surprise there's there's a big correlation between lambdas being introduced in version eight and version eights, popularity, lambdas, and streams were very well received, and in my opinion, are great, I absolutely love them. So important to learn about. Now beyond reducing the verbosity of the code with respect to using lambdas. Beyond that, we also it allows us to treat

        4:25

        functions, kind of like parameters, kind of like you do in in the world of JavaScript with JavaScript, you can pass functions around as parameters if you don't know JavaScript. And I guess that's not very helpful to you. But if you do know JavaScript, and you've done this before, then great. You can sort of think of lambdas sort of unlocking this functionality, if you will, of being able to pass a function around inside of the method signature.

        4:52

        So yeah, it allows us to treat methods like parameters, sort of, so

        4:57

        basically, get the way to think about this

        5:00

        is in my mind is to look at how we had to do it the old way. And and what we had to do in the pains and whatnot of what we had to do the old way before version eight. And then we can look at what the new way is with respect to lambdas. And, and whatnot. So I do have some code. And I will try to, I guess I'm gonna have to put the code in some show notes for this episode, so that you guys can load it up and look at it. Again, I'm tasked with trying to explain code, verbally, without you guys seeing the code in front of your eyes, which is always as I say, a very difficult task. But if you are not driving, and you're able to, you can go to I guess I'll put it up coderscampus.com/51. As this is Episode 51, you can go there and bring up the show notes. And you'll be able to see an example of what I'm doing. I'm also going to post this or I have already posted this as a GitHub repository. So you can also not just see it on the blog, but download it and play with it. Because that's what all the cool kids are doing these days. So

        6:07

        yes, having said that, let's dive into sort of the code. So the old way of I won't say the old way of using lambdas. But in that's not correct. There were no lamb lambdas in the olden days before Java eight. So how did you do this? How did you work? You know, with these things? Well, basically, what ended up ends up being is you are working with interfaces, and you're trying to

        6:33

        utilize or use an interface by sort of instantiating it. So when you try to instantiate an interface, if you have done your homework, you know that that's really kind of not possible, you cannot instantiate an interface, you can only instantiate a concrete class, right? So you can only instantiate a class. So how can you get around this? How do you get around

        6:56

        the whole you can't instantiate an interface, but yet you kind of can instantiate an interface.

        7:03

        It's done through essentially

        7:07

        instantiating the interface and overriding it. So in other words, you are implementing it right there. And then inside of the code. So an example of this, you probably swatch. And so you probably seen, if you worked prior to Java eight, you will have seen this through the syntax of when you say a new interface. So if you tried to list like a list, or a map, or whatever, and you say new list, and try to instantiate a new list, list interface, or map is an interface, those are not concrete classes, so you can't instantiate them. But what you will see is, if you say new list or new map,

        7:44

        and then you try to, you know complete it, what it's going to do is it's going to open up a body of code, it's going to open up curly brackets. And it's going to force you to override each and every one of the well abstract methods inside of the interface, right? Because that's all an interface is made up of, if you want a quick review of what an interface is an interface is made up of public abstract classes, or sorry, public abstract methods, not classes methods. So an interface is made up of public abstract methods. And what does that mean? What is a public abstract method? It's just a method that has no body. Okay? It has nobody has nobody to turn to terrible joke, I'm sorry. There's no body of the code. So basically, what's happening here is when you try to instantiate an interface, it says, Fine, I don't know what you're doing. I don't know why you're trying to instantiate this interface, you can't do that. So here's the workaround, I'm going to force you to override and create the body of every single abstract method for me, because that's the only way you can use an interface, right? You have to give it behavior, you have to override the code and give it a body. And this is usually done. In a separate class, you have a concrete class that implements the interface, right? You have a class implements the interface, and that class is overriding every one of the methods for that given interface. And you'd have it all in one neat place in one class file. Well, when you do it on the fly, if you're doing it in line, if you will, if you're saying, you know, some if you say list, my list equals new list, it's going to say, Oh, well, we're not going to put this in a different class file. We're just going to make you do it right here in inline in the code right now, next to the new keyword right next to the new list, parentheses, whatever, then it's going to force you to create a body and override everything. So anyway, that's sort of what we had to do in the in the olden days. We would be forced to if you wanted to try to instantiate interface, we'd be forced to override everything and give everything behavior and whatnot. Right there. And then so

        10:00

        So and that's sort of what this code that I have, that you can look at, that's what it's doing. So I have some code called non lambda example. It's just a class. That's called non lambda example, a very non creative name. And the, that class has a method and the method is called add strings. Now, this is not a very real world example, I apologize for that I was trying to make some sort of perfect example. And I don't have all the time in the world on my hands. So I settled on just taking a regular example that you find on the internet, I know, that's not the greatest thing in the world, but I will do my very best to, to give you as much detail around that as possible to make it make sense. So for whatever reason, we have a class, it's called non lambda lambda example, that maybe this could be considered a string, utility class, we'll call it string utils. Right? We can't call it that, because that's being used, but let's just say it's a string utility class. So it gives you some sort of methods that are useful, you know, with respect to strings, okay, allows you to do stuff with strings. That's what this class does. And as part of this class that we're talking about, that does stuff with strings as utilities class,

        11:09

        it has a method called add strings. Okay, so what add strings does is it allows you to add together a couple of strings. So in other words, concatenate strings together, again, not a very real world thing, because we already have a method to concatenate strings, it's just a bloody plus symbol that we can put between two strings. Anyway,

        11:31

        how do we do this? How do we have if we have a method that add strings together,

        11:37

        and let's say we have an interface that allows us to add strings together, this, you know, method could just use that interface, and we can instantiate the interface and make use of it right there. And then, like I said, the side effect is, it's going to force you to override all of the methods of the interface. Okay. So if you can imagine, you know, there's some interface called, you know, I don't know, it's called non lambda interface in my code, but really, we could call it the, you know, string utilities interface or something.

        12:12

        And this string utilities interface has a method within it called add strings together, and it allows you to pass in two strings. And what that does is it will take in two strings and return a string back. So it takes in two strings, string one, string two, and it outputs a single string. Okay, so what is the point of this write it? Well, like I said, it concatenate strings together. And that's just the purpose of this particular interfaces method where the method is called add strings together. Again, it's not very functional, but hey, it's, it just puts a space between two strings, great, fine, whatever. Well, how do you how do you use that, then? Well, you need to, you know, in line instantiate and, and define a body for this non lambda interface, or the string interface or whatever, with this add strings together method, you'd have to implement it by returning the string one and string two with a space together. And then you need to take that interface that you quote, unquote, instantiated and invoke that method, add strings together, and you pass it string one and string two. Right? That's sort of how you would do it, if you did not have lambdas. Now, that was a lot of talking, right? That was a lot of talking to try to describe this. And if it sounded convoluted, and weird, it's because it is, it's convoluted and weird. It is an old way of of trying to

        13:38

        perform an operation of like instantiating an interface, essentially, right? Again, you can't instantiate an interface. But you can get around that by implementing it in line implementing all of the the methods within that interface. And the result of that is that you get a big long block of code that's quite ugly, and whatnot. And it's not very, not very readable. And it's, it's verbose, right? That's the whole point here. So how can we make our lives easier, right? Well, that's where the lambdas come in, right? We have these things called lambdas. And they work alongside this concept called functional interface. So there's an annotation called functional interface. And in my mind, I, I take a functional interface and the concept of lambda and I mash them together in my head, because that's really a funk. You can't use a lambda without a functional interface. Okay? So keep those that sort of, again, take that for what it's worth. It's stored in your brain the same way if you like, but like I said, Before, you can actually use lambdas. Before you can actually write out the lambda syntax, which is less verbose than the syntax that I just tried to explain to you without lambdas in order to use that code, that syntax the less verbose syntax

        15:00

        You need a functional interface? So, okay, what the heck is a functional interface? And why do I need that? Well, a functional interface is the word comes from functional coding functional programming. Okay, functional programming is very much, you know, if you have inputs, or I should say when you have inputs that go into a method for a method signature, you have inputs, for any input that you give it, the output will always be the same, meaning, if you have an interface a functional or functional code, I should say, if you have some sort of functional code, functional programming code with an input that takes an integer, if you pass in the number one, you're going to get a result. Okay, let's say that this particular functional code, the way the way it's written, the method that we're invoking is the, you know, the squared method. So it should take an input of a no a single number, a whole number, an integer, and it should square that number and give that as the result. So that means that when you pass in the number one, to this functional code, this functional method or whatever,

        16:13

        you'll always get one as the output. And if you pass in to what is two squared was two, or Yeah, two squared is four. So every time you pass in two, you're always gonna get four, right out, if you pass in three, you're gonna get nine, if you pass in for you're gonna get 16 525, you know, 636, oh, my God, I'm going back to math class, you know, 749, how high can I go 864 981 10 111 121 12 144 13. And that's where my brain stops. So that's as much as much of the squared,

        16:48

        which call it a multiplication table that I've memorized. So anyway, the point is, whatever number you put in, a result will come out. And that result should never change based on the inputs. So you'll never get a situation where you pass into three, and you get 10. Out, it will always be nine, because three times three, three squared is always nine. That is sort of what functional code is all about, right? predictability? No, there's no

        17:20

        side effects that happen. There's no weird situation that if this one situation plays out around this method, and the methods output will change, right? In other words, that's, that's called a side effect. If, if there's a side effect, something weird happened, and then boom, the output is not what you expected. output changes. That's not good. That's, that's not a very stable environment to working in. And that's, that can happen with with a Java language, we can have side effects, right, we can have, you know, inputs, the same inputs can produce different outputs for a given method, if it's not a sort of functional programming style. So at least again, that's what's that's how I think of it in my brain. I'm sure there's a lot more to it. But hey, I'm trying to be as as straightforward as possible here. So does that make sense? functional code means in the same inputs will are the inputs that you put in will always give the same outputs for each given input. So one will get one two will get four should never change. That's the functional lens, if you will, with respect to programming. So what is a functional interface? Well, it's an interface that provides functional code coding in the functional style. Make sense? So when we have a functional interface that provides well being an interface write an interface means it has abstract methods, public abstract methods,

        18:46

        which all interfaces have, but there is a specific requirement for a functional interface, which is that there can be only one public abstract method in the interface. That's it. You get one ladies, gentlemen. So that's sort of the the behavior that is the stipulation the specification for a functional interface. In the world of Java, you have one and only one public abstract method. Now you can do more than just a public abstract method. You can have default methods. I think we've talked about default methods in terms of Java eight, introducing the default keyword.

        19:29

        Anyway, let's let's stick to the basics, though. Have you have one public abstract method, and that is it. Okay. So in my code that I've introduced here, I've given you an example of I just called the call it the lambda interface. And again, these naming conventions just to show that one is lambda one is non lambda. But really, if I were to name this properly, this lambda interface might be called something closer to

        20:00

        Yeah, the string utility interface, right? Or maybe functional string utility interface, or I guess you wouldn't call it functional. That's, that's not true. That's, that's a bad convention. I would just call it string utility interface or string utilities or whatever. You annotate it with the functional interface annotation at the class level, or at the isn't, that's not the right term. Because it's not a class, what would you call that? I always call it class level. Interesting. at the root level, what anyway, again, you'll it's at the top, it's right before the declaration of the interface. So at the interface declaration level, anyway, you use functional interface, it comes from Java, as part of the what java lang. So it's very, it's built right into Java lang, which is like the root, you know, package, if you will. So we have we declared as a functional interface. And all that does is it enforces the single public abstract method.

        20:57

        requirement. If I right now I'm typing in another piece of code, I'll type in like, you know, add another string or something, and I'll have another,

        21:08

        you know, method, the public abstract method. As soon as I do that, when I have the functional interface annotation declared in here, it gives me a compilation error. So the interface goes red, and it says, Hey, invalid functional interface, annotation. lammed interface is not a functional interface. In other words, because I've added a second public abstract method, it is complaining, so I delete, you can't see me delete it, but I've deleted it. And now it's back to just having one method in there. And now it's happy again. So that's what functional interface, the functional interface annotation gives to us is sort of a compile time check to make sure that we are adhering to that single, abstract method requirements. So having said that, why is this why is this helpful? How is this all this stuff that I've talked about, about functional coding and functional interfaces? And one single abstract method? How is this going to help our code be more readable? Well, that's where the concept of a lambda actually comes in lambda expressions or whatnot. So inside of our interface, we have a single method, and we call it add strings together, just like what we called it in our other interface that was the non lambda interface, we had an add strings together interface, or sorry, add strings together method inside of a interface. So in terms of how, what the interfaces look like, they look identical, okay, the the non lambda interface versus the lambda interface, the code is identical, except for the the lambda interface has that one extra

        22:41

        annotation called the functional

        22:44

        functional interface annotation. So in the interface level, nothing changes other than that annotation,

        22:52

        and the rules that come with it. Now, what does the the rest of the code look like? Right? What is my example code look like when I want to use the functional interface.

        23:03

        And this is, again, the I don't say, once again, this is the first time I'm saying this.

        23:09

        The code that I've written that I'm sharing with you, and that I'm talking about right now, is probably not code that you're ever going to actually write. In the real world, at least most of it you won't write, generally speaking in the real world out there in the wild, you do not create your own functional interfaces. Okay, the purpose of this episode, and the purpose of the this exercise, if you will, that we're going through, is so that you get a fundamental understanding of how the inner workings of a functional interface actually works actually functions, for lack of a better term. But just so you know, the caveat here is that you probably won't ever create a functional interface. I mean, you might, but you probably won't, because Java provides a bunch of functional interfaces for us. And we will get into what those are. And the common ones that you'll see out in the wild, we'll get there in in a little bit. Well, how long has this episode been? Do I need to split this up into two? Oh, my God, it's already close to half an hour. So maybe we might talk about that in this one, we might push it to the next one. So just keep that in mind. But for now, I want to teach you how to create your own functional interface and then use it right cuz that's what this is all about. So, in our lambda example, class, we had a non lambda example class where I talked about having the add, you know, add strings. Method, which instantiated quote unquote, instantiated the interface, which forced us to override it and do all the body so everything I talked about already, and then actually invoking it, and using, you know, the stuff that we had to override everything. That was the old way. So the new way, how do we use it? Well, we same kind of start, we say lambda interface, right? So we declare, we declare a variable, the type of the variable that we're declaring is going to be lambda initial

        25:00

        phase, which is the interface that we created. Again, a better name for this would have been string utilities or something.

        25:06

        But we're trying to be lambda forward here. So I called it the lambda interface as the type. And then you declare a variable name, the variable name can be whatever you like. It's just a variable name. I chose functional interface as the variable name. Sure, fine. So we have a functional interface variable with the type lambda interface. Okay, which is an interface, it's not a concrete class. So therefore, we can't instantiate this right? What do we do? Well, we can set it equal to

        25:38

        a lambda expression.

        25:40

        Okay, I don't even know if that's the right term, I think lambda expression refers to the stuff on the right of the lambda, I don't know what the word is to represent the entire thing. But

        25:49

        basically, instead of having to declare a big body, you know, having the curly bracket with a new keywords a new lambda interface, and then having a curly bracket to open the body, and then overriding the single method inside of it with functionality and saying, all that stuff doesn't have to happen.

        26:09

        We take all that stuff, and we boil it down into two things, I guess, sort of three things. But the third thing is simple. Two things, two parts. Okay, and this is where the verbosity goes away, then this is what I'm about to talk about. This is the syntax involved with the utilization of lambdas. Okay, so this is what this is where the rubber meets the road, ladies and gentlemen. So

        26:35

        we will, we will use this lambda

        26:39

        syntax to assign functionality to our lambda interface type that we're this variable that we're creating, okay. So

        26:51

        because the functional interface, or the lambda interface only has one method inside of it, by design, it can only have one public abstract method.

        27:02

        Java knows what the method signature is for that single public abstract method. It knows it already. Okay, it's too we have to we had two inputs for this one. So to go back to it just because you're not staring at the code in front of you. The lambda interface method that we created, the public abstract method was called add strings together. So add strings together with the lambda interfaces method. And the add strings together method has two inputs, s one and s two, which is strings. One, S S, one is a string, and S two is a string. In other words, add these two strings together concatenate these two strings. So probably a better way a better name for this function or method would have been, not add strings together, but rather concatenate strings together. But anyway,

        27:52

        I this is this is the code that I've written ladies and gentlemen, this is what we're dealing with. So it has two inputs, two strings, and one output one string as the output. Okay, that's what the method is declared, there's no body in it. Because it's an abstract method. abstract methods don't have bodies, it's just a method signature, takes two strings in one string out, okay, that's what this adds strings together. thing does. And because it's a functional interface, because we've declared it as a functional interface, Java can do some fun stuff with that. In other words, it can abstract away some, some syntax and some details here.

        28:30

        So because we know

        28:33

        the method that is the functional method, the you know, the single abstract method, we know the specifics of it, we know the the method signature for it.

        28:43

        There's, like I said, there's two parts that kind of are three parts, but there's two parts to the syntax, there is everything to the left of the arrow, and everything to the right of the arrow. Okay, the arrow is the third thing. So the arrow is the syntax that you look for, that's the smell, that's the indication that we're using a lambda. So in the world of Java, the new syntax is this arrow, which is the minus sign followed by the greater than symbol, which looks like an arrow, an arrow pointing to the right, minus greater than picture that in your brain right now I'll take a sip of water.

        29:22

        Minus greater than symbol, that is the signature of the lambda that a signature meeting the telltale sign that we're using a lambda. Okay, if you have any experience with JavaScript, you might be saying, Wait, does that have anything to do with the fat arrow syntax in JavaScript where you have the equal sign with the greater than so? Yes, okay, that's it was blatantly stolen from JavaScript. Ladies and gentlemen, this is the world that we live in. It's cutthroat. We steal code, we steal functionality and make a small tweak and say that it's all brand new. So anyway,

        29:58

        it is a minus sign with a

        30:00

        have greater than next to it. So that's the arrow. And that's the third thing. So there's everything to the left of the arrow, and there's everything to the right of the arrow is what we're dealing with. To the left of the arrow is the method signature. So this method signature, if you were to type it out, you would, you would just have

        30:19

        just the, I should say, just the parameters of the method signature. So we don't even need the name of the method here, we don't need the return type, we don't need the name, we don't need anything other than the parameters. So a better way for me to say that is, the stuff to the left of the arrow is just the parameters, the list of parameters, and you can type it in as string s one comma string s two, if you wanted to, because that is literally if you caught if you went into the declaration of the method, and you looked at the parameters for the method in the functional interface, that is exactly what is written copy, paste, it's the round bracket, string s, one comma string s to close round bracket, that is the list of parameters, you know, surrounded by the round brackets, the parentheses, parenthesis, parentheses, whatever.

        31:13

        That's everything to the left of the arrow. Okay? Now, because we can want, we can also be even less verbose. And because we know that this is a functional interface, and because we know there's only one public abstract method, because we know the method signature already, I say we Java knows the method signature already, it knows the parameters, it knows the types, so we don't actually have to write in the types either, we can literally just write round bracket, S, one comma s two, round bracket.

        31:45

        And believe it or not, we don't even have to call it s one and s two, if we don't want to, that's what we called the variable names of the inputs in the function in the interface, right in a lambda interface. That's what we call them. But we don't have to call them that we call it a one and a two or x one and x two, or X and Y or whatever, dog poop one and dog poop two, right? So that's, we can name it whatever we want. So for this one, I just kept it consistent with s one and S two. But just so you know, you can call it whatever you want. Now, everything to the right of the arrow is where things get pretty cool. So we have a few choices here to the right of the arrow to the right of the arrow is essentially the body that you are going to give to it right everything to the right of the arrow is what we have declared and written already in the non lamda example. In the non lambda example, we had to remember open up the body and the curly brackets, we said new you know interface with open up the brackets, and then we had to override the method. And then inside the method, that method had a body to it. This is the body that we're talking about. So we can take what's inside that body, the curly brackets inside the body that so the curly brackets and there was a return statement, saying return s one plus a space plus s two.

        33:05

        Right? That's what this does it concatenate two strings together with a space between them as one plus a blank space meaning double quote with the space double quote, plus s two, that's how you concatenate was one way to concatenate two strings together with a space in the middle s one plus space plus s two. Okay. So if you just look at the body there, it's curly brackets with a return statement returning that s one plus space plus s two.

        33:33

        So you can just copy paste that body into the right side of the arrow.

        33:40

        Syntax. Okay. And then you're good. That's that's pretty much it. But

        33:47

        there's more.

        33:49

        Because we are returning something and because most times, in the bodies of methods, we're returning something, there's a special shortcut to make this process even less verbose. You can get rid of the body indicators, the body, the curly brackets, the opening and closing curly brackets, get rid of them.

        34:10

        And you can get rid of the return statement, the return I should say the recruiting return keyword, just that return keyword and just have everything to the right of the return be copy pasted it to the right of the arrow. So in other words,

        34:25

        your lambda interface, which I called the variable name, functional interface equals right when you're setting when you're, you know, in the old way, we had to say lambda interface or whatever the other interface is, you know, string, let's call it string utilities, you know, is the interface name and then we call it string. utils is the variable equals something and we had to say equals new in the old way, string utilities and then overriding all that stuff and all that complex stuff.

        34:50

        With this new way, we can say you know, your string utilities, you know, string utilities, whatever equals, in this case, again, it's not string utilities. It's lambda interface, but

        35:00

        Anyway, trying to connect it to the real world a little bit here, the equals everything to the right of the equals is just

        35:07

        open round bracket s one comma s two, right, which is sort of the variables, the inputs, without without the variable types, s one comma s two, it knows that these two things are strings already, we don't have to specify their strings, we can just surround them s s one comma s two, we can surround it in parentheses, put the arrow my assign greater than symbol. And then to the right, we just type in S one plus space plus s two semicolon.

        35:36

        Okay, so it's literally one line of code. I know, there's a lot of talking there. But there's a lot of teaching too, is literally to to declare the interface and to declare the functionality of the body of the interface is all done within one line of code.

        35:51

        So we've taken this interface. And we've kind of instantiated that we've kind of set it equal to something and given it behavior, we've given it the behavior of taking a string as first string as an input and taking a second string as an input and concatenating them together with a space. Okay, that's the functionality that we've defined, we've defined this method. Now, this method technically has a body. But it's still just a method, we haven't invoked the method yet. It's just there. And it could be used if you wanted to use it.

        36:25

        So now in order to use it, you need to say your, you know, variable name, which I named it functional interface. So again, probably could have chosen a better name, but hey, functional interfaces, dot and if you remember the name of the functional interfaces, single public abstract method, do you remember the name probably not, it was called add strings together is my an imaginative name for it. So you do functional interface dot add string together. And what it expects is two inputs, two strings, so you just type in the two strings, right? But whatever two strings you want, that you want to have concatenated together with with a space, and voila, you're off to the races. So in other words, you know, probably, you know, five or six lines of code go goes down to essentially two lines of code. Right?

        37:11

        Cool, fine, great. Grand, why? Why do I care? Why is this? You know, we went through all this, it's been how many minutes now that I've been talking 36 minutes, 36 and a half minutes?

        37:23

        Why is this important to talk about. And to understand? Well, lambdas with the land, when I say lambda, you can think arrow syntax, you know, the arrow syntax of minus sign with a greater than symbol, you know, method parameters in the left body on the right, if you don't have parentheses, if you don't have curly brackets, then it's assumed to be a return statement is gonna be returning the stuff, if you don't want it to return something, or if there's more logic you want to put into it, then you declare the squiggly brackets to actually give it a body explicitly give it some sort of body functionality. But anyway.

        38:02

        lambdas, as I just described them, are used as a part of a bunch of different things now in in Java, any sort of functional programming that you can do in Java. Now, as of Java eight and beyond? They all make use of lambdas. Okay, because there's properties to these lambdas that enforce functional behavior, one of which is anything you use on the right hand side of the arrow has to be final, or it is it is in what's implicitly, yeah, it's implicitly final, which means you don't explicitly declare these variables that you use on the right hand side as final. You don't explicitly declare them as final, there's no explicit writing of the word final in there. But if you try to

        38:55

        or reassign any of the values of the variables on the right hand side of the of the syntax or whatever, inside of the quote, unquote, body of the lambda expression, if you try to do any sort of non final behavior in the right hand side, it's going to give you a compilation error. I guess remember, we can't have side effects here.

        39:18

        Okay, what comes in whatever you know, inputs come come in. Whatever inputs you give in there should be a dependable and expected output for each input. Again, pass in one get one out, pass and to get 4395. Or sorry, 416 525. Right? If we're talking about squaring something, right, if the if the method in the functional interface was called squaring integers or something,

        39:47

        the behavior and the output should be dependable and expected. So one way to enforce that is to make sure that all your variables that you're dealing with are final

        39:59

        so that

        40:00

        That's a little property a little, a little side effect of using functional interfaces pun intended, is that your variables are final, and that can come up and bite you in the butt. Sometimes you'll be using, you know, lambdas inside of a functional interface or whatever.

        40:16

        And

        40:17

        you try to do something where you reassign a variable, and it says, Nope, you can't do that. It's final. And it's like, Oh, that's right, I can't have to think in a functional way here. So that is one thing that you need to be cognizant of be aware of. When you're dealing with lambdas, the stuff on the right is effectively final, the variables are effectively final. So the variables, by the way, are the stuff on the on the left hand side, the inputs to the function, that you are working with the inputs to the lambda expression on the right, the inputs come from the left, okay, and then they are later, you know, injected via using the actual interface itself. So anyway, we'll get there, we'll get to more examples to make that a lot more crystal clear. I, as I'm explaining it, I can tell it's not that part is not clear, there's a lot more to this.

        41:06

        So but what you need to take away right now from this talk, is that there is a way to define the behavior of the body of interfaces, interface methods, okay, there's a way to define behavior of interfaces methods,

        41:28

        such that you it can be done in a non verbose way. So in a non verbose way, you can define the body functionality of interface methods.

        41:41

        So prior to Java eight, that just there just was not any simple way to do this, there was not any non verbose way to do this. So that

        41:51

        the big The other thing to say here is you don't have to use lambdas. Right? You don't have to, you don't have to make use of any of the new fancy, you know, shiny methods, and you know, utility classes and stream, you don't have to make use of any of this stuff, if you don't want to, because all the stuff can be done. Without the Java eight stuff, at least as far as I know, you can do all of it without Java eight, you can do all, you know, everything you could do in Java seven, you can continue to do it that way that you could do it, you know, you can continue to do it the way you always did it, right. It's just this newer way is just a little bit more readable. This is less verbose, it's, it's a little sexier. Right? That's, that's one of the jobs that people take at Java, it's, oh, it's such a verbose language. Well, you know, little by little, they're cutting down on a lot of that stuff. Now, again, the side effect of that is, again, pun intended.

        42:46

        You're hiding details, you're abstracting away the details, as you become less verbose as you type have to type in less code, more and more is hidden under the covers, more and more is required of you to understand

        43:01

        explicitly understand what's going on under the covers for you to be able to use this with confidence, right? Because if you didn't know what lambdas were, and you just saw this syntax with these arrows, like this is arrow all of a sudden, and what looks like potentially the parameters of a method, but I don't see any types. And it's like, we have to know what the types are by knowing that it's coming from the interface, the single method of the interface and had to look at that interfaces and look at the type and like, it could be a generic type. And we haven't talked about that yet. And so there's a lot of stuff that you need to understand about lambdas before you can feel comfortable reading them and understanding them and using them. Otherwise, it's a bunch of guessing going on. So while Java gets a bad rap for being verbose, it's also believe it or not, it's helpful from a learner's perspective, when you're fairly new to programming. Having a verbose language is helpful, because you can see all the details in front of you. I don't want to say nothing is hidden, but a lot of stuff is in front of you, and not very much is hidden in the world of Java. So pros and cons. So there you go. That's, that's

        44:08

        I don't wanna say in a nutshell, because I took a while to explain. That's the your first

        44:14

        soiree into utilizing

        44:18

        lambdas. And the syntax behind them. And what I haven't talked about is, there are again, in the real world, you don't really create your own functional interfaces, there's already a bunch of functional interfaces that you can read, reach out and use, and that should,

        44:38

        you know, solve pretty much all your problems that will ever come up to solve all the use cases that you can think of. There are some functional interfaces that Java has provided to us that we can leverage that are, you know, utilize generics and allow us to use them in a very flexible way. The downside to that

        45:00

        It's very difficult to like, understand when you're reading just documentation and hovering over things, it gets convoluted. And we'll get there. We'll talk about that. Which is why it's important to understand what are the common functional interfaces that Java has predefined and built into Java eight, and is handing us to use and leverage? What are those common functional interfaces

        45:24

        that we can leverage? And and let you know, we should get a good understanding of them so that we feel more comfortable. If and when we run into a situation where it comes up in some documentation. And it's talking about the consumer interface functional interface or the supplier functional interface, or the unary operator functional interface or the function functional interface. You might be saying, What the heck is Trevor talking about? Exactly. I didn't know any of this either, before I actually did a deep dive and had to force myself to learn this stuff. And then I was like, oh, okay, now that sort of makes sense. Now, I can start to, you know, put some some of this stuff together and get a better understanding of how it works in the real world. So, hey, I do the struggling and I do the painful stuff of educating myself, so that you don't have to, you can get it in a nice, plain English way. So we will inevitably dive into that now in the next lesson, because there's a lot of talk about and we're already going long here. So I will stop talking there. And we can learn all about the common functional interfaces that Java has predefined and given to us in the next lesson. Now, before I go,

        46:33

        I forgot to do a pitch to you. shameful, shameful, Shameless, self promotion, maybe shameful. This is a shameful plug. Sure, why not?

        46:45

        Boot Camps, ladies and gentlemen, you heard me talking about them. I've doubled down on boot camps, because I am a believer in that system. If you haven't already heard me talk about it in the last, I don't know, five episodes.

        46:59

        I'm very bullish on boot camps. And I'm very proud of the curriculum that I built inside of the boot camp that we are running. And we're launching new cohorts every month now. So we're doing it monthly. We used to do every quarter. But now I'm getting my processes dialed down and I've hired staff. I have code reviewers, I have another instructor that's kind of like a copy of me, and who are in there in the trenches and helping out helping me out to help train the next generation of Rockstar coders. That's my goal here is to help train the next generation of coders.

        47:39

        And I do it with love, and with as much gentle kindness as I possibly can. But really, this bootcamp requires people who are dedicated now if you're already this deep into the podcast, if you if this isn't the first episode you listened to, if you're like, 50, some odd episodes deep into this, and you've been following me for years, yeah, you're probably what I'm the person I'm looking for. If you're looking to get a job, and you've been learning on your own, and you feel like you're understanding the basics, and you're understanding maybe some of the less basic stuff, the more advanced stuff, but you're still feeling very lost. Or you're just feeling like there's no way you'd be ready for the real world and an actual job in an interview situation. Or you're just feeling like you maybe you've done college and you're still struggling to get a job or, or you're thinking about changing careers or you know, whatever your situation is, if you truly want this, if you enjoy coding, if you enjoy learning, if you find learning fascinating if you find learning about coding, fascinating. And all you want to do and all you daydream about is getting a job in this field and getting the job security and all that like I want us to I want to talk to you, I want you to apply to my boot camp. If any of this is resonating with you, I want you to go and apply to boot camp, you can apply via cod erscampus.com/bootcamp.

        49:07

        In there, you'll be able to

        49:10

        find a link or a button somewhere you can say apply now and fill out an application.

        49:16

        But yeah, if you already have a little bit of knowledge, if you are driven if this is your passion, if this is something that you lose sleep over and you stay up late at night, like learning this stuff. And like I said dream, like dreaming about it like this is these are my dream students. For me. These are the people who I see succeed. I want you to go and apply. Because I'm very confident that within six months, we can be having a conversation about getting you a job and having you placed maybe within the next month or two. So total from start to finish. Maybe eight months. You're working in a job as a software engineer, okay? I don't say that lightly.

        50:00

        There are some people who say that they say, oh, you know, learn to code in three weeks and get a job. And you know, that's highly unlikely. I've been doing this for years now I know the pain and struggles that go into learning this stuff.

        50:13

        Those people are people who, you know, someone who could do it in a couple months or something, they have a lot of pre existing knowledge, a lot of training, they probably already have a degree. And we're right on the cusp of getting a job anyway, those are the people who could do it in a couple months, when you're fairly new to this and don't have much experience. If you know the basics. It takes a good six, it probably takes more than six months, but I try my best to cram as much as I can into six months. But yeah, if you have the drive, if you have the interest, and you've been sticking in there, and you've been learning this stuff and dreaming about it, I want to talk to you go to coderscampus.com/bootcamp and apply.

        50:50

        I think I could change your life. Okay, I mean that. Now, if you are someone who this is like, you know, you've been thinking about it for a month, maybe you've been working at it for a month or two. And you're like, oh, you know, this coding thing sounds interesting. And like, I probably you're probably still too too soon on the journey. If you have no experience at all. Yeah, you're way too soon, you know, you have to sign up for you know, listen to the rest of this podcast a few times or something, then maybe not a few times, but listen to the rest of this podcast before you apply. If you've been at it for a month or two,

        51:22

        you might still be too it might still be too soon for you. Unless you are unless you just have a gift. Some people are just gifted. Some people I've seen, they've been at it for a couple months, and they just get it and it clicks. And but those people are pretty rare. If you if you self identify as a very smart person, yeah, maybe after a couple months, you can apply and do well, we'll see. Either way I want to talk to you. And this is how we get to talk to each other, you can book a call to speak with me or one of my admissions advisors. And we can figure out if you're a good fit for the boot camp, right. And vice versa, if the boot camp is a good fit for you, okay, we have financing options now, so that you don't have to pay for the boot camp. Before you do it. I would highly recommend you do because you need skin in the game. But there are ways to get to the point where you can literally pay nothing. Now you need to be a US citizen and you need to have good credit and blah, blah, blah. But yeah, you can get to the point where you can literally put nothing down and take out the loan, do the whole bootcamp and then you don't start paying until after the boot camp after you've graduated. It's possible, right? You can do that. We have income share agreements, where Yeah, I'm sure if you haven't heard of income share agreements already. There, they're a little bit more convoluted than a loan. But essentially, you pay a deposit upfront, not the whole thing, maybe 20% upfront. And the rest, you don't have to pay until after the boot camp after you've graduated. And after you have employment, making a certain amount per year, etc, etc. And you pay a small percentage of your salary back to pay off the boot camp anyway, that's what an income share agreement is all about. Again, these are ways to get you in if you can't afford the tuition. Currently, as of the recording of this, the tuition is 9800 US dollars, it's a lot of money, I get it. But this is an investment. And if you are someone who looks at 90 $100, and says there's no way I will ever pay anyone that kind of money

        53:16

        to get what I want in terms of my dream, in terms of a job that's going to pay me many, many, many, many times that amount that you're investing, if you're someone who's making $30,000 a year, $40,000 a year or $50,000 a year right now, if you're making $50,000 or less per year, maybe even 60, less 60,000 or less per year, you will make back the $10,000 within one year, and then nothing but profit afterwards. Anyway.

        53:49

        That's me getting on my high horse getting upset with people saying I'm not gonna pay you $9,800 Are you crazy, that's now I'm going to go do an online course well then go do an online course. Go pay $10 for something. I just know, I've been doing this for 10 years. And I know what it takes to become a successful self taught developer with a with putting practically no money as an investment into yourself. I know how hard it is and what it's like you have to be in the top 5% of human beings to get to the point where you can pull that off. Okay. And even then you might not do it in six months or less, you'll you might it might take you a year or two. And then you might as well have just done the bootcamp because it will literally be cheaper anyway. So this is going way longer than I anticipated. Apparently I have a lot to talk about. So the bootcamp is here for you. The bootcamp is a perfect fit. If you're dying to get into the tech world and you want to be a coder and you want to have me there beside you as a mentor to guide you. You want to have daily calls with me. You want to have slack access to me and my staff. You want to get code reviews, you want to get a job guarantee. You want to achieve the goal that you're setting

        55:00

        To achieve, which is you're learning how to code so that, probably so that you can get a job date, most of my listeners are in that position, if you already have a job as a coder great. Some people I've spoken to just want to level up their skills, they're stuck in like Java five world and they want to level up like Java 11. Plus, sometimes there's a good fit with those people. But most of the people who I who are interested in in learning and learning from me right now are doing so because they want to get a job. So if you want to get a job, I have a tried and true predictable curriculum, syllabus, whatever you want to call it, and path that you can follow along with me.

        55:39

        And learn from me in all of the ways that you might be missing right now. Because there's a lot more than just learning this stuff. There's so much emotional support around, there's so much extra that's needed, at certain points of your learning journey, that you just don't get outside of a boot camp. You don't get that support. You don't get that shoulder to lean on and cry on when you are so frustrated with some random thing about coding that is just not clicking for you.

        56:09

        Right, that's what you get in these boot camps. So there's a lot there's a lot to the tuition. There's a lot to the whole program, and I'm very proud of it. And I would love for you to apply if you haven't already. So coderscampus.com/bootcamp, we'll get you in the door. Boot Camp is all one word BOTC a MP. Hopefully I'll see you applying soon. And I look forward to talking back at you in the next episode when we'll dive into the rest of this fun, functional interface stuff. So take care of yourself. Happy learning. And bye for now. Thanks for listening to this episode of the coders campus podcast. But before you go, Trevor has a favorite ask you. In order to keep these episodes free, he'd love for you to leave a rating and review the podcast on iTunes. Just go to coders campus.com/review to leave your own rating and review of the show. So if you have 30 seconds to spare right now, please help out by leaving a rating and review via coders campus.com/review It will ensure that you continue to get these awesome free podcast episodes each and every week. So if you like free swag, head on over to coders campus.com/review Happy Learning

        Transcribed by https://otter.ai

        The post EP51 – Let’s Talk Lambdas in Java appeared first on Coders Campus.

        58 min
      • EP50 – Key #3 of 3 to Getting a Job as a Coder

        In this episode we'll talk about the 3rd key to getting a job as a coder…

        How do you stand out from the crowd?

        You put in all this effort to learn how to code. You likely have a plan, you follow a curriculum, you seek help and learn. You practice and you struggle… but what about when it comes time to find a job?

        Do you have a plan for finding a job other than: “I'll apply to a bunch of openings and make sure my resume is great!”

        Most people don't. Let's talk about that.

        Episode Transcript

        All right, my fellow coders. Welcome to this next episode of the podcast. Thanks so much for joining me, as always. And today, we will be diving into as I'm sure you're well aware by now, the third key the third sort of secret that will allow you to unlock your future career, if you will. This is the the holy grail of, you know, achieving your goal of ultimately becoming a full stack paid web application developer, right? Well, we'll see what we'll get into the third sort of key that I talked about, that's important to know about to to achieve your goal of getting a job. So before I dive into the key itself, I want to sort of talk a little bit about, let's call him James, this is a real story. The names of three people have been changed to protect their identity, no, I just haven't reached out to James to officially get his permission to share his story. I'm sure he would be fine with me sharing it, I just am apparently not only a lazy coder, but a lazy podcaster. So I never reached out. So I won't give his last name, but I'll call him James.

        So this story might be one that resonates with you, you might have one a story similar to this one. But if not, then just know this story is very common. it's by no means specific to James, but James was actually fresh out of university. So he got a college degree. He was you know, super, super proud, super happy that he had done it. But as time went forward, as he was, you know, further and further out, from his official graduation, from university, he could not get a job, let alone even getting a job interview. He was, you know, sort of living in his, you know, parent with his parents, maybe it was in the parents basement, who knows, but he was still living with his parents, and, you know, now in his sort of, you know, early to mid 20s, I guess it would have been sort of mid mid ish, 20s. And, you know, he's living with his parents, and he's tired of living with parents, he wants to, you know, begin the rest of his life, get out and get out there and get a job and, you know, get his own place and, and start to, you know, be a real adult, you know, get off of the parents pay roll and onto sort of his own. But he couldn't do it. He was he was struggling, he could not get a callback for an interview, and he was frustrated. And he didn't know how to solve this problem, right. Until one day, he stumbled upon a stranger on the internet. And the stranger on the internet was talking about this thing called boot camps. And lo and behold, he was sort of sold on the idea. So he, you know, talk to his parents about it. And his parents were a little bit skittish about the idea of, you know, you know, investing a bunch of money in a intuition again, in another program. But after, you know, I being the stranger that he found on the internet, after I spoke with his parents a little bit, I set their minds at ease. And I said, Look, you know, this is something that's very common, you know, students graduating from university still struggling to find a job and needing some extra help and guidance. And really, you know, everything that you've already heard me talking, talking about on this podcast, again, it's, it revolves around a couple things. One is a gap in their knowledge, not realizing that, you know, there's so much more that they don't know about, that they need to know in order to get a job as well as a bunch of other things. But I've talked about these already. I don't want to go into them again in detail. But he was struggling from this exact problem, and he needed some help. I spoke with him and his parents and convinced them that James should join the boot camp. Let's fast forward through the story of him being in the boot camp, obviously going through a boot camp is intensive. But six months later, he graduated from the boot camp, and he received his offer his first actual official job offer for you know, $60,000 starting salary as a Java developer for sort of an international company that has clients everywhere around the globe. And so yeah, it was a great job and he was completely he was actually unsure he thought it was a scam. This job offer he thought it was a scam. I had to set his mind at ease. I said, James, this is like, I've researched the company, job offer sounds, you know, right, right on it sounds very apropos or whatever very, you know, on par with what you know, is expected. Yeah, he had such a good thing in front of him that he couldn't even recognize it. And he was so hesitant to get excited about it. But ultimately, he accepted the job offer and started working at this place and is now as happy as could be so. And like I said, this story is, you know, this is James's story, but this is not a unique story. Okay, I've seen so many students now come through my doors, in this exact same spot, university graduate, can't get a job needs help need some guidance needs, the, the gaps in his knowledge filled or their gaps in their knowledge filled, as well as obviously some hints and tips and tricks and whatnot. But I want to dive into some of those tips and tricks right now, right? This, this sort of key number three that I want to dive into, is how you can achieve an unfair advantage. Okay, so this is all about the unfair advantage that you can get in today's marketplace. So it's how you can ensure that you actually stand out from the crowd, then ultimately increases increase your chances of actually landing that job because that's, that's what we're what we're doing this for, right, that's typically speaking, what everyone is learning how to code. For, that's why they want to do it. Sure. It's fun. Sure, it's cool. It's challenging you level up, it's a mind altering type thing, changes the way you think it's really a fun process. But hey, at the end of the day, we want to get paid, right? And that's what this is all about. So you got to make sure that how can you arm yourself with the greatest opportunities and tools to ultimately get that job. So it's all about the unfair advantage. So step one, and getting yourself an unfair advantage is you need to make sure that you are actually learning the right stuff. Okay, this is obviously not something that should come as a surprise to you. But oftentimes, even though you know this intrinsically, even though you know, this, you know, at your core that you Yeah, you need to learn the right stuff in order to get a job. People still get this, you know, look, squirrel type situation an activity, and they'll go off and get, you know, attracted to some shiny object. thing that's that's happening LIGO and learn a different technology that ultimately is not going to help them in the real world.

        This also happens a lot in university, I spoke about this before, in university, you go a mile wide, on subjects, but an inch deep. So you don't you learn all you learn a little bit about a whole lot of topics. And that's just the wrong way to do it. You don't want to go a mile wide and an inch deep. You want to go a mile deep and an inch wide. If you know what I mean, right, you need to focus on teaching yourself the right stuff, and on teaching yourself exactly what it is that employers want you to know in the real world. Okay, I call this the five, the five pillars, I spoke about this already. But the five pillars of the front end the the thing that connects the front end to the server side, the server side, the thing that connects server side, the DB and the DB. Okay, DB being database. So you have the three pillars, the two pillars flanking each side, and the one of the middle front end server side database. And then the two pillars connecting those together, which is typically an MVC type framework, like model view controller connects the server side of the front end. And something like an ORM and a relational object relational mapping type thing, like hibernate or something like that, or JPA, more specific or more generically, that's a fourth pillar or the ORM layer that that that connects the server side to the to the database. So a front end connects to the server side with MVC, and server side connects the database with an O RM. So that those are sort of the five pillars, and you need to make sure that you are learning the right technologies in there. So this gives you an idea of how you can focus your knowledge, make sure that you are focusing on learning a server side language that's popular, make sure that you focus on learning, probably a relational database, those tend to be the most popular in the real world. Most jobs require you to learn a relational database. So yeah, make sure you're focusing on a popular server side language like Java, a popular database, relational database, like MySQL or something. And then make sure you're focusing on a good front end stuff, you know, HTML, CSS, maybe JavaScript in general, you can dive into a JavaScript framework as well, but I won't get into that here. But yeah, you have to make sure that you're learning the right stuff. That's step number one to gaining your unfair advantage. Step number two, to achieving your unfair advantage is and again, this doesn't come as a surprise. I've talked about this before creating a portfolio you need to make sure that you have a portfolio that in lieu of real world experience, you can lean on To show employers that you actually know how to code. Again, I've said this, but this is important to repeat. Employers want to hire people that know how to code. That is their incentive. That is their purpose. That is what they want. They want to hire people that just know how to code. Right? So how can you show them that you know how to code? The best way to do that is a portfolio, there's no better

        way to demonstrate that you know, how to code other than showing them your code, right? That's a Z, that's the straight, you know, step, what does it Point A to Point B straight line, I want someone who knows how to code, here's the portfolio, right? I've even had some employers say, they won't even look at the resume. Okay, this is not all employers, but some employers will will just completely not even look at the resume, they'll just look for the you know, the GitHub profile or something, the the portfolio that's in the resume, they'll click on that. And then they don't even care about reading the resume, they, they don't care about your university degree. They don't care about your academic, you know, credentials, they don't care about your certifications, they don't care about even sometimes your past experience, if you have some, they don't care about any of that. They just want to see the code that you write. Okay, so this is why portfolios are so important. Now critical error here that a lot of people make, and I've spoken about this before they create a portfolio and proudly demonsaw are proudly broadcast it to the world, which is good. However, the broadcasting absolutely atrocious code without even realizing it. So this could lead to you not getting a callback, if you are broadcasting terrible code that is going to be shooting yourself in the foot foot in the foot, you're going to be shooting yourself in the foot. So you got to make sure that the code you're broadcasting to the world in your portfolio is actually solid code. How can you assure yourself that or assure that you have good code? Well, you need to make sure that you get it reviewed by an expert, how can you get it reviewed by an expert? Well, that comes built into the boot camp, we'll talk about that. But in lieu of a boot camp, you can obviously hire a professional coder, someone with at least minimum five years of real world experience, I would recommend 10. But anyway, five years should do have that experts review your code and make sure that it's good before you know, broadcast your portfolio to potential employers. So step one, learn the right stuff. Step two, create a portfolio and get it reviewed. Okay, these are probably things that you more or less already know about. But Step three is you need to build a network of connections, both in terms of peers, and employers. Okay, so you need to be able to build a network for yourself. You've heard this probably many times in school is it's all about your network, who you know, it's all about who you know, before you can get a job, right? You've heard this before. However, that might have been all you've heard, no one ever then follows up and says, Oh, and by the way, here's how you do that. Here's how you build the network. Here's how you meet the right people. Here's how you meet the right employers, you know, and you're kind of left on your own to figure this out. Right. So having a strong network is critical. It's so critical that this is actually how I got a job when I desperately needed one. I was working way back when as a you know, doing this teaching people how to code. Now again, I don't make a lot of money doing this, I don't make a lot of money teaching people how to code I can make far more money. Just exclusively working as a software developer. It's that's just it's a bit better pay. That's just the way it is. But I just love I love both. So I'm I'm called to do exactly what I'm doing right now. Which is teaching people how to code and impacting their lives and introducing them to this amazing salary. For you know, both a blessing and the curse in my situation is I'm called to teach people. It's a blessing because I love to do it and I love change people's lives. It's a curse, because it doesn't pay very well. But anyway, one day, I found myself in a situation where it was like, Okay, I need to pay my own bills here. I was exclusive exclusively working, you know, doing this, what I what it is that I'm doing, you know, teaching people how to code. And I was not doing any side gigs as a coder. And I had, you know, moved into a new house just had a baby. And you know, eventually hit the point where I was like, Oh, I need to make ends meet here. I need to make some some money. So I reached out to my network.

        And within 24 hours, I had a job. Okay, within 24 hours, I think it was a Thursday, I reached out to my network. On a Friday, I had a phone call with a potential employer. We had a chat and then boom, they made me a job offer. I think on Monday, I started the job. Okay, so that that's even more crazy, right? I was offered a job in 24 hours. And then I started that job within whatever that is 72 hours or whatever. Yeah, within 100. You know, within three or four days, I was starting and working in that job and earning money. So that was entirely because, well, one because I'm a good coder, but two because of my network, okay, you can be the greatest coder in the world. If you have no network, you're still gonna struggle to get a job. Okay. So how do you build a network? Well, one way, again, shameless self promotion. One way is to join a boot camp, where you have peers that you're working with, that you're working alongside, I should say, learning alongside. And guess what, when one of your peers gets a job, as an entry level developer, the company that hired that person tends to be interested in hiring more people for the same position, just like the person that they that they just hired. So I see this all the time, right? One of my students gets a job at a company, and the company loves them. And then the company says, Hey, where can I find more people just like you. And then they say, well, I've got, you know, 20 other people in this boot camp that you can, you know, check out and that just tends to lead to more and more people. It's like a self fulfilling, what's the word, I'm looking for a positive feedback loop of people getting hired, right? That network just keeps building and building. So associating yourself with something like a boot camp, again, doesn't have to be mine, any boot camp that's worth their salt is going to have this sort of network effect built into their programs. It's this unfair advantage that someone like a college grad just won't have, right? A college grad will have their own peers. Yes. But I don't know. It's just the camaraderie that happens with these boot camps are, they just seem to be stronger than, than the college groups. And again, I can speak from real world experience because my college peers, none of them led me to getting my first job. My first job just, I didn't, we were all in the same boat, all my college peers were, couldn't get a job. So we couldn't really help each other out. So something like a boot camp circle, like that helps. Or just obviously, knowing, knowing other programmers who are already working in the, in the real world, just you know, knowing some coders in general is helpful. Right? So in lieu of boot camp, if you just can, can make friends with other coders in some way, shape, or form. I don't know, join a local programming enthusiast group. If there was a local one, or over, obviously, a virtual one, join some Facebook groups, or some discord channels, or something where coders are co mingling with each other, they're gathering, you know, join these groups, and schmooze a bit, right? Make friends try to be open and you know, don't jump right to the hay, who can get me a job in this group? No, you can't lead with Give me something, right. That's not how the world works. If someone just walked up to you on the street and said, Hey, give me something. You know, it's, it's tough for you to say, Sure. Here you go. Right. It's better to lead with what they call value, right? Give value first. So Introduce yourself, and then, you know, offer to help other people or, I don't know, share some tidbits and, you know, just try to make friends and, and, you know, be useful to that community. So if other people are asking questions, and you know the answer, answer those questions, right, be helpful and then ask for help in return. So hey, by the way, you know, I noticed that you're, you have a job already, can you you know, any tips or any tricks that you know, you can suggest that led you to getting a job, and then maybe organically that conversation will go towards the person saying, Oh, hey, you know, I think we have job openings at my you know, company or whatever. Maybe we can get you one or something who knows, right? It's a bit more of a there's a bit more work involved there a bit more of a roundabout way to get a job but it's it's a much more surefire way to getting a job then, you know, by building your network, other than just what we call the spray and pray, right, you spray your resume out all over, you apply to hundreds of jobs, and pray that someone calls you back, right? That's not a great strategy. I know I did that I can say with confidence that does not work. It feels like you're doing something that you feel like oh, I applied to three jobs today. You know, pat yourself on the back. That's great. That's it led to nothing It was it was just an entirely massive waste of time. So instead of spending time applying the job, spend time building your own network, okay? and forth. Step four, I should say is you know, on on the topic of applying to a bunch of jobs yourself.

        You need to not do that heavy lifting yourself just like I said, Don't Don't spray and pray more or less let someone else do the spraying and praying for you so that they can work for you while you are sleeping to get you a job. Right? You you quote unquote hire someone to to be your personal marketer to be your personal Brand Ambassador to reach out to employers and say, Hey, let me let me tell you about this person who is amazing, you know, a great coder. He's got he's, he's passionate, he's got a great portfolio. You know, he's maybe done a boot camp, he's, you know, he or she, I should say, is exactly who you need to hire like. So you can hire someone like that, to do this on your behalf. And it's entirely free to you, you don't have to pay for the service. So this you might be saying, Wait, what I can have someone work for me for free, who goes out and and, and tells companies about how great I am and gets me a job for free? Yes, these people are called recruiters, right? Some some people have a negative connotation built into their mind about recruiters, although I don't know if an entry level coder would have this, this negative mindset, I have a bit of a not a negative mindset about recruiters. But for me who who has a lot of experience. under his belt, as a coder, I get hammered by recruiters all the time with messages begging for me to take a job or something that they have found. So recruiters are great. recruiters are amazing. I love recruiters. So but the point is, reach out to recruiters in your area if you're not already doing that. And and introduce yourself to some recruiters, right this is part of the building a network you can build a network of recruiters and let them do the heavy lifting for you. And they will go out and apply to jobs and introduce you to employers and essentially get you interviews. Right. So you might ask, Where can I find recruiters Well, obviously, you can do it through someone something like a boot camp. But if you want to do it on your own, you can go to you know, LinkedIn, and search just for the word like, you know, technical recruiter or something, and then look for ones in your area and just reach out to them and say, Hey, you know, my name is XYZ and I have some experience in these languages. And here's my portfolio, and I'm looking for, you know, an entry level job or something. So, yeah, that's sort of the, the approach that I would recommend for you. Again, to recap, that key number three there, it's it's your unfair advantage and how you can build yourself an unfair advantage. Give yourself a leg up from all the other competition, applying for entry level positions. So to recap, yeah, the first step is you got to learn the right stuff, right? seems obvious. But sometimes people get distracted and off track, and they learn stuff that they don't need to be learning, okay, so find a mentor, find someone who has a job or has achieved the goal that you want to achieve, and pick their brain and say, hey, I want to do exactly what you did to get to where you are right now. How do I do that? Right? What do I need to learn. So get them to tell you what you need to learn to unlock the success that they have unlocked. Again, boot camp anyway, step two, create a portfolio but not just create a portfolio for yourself to demonstrate that you are a good coder, have an expert review that portfolio, okay, it's a terrible portfolio is is not what you want to be broadcasting to the world, you want to broadcast a good portfolio. Step three is you got to build your own network. This is hard. It's not an overnight thing. It takes time. But the work that you put into building a network is invaluable. So again, find discord, you know, channels or groups that you can join and interact with, find local meetups or groups, either virtually or you know in person that you can go to and talk to fellow coders and interact with them, because you never know where your job is gonna come from. You want to you know, obviously, boot camps are a great way to have that network built into it. Or if you know, you can, you might even be able to reach out on LinkedIn to someone but I doubt that might be too difficult to reach out to a coder on LinkedIn. But hey, you might be able to do it. If there's a job that you are focusing in on, you know, you want this job, you can search on LinkedIn for people who work at that company. And maybe you can find one in your area. And maybe you can reach out to them on LinkedIn and say, Hey, you know, I love the company that you work for. I would love the opportunity to get a job there. Like do you have any any ideas are any advice that you can give to me? I don't know. Again, these are just I've never tried that before. But hey, it might work. Again, I would suggest leading with value. What can you do for that person? First before asking for something in return. Right? So I can't really think about something off top of my head that you could suggest.

        But I don't know maybe it's going on taken out for coffee or picking their brain. People love to talk about themselves. Here's a good tip. I just thought of this in the moment. People love to talk about themselves. That's their, that's everyone's favorite subject. So maybe you could go on LinkedIn and say, Hey, I see that you're working for you know, company XYZ in you know my area. And I would love to work for this company. And I you know, since you're already working for this company, I'd love to buy you lunch and pick your brain. And sort of see what that company culture is like, and tell me about your you know, I'd love to learn about you and see sort of what you did to get a job there. And I don't know, again, try to frame it in such a way that, hey, I want to buy you something, I want to buy you lunch. That's the value. And at lunch, I would love for you to just talk about yourself, and talk about all the things that you did to get this job and you know, how are you so great? And how did you do that? I don't know, something like that. That might work. That might work. I've had that happen with me before, not in the in the scope of programming. I've never had a programmer, like an entry level programmer reached out to me and asked for help in that regard. But I have had other entrepreneurs reach out to me and say, Hey, Trevor, I saw you on, you know, this YouTube channel, or I heard you on this podcast, or bla bla bla bla. And I want to be where you are right now. But can I take you out to lunch and pick your brain? I said yes to that. I went out and had a lovely lunch and some drinks with an author, entrepreneur in my area. And we just chatted one evening, it was great. I loved it. I love chatting with new people and meeting new people. I'm a very extroverted type person. So I love chatting with people. So yeah, that worked. The gentleman was able to pick my brain for a bit, I got a free meal out of it, and I had a wonderful time. So that might work. There you go. The value in this podcast was just elevated, I went off script. And that might actually work for you. So there you go. Step four, leverage recruiters, right? Find a recruiter in your area. Again, LinkedIn will work here, you can reach out via LinkedIn, find a recruiter and get them to do the heavy lifting for you. So those are my sort of four steps to building an unfair advantage for yourself. And ultimately hope with the hopes of helping you get to get a job in the real world and launch your very successful career in the future. Again, you can do this all yourself, but in my opinion, the easiest, most effective both in terms of time and money. way to do this, and to achieve all of these things is to do it via a boot camp, right. I have talked extensively about why I believe boot camps are the most superior method of getting a job as a coder, I have beat that topic to death. All I will say is if you are still interested or haven't yet done, so you should check out our Bootcamp coderscampus.com/bootcamp.

        Otherwise, you should check out any boot camp at all right, as long as they're a reputable boot camp. They've got good metrics and good numbers that they're tracking for, you know, placements, ultimately, the most important thing is that they have a good placement rate. But yeah, that's just, that's just the most effective way to do it. I've been doing this for over nine years now. There's just no better method. So check them out. boot camps are the way to go. They're the easiest in terms of you know, the provide you with the curriculum, they provide you with the mentorship, they provide you with the support, they provide you with the direction, the motivation, accountability, the support after all that stuff in terms of career support, and helping you to get ready for interviews and it's just the the value that you get inside of something like a boot camp is just it's it's unmatched when compared to anything else that I've seen in the marketplace. So check out the boot camps. I'd love it if you check out mine coderscampus.com/bootcamp, go through our admission process. I'd love to chat with you if you have some prior coding experience. And of course, if you have no prior coding experience and you're just starting out your journey, then hey, you can get started for free with our bootcamp prep course. So this is for people who have never coded before you can go to coderscampus.com/start to join that free bootcamp prep course and dip your toes in the waters to see if something like a boot camp might be good for you. But if you already have some experience, you've coded you know a few small applications with some simple you know, loops and if statements and that kind of thing. If you've done that already done some simple exercises, you probably are more or less ready for a boot camp so you can check it out and apply via coderscampus.com/bootcamp. Alright ladies, gentlemen, thank you so much for joining me yet again for this podcast episode. I love that I'm still doing these and I can't wait to see what we talk about next. Perhaps we'll we'll dive into more. We'll move away from the sort of, you know, feel good conversations and the motivation conversations and the tips and tricks and maybe dive back into some, you know, cold hard content in terms of coding related topics. So I know streams, Java, eight streams are a streams and lambdas more specifically, are a topic that is both popular and difficult for aspiring coders to grasp. So I might have some episodes in The future talking about some some streams and lambda stuff. So look forward to or keep an eye out for that content, which should be coming out to you in the relatively near future. So keep an eye out for that. Cool. So thank you take care of yourselves as always happy learning, and bye for now.

        The post EP50 – Key #3 of 3 to Getting a Job as a Coder appeared first on Coders Campus.

        32 min
      • EP49 – Top 3 mistakes coders make when applying to their first job

        In this episode we'll talk about 3 big mistakes that aspiring coders make when trying to land their very first job.

        Getting your first job as a coder will be the most difficult challenge when trying to launch your professional career, make sure you avoid these three mistakes:

        1. Setting up your portfolio and NOT doing this…
        2. Incorrectly utilizing certifications on your resume…
        3. Getting a college degree and then…
        4. Transcript

          Trevor Page

          Okay ladies and gentlemen fellow coders Welcome to now this is my third attempt, trying to record this episode, upgrading my, my hardware and my software to try to record these, these podcasts while I'm up for my walk, it's actually the afternoon now, instead of the morning. In any case, let's get into the content, so

          Trevor Page

          I've been doing this for a while now it's been, what, nine years over nine years that I've been teaching people how to code and I've myself professionally been coding for about 14 as of this point so in my, I guess almost decade of experience helping people learn how to code. There are similar stories that I hear, day in and day out time and time again. And that, that relates to essentially the struggles right so the topic I want to, you know, hone in on today is essentially the three most common mistakes that I see sort of beginner level programmers make when trying to get a job as a coder. So yeah, if you're in the position where you've got a little bit of code under your belt you feeling like you are more or less ready to hit the job scene, but are not receiving any callbacks for interviews, you might be falling into one of these three or maybe all these three categories. So listen up. The first sort of mistake I see is around people who, you know, this is in the best with best of intentions they get their portfolio set up, and with their portfolio set up they're feeling confident in that they are able to demonstrate their skills right they can show off their code and proudly display it to potential employers and say hey, look what I can do, and that's great, that is actually something you should be doing if you don't have a portfolio, and also have no experience as a coder, no professional experience. You need to be, you need to be creating a portfolio, this is mandatory. Otherwise, for sure you're not gonna get any callbacks, but I'm gonna assume that you have some sort of portfolio and by that I mean you have at least one big project that really demonstrates, more or less all the aspects of your skill set, right and more or less demonstrates, all of your strengths as a coder. Now here's the mistake people fall into. They have these, these portfolios, and they proudly display their portfolio. And the problem is that what they're displaying is horrible, Horrible code, and they have no idea that's horrible code because they just literally don't know any better. You know, this is a problem of you don't know what you don't know. Yeah, you probably don't realize that your code is awful and actually it's probably expected that your code is going to be awful if you haven't worked in the real world professionally right. If all you have is a college degree or you've been more or less self taught, you might not have learned everything you need to know to write good code. But there is a solution, no worries, I'm getting to it, but the symptoms of this problem are a little bit deceiving because essentially the symptom of the problem is you're applying to lots of jobs, and you're hearing nothing back about interview potential right you're not getting any calls for any interviews. All right. Now if you aren't getting calls and you are being invited for interviews and then still not getting a job well that's a different problem right. Your portfolio is most likely not the problem. Your resume is most likely not the problem, it's probably your interviewing skills. So these are the people are for the people who can't get the interview. So the symptom is you're not getting any any callbacks, right you applied to 100 jobs, 200 jobs, 300 jobs, and your phone is just not ringing. So, it's deceiving here because it's like, Well what's wrong, it might not qualify and am I applying to the wrong jobs. What's, what is wrong with this situation. Why is no one calling me back, right, and, and this is often the case, you have no experience, and therefore since you have no experience, the employers have to fall back on. Looking at your portfolio or some other means of trying to, to determine without seeing you in person. If you're any good as a coder. Okay. So, in lieu of real world experience they're going to look at things like your portfolio. And if your portfolio, they, you know, flip through it. It's very easy as a senior level programmer to flip through someone's code quickly and make a quick decision within 60 seconds. You make a decision as to whether or not this person is a decent coder or not decent for, you know, respective for the level that you're applying for. So you know, a decent junior level coder is going to have a different criteria than a decent senior level coder. But in any case, that decision can be made very quickly, and if you haven't taken the steps to put your best foot forward here. You can easily get disqualified and thrown thrown into the no pile and then you never hear from any employer ever again. Right. So,

          Trevor Page

          yeah, this is a doozy. So, how, how do you know if you've fallen victim to this. Well, there's no way to know for sure until you hire someone to look at your code for you hire someone who is a senior level programmer with more than five or 10 years of experience, have them look at your code. Okay, now you had to hire someone who is you know, whatever language you wrote the code in they'd obviously have to have experience in that language. That would be the best fit. But you'd hire someone to do it now if you don't know how to hire someone to do that. You, there's places you can go right there's like, There's a website called up work up as in the arrow up and work as in working. So, up, work.com will allow you to sort of post a job opening or a temporary job or whatever like a one time job and say hey, looking to pay a senior level programmer to review my code, right, a senior level coder, can probably take you know if it's a decently, you know, large size project for a portfolio project, you know, it might take a few hours of senior level programmers time, so like maybe a couple 100 bucks, but this is a couple $100 That is very, very well spent because you are going to return on that it's gonna be great if you just get one job, right, the ROI the return on investment for $200. You know, just for the peace of mind of knowing that this is not the problem like my code has been reviewed by a professional. I can feel good about this right. Another opportunity, again, shameless self promotion here. This is something that we just do inside of the boot camp. So for every assignment you do in the in the boot camp and for every Final Project, this the final project is what you would display in your portfolio for every final project, you will get a code review as well. So that's just built into the boot camp, you're going to get a professional with, you know, X number of years least whatever four or five years of experience, looking at your code, and making sure that it's good writing and making sure that you're putting your best foot forward. So yeah, if you're looking to not only just get a job but also you know, improve your skills in general, feel more confident as a coder, fill in any gaps you might have in your knowledge that kind of thing yeah boot camp might be a good fit for

          Trevor Page

          you. Again coderscampus.com/bootcamp to check that out, shameless self promotion over. Okay, so next most common thing, or problem that I see, sort of, you know, junior level programmers make when they're trying to get their first job is with respect to the resume. So again these things are done with the best of intentions, and we don't realize again we don't know what we don't know we don't realize that they are harming our chances of getting a job which is really unfortunate. Which is why I'm here and talking about it right now. So, if you are someone who again has no experience in the real world as a coder,

          Trevor Page

          then you might fall victim to something that again feels right, you know in your gut, this might feel like a really good decision. But in actuality it's a, it's a bad decision and that is one of certifications, so pursuing certifications, and putting them on your resume is not, is for whatever reason, not a good thing. So if a recruiter or a hiring manager looks at your resume, and they see a list of certifications, you know, at the bottom or wherever you know in your Awards and achievements section or whatever, they see a bunch of certifications listed. They actually throw out your resume, that's a red flag for, you know, hiring managers in general. They don't like to see that, and it is a disqualifying factor when it comes to people's resumes. Again, this came as a surprise to me, I didn't find this out until I was actually interviewing hiring managers, myself and just sort of asking the questions to help my students out in terms of getting jobs. So it was a complete it, you know, came out of left field for me, because again you would think that going and doing the work and paying money and putting in effort to get a certification in the language that you know whatever company is hiring for. You would think that would be a good thing. But I guess what what's happened is that having a bunch of certifications listed on your resume is an indicator for someone who's struggling to find employment. Typically speaking, if someone has employment, or does not have a problem getting a job. They don't need to go out and get a bunch of certifications, unless, unless they are being forced to write and let not finally use the word forced, but unless the employer is asking the employee to go and take a time and do this certification, you're probably, you know, you probably wouldn't do it, you probably wouldn't spend your time trying to get a certification. So generally speaking, this is seen as a red flag. And like I said there's some correlation or causation or whatever, that hiring managers have found between getting certifications, and being a good employee for whatever reason. So if you're struggling to get a job. Try to not put a bunch of certifications on your resume doesn't mean you should put none, I would say pick one that you're most proud of. Take whatever one that you spent the most time and effort to achieve, put that one on your resume. Okay, that one's okay you can have one in there that should not look bad on you.

          Trevor Page

          So examples of, okay, certifications to put on your resume again, maybe a maximum of one, I would say, again, pursue what your own risk if you put two, again I would only pick one personally speaking, if I were you. One is the way to go, but a good example of one that you couldn't put is if you pursued. Some of the industry standard certifications like the Oracle Certified Associate or Oracle Certified programmer if you're looking for a Java position, that is sort of a well known and somewhat respected type of certification to have on your resume. I'm not saying to go out and get that if you don't have it, that's not what I'm saying Don't misinterpret what I'm saying, if you do not have that certification. I don't recommend going out and seeking actively seeking an Oracle certification. But if you already have it if you've already invested the time and the money and you've passed and you had the certificate certification. Fine, you can put that one and only one on your resume. Another one that does make sense it passes the gut check which is something like a boot camp right at boot camp. It's, it's, they are well known in the industry and a lot of employers do look positively on a potential student or potential sorry employee who has a boot camp, you know, a certification or whatever. So if they've gone through a boot camp, that tends to increase your chances over someone who has no education. Okay, so fine you can put that as an achievement and put that on your resume. Outside of that, outside of any super popular industry standard certificates or, you know, big boot camps that you've taken a lot of time and effort and put into you know into display on your resume, outside of those two to two things I wouldn't recommend putting a certification example of a bad certification to put, it's like a Udemy course, like oh hey I completed, you know Udemy gives you these digital certificates when you complete a course, don't, don't put that on your resume. That just looks cheesy, it just looks like hey I paid $7 And, and maybe just, you know, click the few buttons and then magically I said you know I complete everything and then. And you know I didn't even take the course but I got this piece of digital, you know, certificate paper that it just don't do that, don't, don't put it that's not impressive. That doesn't that doesn't take months and months of work and lots of time and money to unlock a Udemy certificate, or the like, write those, that's a good example of one not to put on your resume.

          Trevor Page

          All right, so moving on now last but not least, the third most common issue I see in programmers who are trying to get their first job is someone who just graduated with a degree in a related programming field, you know, computer science, computer engineering. I don't know, mechanical engineering, whatever the degree is that, you know, relates to the IT industry in general. So people who more or less are about to graduate or have already recently graduated. If this is you pay attention. People who get it and I'm guilty of this myself so this this comes from. Hopefully, a place of I learned the hard way so that you don't have to. So don't take this the wrong way. If you're, if you have a degree or about to unlock a degree in computer, you know programming field. It's not enough. You can't rely on that solely to get a job. That might have been the case. A long time ago. It was not the case when I graduated in 2006. Okay, I graduated with a computer science degree in 2006 and still could not get a job. Okay, my first job that I got out of University with a degree was something called the forms analyst, you might have heard me talk about this before. I worked for an insurance agency as a forms analyst, which had practically nothing at all to do with programming. It was a job that was not fulfilling, and did not in any way shape or form, flex my programming muscles if you will, my intellectual coding muscles, and it was literally what I called paying my dues I had to pay my dues in that company working this job that I essentially was overqualified for because I couldn't get a job as a programmer anywhere I'd applied to hundreds of jobs for months and months and I think for like six, it was six months I spent applying for jobs. And ironically, the job I ended up getting this one as a forms analyst was not one that I had applied for obviously I wasn't gonna apply for a job that had no programming in it. But I just gave up and said you know what, I'll take it, because that company that insurance company had a Java development team right there was a software team doing Java that, you know, I could potentially move into I could do a lateral move or whatever within the company, but I had to pay my dues in the job I did not like as a Forum's analyst for a year before I finally was able to get an interview for a job as a Java programmer at that same company. And even then, I pretty much flunked to the interview but they, they, they gave me the job anyway because they felt bad for me, so. So, university degree. If you graduated great congratulations, it is a big achievement. I'm very proud of you. I felt great when I did it it felt like this amazing sense of accomplishment and this prestige and it's like oh my god I did it. But the real world is a bit of a, well, it's, it is a, it's tough because it meant nothing. It did not help me get my job ultimately and helped me launch my career, I essentially was able to unlock that job because I was just a good worker in general, not because I had a degree. So, don't rest on your laurels there don't just think, Oh, I know I have a degree therefore, I'm better than 70 or 80% of the other people and I'm just going to get a job, based on that alone, it wasn't true in 2006, it wasn't true in, you know 2016 When one of my friends went through the same process, and hit the same wall, getting a degree, and then still not being able to get a job as a coder. And it's not true. Now, you know this year for any of the computer programmers that have come through my doors. Almost half of my bootcamp students who are actively in my boot camp enrolled in it and taking the going through lectures and everything in the boot camp, almost half of them are have degrees in a related field. As a computer you know computer programming, computer science, computer engineering whatever like they have a degree as a programmer, and they are still in my boot camp so it just goes to show,

          Trevor Page

          it's not the solution. It's not the be all and end all there's more work that needs to be done there. Obviously again self promotion blah blah blah you know the idea you can join a boot camp. And that greatly increases your chances of getting a job because that's what bootcamps are focused on, but that's not the only answer right. It just means that you have to do more to stand out from the crowd to prove to employers that you know how to code. That's all employers want at the end of the day. At the end of the day employers just want to hire people who know how to code. And the story. The problem with the university and the reason why university graduates aren't being hired left right and center is because the university curriculum teaches you a little bit about a lot of things. And that's not helpful in the real world. If you learn 10% of a programming language. Okay, versus someone else who's gone through a bootcamp who's learned 90% of that same programming language. Who do you think is gonna get the job. right, is there going to be the person who knows 10% of Java and 10% of C++ and 15% of C sharp and 20% of JavaScript and 10% of assembly language and blah blah but you get you get my drift right and 10% of astronomy and 20% of microeconomics and all these other electives that don't have anything to do with computer science,

          Trevor Page

          or

          Trevor Page

          the person who just knows 90% of the Java language. If the job that they're hiring for is a Java programmer, guess who wins. Is it the person with the fancy degree with four years of, of, you know, hard work under their belt. And, you know, 10s of 1000s of dollars spent, or is it the person who has the exact knowledge that the employer needs, you know, whose, if you were an employer who would you pick, not to, you know, throw shade at universities. Again, I have a degree myself I went through the process, the greatest years of my life I tribute to university, but in terms of real world skills, real World, I should say professional skills. You know University unfortunately did very little for me, because I learned a little bit about a great deal of things. And the majority of those great deal of things that I learned a little bit about, I never ever used in my entire career. So it's really, it's just a shame that that's the default path, that a lot of people are thrust into. And if you're in that doing that path right now, and this message is hitting you now, and you're feeling uneasy about the fact that I'm saying this. I'm sorry. Again, great experience, hopefully you're having a lot of fun in university again it's a wonderful social experiment. Hopefully you are growing very much as a human being in general. Just don't rest on the, you know, the education in terms of the academic education that you're getting, because you can't rest on that because others, pursuing other means of education might have an upper hand on you. So that might be a hard pill to swallow for some but yeah I comment, I say this with, with the best of intentions for you so anyway let's recap. So

          Trevor Page

          the three common mistakes that you need to avoid if you're trying to get your first job as a coder. Mistake number one is you want to avoid having a beautiful portfolio prominently displayed with awful code. Okay, you need to get that code reviewed, either you hire someone from upwork.com to review your code, who's a senior level coder, like, you know, don't spare. Don't spare any expense here this is an important step in the process, pony up the cash, it's worth it. It's an investment, it's not a cost, it's an investment. And it is worth it. Every penny to hire a professional to look at your code and give you the feedback that you need to make it look good. Okay, or obviously join a boot camp, we'll talk more about that at length in just a moment. Number two is don't litter your resume with certifications especially meaningless, certifications, aka Udemy course completion certifications or something any course generic course completion certifications, don't do it. Pick your best pick your one probably display one on your resume. Okay. Third, as I just ended, or justice spoke about is yeah if you're a university grad or about to be a grad, you're not done, there's still more work to be done, you need to gain more skills related to the job that you are actively going to be trying to get. So, whatever language you're most interested in whatever language you're most comfortable with, maybe double down on that one, but also do a Google search or whatever, indeed search to see the job availabilities for entry level jobs. Generally speaking you want to pick one that that you know has a healthy amount of job jobs available for the language right. Don't pick a language that has like five job postings in your area. Okay. It tends to be, again, I'm speaking in generalities here. Python and Java tend to be the two most dominant languages. When it comes to job availability, at least from what I've seen. Obviously I'm a Java guy so you know take that for what it's worth, but, Java, you know, served me well for the last 14 years of my career. It has led to a very beautiful lifestyle that I'm absolutely blessed and absolutely spoiled, to have. It's crazy in a way. So yeah that's what I would say in terms of the work that you need to do as a grad, it's not done, you need to now dive deep into a language that will open up the most doors as possible for your future career. Now how do you do that, this is where I transitioned into the sponsor portion of this episode which is, yeah, boot camps, right, so obviously I have a boot camp I've been running in boot camps since 2019 now, and I've had a lot of success in both training people with the Java language in the Java stack to be a full stack web application developer, which means you can create web applications using HTML, CSS, JavaScript for the front end, as well as Java on the back end and database, and all the technologies all the Java frameworks to connect everything together. So it's a very well rounded education that you receive. We go deep right we go deep into the Java language, because once you know, one, you know, object oriented language. One popular object or language. It's not too difficult to be able to learn any other one on your own, relatively quickly. So once you know one really really well and you feel very confident with one you've gone deep. It's not hard to go to another one. Okay. So I focus on Java because Java, tends to be a bit harder to learn than most and that's a good thing because if you're doing a boot camp. And you have someone, a mentor, like myself, to guide you and help answer your questions and get you unstuck. It's great to have that as a resource when learning a harder language, like the Java language when compared to something like Python right. Python is, is, you know, popular because it's fairly easy to pick it up. I'm not gonna say it's easy, no known programming language is easy, easy to learn. But Python, relatively speaking to other languages, tends to be easier. However, going from Python to another language if needed, is actually a bit difficult because there's a lot of additional stuff that you're going to hit a lot of additional concepts and you can be like wait what I don't understand this. I never learned this, this isn't in Python. Whereas when you learn Java, a lot of that stuff. If not, you know, all of it is transferable to other languages. So that's why I say arm yourself with a mentor. I would highly recommend boot camps, as I've talked about in past episodes, boot camps are just the most effective means in terms of getting yourself from where you are now, to becoming job ready.

          Trevor Page

          Right. Boot camp and I might say the most effective I mean most effective in terms of least amount of time and effort at Washington State effort least amount of time and cost, right, because there's cost to doing it on your own, without any help from any professionals that cost comes from lost opportunity costs, there's my microeconomics or macro economics coming into play, maybe University isn't as useless as I say it is. Yeah, last opportunity cost of learning on your own. If it takes you two years to finally get to the point on your own, without spending any money as it could have taken you know, six months at a boot camp, you know, that's, a year and a half earlier that you could have been earning a higher income and thus, it's more costly to learn on your own. And it's especially more costly to do it via the education, formal education system like a university or college. I'm sorry. It's hard to say again if you're in there. It's a tough pill to swallow, but that is the real world for you folks. So, boot camps, again, obviously we'd love to have you consider my boot camp coderscampus.com/bootcamp. But as I always say, All I care about in my business, is that you get a job as a coder. So whatever I can do to help you get from where you are now, to working as a professional, you know, entry level coder. I will do whatever I can do to help you to unlock that possibility. Okay, if that's through my boot camp, great. If it's through someone else's boot camp because it's a better fit for you, then great, I can make those suggestions I can point you in the direction of some very successful ones, if that's if that's what needs to happen. I have a lot of I have a lot of confidence in my own boot camp because I can control it, I'm the one who creates all the lectures, I'm the one who's hired all the staff, I'm the one who's, you know outlined the whole process and who obsesses over the metrics like, you know how many people are being employed. So, I have control over that and I have conviction to my own boot camp, I believe. It's obviously the best for you if you're listening to this podcast, but in case, boot camps are just the most effective way to ultimately become employed, like I said if you're a college student, a recent grad or going to graduate soon, you still could be a great fit, like I said, almost 50% of my students in the boot camp are in your shoes. If you're someone who's currently working in a job that sort of adjacent to programmers, such as a QA person, or a dev ops person, or I don't know a product, you know lead that works with programmers or whatever, if you're in sort of the field of software in some way shape or form, just not as a coder. You're also a good fit. I find that a fair number of my students match that profile as well. So if you're adjacent to programmers and work with programmers on more or less daily basis, and want to become a programmer, this is probably a good fit for you. The final sort of group that's not as great a fit, but still does fit is you're just in a completely unrelated field, and you're just tired of the job that you're doing, maybe it's, you know, hard physical labor and your body's giving out on you or you're just stuck in a job that is not fulfilling and you just feel like programming is calling you to learn it and to get a job as a coder if you feel pulled and called to do this kind of work to create things with code. If that just seems fascinating to you. And you've already started the journey, and really want to become a programmer, yeah, that you could definitely be a good fit for the bootcamp as well I would love to have a chat with you and talk about potentially getting into the boot camp so for all of those people, I welcome you to apply to the boot camp, you can do so via coderscampus.com/bootcamp, fill out an application form and book a call with us, so you can book a call with my admissions team, which currently admissions team is a fancy word to say me. I'm currently the admissions team but who knows the boot camp grows. I might have someone else that that takes care of the admissions process. But currently, the admissions team is me so you can book a call with me and we can have a chat and I can learn more about you. Learn more about your background in terms of your interest in coding what sort of skills you already have with coding, and just see if you'd be a good fit for the bootcamp itself. So I would love to invite you to apply, you can do so via coderscampus.com/bootcamp.

          Trevor Page

          To learn more about it. and if you are someone who has no experience in code whatsoever. If you've never written a line of code in your life, or you've never created a simple Hello World application, ever, you know, I would not, I would recommend that you don't go to the boot camp that's, um, that's not the right fit for you. It generally takes a little bit more work to get to the point where you're ready for something like a boot camp. And for those people. If that's you, don't worry, you can go to coderscampus.com/start. So if you go to coderscampus.com/start that allows you to get a free course is, I call it my bootcamp prep course. So it allows you to dip your toes in the waters of programming. Learn from me, get an idea of what the bootcamp would be like, do some assignments. Like I said, dip your toes in those waters and just see if, if you like it, because sometimes this is from you again I've been doing this a long time. Sometimes people who say that they want to be coders, but I've never coded before in their life. It's just something that they say, and it's not until they do the work inside of this free course that they realize, oh, this is definitely not for me. Okay, so I don't want you to, to waste a bunch of money and time in a boot camp if you know, or if you find out in the boot camp, this is not for you. Right, so I want you to get for free. So you can go check out coderscampus.com/start. Try it out for free dip your toes in those waters for free, and see if, see if you like this whole coding thing. Okay, but if you already crossed that threshold, I call it the great filter. If you've crossed that great filter and are sure that you like to code the whole process of learning and doing is fascinating to you and you've done it, and you're still wanting to do anything. Yes, I invite you to check out the boot camp coders camps.com forward slash boot camp. Having said that, I will stop talking about boot camps, I'm sure you're tired of hearing about it but I still love talking about it. I will go ahead and end this episode now.

          Trevor Page

          Hopefully if nothing else you've gotten a lot of value from these three common mistakes that coders make and hopefully you have left this episode with more knowledge and with more confidence in knowing where you're going next. So thank you so much for joining me. Thank you so much for listening and I can't wait to see you in the next episode, take care of yourself. Happy learning, and bye for now.

          Transcribed by https://otter.ai

          The post EP49 – Top 3 mistakes coders make when applying to their first job appeared first on Coders Campus.

          36 min
        5. EP48 – Top 3 reasons why you’ll fail to succeed as a coder and how to overcome them

          In this episode we'll talk about 3 common issues I see that beginner programmers struggling with most when starting the journey of learning to code.

          1. Impostor Syndrome
          2. The overwhelming number of choices
          3. Thinking that struggling is a bad thing (and then quitting because of it)
          4. Show Transcript

            0:09

            Welcome to the coders campus Podcast, where you'll learn how to code from one of the best teachers in the industry. Whether you're an absolute beginner or a seasoned pro, the coders campus podcast will teach you what you need to know, to master the art of programming.

            0:24

            And now, your host, Trevor Page.

            0:28

            All right, so fellow coder, welcome back to joining me on my morning walks. Once again, it's a bit rainy out today at least really cloudy. Hopefully, I don't get rained on but yeah, today I want to talk about a couple of subjects related to sort of some common issues that I have seen in my days teaching people how to code, right. So, you know, these issues may not affect you directly. They might not affect you right now, but they will later or they may have affected you in the past. Who knows, right? So these are just very common things that I see from pretty much any old programmer who's you know, come through my doors, so to speak. The first one is really the most common one, which is this concept of imposter syndrome. So this imposter syndrome will will sort of plague you, if you will,

            1:20

            in two aspects, in my opinion, the first area the first time, the first aspect where this imposter syndrome will affect you, is when you're getting close to that important miles milestone of being, you know, quote unquote, job ready. So if you are coming to the conclusion of your degree, so if you are getting a degree or a diploma, through college and you are almost ready to graduate, you're you might start to feel this and it comes up in the in the form of like, I don't think I'm really ready for a job, I don't feel ready for a job, why would anyone hire me? Right? Or if I was hired, I'm probably just gonna fail at my job, I'm probably just gonna get fired. Because blah, blah, blah, blah, blah. Right? So it's this negative mindset around someone who, you know, potentially has gone through years of a college program and who, you know, for all intents and purposes, should be well versed and well qualified for an entry level or junior position as a programmer, right? So why are you having these feelings, okay, that's the first instance where this whole thing comes up.

            2:37

            The second instance, where you might

            2:41

            experience this imposter syndrome is while you are taking a course with other people, so if you are directly in contact with other students, or if you're directly in contact with you know, peers, or some small group of people that you are learning with, as you are, you know, experiencing the journey of learning how to code, you may compare yourself to others. So you may look at

            3:11

            the the star in your, you know, the star player, if you will, the star coder in your classroom. So you may look to them and say, Oh, look at how well they are doing compared to how I am doing, you know, they have completed all these assignments or something, or they don't seem to struggle at all with any of these concepts. And it just seems like everything comes so naturally to them. And for me, I'm struggling, right, every concept, every new concept, every new assignments, every new, you know, small thing that I learned is this gigantic struggle in order for me to move forward. Right. But the main thing is, you might look at other people. And like I said, you compare yourself to other people. So this is so common. This is something that I again, I've been teaching this stuff now for over nine years.

            4:03

            I see it all the time, I experienced it myself, when I was sort of, you know, getting started. It actually didn't hit me until a bit later in my career. It wasn't until I was hired, as an intermediate level developer, that I really started to feel this sort of imposter syndrome. So thankfully, with my throughout my university career, if you will. And my

            4:28

            first job where I was a sort of a junior level coder, it didn't really, I didn't really think of it. I never really compared myself much to other people. And so I was I was lucky in that regard. It didn't really affect me. But I got a job as an intermediate developer. And I had had a pretty much exactly one year of experience, one year of on the job, real world experience. And that is you know, to go from, you know, one year of

            5:00

            experience to an intermediate level developer, it's that's kind of like the soonest that you can make it happen. That's sort of the earliest in your career that you can make that move. So

            5:12

            I started to think well, am I really cut out to be an intermediate developer? So that's where that sort of, you know, ramped up for me, I believed clearly that I was good enough to be a junior developer, I believed with, you know, all my mind that I was cut out to be a junior developer.

            5:32

            But yeah, that one little step up that one pay, raise that new title, if you will, threw me for a bit of a loop. And I started to feel like, Oh, am I worth it? Am I good enough? Am I you know, am I gonna get fired, you know, so that's sort of where it kicked in for me. So it, you know, your mileage may vary, you can experience this at any point in your career. And I'm sure there are people who don't experience it until they are hired as like a senior level developer or something. So the most important takeaway here is probably a few things. But one, don't compare yourself to other people. It, it literally does you absolutely no good whatsoever, there's no advantage to it.

            6:15

            It's full of disadvantages, right? You are, you know, only most likely going to feel not great about yourself. Because if you are literally not the number one person

            6:27

            in your class, or in your social group, or in your company, or whatever, right? If you're not literally the number one person, you're probably going to have some sort of negative feelings about comparing yourself and even then, even if you're the number one person at your company, there's always someone else in the world that you can, that you will consider to be better than you. Right. And this is obviously not just about programming, this is any, any field any person and this is a human psychology thing. This is just how human beings function. And it's unfortunate, because it literally does you no good to compare yourself. Okay, so the other people that you are perhaps comparing yourself to, they are in a completely different situation from you, they have potentially advantages that you don't have, they potentially have more time on their hands, they have more money to back them, they have less stress they have like, who knows, right? Or maybe they were just blessed with a big brain who knows, like this is it's possible it's not. But that's not in your control, you can't control how well or not well, other people do on their journey. And if you can't control it, it's there's no, you are absolutely just wasting your time. And really, it's self sabotage, you're just sabotaging yourself and your potential progress and your potential success by comparing yourself to others. So I don't know, you probably have heard this, you know, talk before from someone about how it's useless to compare yourself to others. But anyway, human psychology, it's hard to suppress it, it's easy for me to say, Oh, just don't do it. But all I can say what I can say is, if you do do it, you're very normal. It's you're just like, so many other students that I had that I've taught, okay. So my best advice is, obviously, try not to do that. Try not to compare yourself to others. But if you do start to feel like Oh, look at these people who I'm around who are so much smarter than me, try to reframe it in terms of a positive, right? So the negative would be look at these people are smarter than me, I'm never going to make it, I'm never gonna be as good as them. Blah, blah, blah, blah, blah, right? That's the negative way to think about it. to flip it around, you can say, Oh, look at this person, who is further along in the timeline than I am in terms of learning. Right, they probably just been doing it longer than you have, right in terms of hours practiced. So they're further along than I am. So now I can reach out to them and say, Hey, I'm struggling with XYZ concept. Can you help me out? Right. So use it as an advantage, use it as a way and a means to further yourself in your education.

            9:12

            And that's, that's literally what I do whenever the other analogy I use is,

            9:17

            I never want to be the smartest person in a room. Right? If I'm the smartest person in the room, it feels good for your ego. Like oh, look at me, everyone's asking me questions, and I'm able to answer all these questions. And, and you know, this is it feels great. I must be this important person. But really, there's no benefit for that person. If you were the smartest person in the room, you're not getting anything out of it other than stroking your own ego, right? Everyone else has been at benefiting and growing, whereas you probably are not. Right. So think of it like that think they are the smartest person in the room in that case in this hypothetical situation, and you are then able to leverage their knowledge and make yourself better while

            10:00

            They are just stroking their ego. So you never want to be the smartest person in the room, I've been there before. It's not helpful, it doesn't really, you don't grow, everyone else does. So that's the whole comparing yourself to other people and that imposter syndrome. Now, in terms of in terms of the other side of the fence of the imposter syndrome that strikes when you sort of hit a milestone or something, like I said, you get hired for your first job, or you get promoted, something like that.

            10:30

            You know, basically what I did was he just asked a lot of questions. Right? If you feel like you're, you should know, something that you don't ask, ask someone who you deem further along on the timeline than you are someone like someone senior to you. And just say, like, Hey, is it is it expected that I know this stuff. And if it is, then you can say, cool, I can go out and learn it, right? It's there's always a path forward, there's always a way that you can fill the gaps in your knowledge.

            11:00

            And I don't know that this might be a common misconception, that programmers who are like senior level programmers or something, they know it all, they're able to do it all, it is absolutely effortless for them. And they never struggle. And they can just, you know, Sprint, from the start of a project all the way to the end and laugh the whole way and feel great. Like, it's, that's just not, that's not the real world. That's not what Like I said, I have fought I have 14 years of experience coding. I'm still googling stuff, I'm still going to stack overflow myself, I'm still asking other people questions, I still get stuck, I still struggle, you know, it's, it's just part of the process. It's part of software development, okay, as a human being, I cannot know it all. Okay, now me teaching this stuff is, is a bit of a hack for me. Because when you teach something, there's just no better way to learn something than to teach it. So me being a teacher of this stuff really helped me to understand everything at a far deeper level. So, you know, that's one little hack is, Hey, can you try to teach the stuff that you've learned to someone else who is earlier on the timeline than you are? Right? If you are further along in the timeline than someone else's, and they are looking to you, and they're saying, Oh, my God, look at this person, I'm never gonna be as good as they are. Than, hey, there you go. That's the reverse imposter syndrome, if you will. So lovers that try to be the teacher for them, because it's only going to help you in terms of

            12:36

            where you are right now. So, yeah, once you get

            12:42

            on the job, just know that

            12:47

            no programmer knows at all. Okay, every programmer has had to learn it has had to struggle has had to has hit a point where they're like, Oh, I don't understand this, I need to go and learn it myself. Every programmer does that. So you are never expected to know it all. And you are very much expected to be able to teach it to yourself. So that's really in my opinion, there's, well, there's a few things. But in my opinion, that's what separates a senior programmer from like a junior one is a senior programmer can go off on their own, get to a point where they're stuck. And they're like, Oh, I don't understand something. And then they're able to go off and teach themselves with very little help from others. The thing that they're stuck on, they can teach it to themselves, whether it's a framework, or you know, a bug, or they're just able to figure it out on their own, and then make progress eventually. Right, that's what makes a senior programmer, a senior programmer, very little supervision. Junior programmers are not expected to behave like that Junior programmers. If this is your first job. As a coder, you are not going to be expected to be able to figure it out all on your own, you're going to be expected to ask for help. So if you're, you know, they're even intermediate level programmers, same thing, you are not expected to do it all. on your own, you're going to be expected to ask for help sometimes not as frequently as a junior level, but you're still not really expected to do it all independently without ever asking for help. That's just not reasonable. Okay.

            14:11

            So, long story short, imposter syndrome, more or less, everyone has it at some point. So don't feel don't panic, if you have it. The best way forward, is just to educate yourself. Ask for help. And know that everyone else is probably been exactly where you are before. Okay? You're not. It's not that you are not good enough. It is not that you are not cut out to do this. It is just part of the process. It is expected. So expect yourself to suffer from this at some point. Now, another thing I want to chat about something that is along this same

            14:54

            topic, area of topic, what what's the word I'm looking for anyway, in this realm

            15:00

            Discussion?

            15:02

            There is a related thing that I see.

            15:06

            And and it's related to this question. The question is, why do you, I would say most people fail at trying to become a coder. Why is it that there are so many people who start the journey, but so few who actually finish the journey? Okay, now there's, there's, you know, with anything in life, there's going to be a drop off, if you will, there's going to be, you know, the people at the start, or the rather, the people at the end are going to be fewer than the people at the start. Right? That's just bound to happen with anything. Right? If there's a race, there's 1000 people in a race or a marathon, there's gonna be some people who don't finish due to, you know, who knows, you know, they just, they physically tap out, they can't do it, or they get, I don't know, injured or something along the way, and they have to pull out of the race, there's just going to be fewer people that finish, then that started, right, that's natural. That's just sort of how the law of numbers works. But when it comes to coding,

            16:06

            the difference between the people who start and the people who finish is kind of ridiculously vast.

            16:14

            I've mentioned this before, but I'll say it really quickly, in my first year, computer science classes,

            16:22

            the room was filled with like, you know, is a 500 or 400 person lecture hall, right? every seat was filled, it was, you know, not an open seat in the house standing room only, if you will,

            16:33

            you know, it was packed with people first year, second year, that number was cut by 10x. So from whatever 400 went to 40.

            16:45

            And I was like, wow, what the heck happened here, like,

            16:51

            I experienced it myself with some of the peers. In my group, I had, you know, become friends with people in my, you know, first year classes. And they really, really, really struggled through the whole process. And by year two, they switched majors, right? They switched to I've said this before they switch to, I don't know, accounting or economics or

            17:17

            I don't know, English literature or math, potentially, or, you know, they said, you know what computer science is not for me, I'm going to switch out. But the rate at which that happened was alarming. Right. And then to a lesser extent, the same thing happens for year three, and then your four, right, so we're 500 people start, maybe 20 finish. And that is a ridiculous, delta. That's a ridiculous difference. So and the same thing happens in to an even greater degree, outside of that physical classroom. When you think about people who say, Oh, I want to learn how to code and they buy a course online or something, when they start a course, the people, if you counted the number of people with a mindset of, hey, maybe I should try coating. You know, that sounds like it's a great career, I'd like to give it a shot and see what happens.

            18:08

            The number of people out there in the world who start that process, versus the number of people who actually even just finished that one course, let's just focus on that one. course, not even the finish line of I'm now a coder, and I can do it professionally and get paid to do this. Just that one course. The drop off rate, again, is is somewhat similar to what you see in first year, second year, which is

            18:34

            95%. Don't complete the course.

            18:39

            Right? Now, there's a whole bunch of different factors. Maybe the person just didn't like the instructor or, you know, blah, blah, blah, but usually, it's Oh, my God, this freaks me out, I can't do this. I'm not cut out for this. I'm gonna bail. And, you know, maybe I'll never do this again, or try this again. Or maybe I'll try it again in like, I don't know, a year or two.

            18:59

            Right? What happens there? Why is it that so many people,

            19:06

            I don't, again, I use the word fail, you don't really actually fail unless you completely give up and never try again. But that that definitely there is a percentage of people who who fit that criteria of failure. They start, and they never, ever finish. Why? Why is there such a disparity there with with respect to programming?

            19:28

            Well, in my opinion,

            19:32

            there's the obvious, which is, like I've said, learning how to code is hard. There's a lot to know, there's a lot of paths that you can take. So the first problem is this.

            19:45

            There's just so many choices to make at the beginning. Which language Am I going to choose? Which framework Should I pursue for those languages? Which is it macro is a PC should I be a developer or should I do DevOps or should I do automated QA

            20:00

            Should I do some sort of infra infrastructure stuff? Or should I be,

            20:05

            you know, move towards this title or that tie, there's just so many different options in so many different languages and so much choice. It's paralyzing. Okay, the overwhelm that someone can feel just stepping into this realm for the first time, is paralyzing.

            20:23

            And there's a pie chart that I like to there's a common explanation for this. I forget the term, I forget what it's actually called this concept. But it's something that

            20:36

            I learned about when I started to teach people how to code.

            20:39

            And this pie chart is essentially the majority of the pie chart. So I don't know, it's something like, you know, 95%, you picture a pie chart, but 95% of it with one category. And that one category is stuff that you don't know that you don't know. Okay, you know, stop me if you've heard this before. But

            21:02

            again, stuff that you don't know that you don't know. All right, that makes up the majority of everyone's brain matter, right? There is so much that you don't know that you don't know. For example, I don't know, I can think about a couple of things off the top of my head, like plumbing. I am not a plumber, I am sure there are tons of subjects relating to plumbing. And I don't know pipes, that I don't know that I don't know. I like if I if someone if I were to sit down with a plumber and have like a one day of

            21:35

            tutelage, if you will, under a plumber.

            21:38

            There will be tons of stuff. I was like, Oh, cool. I didn't know that. I didn't know that was a thing. I didn't know that it was important to I don't know, use this kind of tape on this kind. I don't know, you know, this is there's, there's just so much stuff that you don't know that you don't know. So when you start the journey, knowing nothing about coding whatsoever, and you step into this world, there is obviously us a ton of stuff that you don't know that you don't know. But what happens is, it will transition very quickly from stuff that you didn't know that you didn't know, into stuff that you now know, that you don't know.

            22:16

            And that's where the overwhelm happens.

            22:20

            So if you were to jump into the world of learning how to code and then you learn, oh, my god, there's something called a server side language and a client side language. And then on the server side language side, there's like 15 different languages, I can learn on the client side, there's this thing called JavaScript. And then within JavaScript, there's a thing called Angular, and then there's a thing called react. And then there's thing called view. And then there's a thing called this and that and Mongo and, and and my SQL and relational databases and, and you know, you know, front end and back end and like, it's like, Whoa, whoa, whoa, like it's, there's just an information overload.

            22:55

            And this leads to, that's the first great separator, if you will, the first

            23:03

            area, the first point where people throw up their hands and say, Okay, I'm out. I can't do this.

            23:10

            Right. That's the first great separator between those who succeed and those who fail

            23:18

            is just literally stepping from the world of I don't know what I don't know, into. I know what I don't know. Right. And obviously, that I don't want to see obviously, the third part of that is the stuff that you know, that you know,

            23:30

            right? So there's stuff I don't know that I don't know, I now know, that I don't know. And that I know that I know. Right? So that the those you know, goes from a huge part of the pie chart to the smallest part of the pie chart, respectively. So

            23:48

            yeah, that's the first great separator of people who fail versus people who don't. Now,

            23:56

            the next part is,

            23:59

            is people who get in their own heads. And I've talked about this before. But for example, one of the super common things that I hear from students is,

            24:09

            you know, they start to struggle with learning how to code because you're going to everyone's going to struggle, that's just gonna happen, it's inevitable, that you are going to hit a point where you're struggling. This is where I say you need to reframe that struggle and make it yourself realize that if you are struggling, it means you are learning that is a good thing. If you were struggling, it means that you are learning you are currently in the process of learning something new. If you feel that struggle, so a lot of students will think oh, no, I'm struggling, therefore, I must be, you know, I must not be intelligent. I must I must not be cut out for this. Therefore, I should quit. Right? And it's just like why it to me is just crazy. But it's because the way I think of it is whenever I'm struggling, I'm in the process of learning something new, which is a good thing. I like that. When I am struggling. I enjoy that process because I look at it and I say I'm about to level myself.

            25:01

            Okay, so struggling is a good thing that's, you know, sure, Fine, whatever. Hopefully that is a little tidbit that you can have a light bulb and say, Oh, cool. I will reframe that in my own mind next time when I'm struggling to learn some programming concept. But sorry, getting back to my point. My point was, I hear this a lot from students, they start to struggle, and then they start to make excuses as to why they are not cut out to be a programmer. The first part is they're struggling and yes, you need to reframe and realize that that's a good thing. But they'll say something like, Oh, you know what, I'm not good at math. I was never good at math. Therefore, I can't be a coder. You know, why did I Why did I even think I could be a coder, I'm not good at math. This is silly. I'm just gonna quit.

            25:44

            And it's frustrating to me, because, I mean, I was okay at math. I did I did decently well, in high school, I got obliterated in university, doing the, like calculus and stuff, like I got obliterated, I had a, I had so much change my major

            26:04

            because of that, so I fell victim to my own, the great divide, I had to slightly tweak my major. I forget the the old major Title I switched to just be computer science, right? I forget if it was like engineering, or I don't know what the title was. But

            26:20

            I switched to just computer science, because the other, you know, degree that I would have attained required me to do level two calculus. And I just was like, Nope, I am not cut out for this. So the point the point is,

            26:36

            I'm not great at math. But I have succeeded immensely as a programmer.

            26:44

            How could that be possible? Also, a lot of my friends who are very successful in their career as a coder, never were good at math. A good example I've talked about before, is Nathan, my good friend, Nathan, was an English literature major. Literally, I always say that, what is the opposite of computer science, English literature, you know, he did it, he got a job, he's now being paid. He's an intermediate coder at the point of this recording, well, on his way to be a senior programmer, I would, I would say, he's doing better now than I was at his point in a timeline of learning.

            27:21

            So he's on track to be a better me, he's on track to be a more successful version of me, he probably doesn't realize that because he's probably struggling with imposter syndrome and all that stuff that I was struggling with at his point, but he's on the path, he's gonna be a superstar.

            27:38

            But he's not good at math. He graduated with an English literature degree, he was all about, you know, writing stories and analyzing the great, you know, written word. And anyway,

            27:49

            so people know, they don't understand where I guess it's like, they make excuses for themselves, or they listen to, I don't know where this this knowledge or this common thing comes from this whole, you have to be good at math to be to be good at programming. I don't know where that comes from. I'll tell you what you need to be good at, in terms of the stuff that I teach, you know, full stack, web development, web app development, whatever you want to call it.

            28:16

            You need to know how to add, subtract, multiply, and divide.

            28:22

            And that's it.

            28:25

            grade school level stuff. Do you know how to add two numbers together three numbers together? Do you know how to subtract and divide and add or sorry and multiply? I can't even say the four things. So that's pretty much all I've ever had to do. I've never had to do a cosine or

            28:43

            derivative or any of these crazy weird, like, I've never had to do a mathematical proof.

            28:50

            My job No, like, that's just not. I don't know where that comes from.

            28:56

            Maybe if you're doing like video game development, that's the only thing I can think of. If you're doing like video game development, then maybe there's like areas where you need to know some math or something. But even then you can look it up. Google it. There's this amazing thing called Google. Anyway.

            29:13

            So the whole I need to be good at math to be a good programmer thing is just one of the common misconceptions about you know how to be a good a good coder. Okay? You don't even have to let me say this. You don't even have to be a good coder. I have worked. what's the what's what's the politically politically correct or gentle term for someone who is not a good programmer?

            29:39

            I guess we'll just say that. I have worked with many people who did not excel at coding. Let's say it that way. I've worked with many an individual from many walks of life, who I can tell. It's like, what are you doing here, man? Like why are you pursuing this as a career but moreover,

            30:00

            How do you even still have a job? Right? So it just goes to show there's so many, there's so many desperate companies out there that look to get as much help as they possibly can get, because there's such a huge shortage of programmers, that they're willing to hire people who don't, you know, like I said, excel in the world of programming.

            30:22

            So,

            30:24

            again, not only do you not have to be good at math, you don't even have to be good at programming to get a job as a programmer. So anyway, I'm being, you know, I'm being silly here. The people who I work with who are not who did not excel in programming was not, in my opinion, because they were dumb or something. It's just because they didn't really care. You know, they didn't really

            30:46

            didn't really like programming. It's like, they didn't want to be a coder. But it was just a job. And they just did it, they clock in and clock out, and so be it. And hey, I can't judge I'm sure you know, we've all been there before. We were just doing a job to you know, pay some bills. So they just weren't incentivized, to learn any more or to get any better. I just like it, I just like learning. I love learning. I love teaching in general, right? Because teaching is the best way to learn. So really, I just love to learn. And that's what sort of guides my has guided my entire professional career is just this huge desire to learn. If you have that trait, if you're always curious and have this huge desire to learn, it will treat you and serve you very well in your professional life, in my opinion, so anyway, know, you don't have to be good at math, to be a coder, you don't have to be a physicist or something to be a good coder. You don't have to be a,

            31:41

            you know, an artistically talented person. To be a coder, you don't have to be a creative thinker. To be a coder, you don't have to be an analytical thinker, to be a coder. Right? coding is learned. And I know it is learned because I had to learn it myself. I started I started very, very early, right? Again, if you're trying to compare yourself to me back to that topic of comparing yourself to others, I started learning when I was 10. You just can't. If you are in your 30s right now considering becoming a coder. Yeah, I have decades of a head start on you. Does that mean you should throw your hands up and give up and say I'm not going to make it? No, of course not. It doesn't take decades to become good at coding at all right? In my opinion, it could take six months in a good coding boot camp. You know, Hint, Hint, nudge nudge. And, you know, another year or two of on the job experience before you can be, you know, a good useful coder, who can be a productive member of an organization. Right? So no, it doesn't take decades, it takes, you know, to be at the point where you're feeling pretty comfortable, confident and being able to mostly work on your own without any outside help. A couple years. Okay, this is not, yeah, it doesn't take decades. So anyway, that was a distraction. Don't compare yourself to me, or don't compare yourself to others, everyone's different.

            33:03

            The point is, all of this stuff is the noise that's going to get in the way of you achieving your ultimate goal.

            33:11

            And I see this happen so often with my students, they fall victim to all these different aspects

            33:21

            of

            33:23

            struggling with coding with learning to code, they fall victim to all this stuff, and they quietly go, whatever disappear into the good night or whatever that that that, you know, saying is

            33:37

            I should know, I don't, I'm clearly not firing on all cylinders this morning. So they, they just fade away and and never to be heard from or seen again. And it's heartbreaking to me because they had this goal and this, this desire and this, hopefully this big purpose to this, you know, to become a programmer and get a job and start a really successful career and make a ton of money and have fulfillment and enjoyment from their from their work. Like I said, it feels like I cheat. I'm cheating at life because I enjoy Monday mornings. I look forward to Monday mornings.

            34:12

            I'm a little bit sad when it's the weekend because I just I like the work that I do. And it feels unfair because there's so many people out there who hate Monday mornings, right? So it's this incredible experience is this incredible way to live your life to achieve this this level of

            34:34

            of I don't know the word is peace, inner peace, I guess when you in terms of your professional life anyway. It's just so rewarding and amazing. And it's sad when someone doesn't get there. Right? And it's especially sad when someone doesn't get there because they have fallen victim to this these poisonous mindsets. Okay, so that my best advice for you is to

            35:00

            Know and acknowledge, in advance that this is hard to do, you are going to struggle, you are going to hit a wall, where you're going to feel like you want to quit. And that there is never going to be a day that will ever come in the future where you are going to understand whatever concept it is that you're stuck on. Okay? Everyone gets stuck in a different place. You know, if it's if it's just the concept, the fundamental concepts of coding and like a loop versus a method versus or whatever, or if it's, you know, something more advanced like Java, eight streams, or lambdas, or, you know, whatever the The topic is, or AWS, or who knows, right, wherever it is, you're gonna get stuck, you're going to something along the way is going to make you throw your hands up in the air and say, I don't know if I can do this, guys.

            35:58

            This is hard, right? And yeah, exactly. That's going to happen, expect it. And

            36:06

            don't quit at that point. Because every other human being on planet earth who has gone through the same journey that you're on right now has also hit that point.

            36:17

            The difference between

            36:19

            the people who succeed and the people who fail. I've already said it are the people who just actually give up and stop.

            36:29

            There is a solution

            36:31

            to where you are currently stuck on there is a solution a way to get you past that point. Okay, there are, again, I've said this before, if it's just an online course you're doing Yeah, your chances of success are so low, like you're, unless you're an experienced programmer already, I should, I should preface it by that. If you're already a senior level coder working in the real world, online courses are great, because you already have the tools

            36:56

            in your tool belt to get past those areas where you might get stuck. Right CEO of a coders, even intermediate level coders, they can get there, they can figure it out, they can get unstuck. They know how to do it, because they've done it before.

            37:10

            They've made it past that sort of great divide, if you will. So for you, if you are a junior level coder, or if you are just starting this journey, you now need to figure out and understand that there are tools available for you to get unstuck. Okay, I've talked about it already, you probably getting tired of hearing this, the most effective way, in my opinion to go from potentially where you are now to success is a good coding bootcamp. Okay, it's not online courses. Like I said, online courses are much better for someone who is experienced already. For someone who has not yet experienced who hasn't had their first job, who has maybe been in the in the field and working for less than a year, maybe two years, I don't know.

            37:58

            online courses are not going to cut it. They're just going to amplify this feeling of Oh my god, I can't do this. Oh, my God, I don't understand this. What is this guy talking about? What is this girl talking about? Look at how well all these other people are doing. Look at all the people who've completed this and I haven't Oh my god, oh my god, I can't do this. I'm going to quit. Right? That's just going to amplify all that stuff. You need mentorship, you need someone who has made it to the point that you want to be right, finding someone who's already achieved sorry for the noise. Someone who's already achieved the goal that you want to achieve. You find that person and you ask them questions, you get help you, you use them as a mentor, right?

            38:41

            So long as that person is good at teaching, right? You have to have someone who's able to walk you through the concepts and if they can't walk you through the concepts then that might not be helpful. But

            38:50

            hey, if they're a good teacher, and they're a good mentor, then great that is going to

            38:55

            greatly increase your chances of success.

            39:00

            So

            39:01

            obviously that can be achieved through a boot camp. I welcome you. If you know nothing about coding, you can get started with a free course, we'll get you into the free course. It's a free four week course that prepares you for the boot camp to help give you the opportunity to dip your toes in the waters of coding to see if it's right for you. But in the important part of that is it also comes with a Slack channel. So you can reach out to me specifically and and ask for help if you need it.

            39:33

            So that really helps you need someone to guide you. You need someone to give you the advice. You can't just get an online course with no help. Okay, you need someone to help you. So yeah, start that free course if you have no background in coding whatsoever. If you're already comfortable with the basics, if you already know what a loop is what an if statement is if else you know what a variable is a data type a data structure. You know what a list is a map is

            40:00

            This set is all that stuff. If all those words that I just said, you know, aren't making you nod your head, like you understand and you're not panicking, then yeah, apply for the bootcamp, right? You can go to coderscampus.com/bootcamp and click on the Apply button.

            Transcribed by https://otter.ai

            The post EP48 – Top 3 reasons why you’ll fail to succeed as a coder and how to overcome them appeared first on Coders Campus.

            45 min
          5. EP47 – Key #2 of 3 to Getting a Job as a Coder

            If you've ever heard of “Writer's Block before”, then you're likely already familiar with “Programmer's Block”

            Programmer's block is when you're sitting down to code, you open your IDE of choice, and stare at your computer screen and say “I haven't got a clue what to do! I don't know where to start!?”

            Ever experienced this before?

            I'm sure you have, and it's completely normal.

            I'll teach you how to address this problem in this podcast episode.

            The post EP47 – Key #2 of 3 to Getting a Job as a Coder appeared first on Coders Campus.

            38 min

          About Coders Campus Podcast

          From the publisher's feed

          Learn how to program using the Java programming language. This podcast will teach you step by step how to use the Java programming language to create your own applications or web applications! These…