 Well good morning Excellent, it's a great pleasure to be here in front of you with you today to talk about something that I'm sure you are as passionate about as I am We we have this luxury we have this luxury to work in a field that Transents almost every aspect of human life Not everybody can have that kind of a plane to what they do professionally We could work in various different industries and yet we could be doing what we're doing writing software This is an amazing fuse to be One of the things that we have to always deal with on a daily basis is How do we really continue with complexity and that seems to creep it all along? But it reminds me of an experience. I traveled quite a bit and on a recent trip I was in the airplane sitting next to Gentlemen and he asked me what we do for a living and I said I'm a programmer and he said well That's the easiest job on earth. I said well I'm glad somebody feels that way Can you tell me why and he said because all you have to know is zeros and ones and I said You know what you're absolutely right and that's why they pay me the big money Because I know in what sequence to put them in and that's where the complexity really is to really make sure we Actually do what results in value to our customers produce those things that we can actually use that takes a lot of time Lot of effort, but one of the things we have to content with every day He is complexity. We come to work imagine for a minute the project you joined and the first few weeks of the project How are things everybody was still smiling at each other, right? You said hello when you walk into the office life was really good and about six months into the project What happened? Nobody wants to talk to anybody anymore, right? We quietly are working. We work late in the night Things have become really hard. Why do things become complex over time? What really makes things hard for us? Well, we'll talk about some of the reasons, but also how to cope with some of those here today So I want to talk about something that is extremely complex But this complexity is a good thing and I want to replace the word complex with the word Capable for just a few minutes because sometimes certain things are very capable and it's worth its complexity And one of the most capable things we can ever have Is we have several of those in this room, which is the brains that each one of us has and and each of her brain Is probably the most capable thing we can ever think of all the devices all the marbles all the software We build they all came from just one place. That's the human breath, isn't it? We are extremely creative We are very talented. We can come up with ideas like nobody can and yet There is something really funny about the human brain. It is the same brain That goes through emotions. It's the same brain that goes through confusion It's the same brain that leads us to think in a very irrational way sometimes and emotions cloud us And we are not able to see the clear picture things get fogged up in front of us And then of course eventually things clear up, but why do we do that? Right? That's kind of where it gets very interesting to think about and and we tend to really analyze things and things are very complex until we can gain clarity on those things this reminds me of A thought experiment that this was done back in the 1930s Einstein and people working with him were talking about quantum physics And it was really hard to understand quantum physics back then as it is probably right now for several of us and This guy whose picture is here is called Schrodinger And this is a conversation that I have a lot of times with my children at home A lot of times the conversation is that is it like a Schrodinger's cat So Schrodinger's cat is our actually pet at our house in fact So we talk about Schrodinger's cat quite a bit and Schrodinger came up with the thought experiment He said that if there's a cat that's put into this box and there's no windows into this box You cannot look through this box at all and if you're peering through this box You cannot see inside of it and with them this box there's a vial and the vial may break at a random time and Immediately as the vial breaks the cat would get killed So the question is is the cat alive or is the cat dead? Well, you cannot say whether it's alive or dead at any time And if you try to open the box to see it will be dead instantaneously So his argument is at any given time a cat is both dead or alive Now how do you really reason that? That things get really confusing and Schrodinger's cat is dead and alive at the same time Well, we contend with complexity all through our lives and as Confucius says That we deal with this every day when we deal with people and Confucius says life is really simple But we insist on making things extremely complicated. Now, why do we make things complex? Now, I think I have a few reasons. I know why we make things complex now Actually, the most important reason why we make things complex It feels good Honestly, doesn't it it feels good when you make things complex, right? Because you are looking at a design you worked on it you go to your colleague and say Can you take a look at my design and your colleague looks at your design and says, you know, that's simple You feel let down. You say, what do you mean? It's simple. Give it to me I'll bring it back tomorrow and then let's say you take back the design and your colleague says, oh boy It hurts my head. It's like yeah, right. We feel good about it Right complexity makes us feel we are important Now if you look at somebody and say, well, you probably hire an intern and the first day after the internship The intern runs back to college and says this company I'm interning with it's really cool Because I don't have a clue what they're doing, right? And that makes it feel more important to you, right? And there's another reason why complexity is so good complexity naturally brings us Job security when it comes to layoff they say lay off anybody in this team, but Joe don't touch Joe We have no clue what Joe is doing. Maybe it's important, right? So complexity leads to job security as well And we think that people who do simple things are useless, right? Anybody can do what they do but this guy was doing complex things He's gonna be good because we don't understand what he's doing So there are several of these reasons why we build complexity because it feels good. Now complexity is like eating donuts Well, okay, I already is like eating butters or game. You were jelly beans. What about that you want to talk about? Have you ever had a chance to eat one of them and stop? No, I was teaching a course in a company and these people were really tricky They put donuts right in front of me. Can you imagine what how hard it is to actually stand in front of food? Like three feet away and not touch it and I tried really hard, right? Every few minutes you get drawn towards it and you tell yourself no I don't need to do it and the human brain is very tricky. Eventually it says it's okay. You can have one And what happens when you have one? I've ever had it sounds to eat one and say this was good. I'm done No, the minute you have one the next thing you know you're pipelining more of them, right? And complexity is like that the minute you create something complex The next time you have to create something more complex and there's yet another thing you're calmly created complex things The more you got to create something even more complex, right? So it becomes a competition on complexity as well. So you got to deal with all of these Well Einstein said any intelligent fool can create something that's bigger or more complex and more violent But it takes a touch of Genius and courage to really make things complex I would say more than a genius. It really takes courage and it takes a lot of courage to move in the opposite direction a lot of courage to say I am actually going to create something simple and I'm not going to make this complex And so it takes courage to really create something simple and that is really hard Now the question I would ask you is if simple was sitting next to you in the bus Would you even know and say, oh you are Mr. Simple aren't you? How would we even recognize simplicity and that's the problem most of us don't even know what is simple The other day I was complaining endlessly that a particular code was complex and the person who reviewed the code Not the code looked at me and said why do you think this code is complex? Look at this code. It's complex. Why would you even ask it's complex and the person said I don't understand it. What's your problem? notice all I've used this a simple Statement only a 40 of it Why is this complex and that's what I understood people don't know what complexity really is They said of course if the simple so I can use 40 of them so this code is still simple Well, the code has enormous amount of duplication and that is complexity. There's a lot of redundancy in it That's complexity the code is hard to understand that's complexity the code is hot to be factor and maintain and they change the word That's complexity. So there are complexity. We have to deal with but the first step in removing complexity is Identifying complexity if we don't even know what's complex and what simple how could we possibly create something that simple? So that's the first step. How do we really create simple? Now unfortunately, it turns out. It's really hard to find and create things simple So rather than telling you what is simple first? I'll tell you what is not simple How about that? Well, if we know what is not simple We could at least remove what's not simple and maybe hope that what's left behind is at least them So let's talk about what's not simple the very first thing is Simple is not clever Now let's think about this for a minute. Is there anybody here raise your hand if you have never written a clever code Anybody who's never written a clever code? The only person would raise the hand is the person who has never written code in the first place, right? Yeah, everybody else has written a clever code. Why? Because it feels good to write clever code. I remember this experience very very well I was writing something and I had a problem to solve and I could have solved this problem in about five minutes But then I looked at this and said, wow Look at how I can solve this problem ten folds over and I spent another hour writing a piece of code And when I finished it, I was so proud. I literally get a pat in my own back And I said Venkat, you're good. This is awesome. And it was very clever So I was very happy checked in the code moved on about three months went by and I got a call from the support and the support said We are calling from production and something royally messed up. Can you please help fix the problem? I looked at the problem and with the two minutes. I said, I know what the problem is I can fix it and the team said I know you're good But we didn't know you're that good. How do you find this problem so quickly? I said because I created it Right because I remember the day I created something really clever and I knew what the problem is I put my head down and I went back and did the code that would have been done in five minutes Because that was the real solution and I rolled back my code and the problem was gone And I learned a very tough lesson that day. It is that when you create clever code Be ready to come back and do some more work on it. It is ready to embarrass you Now these days you can ask me when can do you ever write clever code? Well, you know, you know, I'm a human so I'm sitting there writing code as soon as finish writing the code I tell myself while that's clever admitted delete the code. I start over. I don't want clever code anymore I want clear code. Let's talk about some examples for a minute. Let's take a look at this example What does it say here? Well, let's see what it says. It says public class Well, abstract class Enum e Extends enum e Yeah, I can see his reaction select. Oh and the noise you just heard that's your brain throwing an exception, right? You're like, what the heck does that mean? That is an example of complexity, right? Now, of course, this is exactly how enum is implemented in Java If you go back and look at enum in Java, that is exactly what enum in Java is JDK find has this right now I've had this now. What does that do? Well, I'm sure we can all explain what it does But I bet you if I ask the same question next week, you'll spend as much time if not longer thinking about a game That is a sign of complexity because every time you look at it You have to stare and say what in the world is it doing that becomes really far Now the other day I was missing a team and they said hey, what do you recommend for us to Office case the code because we don't want anybody to look at our code and understand what do we can use for obfuscation? And I said why because your programmer are naturally write self obfuscated code They themselves cannot understand it after they write it. Why do you need a tool, right? So we create code that's hard to maintain so clever code is self obfuscated It's very difficult for us to understand what the code is doing. Let's take a look at an example here Well, take a look at that code for a second What does that code do? Well, let's understand what the code is doing. There is a method called in Squire. It takes float x anybody knows what x is? I got some good news for you What do our x's we don't know but we have half of it That's great And then of course we know this operation. Now don't tell me you don't understand this. This is very obvious, right? It is star in star and percent x Now you cannot say you don't know it because somebody wrote it We gotta be smarter to understand this right and then what does it do? This is fantastic it is obvious what it is doing right and Whatever it does the good news is we eventually return x life isn't horrible, right? Now look at that code and if you are the person who should maintain that code. Oh, how would you feel? How do you feel when you have to go home that night? That's the reason why we don't go home right? We stay at work, right? We don't want to go face the family and say why not grumpy at the end of the day Well, because that's kind of nonsense. I have to put up with every day, right now I'm sure you come across somebody who writes code like this at work And and you're trying to be nice to this person of course this person says this is obvious, right? But you don't know what you say, you know what? This is very obvious to you But what about the rest of the team? What would they do? How would they be able to deal with the code and your colleagues says don't worry We got that we got them covered and what does your colleagues say you do something like this, right? So he says I've got X plus plus and then they do something very very valuable very useful increment That was very helpful, isn't it? I would put all these comments into it. Have you ever seen comments like that? Absolutely. What are those comments? They're called insult It's an insult to the programmers, right? Because it says what the code is doing like shift Thanks, I was not sure there was an increment or maybe something else But the real question is why did you do it? What's the purpose of doing it? What is the effect of doing it? Are the conditions when we should do this and conditions when we shouldn't do it? And most of the time comments don't tell us and comments tell us what is obvious being an insult to us the programmers So the code becomes extremely hard to understand and hard to read as time goes on Now remember, I'm sure you've heard this before right? They said object-oriented programming is great because Object-oriented programming models the real world. Have you heard that? Well one guy took that very neutrally and he was writing a flight simulator and so he created this Maintain a code like this Somebody has got to say stop Take a break go get some fresh air, right? How do you maintain code like this? so the first thing is that Simple code is not clever. So if you're writing code that is clever Rewrite it don't document or comment clever code Refactoring so it becomes easy to understand the code easy to maintain it. That is very important The next thing I'll say about simple is simple is not Necessarily familiar Now this is very confusing to a lot of us. We hear this a lot Now does anybody know what this is? In the room anybody Well, it's actually well actually that's first step. I'm glad you actually recognize it as a character It is actually a Chinese character and I usually have somebody in the room who understands Chinese and usually somebody blurts out saying it is simple Well, it is simple uncomplicated casual common How do you know I googled for it? Of course it's gonna be true then right so it is simple now if I show you this You're gonna say I can understand That is complex But Chinese don't think so they think it is simple So what's going on here? So the other day I was showing a piece of code to somebody and they said, oh my gosh it is complex And I said it's complex. How do you say it's complex? I think it's simple. Oh, no Look at all the things you have in there. That's confusing and I was in a foreign country I looked up to the street and said they see the street sign over there. He said yeah, and I said That's complex and confusing and he said no, it's obvious what the street sign is saying I said why and he said because it's in my mother tongue. It's something I understand and I said, oh So you're saying you are familiar with it. So oftentimes we confuse this term When we say simple, that's a wrong term to use. It's not simple It is what we are familiar with And we have to ask ourselves are we saying simple or are we saying familiar? Let's look at an example here Let's say I'm gonna take a bunch of prices and I want to total the prices after a discount than 10% How would I actually do this? Let's give it a try. So I'm gonna take some price values, right? So I got some bunch of prices on the hand. You can see 10 15 20 bunch of values I want to total these price values, but I want to discount each one of them by 10% So what should I do? Well, let's say double total equal to zero to first begin with right and then I'm gonna output the word The word value of total and then I'm going to say far in I equal to zero I less than crisis dot Hmm is a length or size I Sure Okay, so I Is it less than or less than or equal to is it plus plus you know where I'm going with that, right? What are we trying to do do a very simple task and yet what are we doing? Asking these questions is it size or length is a less than or less than or equal to and then when you finish it Three weeks later somebody says your code is wrong and then we all probably say oh One error, how do you feel when you have off my one error? That's totally stupid right that we have to put so much effort in doing such a simple task a trivial task After all to get this done and if you notice this that was quite an effort to get this done actually can see this I'm gonna argue if you show the scope to somebody and say what does the scope do? What would they tell you then say hang on let me see what it does Let me read and understand what it does then it's of time And you ask them what do they think about this code? They probably we tell you oh, it's a simple code But they got this term very confused The one they're looking for is not the word simple the one. They are looking for is the word familiar Almost everybody who writes code is familiar with this code But I'm gonna say this is one of the most complex code We could actually write Why is this complex it is familiar and complex it is complex because What are you trying to really do find the total of all the values? That are discounted Instead what are we really doing sitting there and looping and what are we doing for looping? Hey, you first set a variable whose value is zero Second initialize the variable index to zero then make sure you increment it Third make sure you set the boundary conditions properly Notice this is called dancing around Notice how much more effort we put in to do this job here and there are so many Moving parts in the scope. I saw Michael Featherstweet one day. He said in optic oriented programming We encapsulate the moving parts in functional programming We eliminate the moving parts. What a great way to think about it in optic oriented programming We encapsulate the moving parts in functional programming. We eliminate the moving parts What's the benefit of eliminating moving parts when you have fewer moving parts fewer things go wrong? Now this code has way too many moving parts way too many mutability You are mutating the total variable several times and you are mutating the variable I Several times there are more opportunities to get things wrong Whereas when you have fewer moving parts, there are fewer errors fewer moving parts easier to understand fewer moving parts Easier to change fewer moving parts easier to make it concurrent So what can we do about this code? Well in Java 5 it's been around for what 10 years now We already have an answer which is much simpler than this We could simply say total equal to zero and Rather than doing that we could say in price in Prices and then we could say total plus equal to price times 0.9, which is the I don't think we are really interested in doing right in the previous case I didn't even do the multiplication is overwhelmed by the amount of code I have to write So this is a lot simpler Notice both the code produce exactly the same result If there are two pieces of code that give you exactly the same result, which one should you choose? The one that is doing less effort to get you that result The one with fewer moving parts to get you the result the one that is easier to maintain To get the result not necessarily the one that is the most familiar Because I may be familiar only to ride a bicycle But you cannot tell me there should be no airplanes in this world, right? So we have to look for efficiency productivity as well. That becomes very critical So in this case the form that we have here is much better So we should never use the other for loop unless maybe we have to manage a Manipulation when index variable, but all the different to those loop through why would we want to use the old formula? We can do a lot better than this. We could do a lot better than this. How? Let's give it a try. So notice what I'm going to do now. I completely remove the variable I can have it if I want to do but I don't have to I'm going to simply say output and I'm going to say prices dot and I'm going to call upon a very fancy iterator this fancy iterator called stream is available in Java 8 now and I can say on this map to double and Given a price value give me a price times 0.9 and then once I get the value out of it simply do the sum operation on it and give me the result Now notice how we change the code and we're not even using an external or loop in this code But what is the benefit? Shockingly I show this code and I can tell you how many times people look at this code and say oh it is complex and I remind them I'm sorry the word you're looking for is Unfamiliar when I'm unfamiliar with something. What does my brain tell me run? This is different. This is strange. You better be scared about it Right. This is human nature We cannot we cannot really work around that we have to deal with it Our human nature is when you see something different be scared of it This is inborn in his wife. We had to and lived in caves. Well, it was a while back Right because we had to put up with danger all the time and so immediately our body Reflects back. I was jogging this this morning beautiful streets around here I was jogging this morning and a tree leaf fell on it fell on me and the first reaction Oh, what was it? Right? That's the human nature. I laugh every time that happens, right? And then the minute you realize it's a leaf you're like, oh, I can handle that, right? So the point really is that we get scared. That's our human nature to be scared and when you look at something very Unfamiliar your brain throws all kinds of exceptions on you and says run This is different in other words. You are afraid because you are stepping out of the comfort zone Think about this for a minute We all are working as programmers and we wake up in the morning Have a nice shower have some nice breakfast We get to work and we start coding and we got them so good We don't even get any as many compiler errors anymore and that is when you know you are in trouble Why because you have become so Comfortable when you are fresh out of college, you knew almost nothing and you are learning everything you can You made all the mistakes you can and people said that's okay. You're young you are fresh will give you help And then we get a little bit of experience and then we tell ourselves. I cannot make mistakes anymore If I don't make mistakes, I'm good if I make mistakes others will laugh at me and they will tell me don't even know this So what do we do? Oh, I know exactly how to not make mistakes If I don't do anything, I don't know I will never make a mistake So what do we do? We draw a comfort circle and ask me become more experienced What do we do we brought in the comfort circle and now we are so comfortable in the comfort circle We stand on it we sit on it We can lay down on it and everything works and then what do we do? We defend our territory and we tell people you dare not to come and change what I do Because I'm very good at what I do and I don't want to be bought back at the bottom of the stack Climbing up again, right? So we become very comfortable and the more comfortable we become It becomes very difficult to learn something different and we start rejecting those Violently saying no no no that's complex. We don't want that stuff Think about this for a minute Take an example of a very small child Seven months old, baby, or maybe 14 months old. I don't know different children walk a different pace This child is just about beginning to stand up and take the first few steps beautiful to watch this, right? And what does the child do takes two steps and falls down? Immediately falls down now. There are a couple of things we can do at this point My wife and I decided way back when we had little children my children are grown up now But when they were very small my wife and I agree that when the children fall down will pretend like we never noticed and We will make sure we kind of look glass through and make sure they're not bleeding or something, right? We don't want to be them to suffering through these so they would fall down and what do they do the minute they fall down? They immediately get up and they look around very quiet And they look at where mom and dad is or where the nanny is where the grandma has and if nobody's paying attention What does the kid do? Wipes and walks away, right? But it's just parents. What do we do? I mean, this is one thing I learned so my wife and I do so hard But we did this and my children never drew a tantrum never There was not a single day. We had tantrums in our children They would never cry in public the minute they stopped crying We would say reason it and they would immediately stop crying and reason and do stuff and it's very different experience Why don't children cry like that? Well, this is what my reason against the child falls down and gets up and looks around What do you do? Oh child if you fall down towards a child and the child looks up And there's a giant coming towards wouldn't you be scared if a giant leaps on you and the child freaks out and cries Not because the time fell down That's because the monster is trying to run over the child right or so it feels Poor children and then they cry every time they learn they fall down Why because the way they fall down they say oh here comes the monster again running towards me And the children get together they tell themselves my parents are really good people. It's over they fall down Right and the children are just tired forever So try this right don't bother just keep quiet when the child falls down see what happens Nothing happens. They just get up and go around and falling down making mistake is natural for us Until some time that's something along the way people tell us our society tells us how silly if you do fail And then we think oh my god. I couldn't fail anymore. What if failure becomes what we do every single day? What if I don't mind failing at all what happens then? Then that's freedom right freedom to learn freedom to experiment freedom to try something new freedom to make a fool out of myself and Only to get better at what I do and there's nothing in our field We really have been a little to lose by trying new things. It is so easy to try new things So this one is very unfamiliar But I'm gonna argue. This is extremely simple. How is it simple? Let's read what this code is telling us. It says given prices find the discounted value of all the prices and Total oh my gosh. Look at what just happened the code begins to read Like the problem statement all of a sudden There's a one-to-one mapping between what the problem statement tells us and what the code is doing There are no moving parts in this code This is declarative programming and there are no loops to deal with the loop becomes internal and automated It becomes a lot more easier to work with this is unfamiliar to a lot of us But once you become familiar you quickly realize this is extremely simple and not so confusing and really hard So we could write the code and evolve it towards simplicity very quickly So the very first thing I would ask is don't confuse What's familiar with what is simple? What we are familiar with may probably be very complex In fact, I would argue most of us are like a boiling frog You probably heard it with the story of the boiling frog you pick. I'm not I'm not suggesting you do this This is very inhumane So don't don't don't try this at home and say Venkat mentioned this right write the code that I asked you to do But not the frog experiment, but they took a frog and they put it in a water at the room temperature And the frog was happy just going around and then they started turning on the heat This is cruel, but it's not on the heat very small amount of heat like every two hours It increases by one degree and after several hours The water was literally boiling and the frog didn't even feel it we programmers are like that We don't even feel this anymore when we look at code like this, right? We have become this boiling frog and we are like, oh we can handle this. It's familiar, but it's complex We are boiling in complexity. We don't feel a thing. Why because we are familiar and that is why we have to be very So then don't confuse familiar with simple a lot of us are very familiar with Impregnative style of programming But declarative style of programming is simpler if we become familiar with it And we have to take the time to become familiar with the style of programming before we can appreciate its simplicity Otherwise, we are condemned to stay with the complexity on the grounds of being familiar with something So a simple has fewer moving parts with fewer moving parts fewer things go along and and that is something to keep in mind So simple is not clever simple is not necessarily familiar And the third thing I would say is simple is not over engineer Now over engineering nobody wants to create code Everybody wants to create frameworks these days. Nobody wants to create usable code They want to create reusable code ready which one said let's create usable code first then let's create reusable code Right, so that becomes very important to achieve that. But why do we create complexity? Well because we want to make things extensible Excessibility is this holy grail. I was talking to a company and Manager said hey my team said every day. We're creating extensible code And after they went into production the first change that came across the team said they need three weeks to fix it He said why do you guys need three weeks to press this break and all that I have to do was just change one field They need three weeks to it. He said why does my team need three weeks when they probably they're creating extensible code I said it's your problem. He said what did I do and I said the code was Extensible until you ask them to extend it if you never ask them to extend it would be still extensible, right? So the problem is we all build extensible code, but you don't have a clue what extensibility is Ralph Johnson the author of one of the famous the kind of four books one said we create Abstraction we create encapsulation. We create hierarchy. We create hierarchy of interfaces and classes Why do we do all of that because we want the code to be extensible, but in doing so we have built so much complexity that when the time comes to make the change the very effort we put into it makes it hard to make the change So a simple solution is easier to change than a complex solution Why because the change never comes based on what we anticipated This is a this comes from the off here Oh, I never saw that coming and when that comes over it becomes hard to make the change this code That's where the complexity proves them. There's a guy named group was a guy named group Goldberg He did a lot of these comic strips where he would create very complex designs And he would show how we can make simple things very complex He's got a lot of these comic strips one of those is this one here This is a very complicated system he built to enable that scratching Now I'm sure each one of us have built this at our company at one point or the other I remember one day. I was at work and I was looking at a piece of code. This was taking a data from database and 200 lines of code to convert it to XML file and Then send this XML document across and I took time to understand what this code was doing Then I went to the code it was called and the code takes this XML coming in 200 lines of code later in such a back with the database And I'm like, okay And I am like why why did we do all of that? Why not just take the data and just insert it in this other place that you have to insert it into So call the programmer and I say I'm looking at this code and the program is very proud Isn't that cool? No That's really cool. Look at the flexibility it offers. I've got the data now I have an XML representation the XML representation is here. I can bring back into the database. Isn't that cool? I said no, I don't see it. Why is the school? He said Venkat, you're no fun. You should have the vision. I said what vision do you want me to have? Look at how extensible this code really is I said, how is it extensible? The data can come from anywhere in the world The data can be sent to anywhere in the world. I said in our application Where does the data come and go from the database? Well, that's our requirement. Why are we doing this? He said Look, look at the flexibility you have Tomorrow you could do anything you want to do with this. It is hundred percent extensible You doesn't matter where the boundaries are. This gives you absolute extensibility And when I was talking I was really with my phone and suddenly he said, excuse me, and he said hello Is that her? Yeah, who's it? Venkat? Venkat? Hey, are you calling me? I said yes Why are you calling me? I said look at the possibility. How extensible this is? Why are we talking to each other? I could be anywhere in the world talking to you So we should always talk to each other by phone even when you're in front of me ridiculous and yet we do this in code all the time Because we want to build extensibility. Well, why don't we first understand and solve the real problem? Hey, how about getting the product out so people can actually use it and give us a real feedback and say Well, your application sucks and here's the way I want you to fix it Let's solve real problems. Let's not solve problems that we create on ourselves There's a name for these these are called accidental complexity And we have to really understand what these accidental complexities are because I would bet you we spent 60% of our effort at work dealing with complexity We have created on ourselves The Inherent complexity is nature of the problem. We cannot get rid of that Inherent complexity is the nature of the domain. We cannot get rid of it But accidental complexity is what we can do we can control we can remove right? That is in our case and we have to do that. That's very very important So I said that simplicity is not clever simplicity not necessarily familiar Simplicity is not over-engineered simplicity is not Terps Now some people get into this anxiety mode. I want to write the shortest amount of code Well, sometimes the cold is small doesn't mean it is better. It can become very cryptic Now look at this code for a second Have you ever seen code like this before? He's like yeah every day at work absolutely we all do right and he may say that's nothing new I've seen this well actually I saw this at a client site and as soon as I saw this code I said hey do you mind if I take a photo of this and he said sure go ahead and I did the little photo of it You may say okay. You're really excited. What's funny about this? What's special about this? It's not this code that I was really excited about it's what I saw below this code and I saw this It said God help me. I have no idea what this means And you know what this product was or is? this product is a very highly Capable engineering application a single license is a million dollars and the guys who maintain this code are all PhDs in their field and that one of the comment this guy wrote is one of those guys I See this as like cave paintings where you're saying please help rescue us We are standard in this cave. We don't know how to get out and then you see their bodies next to the paintings, right? That's how I feel about this This is sad or we see this all the time in code We don't understand what this code means and yet we have to maintain this code That's accidental complexity. We created this on ourselves Nobody told us you are right a cryptic code like this. We chose to do it So the next time you name a variable ask yourselves, how would you feel if mom and dad named you P? Is that what's your name child P? Is that your initial? No, my full name is P That's all the moment. I did that's it. How do you feel? Don't name your children P. Don't name your variables P. Get respected. Give it a good name Right, not a long name. No names are not necessarily good, right? Give it a respectable name So it's easier for us to understand what it's for Look at this code for a second. This is an exception test What does this exception test do? It says over here given this verbose except the name did that way It says set price call the max profit and make sure this code fails with an exception So this code passes if it has an exception if there is no exception. It should fail So you can see that the catch is happy Well, this isn't j unit End unit those of you programming C sharp has this had this feature called you can put an annotation or attribute and say Expected exception So when j unit Was adapted to Java 5 they said hey look now Java has annotations And they said look the end unit guys have been using attributes We can do this too and they put annotations on it. So you can say expected exception and then specify that Well, I don't like this. I Refuse to write code like this. In fact, I complain about this even an end unit But in a couple of years the end unit does a very smart They went at long enough for Java to pick this up as well Java j unit pick it up They deprecated in an unit. You cannot do this in any way anymore. Why because it's a bad idea What's wrong with this? Well at this you pass only for one reason a Tissue never pass for the wrong reason if you look at this test this test will pass only if the match profit method through Exactly that exception the rock cutter exception if it throws any other exception or if it doesn't throw an exception It will fail and what about this method set price better not throw any exception Well, what happened to this one this method would pass if Set price throws the exception also So both the code are not the same this code would fail for fewer reasons than the other code does So a better way to write this would be to write this verbose solution Definitely avoid this so-called dirt solution even though it looks concise or you can really write a concise solution in Java 8 by saying cost it price separately assert the rows and provide a lambda Expression that will control the area of the code that you're looking for so the point really is you have to make sure That the code is not first the code is concise So what's the difference both of them are short But a first code will hurt you when you don't expect a concise code simply get the work done So just because a code is small doesn't mean it's better. It's got to be concise and not first so we don't have to confuse Concise with first we very careful thirst this is complexity baked in concise is not So this is a wonderful code by Tony Ward. He says there are two ways of constructing a software design One way is to make it so simple That there are obviously no deficiencies And the other ways to make it so complicated That there are no obvious Deficiencies so we look at this code and say I don't even know what's wrong with this though. This reminds me of an experience I was called to a company to come and look for review I looked at their code and they said help us to take this code But as I was reviewing the code, I suddenly realized in their complex code There were several pieces where they were not taking care of threat safety and If multiple threads come and that's this code back things can happen and the minute I realized it I said hey guys, did you notice this code doesn't have threat safety? There's a concurrency problem growing in this code One of the programmers got very angry and said hey venture. This has been in production for three years What makes you think you can come and scare us today? And how do you answer such question? Well, thankfully I didn't have to before I could answer the question What are the other developers said? Yeah, but wait a minute every three weeks it crashes. We don't know why So a complex program can do this. We don't even know why the program fails It really becomes hard to understand what's really going on in the code so, okay We talked about what's not simple so far and maybe we can look for those and avoid them But would be sad to leave without at least knowing what is simple Well, let's try let's try to see a few things that are really simple So the first thing I want to tell you is Simple keeps you focused Simple does not distract you Simple does not take you on a tangent Simple does not let you focus your effort somewhere else then where you should be focused on and What is a simple code do it draws you in tells you what you have to do and you are done You're not sitting there and saying I don't understand how this is working. Let me go start researching on this language feature now Right if you're familiar with something it should be easy to understand that so let's think about this for a second Let's imagine. I'm working on a piece of Java code And I'm really not sure what function to call and I know there's a function like this But I know what function really if you call so what's the most logical thing to do is to search Right quick search and we can find out what this function is reasonable, right? So I'm looking for this function maybe to reverse this element and so let's write this one more time can be big Much better beautiful birds what these birds are I'm gonna say let's search for it, but I'm afraid I know the picture is gonna show before that Once again a little less distraction, but so distracted. Let's search again. Can we what are we gonna look for? What did you see? That takes off What are they telling you? Nothing What do they want you to do get your damn work done? To me, how many of you go to Google? Well most of us do why? Because we think Oh much better beautiful birds. What these birds are I'm gonna say let's search for it, but I'm afraid I know the picture is gonna show before that Once again a little less distraction, but so distracted. Let's search again. Can we what are we gonna look for? What did you see? That takes off What are they telling you? Nothing What do they want you to do get your damn work done? To me, how many of you go to Google? Well, most of us do why? Because you value your time That is why you go there you value your time. I value my time When I want to go for it look for a job API, I look for it If I want to know how somebody is making some history, I will Google for it. I don't want to be distracted by Now do you think This is simple to do. How many people in this room? has a courage Courage Einstein said right it takes courage under such a genius to create something simple I don't work for Google by the way, so I'm not promoting Google in any ways. I don't work for that I can speak anything about any of these companies. That's a fun of not working for anybody Why? Well, how many of us at work have the courage to say I'm creating this imagine the day the very first day when the guy walks to the office and says hey I got this interface working. Show me. There you go And That's it What do you mean? That's it. What do you have a text box? Well, okay, I added I'm feeling lucky. Are you sure? Feel lucky to have this job Do we have the courage to do this at work and say I'm done That's it. What do most of us want to do? Put a little clutter. We have to why? Because we won't be valuable if you don't clutter this up Simple city is weak Simple city cannot be good Simple city cannot be useful and what does this tell us? Every one of them is a myth and why do everybody in this room use this most of us at least use this Because it provides value and it doesn't distract us We go there and it tells you thanks for coming now get your work done and leave That is why I go there every day because I can be focused Right and to me that is extremely important. A good code is like that. It keeps your focus Doesn't distract you doesn't tell you stuff You don't need to know doesn't confuse the heck out of you and keeps you focused and says that's all I'm doing Nothing more in nothing less, right? That is hard. It is easy to create this It is easy to create anything else, but it's very difficult to create simple things that keeps folks This is a wonderful quote by Anthony of the south expiry. He says Perfection is achieved Not when there is nothing more to add But when there is nothing left to take away The real beauty the real perfection is when we have less When we have the absolute minimum the absolute essence Just to get things done So we can help the task on hand without this traffic That is the beauty of really creating simple things not easy But that's what we should raise right for so simple eliminates accidental complexity and really Hides the inherent complexity so it becomes manageable. So we have to eliminate these accidental complexities And hide the inherent complexity that we have So I said simple What is simple simple keep me focused? It doesn't distract me. The next thing I'm going to say is Simple is something that fails less When you have multiple variables, it fails more too many moving parts. I mentioned It becomes hard to maintain hard to understand too many logic I had a piece of code somebody gave me one day and he said hey, thank you. I've written this code and this is the code I wrote I cannot understand why it doesn't work. Can you help me this guy said and it's not long code 20 lines of code. I'm looking through the code and I said oh given the same foot There should be the output. He says yeah, right isn't it, but it's not it gives me something else Why so it both are looking at the code like fools And about 15 minutes later. We're stepping through every line of code And then I come to the seventh line of code and he takes the parameter That's the operation on it and sets it back into the parameter. It's a great wait wait wait wait Did he just change that input parameter and the minute I mentioned that he said oh don't I know what I did wrong Never mind. He walks away and the problem is found Because our mind doesn't think we would do something as silly as change something given to us Mutability is evil and we should avoid it good books like Joshua blocks effective job. I tell us right promote immutability Avoid mutability. Why do they say that there's reason as mutable code is something that fails a lot more It's hard to reason code that changes rapidly the state of an object. We're smart But we're not capable. We are to ever human we get confused so easily We're not good enough to maintain those things in our mind Now you probably have see I've been asked this question before Why is the manhole round in shape? Anybody don't worry about being wrong Just give it a try. I'm wrong most of the time. Please go ahead. It will not fall down. You are right In fact that won't confirms you are right, right? Absolutely, I like this when you give the right answer phone rings. Excellent. That's right But that's not the only reason why this is That's correct, but hotly correct. In fact Change the problem a little bit around just for entertainment purposes. Don't tell people I want to fill a manhole to me around, you know, just that's easy. Don't tell them that you tell them Find me something that doesn't fall in. Do you think people are going to come up with a circle? In fact, they did not some of the designs proposed where these Because all of these have the property you mentioned as well. None of these will fall in to the hole as well But the circle has one property None of these have You know what that is Thank you That absolutely is at the end of the very long day This guy is coming out of the home and you're all tired You want to go home and everybody's waiting around and says why don't you put the lid and let's go and the dude says Which direction do I put in? Why don't you build the damn thing there and walk away? We don't have time for that You're right. The last thing I want to do when you get out of the manhole is to try to do engineering And say does it go this way or that way? And the answer he says face north now you're like which way is north? It's dark already, right? It's very simple. It fits any way you want to fit in Now think about this for a minute I I travel a lot. I work a lot longer or so to be tired is human nature when you're tired What happens you're confused when you're tired what happens your brain kind of causes them They are they pulled up to the gas station and I said I want to fill up gas and I'm tired And I drive my car and I pick up this nozzle and it doesn't fit. I'm like, okay. I'm tired Can you just work please? What's the problem? And then I calm down and said let me think about this Why doesn't this work and then it says diesel only and I'm so thankful it didn't fit Because if it had fit the wrong one or put diesel into my patrol car and it would have been a total mess that might right a great design It doesn't fit because it's not intended for this purpose, right? So a good design fails less. That's very important simple as easier to understand and easier to work with Now let's think about a few examples of this. I'm gonna go to some complex code or Unfamiliar code, but we'll figure out so I want to find prime numbers We know what a prime number is a prime number is a number that is divisible by the number itself and by one Oh great. How do we find a prime number almost everybody in this room who writes code has written a code to find prime numbers at some point Do this a for loop and you check within the for loop and you decide whether it's divisible. That's what we do But how about this example is divisible by Tells me whether a given number is divisible by this number. Great. I got a function called is divisible by then I said each prime number if number is greater than one because one is not a prime number and infinite collection Stream dot in frame to the math square root of the number plus one So this is the generator. This is the range for the number None match is divisible by So I simply said go ahead and find me a series of numbers Where none of those numbers in the range match this criteria called is divisible by very expressive Very unfamiliar and no looping externally Right, so we could think about writing code like this rather than writing the internet as time code we used to write That's anything one more thought Primes starting at I want all the prime numbers starting at a given number. Well, how do I do this? so is prime starting and I say return Concatenation of meaning given a number Take this number if it's a prime and Concatenate with all the primes that follow Otherwise skip that number and only give me all the primes that follow So can kind of it with the primes that follow or just the primes that follow Now if you run this code, you won't it won't work It will give you a stack or flow exception because it's an infinite Recursion and it would never run but entertain this thought for a minute Wouldn't it be so cool to write code like this if it would only run? How expressive the code becomes because we can quickly express saying oh all prime starting this number are This value with the prime followed by all the primes or remove the value and all the primes Recursion is awesome for that expressiveness How do we do that? Well, actually we can do that as you can see here in this example. So what did I do? I said next prime if the number is a prime give it to me Otherwise go back and ask for the next primes number. So that's a recursion and then in this case I say primes it starts with the starting number and account and what are we doing in this case? I'm saying go ahead and iterate but what are we iterating across? from the next prime or the starting number and that becomes a generator again a very Unfamiliar code for a lot of us in this room But think about this I say give me a stream from the next number to the generator and Give me only a limit of that number of elements and give me a list Well, this is called an infinite collection. Now. How do you do an infinite collection in Java 6? Java 7 Java 5 short answer you cannot What about languages like closure? Languages like F sharp on the dark platform languages like Scala and languages like C sharp and Java 8 all of these support infinite collections Most programmers programming and mainstream languages haven't used it But programmers using these languages like closure and Scala use it all the time Well, once we become familiar with infinite collections We can say oh we could build with these infinite collections very quickly and then notice in this case What do we do? I say give me prime starting with zero But the first five prime numbers and they're starting from a hundred only the seven prime numbers And we can see the list being printed as appropriate, but this is purely using an infinite collection rather than the traditional approach Simple is elegant Now think about this for a second Why is this? Considered to be the most beautiful painting in the world In fact shockingly did you notice? The most beautiful painting in the world is a painting of a lady Who is simple Doesn't have any ornaments No, you know glaring dwells Nothing really just natural and you look at it. She draws you in You feel calm at least you should Why is that that is amazingly beautiful, but why? Simple elegance No clutter. What is there that you could remove from there? Absolutely nothing You're elegance, isn't it? This is the work of a genius we say But what did the genius do to get the work done? something very simple Right, and that is why this is most amazing I'll talk about an architect dilemma when I talk about architect talk to the real architects not the computer programmer architects the guys who build buildings there is a beautiful church Outside of boss well in Boston downtown this church is called their Trinity Church and I was walking by the Trinity Church, and I do have to admit it is beautiful and You look at this church It is a beautiful church. The cameras don't do a good job when you stand there. The church is beautiful and so they have this beautiful tour Trinity Church in downtown Boston and One of the companies wanted to build a high-rise next to this church and the city said no We will not let you build a high-rise next to this church because We don't want the beauty of the church to be affected in any way When you're standing next to the church, we want to make sure the beauty is still there. We don't want to do it The architect said no, I'm gonna build a building here, and it would only Improve the beauty of this church and you may say how could you improve the beauty of a church by building a building next to it? Are you gonna do something to the church? No, I will not even touch it. I won't even come near it It's going to be beautiful and I have to admit to you. I did not appreciate the church. I Was actually standing for a long time and then my family said do you think we can really go You've been here for too long. I kept staring at this church But not at the church, but the reflection of the church through this beautiful glasses And this is one of the most amazing sites in Boston in my opinion You stand and you are mesmerized by the reflection of this church called the Trinity Church And this building is called the Jane Hancock building. It is just a beautiful building and you stand there and It's an amazing reflection of the church from different angles of this building What a nice angle of the building nice reflective glasses very elegant and Very simple way to solve the problem on him is I don't want to mess with the church I want to improve its beauty and in fact, it's more beautiful now to see the reflection of the church Than to see the church itself in a way and and that is again an example of what we could do with it But the last thing I want to tell you here is that We cannot create things that are simple It has to evolve You cannot sit at work and say today. I'm gonna create some simple and go vote. No You have to earn it. You have to work for it You got to struggle and you have to get to something that is simple arrive at something simple It's got to evolve and that takes time and effort So Richard Feynman said if you cannot explain something to a first-year student Then you haven't really understood it now This is a bit extreme But this is a guy who won Nobel Prize for quantum physics So a guy who won Nobel Prize for quantum physics tells you if you cannot explain quantum physics to a first-year student then you are an understood it and That is very true Because a lot of times when we cannot make somebody understand something It's not a reflection of the person who is trying to understand It's a reflection of the person who is trying to explain that person hasn't understood it I Was teaching for about seven years a topic At the end of seven years, you would say when could you know everything right? Well now I do And I was explaining something in the class and nobody got it on the seventh year I don't like why don't you guys get it? They're like, I don't know we don't understand what are you talking about? I said, you know what never mind forget it. I'll come back tomorrow and explain it So I went home. I spent late into the night working on it and I said why doesn't the class get it and All of a sudden about midnight past midnight. It suddenly dawned on me. I Haven't understood it and I've been teaching this for seven years That's a very shocking moment of truth, right? It's like you've been teaching this doesn't mean you understand it and I suddenly realize oh And it's suddenly like you feel the layer of an Ian and there's more inside of it And you've gone through a layer of understanding and you move it and there's more to understand and those clarity all of a sudden And the next day I came and said let me explain and five minutes explain and it was like that is so simple Why did we have so much trouble explaining this yesterday and I said it's very simple. I didn't know this yesterday I just learned it last night. None of you explain it better So sometimes you have to understand what you don't understand so you can go back and explain it better And that takes some time so we have to evolve that over time as well now Occam's razor says that if you have two solutions to the same problem And if both the solution produce the same result we got to look for the simplest of those two solutions That is very critical Now over the holidays I decided I want to write a book And I I normally write my books in about two weeks I don't have time to travel about you know 200,000 miles a year So time is very difficult for me to find so normally I would keep thinking a lot about books And I would take two weeks in a year and just climb through and write books in the two weeks those two weeks are very entertaining for my family because I would be home But they would never see me. I would wake up way early in the morning work late through the night and I have the door closed my family normally slides food in the door So every few hours the you know food comes to the door I eat that and I just stay there and if they ever see me during the time They would see me that I've not shaved all the hygiene goes to the door So sometimes the children would if I get lazy they would say oh daddy are going to be right writing another book So usually I write my books in about two weeks period I climb through so the time is very very important So this holiday I just said I'm gonna write a book on Java 8 Java 8 is just coming around the corner great time to think about writing a book So start writing a book on Java 8 and as I was writing the book I Accepted myself it'd be so cool to talk about certain things we can do in other languages like Scala like Groovy like closure Like F sharp all these languages Wouldn't be so cool to say about a few things that can be done in there So what I wanted to do was I wanted to implement a tail call optimization What is they call optimization well recursion we all know what recursion is What are the problems the recursion is like in this example? I have a factorial number equals one return number Otherwise return number kinds factorial up number minus one this will run fine for a small number But for a very large number you'll get a stack over flow exception So recursions don't work when their input size is big tail call optimization is a wonderful idea What that was introduced in this fantastic book called structure and interpretation of computer programs I highly recommend this book it talks about a process versus a procedure a procedure is the code we write a process is what runs under the hood and You can write a recursion and run as a recursion. It'll fail for a large number You can write a iteration runs on it as a iteration, but that's mutation most of the time but if we write it as a Recursion but through optimization it can run as a iteration you get the best of both words So this gives you quite a bit of benefit on your hand if you can do that. Well, that's great We can do that, but how do I do that in Java 8? well, immediately I started researching to find out if I can do take all optimization in Java 8 and No, you cannot do take a lot of position in Java 8 and You know looking for programmers they never take no for an answer. I said well Java 8 doesn't do it But can we do it? Well, I have one benefit fortunately And that is I know how this works in Scala and Scala does this through compiler support Well, that's ruled out. I cannot do that. Why because Java compiler doesn't support it So I cannot use a compiler head. I know how Closure does it again that language supports it inherently. I cannot do that Well, I know how glue we supports and they do this very cleverly through library support But I cannot do that also because in glue we it's dynamically tied Java is not dynamically type It's radically tied. How do I do that? So right in the middle of writing the book I gave up on writing the book This was more interesting than writing the book I wanted to research on this and I have to tell you I spent about 20 hours on this code Just trying to figure out how to make tail call optimization work and late in the night I barely had a code that got together and started working and it was very clumsy But there was a sign that this was actually going to work. I said this is great It's gonna work now right the sign of hope you get when something is going to work But it's not a total mess and I said, okay 20 hours later. This seems to be working I'll come back and take a look at it again So let's say I came and look at the code It was a total mess, but I know it can work the feasibility study is over now I want to write this code so I wrote the code and It took me about 10 hours to write this code now, right? To the factory to make it kind of presentable because in a book You have to present something that's actually as others can understand as well isn't it? But at the end of this time it was hard to explain it hard to really Convey what's happening, but more each factory later and eventually ended up with something like this Factorial and I have a fact and a number if number is one return a done-off fact otherwise return a lambda expression of a call to Factorial of that multiplication don't try to read too much into the code But it's a recursion implemented using tail call optimization, and then I call that method that works But there's a lot of things that are not known here. What does done mean? What does called mean? So here's the code for done and called after 10 hours of effort And I have this code a tail calls class, and I have a method called interface called Is complete and I have a method called result and apply So these methods are providing a certain behavior or interface for tail call optimization, and the code itself is something like this Is complete returns of false as a default implementation and a return now for a result And I have a method here's what the code of the solution is invoke and what the invoke says is tell me if this is complete If it is not complete get me the next detail call operation Perform it and then check if it is complete otherwise check it is complete otherwise techniques is complete pure recurve That is all the code is about 20 lines of code you are taking Well great when 20 lines of code you're done right? Well, there was one problem in the code The problem in this code is after all this effort 25 hours plus 10 hours right in the middle of you know getting this job done is Notice this line of code right here Call complete equals current dot is complete What is that doing? What is that doing? Mutating isn't it and you probably heard me several times today saying avoid mutability didn't I well if I'm saying that several times now Guess what I was was I was telling in the book Almost in every chapter several times I told people don't use mutability and Now what are we using? mutability So sitting and worrying about this. What do I do? So I came with a few solutions the first solution was Remember I told you I would use mutability Well, don't use it unless it's unavoidable like this I was the first answer and you're all laughing already and that's why I felt about it. I said no I don't want to write it. Then I came up with a much better answer one that I'm sure you would love I Said do you see I'm using mutability. I Leave it as the exercise to the reader to make it immutable Meaning your author has a no clue what he's talking about right and I wrote that and I knew this is really not good And I told myself no I've got to find a way to remove this beautiful But how and I had no clue how to do it and I realized one thing My code simply sucks And I'm not happy with it, but I don't know how to solve it and what do you do when you don't know what to solve it You bang your head against the wall. What does it do? It either makes your head or makes the wall or both It doesn't solve real problems. So I said all right. I'll come back to it I'll think about it and I went away on the next morning. I was on the treadmill I was jogging and Far away from my computer went on to doing other things right and I was talking on the computer slowly my Little thread in my head is thinking about this problem one more time and one more time and all of a sudden I yelled out oh gosh, of course Why did they think of that stupid little solution and I jump off the treadmill run over to my desk with my Family saying is everything okay? I'm like, yes I found the answer right and I run to the desk and I completely refactored the code and one of the fact of the code was This I said invoke Straight iterate called from the current object applied method Is the call complete find first get me the result for one notice? There's no loop External what am I using really what I'm using what is called an infinite collection and Combined with another feature called lazy collections. You may say why wait infinite collection a lazy collection How would anybody know about it? Well good news. I spoke about that in the previous chapter in the book So the reader knows about this already. I didn't know about it right that I could use it And once I realized it Complete mutability was gone Like that and the problem simply said think of a recursion as an infinite series Recursion we think of a loop where you call a function and then you call the function again And then you call the function again rather than picking it that way Just imagine close your mind and imagine that you have this Recursion where each function is a little box These are the function is connected by a thread forming a train of these boxes How many can you have we don't know because we don't know how many levels we go iterate of recursion So it's an infinite recursion Well, okay, that's great. Now that I have this internet recursion Just apply each of the recursion Until the first one says I am done and you don't have to go anymore Okay, great so far, but how do you deal with an infinite recursion where because you cannot have infinite memory? Well, you don't need infinite memory because the infinite recursions are lazy recursion meaning they do things on demand They don't do it ahead of time So this is an infinite recursion and the fine first says only do as much work as needed But nothing more and it's very optimized for that So it whistled down to just about three four lines of code with no mutability But it really required for the 35 hours of Struggle and a run on the treadmill to find the answer Sometimes the best solutions come to us when we are detached from the problem So if you're struggling with something you don't know how to do it Break walk away go to a park Enjoy a nice walk. Take a cup of coffee. Sometimes I don't watch TV But the only time I sit in front of a TV is when I'm trying to solve a very hot problem I'll be sitting in front of the TV speaker coffee and people say, well, did you hear that news? I say what news on the TV is what TV? I'm not even watching it right my brain is detached from my surrounding I'm sitting away from that, but I'm just getting away from the code. That's what I'm doing And suddenly I'm like, oh, yes, of course I could do that and then right away go and you have a better solution on hand So a lot of times you solve a problem by walking away from it Why is that because our mind is very clever, but it gets engaged and get tangled and you have to Untangle it and re-engage it for it to find the problem and the solution and sometimes This is why sometimes you go talk to other people if you go to somebody and say hey Let me explain to you what the problem is I'm having and half way through explaining probably stop and say, you know what? Never mind. I found the answer and the person is like I'm glad I could help right and said nothing else to you Why is this happening because you detach from the problem and then you really engage your mind and you're able to find a solution So if you want to find something simple take the time to find something simple Evolve simplicity walk away from the problem and come back and you may find something better than what you're trying to do Putting more hours on a problem doesn't yield the result Sometimes you have to work efficiently not work just hard right and efficiency comes from walking away sometimes and re-engaging the mind And we are more creative in finding the solutions after that point. So it has to evolve Again as Einstein said Everything should be made simple as possible, but not any simpler, but the question to ask is is this simple? Or can this be simpler? So this is what one of the things I do any time we create something I Don't accept it as being simple. I give it right away to people People who are smarter than me People who think different than me and I tell them a critique my work Tell me what you think and sometimes they say oh, this is great But a lot of them they say why don't you do this and now I have something better So, how do I know what I did is simple or can it be simpler? Well, now I believe That simplicity is like a shorting your staff The code is probably simple and complex at the same time It is simple because I can understand it. It is probably complex because it probably can be simpler It depends on the perspective of the person looking at it as well It is very subjective But I believe that we can make things simple by evolving it by getting feedback from others by showing it to other people It is a lot of effort. It is a lot of struggle. It is something that doesn't come too easily It's something that we have to work really hard for to achieve that and we have to take the time to do that Simple makes things easy, but it certainly is not easy at all But every minute we spend on it is worth it because as DaVinci said simplicity is the ultimate sophistication in life and it is well worth it. Thanks for your time Do you have time for questions? Five minutes for questions? So anything you want to talk about, share about, would be delighted to give Don't be shocked. Nobody has questions. Naresh will. So I would rather hear from you You don't have to ask a simple question. It can be a complex question. Go for it. Thank you Please I'll hear you So very good question. So the question that you asked was You know, hey, we've got projects. Time has been estimated. Budget has been estimated. All these has been estimated How practically can we realize what we want to realize given all these constraints? Summs up your question? I usually say about this Guy who walks into a bar. Always a nice thing to think about, right? A guy walks into the bar, but what do I do a bar? finds this young beautiful lady and rushes to her and says Sweetie, we're gonna get married. This is the day we're gonna get married on June the 2nd We're gonna have four children. Here are their genders. Here are their names. Here's where they're gonna go to school Here's where we're gonna live. Here's where we're gonna retire. He says all of this and the ladies in panic and says Who are you? Well, the guy says I'm a traditional project manager Now this is absurd, right? Nobody in the right mind would do things and yet that's what we see at work every day We have people come to us and say we got all of this figured out all you have to do is just show up and just get your work done and That's a fallacy No, we all talk about agile. Now. What does it really mean agile developer? Agile developer is really about getting the feedback like to learn about where we are and Steer up to where we need to go with the most efficiency we can Based on the realities of what we know, that doesn't mean don't plan don't have a vision But what it means is only coming to what you can know at the moment and Postpone things to a time when you can get better idea about it. That is very critical So if we want to fix everything, we have fixed one thing That's called failure and that comes as part of the package of that So the reality is we plan only as much as we can really know And the key is adaptive planning and if we're not doing adaptive planning I don't care what they call it as it is not giving them success, right? So I'm not interested in the word agile because what's the point in failing with the word agile? I would rather succeed and not know what I did to succeed rather than saying I was agile and failing with it So adaptive planning is extremely important. These problems don't go away because we use the word agile These go away because we change our behavior and until we have already changed our behavior We cannot expect better results. So there's no short answer for your question. It's not that simple Any other questions or comments? One more maybe Need to think of the current requirement. Just do it simple. Yes in a simple way because I worked in a project like exactly We've got a team of technical architects They made it simple. They considered that requirement They did it and then there was another change in requirement and but when the technical architect decided, yes, this is a change But this will change and put has gone up and the customer was like I thought your technical architects would decide it's such a way that's keyable and then let's rework So that's great question So so let's think about it for a minute. You have a problem and it's very clear But the solution to the problem is not to do more complex things because that doesn't work either So we need to understand what we're wrong here. What we're wrong here is We are doing something based on what we know now and something later comes up that doesn't fit it And a way to tackle this is don't do stuff that come by your way This is kind of goes back to what related to what you were saying Agile doesn't mean we only take what we have on hand and do it You have to step back and get a global picture of what your overall goal is and then you have to prioritize based on two things What's the most valuable and the most? Impactful and if I were to do what's most valuable and most particularly impactful and then when I come back later What I'm going to get is going to be less valuable and less impactful It should be easier to handle it or not as important This is that doesn't eliminate the problems But it can reduce the problem to a great extent the chance of running into something that you talk about to be less In that case because we prioritize them based on value and impact In that way, is it possible that business changes randomly and we off the bat get something that we never expected? Oh, absolutely. I hope we do and when we do that's called karma, right? And we better deal with it. There's no point in saying I will be extensible forever. No Well, you know what? We did our best and here's what we did to minimize all these But when a risk like that happens, let's deal with it. And what do we do with that time? We say, well, this is so important now Let's do that now and because we have done more important things until now and fewer less important things now We can insert this right now and the time we are spending on this We could remove some features towards the end that are less important But don't worry about it. The one thing I'm talking about already done again The prioritization can help again That's something we need to keep in mind and as a development as a government is not running wild without any planning, right? So to plan everything is dangerous. To plan nothing is more dangerous It's a pendulum. We have to be really watchful of and the pendulum has to strike a balance The other extreme is we'll plan all day and get nothing done and all the plan is obsolete by the time we finish This extreme is hey, we will never plan anything and we'll be shocked every time we see something new Well, the nice balance is let's prioritize these and try to understand whatever Where are we going and what's a better route to go based on what we know? And then of course make adjustments along the way that becomes very important as well Well, I'll be around here for today and tomorrow. We'd be delighted to talk to you further at any time off the stage So thank you very much