ebook img

IEEE Software (November/December) PDF

81 Pages·2001·2.107 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview IEEE Software (November/December)

from the editor Editor in Chief: Steve McConnell (cid:2) Construx Software (cid:2) [email protected] Raising Your Software Consciousness Steve McConnell I n 1970, Charles Reich published a best- tory has not been kind to the book. In 1999, selling book called The Greening of Slate magazine’s readers voted it the silliest America.1 In it, Reich identifies three book of the 20th century. Reich’s Con III was kinds of awareness or consciousness, a hippie nirvana, and the “greening” Reich which he calls Consciousness I, Con- predicted was a nationwide movement to- sciousness II, and Consciousness III. ward the hippie culture of the 1960s and Consciousness I (“Con I”) is the 1970s—psychedelic drugs, bell-bottom pants, pioneer mentality. People who op- and all. As the hippie culture faded into ob- erate at Con I place great value on scurity in the 1980s, so did the credibility of independence and self-satisfaction. Reich’s predictions. They don’t easily tolerate other people telling them what to do. Can’t get no satisfaction They are highly self-reliant and Reich’s political predictions may not have self-sufficient. Reich believes that withstood the test of time, but his classifica- Con I dominated the American tion of Con I, Con II, and Con III provides a psyche during America’s first cen- useful model for the software industry today. turies and that this focus on self- Con I in software is associated with a focus reliance was a significant factor in on self-reliance. Software experts often refer to America’s development. software developers operating at this level of Consciousness II is the gray flannel suit awareness as mavericks, cowboy program- mentality—corporation man. People who op- mers, Lone Rangers, and prima donnas. Soft- erate at Con II understand the importance of ware developers at this level tend to have little getting along with others and playing by the tolerance for other people’s ideas. They like to rules. They believe rules are good for society, work alone. They don’t like following stan- and they think everyone should follow them. dards. The “Not Invented Here” syndrome Reich believes that Con II became more dom- thrives. inant than Con I in the mid-twentieth century. Con I’s advantage is that little training is Consciousness III is the mentality of en- needed, and the lone-wolf approach works ad- lightened independence. The Con III person equately in environments that employ only operates on the basis of principles, with little small numbers of programmers who work in- regard for the rules that predominate in Con II dependently on small projects. Con I’s disad- and without the selfishness that predominates vantage is that it scales poorly to projects that in Con I. By the time Greeningwas published, need teams of programmers rather than iso- Reich argued that Con II’s time was over. He lated individuals. believed Con III was in its ascendancy and Con II in software is associated with a fo- would soon replace Con II. cus on rules. Many software developers even- Although The Greening of Americastruck tually discover the limitations of Con I’s self- a resonant chord when it was published, his- reliant development style and see the Copyright © 2001 Steven C. McConnell. All Rights Reserved. November/December 2001 IEEE SOFTWARE 7 FROM THE EDITOR advantages of working in groups. ware approaches, and they fail outside Over time, they learn rules that allow narrowly defined areas of applicability them to coordinate their work with —predictably—precisely because they DEPARTMENT EDITORS others. Some groups of developers are Con II. The world of software is far Bookshelf: Warren Keuffel, create their own informal rules too varied to be addressed by a single [email protected] through trial and error, and these set of rules. Country Report: Deependra Moitra, Lucent Technologies groups can be highly effective. Other For example, compare the practices [email protected] groups buy a prebuilt methodology. you would use to develop a heart pace- Design: Martin Fowler, ThoughtWorks, [email protected] Sometimes the rules are provided by maker control to those you would use Loyal Opposition: Robert Glass, Computing Trends, consultants, as in the classic “17 to develop a video store management [email protected] three-ring binders” methodologies. program. If a software malfunction Manager: Don Reifer, Reifer Consultants, Other times, the rules are taken from caused you to lose one video out of [email protected] books, such as The Rational Unified 1,000, it might affect the store’s prof- Quality Time: Jeffrey Voas, Cigital, [email protected] Process,2 the Extreme Programming itability by a fraction of a percent, but series,3 or my own Software Project the impact is negligible. If a malfunc- STAFF Survival Guide.4 Developers at this tion caused one pacemaker out of Senior Lead Editor level of awareness tend to focus on the 1,000 to fail, however, you’ve got a Dale C. Strok [email protected] details of adhering to the rules. They real problem. Generally speaking, argue about which interpretations of widely distributed products must be Group Managing Editor Crystal Chweh the rules are correct and focus on developed more carefully than nar- Associate Editors “following the methodology.” rowly distributed ones. Products whose Jenny Ferrero and The advantage of Con II is that a reliability is important must be devel- Dennis Taylor developer needs to be trained to use oped more carefully than products Staff Editors Shani Murray, Scott L. Andresen, only a single approach. If a good ap- whose reliability doesn’t much matter. and Kathy Clark-Fisher proach is chosen, the developer can These different kinds of software Magazine Assistants leverage a relatively small amount of require different development prac- Dawn Craig [email protected] training across many projects. The dis- tices. Practices that would be consid- Pauline Hosillos advantage is that a Con II developer is ered to be overly rigorous, bureau- Art Director ill-equipped to succeed on projects cratic, and cumbersome for video Toni Van Buskirk that fall outside the specific metho- store management software might be Cover Illustration Dirk Hagner dology in which the developer was considered irresponsibly quick and Technical Illustrator trained. dirty—or reckless—for an embedded Alex Torres Con III in software is associated pacemaker control. The Con III de- Production Artists with a focus on principles. At this level veloper will use different practices to Carmen Flores-Garvey and Larry Bauer of awareness, developers understand develop a heart pacemaker control Acting Executive Director Anne Marie Kelly that the rules of any prepackaged than to develop an video inventory Publisher methodology are, at best, approxima- tracking system. The Con II developer Angela Burgess tions of principles. Those approxima- will try to apply a one-size-fits-all Assistant Publisher tions might apply most of the time, but methodology to both projects, with Dick Price Membership/Circulation they won’t apply all of the time. The the likelihood that the methodology Marketing Manager disadvantage of Con III is that exten- won’t work particularly well for ei- Georgann Carter sive education and training are needed ther one. Advertising Assistant Debbie Sims to introduce a developer to the princi- ples underlying effective software de- Are you experienced? CONTRIBUTING EDITORS velopment, and that training is not eas- Reich identified the three levels of Greg Goth, Denise Hurst, Anne Lear, Keri Schreiner, ily obtained. Con III’s advantage is consciousness as the zeitgeists of dif- and Margaret Weatherford that, once that training has been ob- ferent eras, but I see Con I, Con II, and tained, the developer is equipped with Con III as three distinct steps along a Editorial:All submissions are subject to editing for clarity, a full range of software engineering path of personal software engineering style, and space. Unless otherwise stated, bylined articles tools that support success on a wide maturity. Most software developers and departments, as well as product and service descrip- tions, reflect the author’s or firm’s opinion. Inclusion in range of projects. begin their careers at Con I and even- IEEE Softwaredoes not necessarily constitute endorsement tually journey to Con II. In many envi- by the IEEE or the IEEE Computer Society. Love the one you’re with ronments, Con II supports effective To Submit:Send 2 electronic versions (1 word-processed The software industry has a long work, and no further development is and 1 postscript or PDF) of articles to Magazine Assistant, IEEESoftware, 10662 Los Vaqueros Circle, PO Box 3014, history of trying and ultimately reject- needed. In some environments, how- Los Alamitos, CA 90720-1314; [email protected]. Ar- ing “one size fits all” methodologies. ever, a further progression toward Con ticles must be original and not exceed 5,400 words including figures and tables, which count for 200 words each. These methodologies are Con II soft- III is needed. 8 IEEE SOFTWARE November/December 2001 FROM THE EDITOR EDITOR IN CHIEF: Steve McConnell 10662 Los Vaqueros Circle The by-the-book methodologies of References Los Alamitos, CA 90720-1314 [email protected] Con II seem to be a reasonable learn- 1. C. Reich, The Greening of America, Random House, New York, 1970. EDITOR IN CHIEF EMERITUS: ing path for developers at Con I who 2. P. Kruchten, The Rational Unified Process: An Alan M. Davis, Omni-Vista are not yet well versed in a wide range Introduction, 2nd ed., Addison-Wesley, Read- of software practices. The specific de- ing, Mass., 2000. ASSOCIATE EDITORS IN CHIEF 3. K. Beck, Extreme Programming: Embrace tails of the rules-based practices prob- Design: Maarten Boasson, Quaerendo Invenietis Change, Addison-Wesley, Reading, Mass., [email protected] ably don’t matter all that much. People 2000. Construction: Terry Bollinger, Mitre Corp. who are trying to raise themselves 4. S. McConnell, Software Project Survival [email protected] Guide, Microsoft Press, Redmond, Wash., Requirements: Christof Ebert, Alcatel Telecom from Con I to Con II simply need to 1998. [email protected] take a first step away from the chaos Management: Ann Miller, University of Missouri, Rolla of a completely unmanaged project. [email protected] Quality: Jeffrey Voas, Cigital They must learn a set of rules and get [email protected] some experience applying those rules Experience Reports: Wolfgang Strigel, Software Productivity Center; [email protected] before they can advance to the Con III level, where they understand software EDITORIAL BOARD project dynamics well enough to break Don Bagert, Texas Tech University the rules when needed. This whole Richard Fairley, Oregon Graduate Institute Martin Fowler, ThoughtWorks process is part of the natural progres- Robert Glass, Computing Trends sion from apprentice to journeyman to Andy Hunt, Pragmatic Programmers Warren Keuffel, independent consultant master. Brian Lawrence, Coyote Valley Software Karen Mackey, Cisco Systems Deependra Moitra, Lucent Technologies, India Don Reifer, Reifer Consultants Suzanne Robertson, Altantic Systems Guild Dave Thomas, Pragmatic Programmers Karl Wiegers, Process Impact INDUSTRY ADVISORY BOARD Robert Cochran, Catalyst Software (chair) Annie Kuntzmann-Combelles, Q-Labs Enrique Draier, PSINet Eric Horvitz, Microsoft Research David Hsiao, Cisco Systems Takaya Ishida, Mitsubishi Electric Corp. U p c o m i n g T o p i c s Dehua Ju, ASTI Shanghai Donna Kasperson, Science Applications International Pavle Knaflic, Hermes SoftLab Günter Koch, Austrian Research Centers Wojtek Kozaczynski, Rational Software Corp. Tomoo Matsubara, Matsubara Consulting January/February ’02: Masao Matsumoto, Univ. of Tsukuba Dorothy McKinney, Lockheed Martin Space Systems Building Systems Securely Nancy Mead, Software Engineering Institute Stephen Mellor, Project Technology from the Ground Up Susan Mickel, AgileTV Dave Moore, Vulcan Northwest Melissa Murphy, Sandia National Laboratories March/April ’02: Kiyoh Nakamura, Fujitsu Grant Rule, Software Measurement Services The Software Engineering Girish Seshagiri, Advanced Information Services Chandra Shekaran, Microsoft of Internet Software Martyn Thomas, Praxis Rob Thomsett, The Thomsett Company John Vu, The Boeing Company Simon Wright, Integrated Chipware May/June ’02: Tsuneo Yamaura, Hitachi Software Engineering Knowledge Management MAGAZINE OPERATIONS COMMITTEE in Software Engineering Sorel Reisman (chair), JamesH. Aylor, Jean Bacon, Thomas J. Bergin, Wushow Chou, William I. Grosky, Steve McConnell, Ken Sakamura, Nigel Shadbolt, Munindar P. Singh, Francis Sullivan, July/August ’02: James J. Thomas, Yervant Zorian The Business of PUBLICATIONS BOARD Software Engineering Rangachar Kasturi (chair), Angela Burgess (pub- lisher), Jake Aggarwal, Laxmi Bhuyan, Mark Chris- tensen, Lori Clarke, Mike T. Liu, Sorel Reisman, Gabriella Sannitti di Baja, Sallie Sheppard, Mike Williams, Zhiwei Xu November/December 2001 IEEE SOFTWARE 9 ddeessiiggnn Editor: Martin Fowler (cid:2) ThoughtWorks (cid:2) [email protected] To Be Explicit Martin Fowler S oftware is an odd medium in which Attributes and dictionaries to construct something. Because few Let’s say we want a person data structure. physical forces make you design one We can accomplish this by having specific way or another, many design deci- fields, as Figure 1 shows. Of course, to make sions sadly resist any form of objec- this work, we must define the variables in the tive analysis. Where design counts is person class. Like many modern languages, often not in how the software runs but in Ruby provides a dictionary data structure how easy it is to change. When how it runs (also knows as a map, associative array, or is important, ease of change can be the hash table). We could use Ruby instead to biggest factor in ensuring good performance. define the person class, using the approach in This drive toward change- Figure 2. (This is slower, but let’s assume this ability is why it’s so important section of code isn’t performance critical.) for a design to clearly show Using a dictionary is appealing because it what the program does—and lets you change what you store in the person how it does it. After all, it’s hard without changing the person class. If you to change something when you want to add a telephone number, you can do can’t see what it does. An inter- it without altering the original code. esting corollary of this is that Despite this, the dictionary doesn’t make it people often use specific designs easier to modify the code. If I’m trying to use because they are easy to change, the person structure, I can’t tell what is in it. but when they make the pro- To learn that someone’s storing the number of gram difficult to understand, the dependents, I must review the entire system. If effect is the reverse of what was intended. the number of dependents is declared in the class Person attr_accessor :lastName, :firstName, :numberOfDependents end def frag1 martin = Person.new martin.firstName = “Martin” martin.lastName = “Fowler” martin.numberOfDependents = 1 print (martin.firstName, “ “, martin.lastName, “ has “, martin.numberOfDependents, “ dependents”) Figure 1. Explicit end fields (using Ruby). 10 IEEE SOFTWARE November/December 2001 0740-7459/01/$10.00 © 2001 IEEE Figure 2. Dictionary fields (using Ruby). class Person attr_accessor :data def initialize() @data = {} class, then I only have to look in the end person class to see what it supports. end The key principle is that explicit code is easier to understand—which def frag2 makes the code easier to modify. As martin = Person.new Kent Beck puts is, the explicit code is martin.data[“firstName”] = “Martin” intention revealing. martin.data[“lastName”] = “Fowler” This dictionary example is small martin.data[“numberOfDependents”] = 1 in scale, but the principle holds at al- print (martin.data[“firstName”],“ “, most every scale of software design. martin.data[“lastName”], “ has “, martin.data[“numberOfDependents”], Events and explicit calls “ dependents”) Here’s another example, on a end slightly bigger scale. Many platforms support the notion of events to com- municate between modules. Say we have a reservation module that, when events that affect a reservation, and any the reservation class to get something canceled, needs to get a person mod- object that wants to do anything when else to happen when you cancel a reser- ule to send email to that person. an event occurs can build a handler to vation. As long as other objects put We can do this using an event, as Fig- react when it occurs. This approach is handlers on the event, it’s easy to extend ure 3 shows. We can define interesting appealing because you need not modify the behavior at these points. public delegate void ReservationHandler (IReservation source); public class Reservation ... public String Id; public event ReservationHandler Cancelled; public Person client { get { return client; } set { value.AddReservation(this); } } public void Cancel(){ Cancelled (this); } public class Person ... public String EmailAddress; public readonly ArrayList reservations; public void SendCancellationMessage(Reservation arg) { // send a message } public void AddReservation(Reservation arg) { //invoke SendCancellationMessage when the cancelled event occurs on arg arg.Cancelled += new ReservationHandler(SendCancellationMessage); } Figure 3. Cancellation using events (using C#). November/December 2001 IEEE SOFTWARE 11 DESIGN However, there is a cost to using that it’s hard to determine what the dency from the class triggering the events—I can’t see what happens at program does when you call a event to the one that needs to react. cancellation by reading the code in the method. This becomes particularly This lack of a dependency is valuable cancellation method. To find out what awkward when you’re debugging, when the two classes are in different happens, I have to search for all the because behavior pops up suddenly packages and you don’t want to add code that has a handler for the event. in places you don’t expect. a dependency. The class case of this is The explicit code for this (see Figure 4) I’m not saying that you shouldn’t when you want to modify a window clearly shows in the cancel method the use events. They let you carry out be- in a presentation when some domain consequences of cancellation, at the havior without changing a class, object changes. Events let you do this cost of modifying the reservation class which makes them useful when while preserving the vital separation when I need to change the behavior. working with library classes you of the presentation and domain. I’ve seen a few code examples that can’t modify. They are also valuable Those forces both suggest events, use events heavily, and the problem is because they don’t create a depen- but in their absence, the lack of explic- itness of events becomes more domi- nant. So, I would be reluctant to use events between two application classes that can be aware of each other. As you can see, explicitness is not always the dominant force in design decisions. In this example, packaging and dependency forces are also im- portant. People often underestimate the value of explicitness. There are times when I would add a dependency to make code more explicit, but, as al- ways with design, each situation has its own trade-offs to consider. Data-driven code and explicit subclasses My final example is on yet a bigger scale. Consider a discounting scheme for orders that uses different discount- ing plans. The blue plan gives you a fixed discount of 150 if you buy goods from a particular group of sup- pliers and the value of your order is over a certain threshold. The red plan gives you a 10 percent discount when delivering to certain US states. Figure 5 presents explicit code for this. The order has a discounter with specific subclasses for the blue and red cases. The data-driven version in Figure 6 uses a generic discounter that is set up with data when the or- der is created. The generic discounter’s advantage is that you can create new kinds of dis- counters without making new classes by writing code—if the new classes fit in with the generic behavior. For the sake of argument, let’s assume they can. Is the generic case always the best choice? No, again because of explicit- ness. The explicit subclasses are easier to read and they make it easier to Figure 4. An explicit reaction to cancel (using C#). public class Reservation ... public String Id; public Person client; public void Cancel(){ client.SendCancellationMessage(this); } Figure 5. Explicitly programmed discount logic (using C#). public class Order ... public Decimal BaseAmount; public String Supplier; public String DeliveryState; public Discounter Discounter; public virtual Decimal Discount { get { return Discounter.Value(this); } } } abstract public class Discounter { abstract public Decimal Value (Order order); } public class BlueDiscounter : Discounter { public readonly IList DiscountedSuppliers = new ArrayList(); public Decimal Threshold = 500m; public void AddDiscountedSupplier(String arg) { DiscountedSuppliers.Add(arg); } public override Decimal Value (Order order) { return (DiscountApplies(order)) ? 150 : 0; } private Boolean DiscountApplies(Order order) { return DiscountedSuppliers.Contains(order.Supplier) && (order.BaseAmount > Threshold); } } public class RedDiscounter : Discounter { public readonly IList DiscountedStates = new ArrayList(); public void AddDiscountedState (String arg) { DiscountedStates.Add(arg); } public override Decimal Value (Order order) { return (DiscountedStates.Contains(order.DeliveryState)) ? order.BaseAmount * 0.1m : 0; } } // to set up a blue order BlueDiscounter bluePlan = new BlueDiscounter(); bluePlan.AddDiscountedSupplier(“ieee”); blue = new Order(); blue.Discounter = bluePlan; blue.BaseAmount = 500; blue.Supplier = “ieee”; November/December 2001 IEEE SOFTWARE 13 DESIGN public class GenericOrder : Order ... public Discounter Discounter; public override Decimal Discount { get { return Discounter.Value(this); } } public enum DiscountType {constant, proportional}; public class Discounter ... public DiscountType Type; public IList DiscountedValues; public String PropertyNameForInclude; public String PropertyNameForCompare; public Decimal CompareThreshold; public Decimal Amount; public Decimal Value(GenericOrder order) { if (ShouldApplyDiscount(order)) { if (Type == DiscountType.constant) return Amount; if (Type == DiscountType.proportional) return Amount * order.BaseAmount; throw new Exception (“Unreachable Code reached”); } else return 0; } private Boolean ShouldApplyDiscount(Order order) { return PassesContainTest(order) && PassesCompareTest(order); } private Boolean PassesContainTest(Order order) { return DiscountedValues.Contains (GetPropertyValue(order, PropertyNameForInclude)); } private Boolean PassesCompareTest(Order order){ if (PropertyNameForCompare == null) return true; else { Decimal compareValue = (Decimal) GetPropertyValue(order, PropertyNameForCom- pare); return compareValue > CompareThreshold; } } private Object GetPropertyValue (Order order, String propertyName) { FieldInfo fi = typeof(Order).GetField(propertyName); if (fi == null) throw new Exception(“unable to find field for “ + property- Name); return fi.GetValue(order); } } Figure 6. Data-programmed discount logic (using C#). 14 IEEE SOFTWARE November/December 2001 DESIGN //to set up a blue order GenericDiscounter blueDiscounter = new GenericDiscounter(); String[] suppliers = {“ieee”}; blueDiscounter.DiscountedValues = suppliers; blueDiscounter.PropertyNameForInclude = “Supplier”; blueDiscounter.Amount = 150; blueDiscounter.PropertyNameForCompare = “BaseAmount”; blueDiscounter.CompareThreshold = 500m; blueDiscounter.Type = DiscountType.constant; blue = new Order(); blue.BaseAmount = 500; blue.Discounter = blueDiscounter; E understand the behavior. With the xplicitness is not an absolute in de- what makes good design have evolved generic case, you must look at the sign, but clever designs often be- (hopefully in the right direction). generic code and setup code, and it’s come hard to use because they harder to see what’s happening—and aren’t explicit enough. In some cases, even harder for more complicated bits the cost is worth it, but it’s always of behavior. Of course, we can extend something to consider. In the last few Martin Fowleris the chief scientist for ThoughtWorks, an the generic order without “program- years, I’ve tended to choose explicit de- Internet systems delivery and consulting company. Contact him ming,” but I’d argue that configuring signs more often because my views of at [email protected]. that data is a form of programming. Debugging and testing are often both difficult and overlooked with data-dri- ven behavior. The generic case works when you Boston University have dozens of discounters. In such cases, the volume of code becomes a problem, while greater volumes of If you have significant academic or industrial experience in developing large data are less problematic. Sometimes software systems and you are committed to improving the practice of software a well-chosen data-driven abstrac- engineering, we want to talk to you about a faculty appointment at Boston Uni- tion can make the logic collapse into versity in Computer Systems Engineering. Our graduate program teaches the a much smaller and easier-to-main- engineering skills necessary for the effective development of large-scale com- tain piece of code. puter systems in which software provides essential functionality. We teach stu- dents to apply engineering principles to the design of a full range of computer Ease of deploying new code is also a products from embedded systems, to data communication networks, to soft- factor. If you can easily add new sub- ware products. Three types of appointments are available in the Department of classes to an existing system, explicit Electrical and Computer Engineering (ECE) starting in September 2002: behavior works well. However, generic • Research oriented tenure-track and tenured appointments. behavior is a necessity if new code • Non-tenure track positions, which require extensive experience in practicing software engineering. means long and awkward compile and • Adjunct (part-time) positions for Boston-area experts who are interested in link cycles. teaching their specialty at the graduate level. There’s also the option of combin- All positions require a commitment to excellence in teaching at the undergrad- ing the two, using a data-driven uate and graduate levels. For additional information on the College of Engi- generic design for most of the cases neering and ECE Department visit the College’s homepage at http://www.bu.edu/eng/. and explicit subclasses for a few hard To learn more about opportunities for a non-tenure track OR adjunct posi- cases. I like this approach because it tions, please e-mail: [email protected] and a faculty member will call to discuss keeps the generic design much sim- our opportunities. For tenure-track OR tenured appointments, send your Cur- pler, but the subclasses give you a lot riculum Vita to: Professor Bahaa E. A. Saleh, Chair, Department of Electrical and of flexibility when you need it. Computer Engineering, Boston University, 8 Saint Mary’s Street, Boston, MA 02215. November/December 2001 IEEE SOFTWARE 15 focus guest editor’s introduction Reports from the Field Using Extreme Programming and Other Experiences Wolfgang Strigel, Software Productivity Center earning from the successes and failures of others is a quick way to L learn and enlarge our horizon. Our own experience can only cover a narrow path though the wealth of existing knowledge. Last June, the IEEE Software Editorial Board decided to make more room for experience reports and give our readers a fo- an experience report, please refer to www. rum to share their own learning experiences computer.org/software/genres.htm for author with others. If you are interested in submitting guidelines. 0740-7459/01/$10.00 © 2001 IEEE November/December 2001 IEEE SOFTWARE 17

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.