future aircraft technology

Then figure out what the things are in your use casethose are generally the nouns. Each class in your application should have only one reason to change. Fidoonbarks control the remote to be let 2. * System.out.println(\nFido has gone outside); System.out.println(\nFidos all done); try { Thread.currentThread().sleep(10000); } catch (InterruptedException e) { } We simulate some time passing here. } Before running the Americas for Ivar Jacobson Consulting, Dave worked for a number of years at Rational Software (now a part of IBM). Write the complete use case for Get directions. Get direction s Use Case 1. That also means its loosely coupled with the rest of the applicationchanges to Instrument, for example, dont have a lot of effect on the Inventory class. The client provides a set of specs for their ideal guitar, in the form of a Guitar object. Write those things in the blanks below: you are here 4 577 coding from a class diagram Sharpen your pencil answers Write the skeleton for the Airplane class. from Airplane. match the clients sp Inventory.java well-designed apps rock Getting ready for another test drive Youll need to update the FindGuitarTester class to test out all these new changes: public class FindGuitarTester { This time, the client sends a GuitarSpec to search(). stores a single Dog or attribute Door. 62 Chapter 2 gathering requirements Listen to the customer When it comes to requirements, the best thing you can do is let the customer talk. pressButton ( ; System.out.println(\nFidos back inside); } ( 90 Chapter 2 ( } ( ln ( "but he's stuck outsid osen You could have ch Todd t ou the message ab mote, but re grabbing the test for were trying to remember? 98 Chapter 2 Use these magnets to indicate the clear value of a use case. If serve() changes, youve got to update code in only one place: DessertService. We love that you thought about Fido getting stuck outside, and took care of that, too. Things are going well at Dougs Dog Doors. And theres a lot more to learn about class diagrams, too. Ready for someone else to let your dog outside? Its a use a system takes to make something happen. 8. How am I supposed to ever get good at this? Make your code as smart as you are. Any time the hardware hears a bark, it calls recognize() in our new BarkRecognizer class, and we open the dog door. Th capabilities for: configuration Defining and representing a board ies or other fighting units Defining troops and configuring arm Moving units on the board Determining legal moves Conducting battles Providing unit information eloping a turn-based strategic The GSF will simplify the task of dev GSF can devote their time to board game so that the users of the implementing the actual games. Tex does his business. I hadnt thought about that, but youre right; we really should be focusing on the interface, and not all those implementation classes. The bark recognizer must open the dog door when it hears barking. Lets write down what should happen if the door closes before Fido gets back inside. Even though these last ten topics dont deserve more than a mention, we didnt want to let you out of Objectville without a little more information on each one of them. Start and Stop 2 In the dog door, Fido is the external initiator. you are here 4 265 the ease-of-change challenge The Great Ease-of-Change Challenge How easy is it to change Ricks search tool? Do you think software designed like this will be easy to extend and maintain? Features covered check! We shou put try and encapsulate what varies, and way, all the serving code in one place. Instead of focusing on getting the owners dog outside, he was worrying about one specific bark. Game Designer Most of the features relate to what the game designer does with the framework. A: The idea behind encapsulation is to protect information in one part of your application from the other parts of your application. Todifdthe or Gin a hea rs Fido bar king. Style toString(): String Those spec classes sure look a lot alike. In other words, were focusing on our code. in terra a with different types of terrain. Youve already seen that class diagrams give you a lot of information about the attributes and operations of a class. 106 Chapter 2 * Readers of Head First Design Patterns will find these categories familiar thats because OOA&D and design patterns go hand in hand. I was so excited but it turned out that I handled the situation when the customers credit card was rejected. one thing really well and does not try to Cohesive classes are focused on specific tasks. Alternate Path: Sure, it may sound that way. specific. Todd and Gina: No, not at all. Youve seen the customers; now lets look at the use cases. Small Problem Big Problem you are here 4 281 solving big problems The things you already know Youve already learned a lot of things that will help you solve big software problems you just may not have realized it. HeadFirst: Ignored? The dog door opening must beDoor, What the Door Does tall. Todd or Gina hears Fido barking. Rick will have to wait until Chapter 5, though weve got some hairier issues to tackle in the next chapter. The owners dog goes outside. Weve got quite $200 an array of OO answers$200 tonight, I hope youve $200 come ready to ask the right questions. Alternate Path: Yeah, thats what 3.1 and 4.1 keep telling me. particular customer goal. Probably the best web designer centric book on Ajax. Stefan Mischook, Killersites.com Using the irreverent style common of the Head First/Head Rush series of books, this book starts at the beginning and introduces you to all you need to know to be able to write the JavaScript that will both send requests to the server and update the page with the results when they are returnedOne of the best things about this book (apart form the excellent explanations of how the code works) is that it also looks at security issuesIf you learn Ajax from this book you are unlikely to forget much of what you learn. Stephen Chapman, JavaScript.About.com Head Rush Ajax is the book if you want to cut through all the hype and learn how to make your web apps sparkledyour users will love you for it! Kristin Stromberg, Aguirre International If you know some HTML, a dollop of CSS, a little JavaScript, and a bit of PHP, but youre mystified about what all the Ajax hype is about, this book is for youYoull have a blast learning Ajax with Head Rush Ajax. Yes, with over 550 pages under your belt, there are still things we couldnt cram in. 6.4. Randy AND Sam: It works! The BarkRecognizer needs to know which door it will open. So just like you keep the data in your classes separate from the rest of your apps behavior, we can keep the generic properties of a guitar separate from the actual Guitar object itself. But, remember, one of the key points about a use case is that it is focused on accomplishing one particular goal. You (and your co-workers) will think your software is great when its easy to maintain, reuse, and extend. When intermediate or advanced concepts come up, theyre taught as if they might be totally new to you, though. Very cool! Why dont we have the DogDoor close itself? The framework keeps up with whose turn it is. Oh, wait then if the game uses the system, what is it? 1, 2.1, 3.1, 4, 5, 6, 6.1, 6.2, 6.3, 6.4, 6.5, 7, 8 Fido gets stuck outside. A what is its type? Remember the second step in writing great software, from back in Chapter 1: Apply basic OO principles to add flexibility. you are here 4 67 what can go wrong will go wrong Plan for things going wrong Below is a diagram of how Todd and Ginas dog door should work; all the numbers match up with the steps in our list on page 66. Fido goes back inside. Your brains thinking, Better leave room for more important things, like which wild animals to avoid and whether naked snowboarding is a bad idea. So how do you trick your brain into thinking that your life depends on knowing object-oriented analysis and design? 2.1. Remember, most people expect things to work even if problems occur. 1, 2, 3, 4, 5, 6, 6.1, 6.2, 6.3, 6.4, 6.5, 7, 8 7. The owners dog barks to be let out. class DogDoorSim { } public class DogDoorSimulator { DogDoorSimulator.java You should have written in periods, semicolons, and parentheses as you needed them. Could you make the search tool return both of them? } else { System.out.println(Sorry, we have nothing for you.); } // initializeInventory() method here instruments to Ricks We also need to add some for more than inventory so we can searchthe next page. Sharpen your pencil The search() method isnt the only thing that makes adding new instruments to Ricks application difficult. All of the words to answer the puzzle below are somewhere in this chapter. List neighbors = (List)network.get(start); for (Iterator i = neighbors.iterator(); i.hasNext(); ) { Station station = (Station)i.next(); if (station.equals(end)) { route.add(getConnection(start, end)); This first pa return route; code handles rt of the } else { the end stat the case when reachableStations.add(station); connection awion is just one previousStations.put(station, start); } starting stat ay from the ion. } But all that means the software will be easier to change, doesnt it? GuitarSpec.java. stored in the door // etc Sam: Ill delegate bark comparison Sam is using a Bark object, and he lets that object take care of all the sound comparisons: public class BarkRecognizer { Sam has the hardware guys make sure he gets sent a Bark object now, not just the String bark sound, like Randy. 2.1. Frank: Weve gone through this already: the properties for each instrument are what vary. 8. class BarkRecognizer { recog } We need some software to run when Dougs hardware hears a bark. ld The alternate path shyoouu ce on sy have been ea nts figured out the requireme for the main path. Its never easy trying to figure out where to start. The m things, the easier ore you encapsulate break a large app it will be for you to pieces of function up into different ality. ACOUSTIC, ELECTRIC; } public String toString() { switch(this) { case ACOUSTIC: return acoustic; casepublic ELECTRIC: enum return Builderelectric; { default: return unspecified; } FENDER, MARTIN, GIBSON, COLLINGS, } OLSON, RYAN, PRS, ANY; to these We can refer A, or as Wood.SITKON, and Builder.GIBSse string avoid all tho completely. Randys not thrilled he lost either, but figures Maria might be his ticket to winning the next programming contest. Bruc e scratche s at the door agai n. 6. // Override the superclass matches() public boolean matches(InstrumentSpec otherSpec) { s if (!super.matches(otherSpec)) hes() uses the superclass tc ma ms return false; tches(), and then perfor if (! Its not about doing silly diagrams its about writing killer applications that leave your customer happy, and you feeling like youve kicked major ass. write well-designed and robust code. External Initiator Every use case is started off by an external initiator, outside of the system. Tex comes back inside. Randy: Well, yeah, I guess I can see that but I had a good idea of how my system would work, too. _____ 3. The thing I liked most about this book was its focus on why we do OOA&Dto write great software! Its almost like double-encapsulation or something. 6.4. Checktsitfor you before going on if your out e new to UML or OO programm ing. Woof! you are here 4 113 the customer is right Back to the drawing board Time to get working on fixing up Todd and Ginas dog door again. Its trying to make sure that this obviously non-important content doesnt clutter up scarce resources. Fido does his busine ss. Nobody is happy when an application that worked yesterday is crashing today. Make sure your software does what the customer wants it to do. 242 Chapter 5 (part 2) 2. brain power Is anything wrong here? happen? 2.1. Use cases are often too detailed at this stage, so a use case diagram can help you see what a system is like at 10,000 feet kind of like a blueprint for your application. The Ultimate Dog Door, version 3.0 Opening/closing the door Main Path 1. Happy Path: Yeah, pretty much. If your use case doesnt detail exactly what your system is supposed to do, then you could miss an important requirement or two and end up with unhappy customers. The key pad mus t be able to lock the dog doo r and all the win dows. the Heres our Step 3, fromote back wr original use case we in Chapter 3. This code simply passes in the text file, and then tests a few stations and connections to see if they got loaded. you are here 4 35 time for some serious design Design once, design twice Once youve taken a first pass over your software and applied some basic OO principles, youre ready to take another look, and this time make sure your software is not only flexible, but easily reused and extended. Q: And thats because we use the Instrument class directly now, right? The game is complete, and you can actually play it. DogDoor.java Remote.java class DogDoor { class Remote { open() class press} DogDoorButton() } Sim { } javac *.java DogDoor.class Remote.class DogDoorSimulator.class DogDoorSimulator.java 3 Run the code!