So, let's do this, let's light this candle. So, we're going to talk about extreme programming using open source tools. Alright, and I'm Matt, and this is Luis. That's our contact infos, if you want to talk to us later or whatever. We're doing two talks, Luis is doing three. He's a bigger slut than I am. But, we're doing two talks around this kind of area of discussion. So, this one's about extreme programming. We're going to talk about a project that we open sourced from our black hat class that we taught for four days. And, this is kind of an introduction to that project from the perspective of how the project was developed. And, what we're going to show you is how to write really fucking badass security tools using kind of common sense engineering instead of like jerking off into a jar and then releasing open source and expecting people to respect you. No names. Alright, so I'm Matt, and I've done speaking and writing. Last time I spoke at DEF CON was in 2000 or 99. DEF CON 8, I think. 2000. And, at that time, Luis and I did back-to-back presentations. And so, I talked about testing IDSs and firewalls using open source tools. And, how to find exploitable bugs in firewalls and IDSs and other protocol parsing type things. And, not a whole lot has changed since then. But, even so, I'm going to talk about something different instead of rehashing the thing I talked about seven years ago, unlike some people. So, in that time, we released several exploitable security advisories. Luis and I worked together on a lot of that kind of stuff. One of them was... What was one of them? NetBSD. What was it? ICMP something? Oh, yeah. NetBSD, unaligned ICMP option. We found one packet that would crash. NetBSD, OpenBSD, or FreeBSD was one packet. That was kind of fun. IE5 on UNIX. Oh, and exploitable bug in Trillian 3.1. Or, any version of Trillian, really. And so, various security advisories. Basically, we know what we're talking about on the exploitable side of the house. And so, this might seem a little bit fruity, this whole extreme programming thing, but we're coming from a perspective of deep reverse engineering and very deep technical stuff. And so, I've worked a lot on product stuff, on security products. I worked on network security scanners a long time ago. I worked on one of the first hybrid host-based intrusion detection systems. That was a little bit too ahead of its time. And, of course, everyone's like, why would I put an IDS on my host? And, of course, now that's a gazillion dollar market. I also contribute a lot to open source and I fund a good deal of open source development. One of the things I'm funding right now is a PlayStation 2 emulator so I can play it on my Xbox because I don't want to give Sony a dime and I want to play Katamari. So, I've been doing extreme programming and natural software development for a little over four years now. And honing that and getting better and better at it. And so, I'm going to talk from the perspective of a lot of experience with seeing what goes wrong and course corrections and things like that. You can talk about yourself. So, my name is Luis. I do a lot of reversing work. I'm doing another talk here at DEF CON on how to combine disassemblers and debuggers together to maximize your results, feedback everything from your debugger back into your disassembly and create this kind of loop of information. And I've done a lot of hardware and software reversing. I've worked on different projects, some with Matt and other security projects. But really, I'm here today to talk about my experiences just starting out doing agile development. This whole project that we've been working on, I started coding it about four weeks ago. I'd never touched C-sharp or any type of XP programming before. And I was just giving some customer tests by Matt and based the whole project around that. And I thought XP programming was retarded. Like when I first started programming, I was like, I don't know if I should have started doing it. I just thought it was all these really simple tests and it's just like people wasting time instead of like really doing coding. But as we'll go through this talk, I'll talk about how my opinions have changed. And part of it, there's this great quote from Office Space when they're in the car and they just found out that they got like, I don't know, like $300,000 in their bank account. And they're only supposed to be taking out pennies a day, right? And the Michael Bolton guy says, I always mess up the mundane details. And that's what this is all about. This gets rid of all those little bugs. So I'm going to hand it back off to Matt. All right, quick agenda thing. I got to like deep throat this mic for this to work. It's really strange. Anyways, so extreme programming. We're going to talk about stories, which I know sounds really gay, but you'll understand in a second. Why it's useful to think about features in this way. Pair programming, test driven development, incremental design and continuous integration. And some of the tools that you can use to do remote pair programming and things like that. And I use these tools a very little bit with Luis leading up to the class when he was basically done with the code. And I've also used them when working with outsourced engineers basically to pair with outsourced engineers and do XP with people who are really far away. And so this is how this can kind of apply to open source projects where there's kind of a time disparity between members of the project. And then we're going to do a quick demo on the involving the code that the open source project we talked about that analyzes x86 binary code to find exploitable security vulnerabilities automatically. And again, there's a second talk where we're going to go way deep down into that tool. But this talk is more about the process of developing that tool. Even so, you're going to get a glimpse of it. Yeah? All right. So extreme programming. Main thing with extreme programming in all Agile software development is you have short release cycles. There's this open source thing of release early and release often I think is what it is or whatever. That came from extreme programming in Agile software development. That wasn't like an incredibly new thing. And it seems to work really well in the open source world because you get a tight kind of feedback loop. You find bugs sooner, et cetera, et cetera. Your users get a hold of it if they really want to and what have you. I think some people, a lot of open source projects sort of just release without even thinking about it. And so it's frustrating to the users because you go download something that supposedly fixes it. You have to go download like the daily snapshot or nightly snapshot that fixes a bug. It turns out it won't even run because it just crashes when it starts because they don't do any testing. But anyway, that's really one of the things Agile software development is all about is release early, release often. And there's a concept of weekly releases and quarterly releases, quote unquote. And what they mean by weekly releases is, basically, you want to plan to have a complete, fully tested working release every week, maybe two weeks or depending on whatever, three to four weeks, but no more than a month. And by doing this, basically, you always make sure the code is always releasable and you basically have to maintain a very high level of quality to make this happen. Otherwise, you're going to go to release and you're just going to be tripping over your own dick the whole time, fixing little bugs and other things because you weren't keeping a firm control of quality. And this is the exact problem that commercial software has. People respond to simple security bugs where you look at the disassembly, you're like, why don't they just release a patch and fix this? It's because they don't have good quality processes. And so hopefully, for the love of God, the open source community can not make the same mistakes that the closed source commercial community makes, one would hope. Quarter releases, so you want to use weekly releases, but then you want to batch things together in a conceptual continuity package of, here we're adding little features every week to, I don't know, say like, add VoIP support to some Jabber client, let's say. And then at the end of that, you're going to do an official release with everything packaged together and really well integrated, et cetera, et cetera. And so you want to kind of plan like, okay, in three months, we're going to do a release of this Jabber client with VoIP support, let's say. And then you figure, okay, how are we going to get there, release, you know, little release, little iteration by little iteration until we are done. So the other thing with extreme programming in Azure Software Development, documentation that is not in code, i.e., that is not code. i.e., you have to update documentation every time you change your code is a waste of time. Because A, you have to waste time not coding and you have to keep your documentation up to date if your documentation isn't in code. And B, if you don't do that, your documentation is worthless at best and misleading at worst. I don't know if anybody here has ever seen some like, open source API documentation that's totally wrong. Or read a book, like I was reading a book on cruise control, which is an automated build thing. And the book was wrong because they were going off of the docs of cruise control and the cruise control docs were wrong. And that irritated the piss out of me. So if documentation isn't in code and tests and you're on an open source project and you're trying to move fast, you're basically slowing yourself down if you don't put your documentation in your code. Automated tests show progress, basically. So, you know, if you have automated system tests, and we'll talk about that in a second, for a feature, you know you're done with that feature when that test passes. Otherwise, you can continue to just like, you know, like mentally masturbate or whatever and do all kinds of things that have nothing to do with closing the feature down and getting the feature done. It's really irritating when your users are waiting for a feature from open source or closed source project or fix a security bug or a security patch and you can't close it down because there's nothing to focus on. And so we're going to talk about doing the simplest thing that could possibly work and having tests, having automated tests focus your work a great deal. The other thing is evolutionary design is the concept of big design up front or BDUF as it is called. And so there's two kind of ways I've seen open source projects go. Either it's all a design and there's no code whatsoever and you're busy like tweaking a design, this utopian design for God's own whatever it is that you're working on. Or you shit out code constantly and that doesn't mean there's no cohesion, there's no coherence, it doesn't make any sense. Either extreme is really bad and so extreme programming has an approach that basically and agile development has an approach where you let a design emerge by doing things intelligently. And you think about it a little bit. It's not no design, it's the least amount of design that you can do and still produce really good code basically. The other thing is XP and agile development balances short term instincts and long term kind of needs basically. Long term needs are code that's not shit. Or stuff that doesn't crash when you run it. Or happy users or whatever. Where short term instincts are we have to get this feature done now. We have to get this security patch out now. And how do you balance these two things in a meaningful way without sort of shirking either one. How do you be responsive without fucking your design to the point where you're going to have to rewrite it from scratch for instance. And also between all these things like pair programming and test driven development and all those things, you have no fear. How many people here have worked on code or worked on a product or worked on whatever where people say things like you know I could fix that but I'm afraid I might break something. How many people have heard that? Yeah. That's fucking bogus. Alright. That's a position of helplessness. And that's fucked up. I don't like to be in a position of helplessness. Especially when it comes to code I just fucking wrote. And so no, even on an open source project no one should be able to like take away your position of kind of safety or security. From that perspective. And this is again where a lot of commercial software companies are where they're like they can't do anything. It's not because of bureaucracy necessarily. It's because they're scared of their code. They don't know all the nooks and crannies. They don't have automated tests. They didn't do a pair programming. So the fearlessness makes us bam. How many people here know Aqua Teen Hunger Force? Aqua Teen Hunger Force? So there is an episode called Super Computer. So anybody seen this episode of Aqua Teen? Three people. Alright. There's three real fans in the audience. So Frolok wanted to name the super computer Oogie McTar. Which is a Klingon name. And Shake's suggestion was to call it Badass Mother 4000. Twice as fast as your ass. When you do XP it'll seem like you're going slow at first. But here's the thing. With all these things in place you move fucking fast. Like that. And you're always coding. You're not debugging. You're doing like worthless shit. It feels really great. So it seems slow at first. But basically what it is. It allows you to move very, very quickly. Because you don't have any fear you're going to break something. Or that, you know, whatever. So stories are a short description of an end user goal. An end user goal like. Here's a small C program. I want to detect the exploitable format string bug in this particular program. That's a story. Right. And basically what it comes from the perspective is. What does the user. What's the user goal. What's the user trying to accomplish. Right. In like. What's like their primary goal basically. And it sounds obvious. But if you don't start from this point. And you're like. Yeah. Avoid Jabber client. Never mind how people might want to use it. Right. And then you make it so it's embedded on a USB key. And you have to like hook it up to like. You know. Two tin cans connected with string for it to work. This is what happens. Right. Well intentioned. You know. This would be a really cool tool. This would be really cool. You know, whatever. Or library or whatever. If you don't think about like how it's actually going to be used. Which a lot of people seemingly don't. You're going to produce something that no one wants to use. And then you just wasted your time. And a whole bunch of other people's time. I personally don't like to do that. Maybe other people do. But probably not. So you take this story. And you're like. Okay. How, you know. How hard is this basically. Instead of estimating in terms of hours or days or whatever. You say how hard is this going to be. So XP has a concept of points. Or you can call it whatever you want. Just don't use a time based thing. Say. Oh this is one difficulty point. This is two difficulty points. This is three difficulty points. Right. And so over time you start to figure out. Oh one difficulty point over time. You know averaged out. Takes about eight hours. Let's say. Or whatever. But it's all points. It's all abstract. You don't want to like force people to think. Oh God I've got to get it done in two days. Otherwise like I look lame or whatever. This is one of the things. This is a total trap of software estimation by days or by hours or whatever. Because as you get closer and closer. You start taking more and more shortcuts. So you can meet some deadline that doesn't really matter. Where the thing that matters is delivering working high quality code. As opposed to meeting a deadline or winning a race. Hypothetically speaking and this varies. Each story should take one to two days at the most. Right. If a story is like. If you can't think of like a way that the story might be completed in like one to two days. It means it's too big of a story. You need to split it up. So instead of like the story is. We need to have a Jabber Voip client. That's kind of a big story. You're not going to finish that in two days most likely. I don't care who you are. At least not with high quality and with tests and what have you. So you have to kind of like learn to break it up. What's the minimal incremental step we could take that would deliver value basically. That would be kind of useful. Right. Even if it's not releasable to the general public or whatever. Something we can get started with. That's like the seed of whatever. Right. So maybe like how about just like you know connecting to the Voip network. Or connecting to the Jabber network or whatever. Or finishing the first Voip exchange. Never mind the codex. Just finishing the handshake. Or whatever. And so breaking things up into these little kind of pieces. And then when you like when you have these pieces you're focused on. And you make sure they work 100 percent. Instead of trying to like throw together an entire system all at once. That's how you make sure that your code is really high quality. And everything works incrementally as a unit. Instead of trying to throw it all together at once. And so the other thing that you do with stories is. You come up with an automated test. A way you can automatically test. And that test fails. And when you are done. Implementing the functionality that you're trying to do. The test passes. So you know when you're done. And so you can focus on doing the simplest thing that could possibly work. To make that pass. Sometimes that involves cheating. But we'll talk about that in a minute. And so in this context how do you deal with bugs. Like here's a problem with bugs. Bugs are like fire alarms or whatever. It's like stop everything you're doing. We're going to go fix bugs now. That's horseshit basically. And that's not the way to develop good software. Because if people are going to keep distracting you with bugs and bugs and bugs. You're not going to finish your story. You're going to forget what you were doing. And you'll come back to your story. And be kind of scatterbrained. And that's not good. Just common sense basically. So the way that you deal with bugs. Bugs are also stories. So if you have like one week iterations. And there's like a bug or whatever. Schedule it to the next iteration instead of the story. If it's that important. Usually bugs are usually not actually that important. When it comes into the grand scheme of things. Alright. Pair programming. This is the most controversial part of XP for some god damn reason. I really don't know why. But basically pair programming. We're going to do a demo. You're going to see it. It's two people programming at the same time. And you're like how the hell is that going to work? Do I have to share the keyboard? Or is it two keyboards? Or what the hell. We'll show you in the demo. It's a lot easier to show than to describe. But basically pair programming is like a constant code review. Effectively. And so the general thing to remember is that. Code written by one person is readable by one person. Code written by two people is readable by at least two people. Two different people. Alright. How many people here have like worked on an open source project. And somebody contributes a big chunk of code. And you can't read it basically. Okay. How many of you have thrown away that code. And rewrote it from scratch? Right. That's a big fucking waste of time. Right. You're going to piss off the person who thought they were doing good. Right. And it's a waste of your time. Because that's a great feature. And now you're distracted from working on the thing you were focusing on. To fix somebody else's shitty code. For the sake of you know whatever. And so this helps avoid that problem. And so one of the problems with pair programming open source stuff. Is the geographical disparities of time zone disparity. Like a temporal disparity if you will. And so. And kind of like how do you deal with that. So we're going to show remote pair programming thing using VNC. And we'll get into that when we get into tools. But basically you can kind of like. Ping pong around the world. Or kind of like pass the torch around the world. If you have like somebody who's in like you know on the west coast of the US. On the east coast of the US. And somebody who's in the UK. And then somebody who's an Indian. And someone who's an Asian. Someone who's whatever. You can make sure that that's like everybody's pairing with someone. As you go around the world. Or you don't have to pair all the time right. You know you don't have to pair all the time. There's a practicality that comes into play basically. You know and so you want to just like kind of make sure people new to the project. Are on the right track. Perhaps. Or you know make sure that they're always checking in tests. TDD test driven development which is I think is the next slide. Is probably the most difficult part of extreme programming. Everyone focuses on pair programming. Because I don't know it's the programming is less about their ego. Or I'm not sure what the real sort of social problem is. But TDD is much much more difficult to grasp as a technical concept. And to execute upon. Another thing too is that it provides sort of check and balances. Between when you have more than one person. You have two people. You're not going to write crappy code when someone else is looking at it at the same time. And it keeps the standards up. And you can also be like hey does this look cool. Am I like smoking crack. Or is this is this wrong. Is this right. And you go back and forth. And you brainstorm ideas and it works out quite well. Yeah. The code basically ends up really bad ass. Right off the bat. No time wasted. No throwing out code. No like writing and then a rewrite. If you're rewriting code you're a fucking idiot. If you're like oh we're going to rewrite this in six months. Blah blah blah. Yeah. Why don't you just do it right now. So that you can move on with your life. Basically. I really don't understand why people choose to like take steps that are ultimately going to waste their time. And produce code that no one wants to use or contribute to. Maybe it's some S&M thing. I don't know like some kind of kink. Like you know I want to waste my time. That's the only way I can come or something. I don't know. But anyways. And so there's a kind of a with Parapro is kind of like a ping pong that goes on basically. It's like well. And so one of the responses when I had a job I had. It's like something I was like I don't want to pay a program. I don't want someone to watch me pair approach program all day. I'm like no one wants to fucking watch you program all day. All right. This isn't about you. Like his response is like very kind of indicative of his kind of overall megalomania. But you know no one wants to. Nobody wants to watch you program all day. You know it's an interaction. It's a back and forth basically. And you'll see in the demo when we pair program kind of what goes on. And so one of the ways to like make sure. It's kind of even is one person writes a unit test. The other person makes a pass right. Then the other person refactors and you kind of go back and forth. Anti patterns you want to avoid are only one person. The pair writes the tests. That's that sucks just as much as watching somebody program basically. Or or you know or someone's a keyboard hog or whatever. And so these issues are easy to get around if you're physically pair program with someone. If someone's like cogging the keyboard just like poking with a stick and say knock it off. If it's remote. It's kind of just say over the VoIP or whatever that you're using. And we'll get into that in a second. Is is this like hey you know why don't you sit on your hands for a second. And once you tell me what you'd like me to do. So I get a chance to type right. It's it's it's it's it's a it's a ping pong thing. It's a balanced thing. If it's not basically if there's someone's a keyboard hog or I don't want to pair. Or the thing to avoid the real thing to avoid. It's a real big social problem. That's just going to end in tears as special people who don't need to pair. Because they're so fucking smart that they're programming dicks are so big. That they don't have to pair with anyone. But everybody else does. That's that's that's fucking bogus. That's that's completely bogus. It generates bad feelings. There's one smart person and everybody else is dumb. There's a couple smart people everybody else is dumb. Don't fall into that temptation. I've worked at two jobs now that have done that. It generates bad feelings about the people who are special and rightfully so. Someone doesn't want to pair. Kick them the fuck off. I don't care how smart they are. There's lots of smart people. And you can find someone with more humility. The problem with people who don't have humility who won't pair is they won't admit to mistakes. They'll cover up mistakes. Because they have to sort of exude this image of being like the most awesomest programmer on the planet or whatever. So these are the people who'd be who'd be like yeah select is broken on Solaris. Right. My program is not fucked up. Select on Solaris is broken. Select is not broken. Select is not broken. Your code is fucked up. But this is the kind of shit you hear from people who don't have humility. It can't be my fault. My programming dick is this big. Right. And if I admit to any mistakes. Yeah. Right. It's just going to like reduce me in the eyes of my peers. This is a real social problem. I'm like joking about it. This is a real social problem. If you see us on your project open source or otherwise get rid of that person either make them change or get rid of them. It's ultimately poison. Test driven development. I think is probably. One of the best things to happen to software development since I don't know when since like for GLS or something. It's really really quite amazing. So let me try to go through this relatively quickly. So the first thing you do you start out with a failing system test. Like I said you have a feature like the negotiation has to finish. Right. So how let's say it's a joint joint Weber client a jabber VoIP clients. Good thing I didn't drink any caffeine. Or otherwise I'd be totally incomprehensible. So how would you write an automated system test for that. Well. How do you write an automated system test for that. Well you could start a server background the process a little basic kind of server. Start your client basically and have them say hello to each other. And you can verify that that works. And then when the test is done when the client is done the server exits and et cetera et cetera. Right. That's pretty easy. So you start out with that. Right. And that you're failing sort of. Your failing system test that's going to do that. Your main goal in life is to make that test pass anything else as a distraction. So once you have a failing system test you go into failing unit tests and this will make some more sense when we get into it. When we start programming you buy it open still. No that's OK. All right. Good. We've been fucking with me all day. So I just thought he was screwing with me a little bit. So yeah. So you have your failing system test. Then you start writing failing is a TDD. That is you you have a you write new code to make a test pass basically. So you start with a failing unit test that probably with brand new code start the failing new test that doesn't even compile. Right. The method does the function doesn't exist the class doesn't exist et cetera et cetera. Right. You start with the simplest test that could possibly work in the case of a stack. For instance you'd make a new stack and verify that it's empty. Right. Stack doesn't exist and is empty doesn't exist. And so you go and you implement those things to do the bare minimum to make it work. And so. The simplest thing do the simplest thing that could possibly work. Not the stupidest thing that could possibly work. This is not a license to sort of duplicate large swath of code and to continue to produce shit just because you have tests basically. Right. So you have a failing test. You make it pass and then you refactor. This is what you have to do. Otherwise you're going to have lots of tests for code that is still shitty basically. And you can't maintain the code and you can't maintain the test and the system is still very brittle. It's a very important component basically. You have to kind of do all these things together. And so there's kind of a rhythm to TDD. And that's like test a little code a little test a little code a little test a little code a little refactor to eliminate duplication et cetera et cetera. Make to make and then make the tent. So it's like failing test passing. It's called red green refactor. It's called the stoplight pattern. If you read Kent that's Kent Beck's book red green refactor. It's called stoplight pattern basically. And you repeat this until your system test passes. Right. So that's the kind of rhythm basically that you get into. And once you and it seems really slow to get into the rhythm basically. And you're like OK boom boom boom boom. And so it's red green refactor because in the tools failing tests it gives you red and passing tests gives you green. You talk about the green addiction. I think we have to show it. OK we'll show it. And then at least we'll commentate upon that. The other thing is really great about TDD is it just works. There's none of this like you know spending lots of your time in a debugger trying to figure out what the hell's going on in your program. I personally find that extremely tedious and boring. I like to write code. Debugging is not writing code basically. I like I like to write code like to write very clean code. And when I have when I'm in the debugger I am frustrated basically because basically that meant I took too big of a step without tests or something like that. And do you want to talk about that. Sure. Go for it. So you work in these small incremental steps and when when I started noticing that that things weren't really going as slow as I had originally thought is because I hadn't opened up a debugger at all. We were coding for I don't know like eight hours straight and not once that I have to open up a debugger and I'm not the type of person that is shy about a debugger. First time I see any kind of code. If I even if I source the first thing I'm going to do is I open up in Ida I start all a debug whatever I look at stuff better and assembly a lot of the time than I do in source. So this was really surprising to me. And so what we started doing is just do little little incremental changes. You add one method test that make sure that the interface is working and then then that solid you can move on to something else. So it's kind of like you have all these little modules you test this module here. Everything is working fine. You can set it aside. You don't have to worry about it anymore. Then you move on to the next thing and it's like building blocks is you have it like it's like a pyramid. You start putting things together one after the other after the other. And then finally you have this complete solution and you can if you want to replace a block you can place a block. It's not going to all fall down. Or if it does you know. Yeah. If it does you know. Yeah. Your tests tell you everything you do one change. You're like OK I'm going to try to change. Let's say I'm going to I'm going to try a different protocol with with the server and you write that. If it doesn't work your tests are going to tell you and you could just revert right back. Any change you make you'll know right away if it affects any other part of the program. You don't have to worry about OK if I change the structure here. It's going to affect everything everywhere and it'll never compile again. The the very wise phrase I can't remember where I read it. It was probably Ken Becker Ron Jeffries. If I say the code will tell you what to do. The code will tell you what to do. If you have a failing system test the code is telling you to implement a feature. If you have a failing unit test the code is telling you to do the simplest thing that could possibly work to implement that test. If all your tests are passing and you make a minor what you perceive to be a minor optimization such as like changing a class to a struct or what have you. Now your tests start to fail. You made like a two line change back back you're back to passing. As opposed to oh God I guess you have to like figure out how to integrate this or you know just like coded for eight hours straight. And now like everything's broken. You don't know what to do. You're blurry eyed. The crank that you snorted to program really fast is starting to wear off. And you're like shit. What do I do? Fuck I'll just have to revert. Eight hours wasted. Fuck that shit. I don't like wasting my time. Maybe some people do again. Whatever your kink happens to be different strokes make the world go around. So it just works. Less debugging more coding. I fucking hate debugging. Hate debugging. Programming by intention. The other thing with TDD is that since you're like since basically you're writing your test first you're getting like real bird's eye view of kind of what the code's going to look like when people other people go to use it basically. So if it takes you ten lines of code to make a connection to the Jabber server or whatever I keep using this example but run with me here. Right. If it takes ten lines of code your API is wrong. It's design feedback on your API. You get that from writing the test first. So by starting out with a good API. That's clean from a consuming and test kind of perspective. You basically get all the advantages of if you had modeled it in UML for six months with no code written whatsoever or did like God's own design for a Jabber client with no working code. He said not only do you have a very clean decoupled really maintainable and extensible design because you had to write the tests first and for things to be testable they have to have those design qualities. You don't only have that you have working code and regression tests at the same time. It's really fucking bad ass. And this is the thing something that people kind of I think don't get when they read about TDD. It's more of a design methodology than a testing methodology. It's like testing is for QA testing is for whatever blah blah. It's like OK. So your job is to write shit that doesn't work. All right. If you want to admit that see how we see how far that gets you in your career like maybe you know maybe in government work actually. Anyways. But probably you know you don't say that out loud. And so if you kind of like start to think about it. Yeah I probably should make sure that my code works so I don't waste my peers time. Right. Or I don't fuck up this open source project and look like a complete dunce. It only takes a little bit of foresight to sort of like all of you do like have a little conversation in your head basically and you realize oh why do I think that. Why do I think testing is for other people and not for me writing the code. It's a really bad kind of social thing that's been kind of persisted through the years. I don't understand why. Anyways. And so writing things in TD to make sure you're programming by intention things work because you intended them to write how many people have been writing code and you think that you're not done but all of a sudden things work. And you're like why is this working one two three four five six. Right. That's just as bad as if you expect it to work and it doesn't. Basically you are no longer one with your code. You don't know what's going on. That's a bad place to be. That is a very slippery slope. And when things work when you don't think that they should that that that's just as dangerous as the opposite kind of situation. Right. And that's called programming by coincidence. That's a pragmatic programmer thing which is really great book pragmatic the pragmatic programmer. They got programming by coincidence. It happens to work. I'm real happy. Yeah. Right. I just happen to not have diabetes. Does that mean I'm not going to go to my doctor. No. Right. So incremental design so TDD can leads in incremental design or emergent design as it's sometimes called. And this comes down to what I said earlier the code will tell you what to do. It is very simple very wise thing. It is by the way I hope you know this is we're talking about like methodology we're talking about code right talking about plans and designs and documents and bullshit. We're talking about writing code staying in code as much as possible. And getting as much done as possible without wasting time. If you like to write code and you and you like to not waste time. This is really what you should be doing basically. Anyways. So there's a couple things with the emergent design and TDD right. And one of the things is that if if you can't test if something is difficult to unit test if you can't test it it's wrong. Your design is wrong. Get over it. Make it testable. If you can't test it if you can't mock out the sockets or you can't do whatever. You're you're. You're wrong basically. And you have to own you have to set up and go OK. It's difficult to test that doesn't mean unit testing sucks. That doesn't mean that like the unit testing tool is broken which is similar to the select is broken thing you have to go OK. This is this is the test code giving me design feedback. I need to consider this and figure out how this can be made easier to test right or how it can be made to be testable. If it's not testable your design is wrong. You have close coupling inappropriate intimacy. I know coupling and intimacy that's really funny. I didn't make those up. Those are object oriented. Weenies came up with that like in the mid 90s and it's in the design patterns book thinking in for book and stuff like that. Having a design with these problems with coupling problems and appropriate intimacy and circular dependencies means you're in for a world of pain just like in the Big Lebowski. Right. Have you heard of Vietnam Billy. This is what happens when you fuck a stranger in the ass. You're hitting for a world of pain. Basically and this is the test telling you right now when it's easy to change once you have a lot of code all based around design changing it becomes much much more difficult especially when you have coupling and like inappropriate intimacy and circular dependencies. Good luck refactoring that this is what this is where people hit the brick wall. They're like shit. We have to rewrite everything now. We have to start over from scratch. Maybe we'll reuse some of the code or whatever every every read I've ever seen has always introduced more bugs and it solves basically. Because you're not giving yourself the feedback loop. You think you've learned your lessons. There's less of salient details. You have not picked up on as far as the feedback from your design. I don't care if it's in UML or whatever the test tell you what to do. The code will tell you what to do as far as your design. So the other is fake it till you make it right. Do you need to come up with a complete implementation of the Jabber protocol to pass this one test of the handshake finishing. No you don't if it's not encrypted. Do you need to like. Write use an SSL library or whatever. No, it's all about scoping scoping your stories down to the point where it's like a small chunk of functionality is going to be easy to easy to implement basically. And so and so one things you can do is you can fake it till you make it basically and we'll get into that when we start writing the test. But basically doing the simple thing could possibly work like if you're writing out one test that expects a certain method to return zero and it just make that method return zero right. And then you write another test that expects one or some other return value. That's when you that's when you generalize basically you don't generalize up front. We don't design up front. We wait for the code to tell us what to do. Let me see. So Lynn eliminating duplication. How many people here have seen like probably I don't know entire functions duplicated across a project like maybe ten plus times. Yeah. How many people here think that's fucking retarded. Yeah. You're right. You're not wrong basically. And so eliminate duplication. This is another thing of the code will tell you what to do. You have duplication. There's two there's two different kind of acronyms. There's DRI which is don't repeat yourself. And it was once and only once. Oh which are two a pragmatic programmer kind of things. So don't repeat yourself. If the code is repeating if there's more than one source of information for a particular kind of information in the system. There's something wrong in your design. It's it comes down to it. It's hard to sort of encapsulating responsibility for certain things effectively or coming up with a generalized class design or whatever. But sharing code is good for the most part if you don't do it stupidly. And so eliminate duplication is one of the best things you can do to improve your design. This is another without tests even forget TDD. If you see duplication refactor. So there is no duplication. The code will tell you what to do to improve your design and improve your code. You just have to stop thinking you're incredibly clever and pay attention. And listen to the code testing in a coupling and inappropriate intimacy. So coupling is basically safe. You have like two classes basically right and they call into each other all the time, right? It's really close coupling basically. It's kind of like there's like almost like a sewing pattern design these two between these two classes and basically they're useless without each other. That's coupling basically and it doesn't make for a very versatile design. And I mean I'm not going to go into why that's a really bad idea. Hopefully it's somewhat obvious. If anybody has any questions come talk to me later and I'll explain it to you. Inappropriate intimacy is similar where like basically one component of your app knows a little too much about the internal workings of how this other thing works. Like it knows too much about like it knows that oh it goes eight characters in adds five and does whatever to come up with its IV for its encryption or whatever. You don't want to have those details spread throughout the system that comes down to once and only once. The details of how that is done should be expressed once in the system, right? Sometimes you write tests that know a little bit too much about the underlying class or whatever and you want to kind of pay attention and avoid that also. And for the sake of brevity I'll move on. But if anybody has questions let me know. Okay. So then there's cohesion. So I've been talking too much. So we're going to skip to the next slide. Continuous integration. Build your software all the time. You have an automated build that runs once a day. Run it all the time. There's no reason not to. Why wait until 12 a.m. or 5 a.m. or whenever your build runs. You'll find out that your code doesn't compile or your tests are failing. If you have an automated build run it all the time. It's just kind of common sense basically. You don't have to have a dedicated build machine. You can have a shell script that does an SVN update, compiles the code, runs the unit tests, and then runs the system tests. That's like a four-line shell script. Let's see. Yep. Oh, the other cool thing is that you know whose fault it is. It's like, oh, there are 50 check-ins that day from 100 different developers. Whose fault is it? I don't know. You could go look at diffs for like eight hours to try to figure it out. When you have a continuous build that runs all the time, there's probably only a couple of check-ins that have happened since the last build. So you're going to know who broke it and then you know who to kick in the balls basically. So we see tools, basically stories. You don't need anything fancy to do stories. You just have a wiki basically or on SourceForge they have a feature request tracker, which is a good place to store stories and things like that. You don't need a commercial tool or anything fancy. Some people just have a little text file in their source control repository. Pair programming remotely. You just need a remote desktop software. Luis and I like tight VNC rather than tight. That's right, just like your mom and your dad. Yeah, we prefer tight VNC. It's an open source thing. It's got a lot of cool optimizations. It just works really well. Real VNC is still usable and you should use that. On Mac OS there's a couple of VNCs that you can use. Tight VNC doesn't run on Mac OS just yet if you're pairing between different Mac developers. So here's some command line options I found to be useful. Dash BGR233 is the best, by the way. It takes 16-bit color information and puts it down into 8-bit color information, but it doesn't look really, really weird dithering-wise. That's really handy if you're pairing with an open source developer. If you're a developer, say, in India or whatever, where they have that kind of limited bandwidth coming into the country, or someone's on a dial-up, this is still utterly doable. It might look weird depending on the colors and the ID syntax hiding you use and stuff, but check it out. It'll basically work. You can also do it within VMWare. You don't have to worry about sharing your whole desktop. You can have a VMWare session running and then also tunnel all the VNC over SSH. Yep. It's possible to do this highly securely if you don't trust that developer in India or Pakistan or Germany or wherever, or the US for that matter. Another really key component is audio chat. There's a bunch of free audio chat stuff that you can do, basically. Pair programming and having to switch to an IM client in the middle of writing code to communicate doesn't work. I tried it. It seems like it would be okay, but it doesn't work. Audio chat is really a necessity. There's free stuff you can use. Jabber has a thing called Jingle, which I guess was developed by Google. Was that developed by Google? Yeah. There's a lib jingle. Copete, with my personal preference, 0.12 implements this. Game 2.0 implements this. Google Talk is technically not open source, but I figured I'd mention it anyway. It also implements that. If you're not totally worried about completely using 100% open source stuff. There's also GNOME meeting, which uses H.323 or whatever it is. That can also interact with... That Windows thing. I can't remember what it is. Net meeting, thank you. There's also Skype, which is not open source. Please forgive me. It's still very useful. It's still a useful tool. There's a Linux client, there's a Windows client, etc. Webcams are not necessary. Don't waste your bandwidth with webcams. What the fuck are you going to do, sign language to each other? If you're working with a deaf developer, fine. If you're not, webcams are a waste of time. It's a waste of bandwidth. You want your typing to be very responsive. You want your audio chat to be very responsive. I talked for too long. I'm sorry. Do we have time for questions? Where's the person? Two minutes. Four questions. Do you want to ask questions or do you want to see us demo this real quick? Yes. Jesus fucking Christ. The rest of the slides document different tools and things like that. C-Sharp compiler, blah, blah, blah. It is good. The SVN repo for this project is on SourceForge at that URL right there. It's not in the slides because we wanted to release it exclusively at Black Hat and DEF CON. It's on the printed slides, so if you're so interested, write it down. It's not on the CD. System test failing. How are we going to do that? Start VNC. No, start VNC. That's a good idea. Let's just show them the framework. You can just show them the end unit. Network is unreachable. All right, no problem. It's just, it's not at it anymore, is it? Oops. All right. So, what is it? That's what I did. Whoops. Caps lock on. Sorry about that. Sorry about that. All right, cool. So, for some reason in Kubuntu, when I do dual monitors, it will only do 640 by 480. Anybody who knows how to fix this, please let me know so that the talk tomorrow isn't greater than 640 by fucking 480. But just to show, like, his laptop is some ungodly 16 by 9 resolution that's, like, really huge, but just goes to show, like, I can still see. I can still see the code. I can still interact. In fact, I was in the Minneapolis airport stuck because of United Airlines who suck balls. And Luis was like, I'm having this compile problem. I'm not sure what to do. I was able to use palm VNC on my Treo to VNC into his thing while I was talking with him on the phone and go, oh, you're using parents and you use less than and greater than. That's pretty badass in my personal opinion. So, anyways, so we can see the code here. And so, this is a, huh? All right. It's a VNC connection, basically. And so, the system sets that we have are one with a simple Python script that will show very briefly for 30 seconds. These are the unit tests. This is the green. You get addicted to the green. Every time you see more green, it's like you're doing something right. Every time you see the red, you're like, oh, shit. That's really what it comes down to. And every time you see the green, you're like, yes, everything I just did is 100% correct. And I know it. It's a real ego boost. That's basically why there's no other way to work in my personal opinion. So, the system tests. We'll show the rest later at the next talk, which is on Saturday at 8 p.m., assuming that those start on time, et cetera, et cetera. Thanks.