Hello and welcome to lecture six of the Sports Biomechanics lecture series supported by the International Society of Biomechanics in Sports and sponsored by Vicon. In the first of our three lectures today, I'm joined by Pedro Maruso from the Polytechnic Institute of Lyria in Portugal. Pedro was actually winner of the ISPS new investigator award in 2014 and he's got a lot of interesting research involving the biomechanics of swimming. So today he's going to give us a brief overview of some of the literature in the area of swimming biomechanics. So thank you very much and over to you Pedro. Well, thank you very much Stuart. First of all, I really would like to thank the opportunity for making this presentation. Really, thank you for ISPS, but also, and most of all, thank you for Stuart for coming up with this hard work, getting many people talking about their passion and what they love to make research about. So indeed, when I was invited to talk about swimming biomechanics in this type of situation that we are living in, I got a little bit stressed up about what to talk about without taking one day totally or something like that but to make a short presentation about half an hour on swimming biomechanics. So before that, if you saw some of the previous lectures and if you didn't, I really invite you to do so. I would like to start by telling a little bit about myself, because I really think that is very useful for the ones who don't know me. But there's one big thing I would like to tell is that I was born fat. So really, I was born really, really fat and probably because of that my parents put me to play almost all sports that you may know. Apart from sports, they also put me on the ballet. So as you can see on that picture that fatty guy over there. It's me. So for the beginning that I remember human movement was always on my mind. So I was one of those guys who didn't have any type of doubts about what to do in the future, and it would be something related to sports. Indeed, I come from a small city here in the middle of the country you can see over here. And so when I had to study to get my degree, I went up north to a faculty of sports of the University of Porto that many of you already know that is a very big regarding sports sciences and where biomechanics as a role, a fundamental role for the students. And from there I took a very, well, let's say hard decision on 2001 on the exact same day of the World Trade Center came down. So I had to choose an option and I decided to take the option of swimming. And that was something that was by the time something that really was challenging because what we used to say is that when you put water, everything becomes much more difficult. So as you can see, we were a small group of people over here, if you see the picture of the ones who selected, for instance, soccer, you will see that they are much, much more. So we had the challenge to really come up as a group interested in swimming, mostly interested in swimming biomechanics and physiology. And so it came up to be one of the best decisions I took in my life. These gentlemen over here, some of you may know it's Professor João Paulo Vila Boas. If you go to the Web of Science and you search for the topic swimming, you will see that he's the top leader author. And most of all, he was probably responsible for being the father of so many young researchers that's in Portugal and abroad are making very big, very important research on the field of swimming. So it was for me a huge pleasure to be student of him and try to learn with the best. There are some examples like Professor Ricardo Fernandes or Professor Tiago Boas that many people know are top researchers on the field. But apart from that, and I was supposed to be talking also to some of students that are nowadays taking for instance their first degree or even their master degree. And I have to tell you that swimming became my passion. So indeed, when you are studying you should try to find and reach what you get in love with. It will become much easier. And of course it will be much more interesting for you to keep working on that on your free time. So I really got enthusiastic with the idea of the idea of the waters induced biomechanic issues. And I tried to do everything I could to get involved with the ones who could benefit the most with the swimming biomechanics that is the swimmers. Of course the coaches, and even when you find obstacles on your path, don't quit. So there was no funding for me to go to the World Swimming Championships in Manchester, but I was able to get a backpack and sleep in a hostel and by myself become a volunteer of the organization and get to know the best swimming coaches of the world. So just a final remark about who I am, who knows me, tell me that I'm a workaholic, but I do expect that before this situation that we are living a little bit like this and after I suppose that it will keep being the same. So regarding biomechanics, the main question that I really like to talk about is how can it be useful for swimming performance, indeed trying to increase the swimming performance of our athletes. As you can see down here, there's my email so please feel free to use my email or my Twitter account to get in touch. I will be more than happy to keep the contact further this presentation. So about biomechanics, and you can see here, I'm sorry, now starts. You can see, you can see here then the video that this is front crawl on both videos. This is the same swimming technique, the same swimming stroke, but the truth is that they are totally different from the left to the right side. So the main thing that I got interested in the last few years is that when you are talking about the same stroke, you might be talking about different biomechanical constraints that will surely have an impact on swimming performance. And so I made this draw over here, and before we're live getting feedback response in real time, I would like to ask you how do you think it will go with the world record for the 50 meters freestyle to the 1500 meters freestyle. So if you would put here the 100, 200, 300, 400, etc., if it will go like the orange curve, the blue curve, or the green curve. The interesting thing that you might do this homework is that you will come up with an almost perfect correlation between the time and the distance. And indeed, when we start thinking about this, we come up with a very interesting idea is that swimming is a very easy sport regarding the rules, and what you have to do. If you go to the starting walk, you already know the distance that you have to travel. Most of the elite swimmers already know how many strokes they will have to do to finish the event. And so you have to make it the fastest you can. And that's it. The main issue is, indeed, how can you make it faster? And how can you make so that your, the energy that you are using is really, really used for the purpose that you want. So are not to spend energy that it's not efficient. And as I said at the beginning, swimming, swimming biomechanics need to become your passion to really go over this and try to understand clearly, how can we come up with tools that might improve the performance of our swimmers. So this is a small example of some of the things that I got really enthusiastic about. And I think that studying is one of the most important things that you can do for the rest of your life. Because when you study, you have, you must have your open mind. And with that open mind, you'll be able to see what others are coming in conclusion with, and how can you use that for your daily work. But also from studying comes a different thing that really should be questioned about that is your experience. And the experience that you go through will tell you a lot of things about how to work. I have a small experience that I really, really came up to me when I had some time to think over it. That was with the Olympic Games in Beijing 2008, when I was making some biomechanical evaluation, not from the swimmers but from the national Olympic throwers. And by the time I was really, really only looking up to the biomechanics and the bio energetics that was only the only, it was the only thing that was I was thinking about because I really thought that would be the only important things. But I was able to understand that even if you make the most rigorous work on this side, there will always be a mental side that really comes up with the final result. I do not try to elevate something and forget all the other aspects because there is a multidisciplinary issue regarding some performance on sports, and most importantly on swimming performance. With that in mind, well probably most of you know about this issue here on the Beijing Olympics and the finish of this event. And I usually say that when you look about genetics, they give us the tools like everyone tells about how the mechanical issue for Michael Phelps could be improved regarding his anatomy. But indeed, I do think that biomechanics teaches how to use them. So if I have some type of genetic profile, and that will give me some type of stature and arm length, probably biomechanics has the skills to teach me how to use them the most correctly as possible. So with that in mind, I would like to tell you that regarding the forces that the swimmer produces inside the water, that's something that we've been trying to understand for years. And most of the evidence really comes up for what the swimmer does, and then we try to understand why does he does it. Some different type of evaluations come up. Some of them on dry land, some using and pressure systems, some using some mechanical models or some forced reducers on the mad system, and the one that I was working most. I'm working most throughout the last years is indeed using a load cell connected to the swimmer so that the swimmer can make his stroke at the same spot using both arms and legs, while you are recording the forces that he is producing. And that idea, well, Majel in 1970 came up with this proposal, however, here you can see it was in paper. So it was really, really hard for me to understand how can we, without the technology that we have nowadays, make some type of evaluation on paper and trying to understand for instance, average, the difference between the right side and the left side, etc. But he came up with this approach regarding, well, he used the idea of Carpovic in 1939, and then he improved it, and he came up with this situation. And indeed, throughout the years we have so many advances on technology and for sports sciences that was also very, very interesting because it made this available to get much more data and much more information. But the main thing I really would like to come up with is that throughout these years. And as I said at the beginning, my main issue has always been trying to understand how can these approaches, how can these swimming biomechanics, how can these evaluations be useful for the swimmers and coaches. Well, it's my idea and my way of working, but I'm not so much concerned about publications about making the papers on the best impact journals. I really think that it's important to spread that and this disseminate the knowledge, but most important and the first situation is indeed trying to be useful for the athletes and in this case, for the swimmers. So I do know that getting in evaluation system and trying to see how am I able to draw the profile of the swimmer. That will event me find me that will identify me at that precise moment, which are strengths and in week of those weaknesses.  And the main issues that they are always questioning is that, indeed, if I do know what parameters should be evaluated, how can they be evaluated. When should they be evaluated and even even more important, how often should they be evaluated, because, at least from the research that we've been witnessing in the last years, we do know that when it comes to swim practice, there is a big doubt about how to increase volume and how to increase intensity. And we cannot go infinitely to increasing volume. So we need to work on the appropriate intensity so that you can get the best outcomes of your training. And indeed, this is something that they they know that I focus a lot is that how can the results be used in the real situation. And many times we are well surrounded by the pressure of publishing or perishing. And so we do a lot of intricate studies, but without the tools that really are useful for the streamers that sometimes are very, very easy to come up with. And so, this is just a small example of something that, well, it comes up with the passion that I talked about. And in 2003, in my city, there was no chance of having a subaquatic camera. And so I went to a shop, and I bought this surveillance camera over here, a very cheap surveillance camera, and with some few adaptations I was able to put it recording underwater. And at the same time, using an above water camera, I was able to get a dual system. And I can tell you that forgetting this camera over here that is a conventional camera, I'm talking about 100 euros over here, and I'll tell, well, 15 or 20 euros, this type of trolley. So it's very easy to get this type of approach. Well, in 2003. Now we have GoPros, now we have other full systems. But the most important thing is really don't quit when you don't have the best equipment that you should like, or you would like to have to make your research. And so, getting a little bit with imagination, I was even able to get the four cameras working at the same time, and so that I could record on the frontal plane and or the surgical plane at the same time and indeed try to be useful making some kind of qualitative analysis. So this for me was very important just to say one thing that when you get some obstacles that you probably will don't give up. Never. So try to talk to everyone you know try to come up with an idea of how can we overcome this difficulty, and now can we really come up with the ones that you were things that you want to study. I'm sorry let me just get this volume down because indeed it was very, very loud for me but just to give you an idea like this is the swimmer swimming, what I will call free swimming so there is no nothing interfering with his swimming technique is swimming comfortably throughout the pool, and I selected back stroke on purpose because you can use well any type of stroke that you want, you can get the instantaneous velocity of the swimmer, but what you can see is that he has attached to him a speedometer. So you get instantaneous velocity of the movement, but many times the kicking will interfere with the results that you are trying to measure. And you are restricted to one swimming pool, as you can imagine if you are working on a 25 meter swimming pool. That's the distance that you can cover. So feather swimming for the ones why not so aware of it. It's using a swimmer so you put the swimmer connected to a load cell over here. There is a small angle so that you can avoid that kicking process on the wire. And so he swims on the same spot, you can change the intensity, as you notice he started slower, and then we got the whistle and he started working it with more intensity, you can use it for the fourth stroke for strokes, you can use it using equipment or not and you can see the differences. So there is a real world that you can use for this show. I just would like to get something that when we read the papers we really don't get with that idea. I think many people think that when I talk about the useful that that would seeming can be they see some kinematical changes. Well, of course they do. And if you go to the gym, you will see that a bench press it's much more different than these two real stroke but they keep doing bench press so the idea is not use these as a tool for training by itself for many for, well, high volumes. The idea is using these to make evaluations and indeed try to understand all the forces produces in water are getting what's the behavior of those forces. So, with that in mind, we come up with some ideas on how could we validate this approach and try to understand if it was very similar or not to free swimming, and it is worldwide people are using tethered swimming and comparing it with free swimming and the differences. Well, there are some kinematical differences but so short that indeed it can be used for swimming evaluation. And for instance, both things stroke rate a biomechanical aspect or in the elected production, more on the physiological side, you see that there are indeed very small differences between the two approaches. But with something like these so as long as he's swimming, you are getting these instantaneous force production. And something that I really would like to make give up the challenge the challenge to you that are hearing me is that this is something that we come up after 30 seconds of stroke, and you can see, there is an average, and there is some variation. But the challenge is indeed we should be looking further to something that came up in 2007 on sports biomechanics that is these movement variability, and how can these be really really important for the athletes performance and on this case for the swimming performance. On that side, you can see that we have the instantaneous force, you can separate the right side to the left side I call the dominant and the non dominant, and you can see some asymmetries regarding the force production. You can even see some type of behavior that all swimmers presented, apart from their level. So I'm talking about elite streamers, but I'm also talking about lower level swimmers. They are asymmetric, and they are symmetric not only on the force production, but also as already stated by research French researchers on upper limb coordination, or even on the end path. So if the swimmers are symmetric. Let's call it like that. How can that be useful for me on the biomechanical side. Indeed, how can we know if those symmetries may alter the optimal function, or they are within the thresholds of normal variation. So I really suggest. Well, I, you might see the link over there but it's easy to find the papers from Ross Sanders on 2011 12 and 13 on the journal swimming research. So we come up with some interesting ideas on a symmetry. And don't forget what I started to say that is swimming the 15 meter freestyle. It's totally different from swimming the 1500 meters freestyle, both using front crawl, but with several differences regarding the biomechanical issues. So apart from that, you may also use that route swimming to put the swimmer using both the upper limbs and the lower limbs, or you can constrain his movement using only the upper limbs and only the lower limbs. So if you can do so, you come up with something also very, very interesting. There is, as expected, when he uses the old body, he makes much more force he's able to produce higher levels of force, of course. And when he uses only upper limbs then he can produces higher forces than using only the leg action. One interesting thing that really come up with my mind was what's happening with these 15% when you make some calculations of a swimmer that okay. I would say that he gets 100% of the force production when using the all body, but only using upper limbs is able to reach the 85.7%, well with the standard deviation around eight. And then when using only the leg kicking is able to reach 35%. So this is the results from one swimmer, but on average, that's something that we've been having. When you make these plus this, you will get over 100%. So what can that tell me, what can these value over here tell me when I've made these deficits of, I will call it a deficit of force production, how can that be useful for me. Once again, this is also a symmetry. This is also regarding the differences that you can achieve from the upper limbs to the lower limbs, and how can we know if they are not are or not in the normal variation. And this idea over here from Kaskin in the late 90s, when he was stating that indeed, when you are talking about propulsive forces and swimming velocity, they should be balanced. And if they are not balanced, if you fit over here, probably you will need to have some improvement on your propulsive forces, and if you are somewhere over here, you need to have an improvement on your swimming technique. Well, this is a theoretical statement, but a very interesting statement regarding the relationship between the forces and the swimming velocities. And we do know that swimmers aim to be, well, applying most of the time forces in the water. And with that, they will come up with an, well, it will certainly occur a variation of velocity in each stroke cycle. And this is a very interesting issue that there are a huge amount of manuscripts working on this inter-cyclic velocity variation and how it can be considered an efficiency parameter. Once again, always having in mind the performance optimization. So for me, the main result comes, as I previously said, looking at the subject, looking at the swimmer at that precise moment. So I come up with this data, these are different swimmers, these pots are different swimmers with their swimming velocity, and the forces exerted. And that tells me something that I really should look at. Each one of these is a different swimmer. I should know who's, who's, who's who, so who's this red one, who's this blue one. Why? Because I really should understand that they are in a stage where they should increase their strength, I need to focus on their coordination. Only with that inappropriate coordination, it will come a speed increase. And with that speed increase, we should also be aware of that coordination. So if you take a look at this situation right here, and if you study the same subject, and you evaluate them again three months left, again later, see what happens. They are over here. And now they change. They change some for the right, some for the left, some for up, some for down. But the, well, if you are only interested in the average, they will keep more or less the same. But indeed, watching this will tell us if the strength increase that we are achieving is, or it's not being useful to increase speeds in the swimming speed, the speed, the swimming speed. And if that is not happening, coordination work needs to be done. Some of the later approaches that we've been working with is that indeed trying to understand if the inter-cyclic variation of velocity can also be used as the inter-cyclic variation of force. I didn't put here, and I would like to ask you to try to guess which one is force and which one is velocity. You see, they are very similar. Right. When I come up with the values of course then you can notice that it's the velocity and lower is the force. I'm talking about the technique for evaluation that comes up with very similar resources to free swimming. And if so, probably using also the inter-cyclic variation of force. That is something that I'm researching with Spanish colleagues right now. It's using it on the swimming full moon as a way to make some quantitative analysis of the swimming technique. But as I said, most of the times I'm really, really interested how can we be useful and how can we translate this to something for coaches that are not available to have a load cell and measure the strength forces that the streamer produces underwater. So just to finish and to tell you something regarding the future and what I'm looking up further is that trying to get interesting results on swimming biomechanics that are user friendly. And that is something that, well, every biomechanist is always thinking about how can we be useful for the coaches. The device that you can see over here is attached to the back of a swimmer. And there's something that I really think is interesting for everyone to understand that is with this device, the swimmer can go and make all the practice and I'm talking about two hours in the water or more than that in the water. And then the coach comes home. It takes the data on his computer. And one of the important things that the system does immediately is that the coach doesn't have to tell the system which stroke he was swimming on training. So immediately we can recognize if it was front crawl backstroke butterfly or breaststroke. I will show you a short video, it will run very fast because I really cannot show this yet, but just give you an idea about the future. As I said, you just need to select which is the length of the pool and upload, and it will run very fast but try to understand that we immediately can get the results on each stroke and get very data on one training and have reference of past trainings for all the swimmers that are using the equipment. And this is something that I really think that we will be looking in the future, because we need to understand that the tools need to be useful for training. And so the coaches cannot be waiting one week or two weeks for the results. With this system they will be able to immediately get results on body rotation, trunk inclination, stroke rate, stroke length, velocity throughout two, three hours of training. Finally, telling you that this statement is very interesting, but nowhere in sport is performance so dependent on the interaction of the athlete with the surrounding medium than in competitive swimming. So if you are studying and you really want to come up with some challenging ideas, putting water on this equation will certainly be a very interesting challenge for you. Finally, thank you once again for ISPS for having me, never forget to learn with the best, because keeping humble and keeping your open mind will certainly have a very good result for yourself.  Just don't go to conference and sit quiet if we have questions, please ask them get in touch with the speakers, etc, etc. Thank you very much all the swimmers that I had the chance of meeting throughout my life because indeed this would not be possible without their cooperation. Thank you very much for listening. Okay, brilliant. Thanks Pedro that was really really interesting I know I said at the start when we were chatting before we went on air that swimming biomechanics is an area. I find really interesting, mainly because I'm terrible at swimming. But also just because of all the problems in data collection that Pedro touched on. So I know for most sports biomechanists could rock up at the venue set up their equipment and start collecting data. But if a swimming coach said to me, can you come along and collect some data in our training next week. So I'd have to go away and do a lot of reading and research into how can I actually collect that data, because a lot of the techniques we normally use wouldn't work for obvious reasons with the water involved so that was really interesting. I'll quickly go on to a few questions, just to shout out that all of the other lectures scheduled are on the screen now. So if you haven't already go back and look at the five lectures from previous weeks. This is the first of three today. So we've also got a couple of talks relating to football or soccer, and then there's another couple coming up next week as well as some more after that. But my first question for Pedro, I'm really interested in movement variability and functional variability, which you touched upon a little bit. So I just wondered if you could go into any more detail on either the asymmetry or just variability between strokes and, for example, do elite swimmers have more or less variability than lower level swimmers, or are certain aspects of the stroke more variable than other aspects. I don't know if that's something you're able to touch on, but it's something I'm quite interested in. Well, well, yeah, to be honest, that's something that I'm really, really interested also. And well, when I was making, for instance, my PhD, I was not even looking at that, but I have all the data. So I'm looking at that in the last few years. And indeed, it is quite interesting that you find similar variability both for the elite swimmers and for the lower level swimmers. And that really came up with me with with my mind, regarding, for instance, the idea that I had about the asymmetries. As I, well, theoretically, I was thinking about being symmetric would be better for the swimmers. But the truth is that for very high level swimmers, swimming the 50 meter front crawl, they want to be the most propulsive as possible. On the strokes, most of them really use one end to make much more impulse than the other. So they are swimming asymmetrically in purpose. And indeed we were able to many to measure the mechanical impulse and understand that they can reach higher impulse than a symmetric guy. There are so very big differences in the same swimming stroke because if you then go to butterfly or for breaststroke. Well, it comes up to be some other different challenges because as you can imagine in the simultaneous techniques, you will have for sure long periods when you are not able to make propulsive actions. So I really think that in the future, much more research needs to be done regarding this variability because to be honest, on my PhD, we use the average and the standard deviation and the coefficient of variation to understand how was the variability. And we are far from understanding how can these variable variability be one of the most important issues for increasing the swim performance. Yeah, really interesting. Thank you. And my other question that I was quite interested in was this idea that the arms of the upper body in isolation, and it was around 85% of the force produced or applied by the whole body, and then the lower body in isolation, thinking about 35%, but the idea that both of those numbers together is considerably more than 100%. And kind of, I wonder if you could go into a bit more detail on why that might be. That's something that I do think that they have the link of some of the manuscripts that I made a reference. And so there is one paper regarding this relative contribution of the upper limbs and the lower limbs. Because what I noticed is that when the first studies were done, they were really stating that, well, it's about 85% to 90% dependent on the upper limbs. So in your mind, you start thinking that the leg kicking is only important by 10%. But if you start reading some manuscripts and you start making some testing, you will see that the importance of leg kicking is probably much higher than 10%. Because indeed, we are not talking about just taking the less of the 100% minus the 90. What we came up with was values for all swimmers above the 100%. And what we were able to understand is that the last coordinated swimmers were the ones who were able to achieve higher values of the upper limbs and higher values of the lower limbs, and were not available to reach such higher levels when using the all body. So that value over there that I presented, we call it force deficit, was higher for that swimmers. And this is interesting not only when you are using feathered swimming, but to put a swimmer making a trial, making a free swimming on your swimming pool, using the all body or using only upper limbs or using only lower limbs. You will certainly see that you have swimmers who are not able to translate when using the all body. And for me, it is mostly due to the coordination of the swimmer and his ability to make the perfect synchronization between the right and the left side. And with that, with the upper limbs and the lower limbs. Okay. Yeah, really interesting. Again, so just as a follow on to that, because I was wondering whether it was in any way due to certain musculature being involved in both the upper limb and lower limb aspects, but based on what you said about coordination. Do you think that the actual figure, as in how far over 100% it is, would maybe vary for different levels of swimmer and that might be some kind of indication of coordination within the stroke. Yes, yes, that that's my mind idea. So, as you as you can imagine, like, well, all all the high level swimmers they make strength training on the gym, for instance, and if you notice that your first thing if you notice that your swimmer is increasing the strength on the gym. You should be expecting that he's being able to increase the force production in the water so his speed will increase. So that's the first question that we need to understand is really having a transfer a bit one between what's being done in the gym and then using it in the water, and if it is. Is it making equitative improvement regarding the upper limbs and the lower links and the coordination between them. And indeed, what I came up with is that that idea of having each swimmer understanding what's the behavior of himself is that if you have a swimmer that comes down and right on that evaluation. It's probably a swimmer that needs to improve his swimming technique and the swimming coordination so it's not the most useful thing to keep increasing the strength on the gym, or in different tests that you do in the water, without working the coordination of that swimmer. Okay, well, while you're answering that we've now got a couple of questions from viewers on YouTube. So I'll try and kind of will try and get through those quite quickly. And but the first one from the fit owl, who says, since swimming is a whole body movement is any kind of kinetic testing of any use or application to that. I'm sorry, Stuart. I think that the question was, if we are using the whole body. Can we do some type of measurements. Yes, so with isokinetic dynamometry so strength testing and say the knee extensors or knee flexors. For example, would that transfer to swimming do you think or is it a bit too abstract. Yes. Let me just tell that. Many years ago, there is a book by Wilkie and medicine. Many years ago, and it is quite interesting to understand the tools that they propose to increase the swimming speed by the time they really got some my interesting ideas regarding the velocity of the movement. So isokinetic systems are being used mostly to understand something that all swimmers are worried about that is lesions. So injuries, let's say injuries are one of the issues that we really need to be aware of. The using isokinetic systems is one of the ways of measuring the real the ratio between, for instance, the shoulder, the shoulder anterior and posterior length of the of the muscles and power of the muscles. So, indeed, not so much on the swing performance because when you are talking about the stroke cycle, you do understand that the velocity of the end is increasing throughout all the movement, and that is probably one of the things that most motivated me to use the isokinetic system because you are indeed not changing the pattern of the and and the velocity of that and while if you are using isokinetic system, for instance, in dry land, we're using the swimming bench, probably you are changing a lot of the also the swing velocity of the end. And so, as I said, if you have the swing bench and if you can use it to make the isokinetic evaluation, try to use it try to see if there is some imbalance between right and left arm, but try to understand further on the approach in the water and, indeed, those, well, weaknesses that should detect are or not transferred to the water. Thank you. And the second question is from DeGal Bronsky. Apologies if I've pronounced that incorrectly. And but DeGal says thank you for the talk. I was doing a PhD about the fluid mechanics of underwater fly kick. And I was wondering if you've ever had to estimate the efficiency of this technique. And how would you do it, or I guess, if you haven't, how would you estimate efficiency of any swimming technique. Thank you very much for the question because, indeed, that's something that I really never got into it. We had, as I said, I made most of my research on the first degree and on the master degree in the Port University. They have their biomechanics lab and they have a very strong research group on swimming biomechanics. But most of the issues that we were studying at that time was indeed trying to understand how the kinematic and the kinetic analysis could be performed or could be enhanced in the water. And so studying the fluid mechanics is something that they come up with very brilliant ideas, mostly regarding the approach that they had with the engineering faculty that is just on the other side of the street. And I would be more than interested in giving some manuscripts and some papers that I have. I just, well, we edited a book on a sports science performance that I would be more than able to share with him. If he just sends me an email where there are some ideas on how you can measure that efficiency. I have some Japanese researchers that are making a very interesting work. They presented it in the last biomechanics and medicine conference. And so I really wish you the best on that PhD because indeed a very interesting idea. And if I can give you my ideas that don't quit with the difficulties that you will have because when I was in Manchester in the World Swimming Championships, I saw the most interesting underwater click kicking and indeed that's something that in the future it will make an even bigger difference between the gold and the silver medal because the underwater phase is something that we really need to look. And I'm always telling the coaches over here that they spend, well, I will say 90% of their time on the swimming and 10% of starting interns and that needs to be thought about and probably give much more interest, much more detail on the start interns technique. Thank you. It's really great to offer your advice and insight and kind of help current students out as well through that. So I think if anybody else does have any questions for Pedro, then either use the comments on YouTube and we'll keep an eye on those. If you get in touch over Twitter and we'll try and get any answers to you. Yeah, all that really remains for me is just a huge thank you Pedro that was really really interesting and something I know myself and hopefully a lot of other people will have benefited from and kind of been exposed to a whole new area of biomechanics and research. So thank you very much for that and the people watching please don't forget the other lectures on the screen as well. Thank you very much.


Jeznjak je tudi očetan. Tako je to da je tajga tezdu, kako se na Kainojne je začala z kratiljnjom zjebitih všeč, tudi očetanje in tudi očetanj. Vsih je, da sem tukaj tukaj, početnja moji vziv vse izgov na cistem desine, ne zanoj vse, kako vsečem, ... in tudi, vsečen, tudi. To mi je, če ne možeš vzlušati, pa je vzlušati vzlušati na bloga. Vzlušajte, da vzlušajte na bloga. Vzlušajte, da vzlušajte na Python. TDD, kriptografi in infrastruktur. To je vzlušajte vzlušajte vzlušajte. Vzlušajte, da vzlušajte na kriptografi in infrastruktur. To je kriptografi in stivno na bož naminga na boža. Tad me je moratilo, da je bilo arhitektu, vzlošajte, da je to? Ko je to? Vzlušajte, da je bilo boastiprosniko, razsig se na vzlušav, ki je tez na boža. Tako razstavojove tvojeh milijs. Vitruvius, ki je romansk, arhitek, in inženir, izgleda, že všeč je o Firmitas, Utilitas in Venustas, kaj je v moderni ingričnih vsečen, je djurabilitva, utilitva in vsečen. Vitruvius izgleda, že všeč je o vsečenih vsečenih, te govorila, kaj je vsečen, bo vsečen. And for me this was very interesting, because how many times do you think about your code as something that has to be useful, beautiful and durable. Useful, yes. Nobody wants to write something that is useless. But what about durable? Zvukam framor nam je kredil jen da je na svojo grozo za dnev. So nekaj scifi, kaj je bilo stavil. I nekaj lepši. To je bilo všeč je zelo način. Pa vzpomeni, da vse zato mu prip upbeatj vse vzlučili in vse več. Taj drugi pogledov ne bilo včesk, in taj je občasno, da inginira, ovrčenak, je inginersk, in ingin, kaj smo tudi pravati, kaj je vse se način več, in ingin je inginuacija, kar je lati, nič nekaj prav, nič nekaj prav, nič nekaj prav, nič nekaj prav. Zelo, sem vzal, da sem počekal, da je zelo na kvalitku, nekaj in ljudi kvalitku, pa je bilo to vzal, da je zelo na vse definitivi kriče. Eno je vsega in svojnozaj na zelo na naštavljenje in vsega zelo. Vsega in vsega je zelo način o komputeri, a je svega vsega in vsega komputeri, zelo vsega, zelo način o komputeri, ta je vsega zelo način, I wanted to come up with something a bit more compact. So I tried to merge them into these, which is the art and science, in which the components of a computer system are organized and integrated. I want to stress art and science. How many times do you think about what you do daily as art and science? As science, yes, data science, computer science, the mechanical part, right? What about art? When do you look at your code and think this is art? Why is it not data art? Why is it not computer art? Not as in, you know, painting something with a computer. Our code is beautiful, or it can be. And the other two interesting words here are organized and integrated, because a system architecture, when it comes to computer science, is all about where components of the system are, and how data flows between them. So this is the integration part. So now that I defined architecture, the following question is, do we need it? So do we need things, our code, to be useful, durable, and beautiful? And this is up to you. I'm positive about this, otherwise I wouldn't be here. But I want to give you a couple of examples. One comes from the traditional architecture, and it's the bridge that is in front of this building, somewhere back at the bridge. It's interesting, I was looking at it these days, and I thought, does this bridge have to be shaped like an harp? If the requirement of the bridge is just to take cars from one side to the other, it doesn't have, you just need a plain bridge, something that I could design, because I don't know anything about bridge design. But if the requirement is to make your journey better, while being shaped like a harp in Dublin, it's a nice thing to have. So this is food for thought, maybe. What is the requirement of your code? What is it that you are creating? When you create a library, do you just create some machinery, or do you create something to make the journey better? The other example I have, it's about something lasting a long time. The unit system, the operating system was designed in 1971, so 50 years ago, and it was well thought. Not everything in a unit system is perfect, sometimes it's far from it, but it was well thought. So well designed that I am running a Linux machine, and Linux is a clone of Unix, and many of you use macOS, which is a derivative of Unix. 50 years. So, again, how many times do you look at your code, the code that you write, and you think, in 50 years people will still use this code, or at least these ideas? Anyway, I'm not the only one who thinks that system design is an interesting thing. There are much smarter people than me, who wrote a lot of books, there are vast literature about this. I selected five books that I read, which I believe are interesting about the topic. Some of these are door stoppers, pretty thick, so if you are not up for the challenge, I recommend retrieving at least the two in orange, so design patterns and enterprise integration patterns. At least read the introduction. And I'm not joking, the introduction to these two books, the two introductions are short, but they give you a narrative of the challenges and some of the solutions that you might have when you design a system. And I was really flabbergasted when I read the introduction to design patterns, because it was like, hey, I face these issues every day. I want to mention another thing about enterprise integration patterns. This is a book about messaging, message-based systems, more about distributed systems, if you want. But it's interesting that message-based systems, microservices, for example, the software design and languages, they are all in the same league. They share a common trait, which is messages. Object-oriented programming, and you can quote me on this, is supposed to be about objects that exchange messages. So every time you call a method on an object, you are sending a message to something. So it is a distributed system. And if you think about that, when you code in Python, if you think about messages, this might not change the code itself, because you are still calling methods, but it will definitely change the way you think about your code.  Anyway, this might be for another talk, another time. Now that I defined architecture, I decided for you that we need it. Let me define clean, because this is about the clean architecture. I found it easy to define the opposite of clean, the picture in the background. If you look at that system, you can definitely say this is not clean. It's not tidy. Good luck maintaining something like that. They said pull the green cable. Good luck. This is an extreme example, probably, but sometimes our code looks like that. You change something, and suddenly everything crashes, and nothing works anymore. Instead, in a clean system, or in a tidy system, if you want, you have these characteristics. For each component, you know the three w's. You know where it is. It's easy to find the component in the system. It's isolated. You know what it is from the name, for example. And you know why it is in the system. You can say why it's been included. In the pictures in the background, there are two hardware systems, and they are tidy. It's easy to trace where a cable goes. Some are color-coded, so it's easy to understand why they are there, what they are doing. Ok, now that I define the clean architecture in terms of the words, let's go for the concept F1 example. So what is the clean architecture? It is a concept that was introduced by Robert Martin some years ago. Robert Martin is a system designer, developer, and I'm not here to advertise Robert Martin's work, mostly because Robert Martin is very good at advertising himself, you know, so. But I'm going to use the same name. It's important for me to stress that the concepts that Robert Martin dubbed the clean architecture predate his work, so they have been around for a long while. So let's call it the clean architecture, but it's a set of concepts that predate what Robert Martin did. What is it? It's a layered approach, so it's a way to structure your software project, your code. It's layered and it's circular. So in the traditional, say, definition, we have four layers. You can have more of them, but these are the traditional ones. Entities, use cases, gateways, and external systems. What happens is that when you create something in a clean architecture, this something, this component, will belong to one of these layers. And there are rules. There is actually one simple rule, one rule at least, which is that your component can see, I'm going to define what C is, can see only what has been defined in an inner layer. So if you create something in the use cases layer or ring, you can see everything that has been defined in the same layer, use cases, and everything that has been defined in entities. You are not allowed to use, to access anything that has been defined outside. And that has to do with dependencies. The problem of unclean systems, remember the cables before, is dependencies between components. When you have a component that depends on other components and these other components depends on other components, and you can't trace these dependencies, and sometimes they are circular dependencies. In a clean architecture there are no circular dependencies. The golden rule, I'm going to introduce it now and then show you an example that clarifies it, is that you talk inward in the use cases. What does it mean? Simple structures are data types that have been defined inside. So, for example, again, something in use cases can use data types, and I mean data types in Python, for example, you can instantiate them, if they have been defined in use cases and if they have been defined in entities. If something has been defined in systems, you don't see it. You can't instantiate it. Interfaces. Interfaces have to do, so they are related to dependency injection, which is something I will introduce later. What is an interface? Going back to what I said about objects and sending messages, when you send a message to something you expect it to be able to receive that message. In Python, we don't have an explicit way to state interfaces, to create them. Even though we have now protocols, we have abstract-based classes, there are many ways to work with interfaces, and we can discuss about this another time, because there is not enough time today. Anyway, I'm coming back to this slide later after the example. The example today is simple. The code I will show is Python. It's valid Python, but I stripped all the error-checking, a lot of things that are not useful. Obviously, the real code is a bit more complicated. My use case is to retrieve a list of items. It's very simple. When do we want to retrieve a list of items? You have a social network and you want to retrieve a list of posts. Or you are Amazon, you want to show a list of proper items that you are selling. In this example my use case is just a simple function. It exists in the use cases layer and for the time being it doesn't do anything. Then I define some entities. Entities are models. They represent real items that are in my business logic. So in this case, for example, something with a code and a price. Just a simple class that captures data and encapsulates data. The entities live in the entities layer and they are known to all other components. It's 2022 so we probably want to build a web application, but this is not required. It's just an example. The web application requires a web framework because I don't want to implement the logic to deal with HTTP requests and all these things. There are smart people who did it for me. In this case I'm using Flask, but I can use any other web framework. The web framework exists in the external systems. I want to say a couple of things about this. I mentioned business logic before. The business logic is what you market. It's the core of your application. The web framework is not, generally speaking, part of your business logic. You are not marketing Django. You are not marketing Flask. You are marketing a social network. You are marketing items, delivery, whatever. It's reasonable for the web framework to be in a very external layer where we use it, but we don't manipulate it. The core, the most important thing in a clean architecture, I would say in any architecture is the business logic. This is what 99% of your time should go. Every time you spend configuring external systems, it's not wasted, but it's not given to the core of your business. Anyway, this is the web application, the web framework. Now, what is the task of the web framework? The web framework is there because it has to translate HTTP requests into calls. This is all a web framework that has to do. Granted, it's not an easy task. There are many things involved, but this is what the web framework should do. Get an HTTP request and transform it into a call, for example, for a Python function. In this case, this is exactly what I'm doing. I'm calling the use case, which is a function. Here you see that the web framework communicates with the use case simple structures. What does it mean? In this case, I'm using request args for the sake of simplicity. It's just a dictionary. It's a simple structure because it has been defined in the language. It might be an entity or it might be something that the language defines. All these things exist in Python. Whatever is defined in Python as a core language is available. The use case is a simple structure. Something that the use case can understand. For example, I shouldn't send anything that is defined in the web framework. Some structure that has been defined there. A type that Flask uses to manage an HTTP request. Because the use case doesn't do anything. Doesn't know anything about HTTP requests and it shouldn't know anything. Then we have to retrieve items and data. Data is stored usually in a repository. We are used to think about the repository as a database, which is what I have in the example here. But I want to stress that a repository is much more than a database. For starters, it doesn't have to be a relational database. It might be no SQL. MongoDB, for example. Or it might be for example, a web API. It's a source of data. You call the API, you get data. It's exactly what you do with a database.  It might be a hardware sensor. That is a source of data. It's a repository. Let's think about it as a database. I'm going to say database, probably a lot of times. But the repository is the right word here. And the database, the repository, exists in the external systems layer. Because again, it's something that is not part of my core business. It's not my business logic. In system design we usually call the web framework, the database, everything that is outside as a detail. We call it a detail. And many times it surprises people that what detail, I mean configuring Postgres and all these things, it's complicated. It's not secondary. It's not just so simple. A detail means that it's not part of the business logic. This is not what I'm marketing. If my product works with Postgres or works with MongoDB, you are not concerned. You as a client are not concerned. Your problem is to receive a service. So this is why it is a detail. While the specific algorithm I use for my recommendation system, for example, is the core business, is what you like of my product. OK, so this is the difference between core business logic and a detail. So the database is a detail, even though it might be complicated. However, it exists in the external systems. So as I said before, the use case is not allowed to communicate directly with the database. In Python terms the use case is not allowed to instantiate anything that is tightly coupled with the database that is connected with the database directly. Because if I had code in my use case something which is, I don't know, Postgres, a library to interact with Postgres or to interact with MongoDB, I am coupling my use case with the implementation of the database. And this is not good because at that point I have my core business, my core business logic coupled with a detail which might change, might not be the same thing in time. So I create an interface. This is, in this case, we are talking about Python, it's an object that provides a facade. So this is a set of methods that are common to databases. So the web framework instantiates the database interface or the repository interface. The web framework can do it because it's in an outer layer. So the web framework sees can see what's in the gateways. And passes to the use case. This is called dependency injection. If you are not familiar with the concept, I have a slide for that later. But look at it, the use case, the code of my use case doesn't have Postgres repo hardcoded in it. I'm receiving an object that provides methods that might be an object of Postgres repo, MongoDB repo type, whatever. The important thing is the interface or the set of methods that thing provides. Cool, now internally I'm in the use case now and I have finally my business logic. This is where my brain comes into play. I have to write something that implements the recommendation system, whatever filtering you want. Eventually, sooner or later I have to use the database interface to retrieve the data. In this case, I'm calling repo list. Passing the parameters that I received from the HTTP request or from outside I should say where they come from is not important. The business logic might be, for example, to prepare the parameters to add some filtering or to do something else. Anyway, back to the database interface I'm calling repo list here, repo list. I'm in the database interface now and the database interface is tightly coupled with the database. That is Postgres repo so it has been designed to work with Postgres. It's in the name. The two communicate with a specific language. In this case I'm using SQL alchemy. It's an object of additional data but eventually I'm in a mindset of querying a relational database. This is what I'm doing here. I'm committed to relational databases at this point and this is what I'm doing. The two things are tightly coupled. What the database interface does is to, as I said, query the database and then it transforms the output and the database just sends me values. It's SQL. Standard types known to SQL databases. The database interface has the task to convert those values into entities because at this point everybody can see entities as a layer. It's a very inner layer. The database interface can say these SQL values become items as in items that I defined. And these items send back to the use case as a result of the repo list. At this point I can add more business logic. Just to say that obviously if you want to, if you have to call your repository you can do it at any time. Your business logic is around that call. It's where you augment results, ok, with your algorithm, with your cleverness, your product. At this point the use case has the result and it can send it back to the web framework or to whatever called it. And the web framework so this is again, sorry, entities. The web framework can knows about entities. So this can still be an entity, a model that I created. The web framework again has one task that of converting the entities, which are specific models of my business into something that is understandable outside. For example, JSON. This is the task of the web framework. My use case doesn't know anything about JSON, it doesn't care because the use case is ok with entities. It's part of my business. This is the journey of the data in a clean system at least in this example in a clean architecture. I want to go back quickly to the initial slide about the golden rule. Talk in words through simple structures and outwards through interfaces. Have a look at this code. These are two different possible implementations of a use case. The second one is the one I used. The first one is the incorrect one, if you want. Why is it incorrect? It works. Ok, first of all, so it's not incorrect from that point of view. But these couples my code, the code of my use case with the Postgres repo. It means that I can't use anything else. If I want to use something else I have to touch the use case. But the use case is your business logic. And it shouldn't be touched because you change something which is a detail where you store data. Ok? The second one instead, and this is a good example I hope of dependency injection is when you create something outside and then you pass an instance of it. The instance has been instantiated outside, so part of the code that is coupled with the type the Postgres repo is outside in this case is the web framework. Your use case just receives an instance something that can accept a certain set of messages. Does it make sense? I hope so. This is what happens in a clean architecture, simple structures inside interfaces outside. Cool. I want to tell you about the advantages of the clean architecture. Why should I go through all this pain? And there are two specific things I want to mention. The first one, probably the most important one for me is testability. A clean architecture, a software designed with a clean architecture can be tested very well. What do I mean by that? Look at the use case. I can easily isolate the use case from the web framework and from the database interface. It's just an object that receives a repo and some parameters and returns some results. So what I can do is to pass a dictionary of parameters a mock database interface so something that pretends to be the database interface that is connected with any database. It's just a mock. It returns a fixed set of data. And check that my business logic works, given that input gives some output. This allows me to test my business logic in isolation. I don't need the database to test my business logic. I don't need the web framework because these are details and my business logic is not about details. At the same time I can test the details because, yeah, details but they are part of the implementation. So I have to test that my web framework works and the web framework can be detached from the use case because the web framework, the only task is not a simple task again but the only task of the web framework is to accept HTTP requests convert them into calls. Get the result of this call and convert it back to an HTTP response. As I said, it's not simple. I have to test that this works and I can do it in isolation. And last I have to test, I can test my repository interface. This requires the database because this is an integration test. I'm testing that my the facade of the database works so I need the database running. This might be a slow test that you might run just sometimes. Again I want to stress this I see it too many times when it comes to testing in particular with web frameworks we end up testing the database. So we store a model then we retrieve the model and we say, yeah, it works. Thank you very much. This means that Django or whatever framework you are using that Postgres works but this is not what you are supposed to test. These are provided by third party. This is not part of your code business. The second advantage is about customization I would say. Look at this. In this case I have two different use cases. One is to list items and one is to list users. A phone for some reason for example for performances reasons I store the users in a MongoDB which is not relational. So I can't use it with a SQL alchemy for example because it's not SQL. But this is not a problem in a clean architecture because my use case is customized. It just has to receive a different object that is instantiated by the web framework. Pay attention that this might happen inside the same use case. So those use cases those two use cases might be the same. You might have some logic inside might be part of your business logic that says well in this case I go and fetch things from repo A in this case I go and fetch things from repo B performances for example. But these repos are something that you get from outside as you see here I'm instantiated them in the web framework not in the use case. And the other sign of this is that the web framework is just one of the possible front ends. And with front end now I don't mean reactors, similar things I mean the way you present your results to the client it might be a command line interface it might be a web protocol or something else. Because I just need to call the use case and translate the output of the use case into something that is meaningful for my front end. HTTP request for a web framework something else for example text for a command line interface. Ok, at this point I want to draw a comparison with an architecture that we or at least many of you probably know which is the Django architecture. Django is amazing web framework well known in the python community it has a different architecture it's not the clean architecture this doesn't mean it's unclean maybe well yes it's unclean given the definition it's unclean. What I mean is I don't want to say it's bad I'm coming back to this later I just want to draw the comparison for now. Well Django has models these are similar to entities superficially speaking they just represent part of my business I have items, I have books films, something that I'm marketing. I have business logic obviously otherwise why should you use Django you have something to market something to sell. Business logic in Django is usually implemented in views but it can be implemented in functions that are called in views so this is similar if you want to what I did before with the clean architecture. Ok, the first big difference Django has an ORM an object relational mapper which is if you want a gateway it's an interface because if you use MySQL if you use Postgres your views don't change so you are using an interface you are using something that masks the details of the underlying database however, the object relational mapper the name says it all it is an interface to relational databases and it's not easy to use Django with no relational database or with something else a web API because of the ORM is customized for relational databases and this is different in a clean architecture because the gateways is a more generic definition of interface last, two components the database which is an external system which is also tightly connected with models because models in Django can be saved and retrieved from the database natively so the models are connected with the database they are aware of the database what is the drawback of this that when you test your Django application you need the database it is possible to test it without the database but you are sort of fighting against the framework you are doing something that the framework doesn't want you to do so again it might not be bad but it's different so there is a big connection between two layers one is the inner layer and one is outside and the same happens for the web framework itself as in the part of the framework that deals with HTTP request and responses because that is connected with the business logic as I said before you usually implement your business logic in views and views are specific things provided by the web framework they are connected with URLs so far this is the Django architecture just to show you that there are different approaches to the things and as I said this might be a good approach it's not bad, it's just different but as you assume I convinced you in 40 minutes you are like yes the clean architecture is the way to go so I want to go back home and convert everything to the clean architecture well, don't do it so if you want to do it do it the right way so I always recommend to remember what happens to what happened to Netscape when they decided to rewrite the whole thing from scratch just everything, have you heard of Netscape lately? no it resurrected at a certain point but you know it's a sad destiny that of Netscape and it's for a bad choice so don't do the same choice migrations happen one step at a time so my recommendation if you want to try these concepts is to isolate part of your system something tiny in your system and reimplement it maybe with a clean architecture something that doesn't affect the rest of the architecture remember that when it comes to web applications you have load balancers they are your best friends you can always root requests to another system and you can go back quickly if it doesn't work final slides is this the definitive architecture so done perfect architecture we don't have to do anything else go and implement everything with clean architecture thank you very much so the answer to this question is in my opinion the answer to any computer science question ever and it is it depends it depends on many things it depends on your requirements for example when it comes to the clean architecture vs something else for example the jungle architecture I tend to show this slide you are the crossroads between these two options Lego vs Playmobil on the right you have something that works out of the box and it's very nice you can play with it, it's amazing I don't play with it nowadays but I remember you want a farm you get a farm it's customizable up to a certain point you can move things around on the other side on the left you can build whatever you want but you are on your own so it depends what are your constraints what do you want to achieve can you mix and match the two yes you can so this is my recommendation to design a system always stop and think look at the requirements don't go for a solution out of the box it might be the right solution but you have to be clear that why it is the right solution really last two slides I wrote a book about these concepts clean architecture in python it's a free book, it's available there the example I showed you today it comes from the book there I implemented it properly with TDD a lot of error checking so the whole book is about that example I implemented it with Postgres and MongoDB just to show that it's possible to use different databases for the Europe items for this week and next week I teamed up with some friends and they gave me the book and other books for free it's a bundle worth $60 so you are free to follow us on twitter and you can check the URL only in pub to get the bundle for free with that I'm done I hope it was useful, thank you thank you very much Leonardo for that very inspiring talk we have a few minutes available for questions so if anybody has a question we have a microphone here just quickly go to that microphone and ask a question I'll be around for the next two hours so feel free to get in touch ok, hello thank you for the really nice presentation and while I try to follow the layered architecture, the one thing that I always struggle this with so if you want to really follow these then it seems like you have a lot of duplication so you have to have the models in the core of the business that your business or your cases are using and then you want to persist also those models into the database or somewhere else you then need to have some kind of definition of how this happens with some bookkeeping data and potentially the duplicated definition of the original data so it seems that there is a lot of duplication that is painful to implement the clean architecture I don't think there will be duplication we might talk about this later there is definitely a lot of message passing so if that is what you mean by duplication yes, the same data is going around a lot which is part of the drawbacks of the clean architecture there are a lot of layers that is my impact performances like you don't have direct access to the database in terms of duplication I'm not really sure what you mean so if you want to expand on that for example, in the example that you show for the jungle you define the model once and then that's also the definition of how the table would look like majority of ORMs work the same way so you have a single source of truth that defines basically the layout of the data in the database as well as the layout of the model that you're working with so if you don't have the application that's really convenient and very simple to work with and define your system so if you don't want to use that then you need to have I definitely see what you mean thank you, now I understand yes, it's true that for example the model I use in entities correct me if I understood the wrong way is duplicated in the database interface because this is what I'm storing there is no way to avoid it because this is a feature as in I am splitting the model the entity if you want as in a business entity and the entity as something that is stored in the database I agree this is more work and there is no way to avoid it because it's considered a good thing again it's part of the it depends on the requirements in your business logic this separation is not needed or it's overkill and you're free to go with a different architecture but the idea if you want the extreme idea is to split these two things because they might exist in the same space but they are not the same thing one thing is the business logic one thing is how the business entity one thing is how I store it thank you very quick final question hi hi Leonardo, thank you you're welcome I really appreciate your emphasis on beauty and art in terms of software with clean architecture I can see the benefits of say durability utility by making architecture clean do I get beauty out of the box or is there something more elusive making something beautiful maybe a bit more elusive beauty beauty is to be defined to be honest when I was working on the book and I came up with the example and I was looking at the projects where components were how they were interacting between them at a certain point my feeling and this is pretty personal was like this is really beautiful it clicks, it works and this is what I meant as in beauty for me it might be subjective definitely doesn't shine doesn't come in colors but the beauty of that system for me is that it's tidy I know where things are I'm confident that when I'm touching something and touching just the little universe around that component and not other things this works for me and this is the beauty in that architecture for me


All right, hey y'all Mr. Gibson here with your next lesson in cryptography and today we're going to be looking at One method that we could use to determine the keyword length for the vision air cipher We'll go on to learn how knowing the length of the keyword is going to be really helpful for us but for today, we're going to focusing on Just how to find the length of that keyword and the method that we're going to be using is called the kasiski test The kasiski test was named after this person here Friedrich Wilhelm kasiski a German military person Who wrote in 1863 a 95 page book on cryptography? And it was the first published account of a procedure for attacking the vision air cipher But more broadly polyathletic substitution ciphers of other types as well It's worth noting that Charles Babbage was most likely already aware of this method about 10 to 15 years earlier But just hadn't published it Maybe just kept it to himself. Charles Babbage is widely known as kind of the The father of computing and then creating some of the first mechanical computers ever ever made This method that we're going to discuss relies on Analyzing the gaps between repeated fragments and cipher text Um and those gaps are what's going to give us the hints about the length of the keyword Now you might be thinking like there shouldn't be any repetitions in our cipher text That's one of the main reasons we switched over to polyathletic ciphers Because unlike monoathletics substitution ciphers The same letters in your plain text don't go to the same letters in your cipher text. That's the whole point So how do we get repetitions? So let's start by looking at some repetitions and think about well Why are they even there? So here's an example cipher text This was in ciphered using the vision air cipher And if you stare at this for a little bit, you might see some repeated fragments. I'll highlight them here now There we are There's more than just these two, but we're going to focus in on the repeated fragments z v r a o and m b d b m v s So a five letter fragment read that repeats and then a seven letter fragment that repeats And we're going to think about why are these here? Is this just random? It's supposedly, you know plausible that these these could just show up by chance But the fact that we've got so many repetitions of this length seems like it could not just be random There's got to be some underlying pattern here at play So let's take a look at maybe how these repetitions in our vision air cipher texts are generated To do that we're going to use this plain text phrase This is a little fragment here of a sentence at one sentence that ends on a plane And then the next fragment starts with the plane is due And we're going to try and encrypt this using vision air with a couple of different keywords here We're going to see do any of these keywords cause a repetition to occur in the cipher text for the same fragment in the plain text So we'll start with the five letter keyword water And when we encrypt our plain text into cipher text We'll see that the plain text repetitions start eight characters apart. So the first letter p to the next letter p is eight characters But we don't get a repetition in the cipher text. The first time is tc w and x and the second time is pe e a so No repetition for this one Let's try a different keyword. Let's choose a shorter one a four letter keyword just chose milk And when we encrypt our same phrase using that four letter keyword We do get a repetition So we have eight letters or eight characters between our plain text repetition and we get a cipher text repetition They both go to zx i y o we can kind of see well It makes sense the running key seems to have the same five characters above the word plain in both circumstances Let's try one more time. Let's use an eight letter keyword We'll choose the word hospital And when we create our running key and we encrypt our plain text Yet again, we get a repetition in the cipher text because again In the running key the same five letters appear over the word plain both times So let's think about that for a minute Why are we getting sometimes our running key lining up over the same words in the plain text? What might cause that to happen? So you could sit here and we could do some trial and error and try a bunch of different key lengths and figure out Which ones caused the repetition but for the sake of time I've got some information to share So let's look When we had our characters that repeated in the plain text eight characters apart It turns out that keywords of length two four and eight would cause that repetition in the cipher text If our repeated plain text fragments were a little bit further apart, maybe 10 characters Uh the keywords of length two five and 10 would also cause repeat repetitions in the cipher text And if we had a plain text that repeated 20 characters apart The keywords that would cause repetition would be two four five 10 and 20 So you need to hit pause on the video here and think about what's the pattern here What's causing the repetition based on the length of the keyword when you know how far apart your plain text fragments are Turns out the result is that if you have your keyword of a given length, we'll call that n If that n divides into the distance between the repeated plain text fragments, which we'll call delta Then the corresponding cipher text is going to repeat as well So a couple ways we could think about that if you want the math way We could say that delta the distance between the plain text fragments is congruent to zero when We're working in the modulus of n If you're more program or python Minded we could say that if the delta mod by n is equal to zero Then that means you're going to get the repetition in the cipher text So let's see how this plays out here. Let's go back to our example. Let's see how we can use this fact to our advantage here We're going to look at first at the fragment z v r a o And we're going to look at the index in our string Or basically the position in the in the cipher text that the repetitions start at so the first one's at index 102 And then 134 and then 390 402 and 426 With the green ones here the m b d b m v s They're at 143 155 307 411 and 439 And I find it usually pretty helpful to put this on a table So we've got our repeated fragments the indices of each occurrence of the of the fragment And then I calculated those delta values. So just looking at like to say z v r a o The first occurrence is at 102 the next one was at 134 So the first delta value is 32. They were 32 characters apart And then between 134 and 390 was 256 apart and then 12 and 24 respectively And then for the second fragment the m b d b m v s those delta values you get are 12 152 104 and 28 Now notice we can get a lot of different delta values But there's only one value for n n is the actual value of our keyword And remember what we just said If we assume that those repeated fragments in the cipher text Are coming from not chance but repeated fragments in the plain text Then whatever the length of the keyword n It has to divide all of these deltas not just one or two but all of them So there's a couple of strategies that we could we could use here We can just kind of guess and check and you might kind of realize we'll start with a small number So if it's got to divide 12, let's start there. So it's how they got to be two or three or four or six or 12 And then you can kind of start cross referencing those against the larger ones Well, okay, it can't be 12 because 12 doesn't divide into 32 for example Or it can't be six because six doesn't divide into 28 and you can start whittling down your possibilities from there And once you do that you realize well, it's got to be either two or four And a lot of times when we can narrow it down the two or three choices We can just assume that whoever the person encrypting the message is they use the most secure option So if I had this two or four, I would guess four a two letter visionary keyword isn't isn't very secure Another way you could do it that's a little more systematic as opposed to kind of guessing and checking Because we can use the prime factorizations of our delta. So You might remember learning in school that every number can be factored down to Its primes So for example, 12 can be factored down to two times two times three or two squared times three And what we're going to do is we're going to kind of work our way from smallest to biggest of our delta values And comparing its prime factorizations To figure out which factors are in common between all of these numbers because if n it has to divide all seven of these numbers That means n should have the same really share some factors with all of these numbers That's what it means to divide it means that it shares the factors of the number It's dividing into or at least some of the factors So We'll go to the next row here and we'll see that 24 factors the two cubed times three And if you look at well, which factors does it share With our set of common factors so far. It still only shares two squared times three And then we'll prime factorize 28 and we get two squared times seven And we'll look okay. Well, which of those factors does it have in common with our our list so far So if you compare that to two squared times three the only factors in common are two squared And then we'll prime factor 32 that's two to the fifth The only factors in common between two to the fifth and two squared are two squared And we can keep moving down the line And ultimately we realize that the only factors that are in common between all seven of those numbers Are two two squared, which means that the only possible numbers That our key length could be is either two squared itself or some subset of those Factors so either two or two squared So we get the same result. We know that our key could either be two or four in length and again, we'll assume four Now the question becomes Now that we know or at least feel pretty confident that our keyword has length four How do we know what the keyword is and what's the resulting plain text? But we're going to save that for a future lesson for now. That's it for the kasiski test Make sure you practice this a few times using our checkpoint quiz and make sure you got a hang of it Thanks for watching. We'll catch you on the next one


Hi guys it's David here and in this video I'm going to talk about the secret reason we put things off so most of us procrastinate we construct these goals that in our mind are going to bring us to where we want to be in life we know what to do we know what to do to see those things come about right but we don't do it and after a while you know it becomes this cycle of setting targets failing to follow through with them and feeling a sense of guilt it's very very common and really when you do this for long enough you realize that there is a purpose behind that whole process behind that whole pattern of behavior and it's quite it's quite a big realization it's sort of a hidden reason hidden motive behind why we do that to ourselves and it's really this for you to achieve those things that you want is very simple it's actually very simple and you know whatever you think is required of yourself to do those things it's not even as hard as you think it is okay all it requires is a little bit of of input from your part and um consistently showing up and putting in some some effort some achievable effort right but we don't do that and the reason is what happens if you do all those things you complete your checklists and everything else and you're still left with that sense of hollowness of what now okay so it's a sort of a fear of getting in touch with the emotions that are there that actually drive us to want to improve ourselves all the time okay if you're very productive and you get things done you get to a point where you can rest for a while okay you've got some time to sit with yourself okay and it's a fear of I I'm not sure what I would do with myself if I had all my goals achieved right if I did those things that I've been thinking about for such a long time and beating myself up for for not doing right so here's the good news here's the good news when you do reach a certain level of productivity and consistency and actually do finally get around to doing those things that you've braided yourself for not doing you do you do come to a point where you um where you sit with yourself and there is a sense of hollowness there is a sense of what now but the good news is that answers come okay answers come and it's very good to be in that place because usually okay the sense of emptiness is still there but the at least the the underlying sense of guilt about not doing these things not getting them off your checklist is not present for a while at least so you do have some time to just sit with your emotions and not rationalize them away saying oh well I need to do this I need to do this you know those those excuses are gone so you're just left with your feelings and you sit with them and new answers come okay all that is needed is to sit for a while and really ask some serious questions okay sit in stillness I don't mean to intellectualize this or to um plan and micromanage your future just to sit for a while and get in touch with your higher self your higher mind your your intuition whatever word you want to to call it okay and answers come answers come your even the way you see the world changes okay um your mindset changes you start to hear a a more loving voice that doesn't always get a chance to talk because you're so preoccupied with to-do lists and guilt and attack thoughts because you're not being this wonderful productive person okay so realize remember that if you're in this pattern of setting goals not doing them the real fear here the real reason you're you're not motivated and you're not doing those things is because you're afraid of what would happen how you might feel when you are productive when you have actually achieved all those things okay and you've actually have gone about around doing what you think you need to do okay um but the good news is there's nothing to fear okay you face that fear and you start to realize okay there's another level for me okay there's something else I can do there's always another level for you okay there's always another level for you so it helps to bear that in mind because it can help us to understand why am I not following through with the things I need to do that I know I need to do and I know how to do it's really because we're afraid of what will happen in the silence okay so I hope guys you find that helpful um also if you want to contact me for I do want to one work uh psychotherapy um you can contact me the link is in the description very easy to um just send me a message and I will get back to you very quickly so guys thanks very much and I will see you in the next video