📄 extremeadaexperiment.html
字号:
</PRE>==
<hr>
Regarding C and windows with variable references. I find that I can program in an extreme manner in C++ by leveraging the compiler. Writing code using undeclared methods and changing method and variable names deliberately to force errors on recompilation. A good IDE puts you at the point of the error, which is an area that you need to touch. I know it sounds trivial, but when I look over other people's shoulders, I often don't see this technique used deliberately in compiled languages. It is often as fast as a search if your dependencies are in order, and it does not break your rhythm. -- <a href="http://c2.com/cgi/wiki?MichaelFeathers">MichaelFeathers</a>
<p><em>Neat idea, Michael. It'd surely work in Java too. Next time someone holds a gun to my head and makes me work on one of those, I'll try it! --<a href="RonJeffries.html">RonJeffries</a></em>
<p><UL><li> Michael, can you explain this some more, perhaps giving a small example? I don't think I quite get it. -- <a href="http://c2.com/cgi/wiki?MarnixKlooster">MarnixKlooster</a>
</UL><hr>
One example would be removing all the "#includes" or "package" declarations from the start of a C/C++ or Java program, submit it to the compiler and put back in the packages it complains about. Another example would be to change the type of an instance variable from short to long, and <em>rename it</em> according to <a href="http://c2.com/cgi/wiki?HungarianNotation">HungarianNotation</a>, and recompile. All references to the old name will show up as compiler errors, and a good IDE will take you to the source code of each one in turn.
<p>Incidently, this is in contrast with the school of thought which says that your code should always compile correctly first time. That you shouldn't allow yourself to make mistakes, hoping that the compiler will catch them, because compilers don't catch all mistakes. Michael is suggesting we deliberately submit known bad code to the compiler so that it can help pin-point why it is bad.
<p>You can see there's an element of risk involved - perhaps a name clash, previously hidden by scoping rules, will emerge and make one instance of bad code compile after all. This could lead to a subtle bug, hard to find by reading the source. <em>"Machines increase the number of things we do without thinking,"</em>, which is always a mixed blessing.
<p><em>I do find that this technique amplifies the <a href="http://c2.com/cgi/wiki?MentalStateCalledFlow">MentalStateCalledFlow</a>. In that state, I find that I am thinking not only about where I am in the code, but where I will be after the next compile for the errors that I know will occur. I can make a strategic decision to work on something else once I see what the errors are, and even mark a place in code by typing gibberish in place and hitting F5 (compile in my IDE) again. The goal is EconomyOfMotion<a href="http://c2.com/cgi/wiki?edit=EconomyOfMotion">?</a>. Less mental state is spent on moving to the search command and more is spent on thinking several moves in advance. It helps to have a well threaded IDE which allows you to call up and edit while the compilation is in the background. In lieu of that, if the compile takes more than three seconds, you have a moment to reflect while you know that the compiler is doing tedious work that is nonetheless profitable. So, it does replace some thinking, but it allows time for other thinking. In a sense, this is <a href="PairProgramming.html">PairProgramming</a> with the computer. Sometimes juggling six eggs is easier than juggling three.</em>
<p><em>That said, I do know that there are risks. I suspect that there is plenty to learn by coding next to someone. I'm eager to know whether anyone else codes this way, or whether this can be considered hazardous. I haven't encountered the name clash bug so far. -- <a href="http://c2.com/cgi/wiki?MichaelFeathers">MichaelFeathers</a></em>
<p>I tend to over-emphasis the risks. The <em>"WithoutThinking<a href="http://c2.com/cgi/wiki?edit=WithoutThinking">?</a>"</em> quote about the dangers of technology affected me profoundly when I first came across it, and I am rarely able to explain it to others well.
<p>The general idea of an environment that understands the subject matter at hand, and helps you navigate through it, is clearly valuable, and the compiler+IDE combination is an available first-draft. As we've described it, it works best (I think?) with statically typed languages - you wouldn't try it with Smalltalk. However, I this is directly analogous with some of the descriptions of working with the Smalltalk runtime, where the problem spots are found by executing rather than compiling. -- <a href="http://c2.com/cgi/wiki?DaveHarris">DaveHarris</a>
<p><DL><dt> <dd>I find this a surprising reaction. I have been following roughly the same techniques in my recent Java work that <a href="http://c2.com/cgi/wiki?MichaelFeathers">MichaelFeathers</a> describes (no multitasking, due to limitations of the environment). However, I got there from a different path -- I got my inspiration from the description of <a href="JustInTimeProgramming.html">JustInTimeProgramming</a>, which is a <em>Smalltalk</em> technique. -- <a href="http://c2.com/cgi/wiki?BillTrost">BillTrost</a>
<p></DL><em>It is worth saying that what I do with the compiler is a micro thing that is slightly analogous to what <a href="ExtremeProgramming.html">ExtremeProgramming</a> does with <a href="UnitTests.html">UnitTests</a> at a macro level. I use the compiler to eliminate one class of errors (message not understood) fast, as well as make other code transformations quickly. I'll agree that thinking about your code is a great thing, but I do notice that I have my best thoughts when some other part of my brain is otherwise occupied doing rote work that the compiler tells me to do. And being jump-started to look immediately at the ramifications of a change (in context) is, to me, a good thing. The immediacy of impact helps me form a good idea of the code in mental RAM (six eggs in the air). I'm reminded of studies I vaguely remember that linked productivity to short edit-compile-link cycles. Longer feedback loops keep less eggs in the air. Again, I'm perfectly willing to try sitting meditatively, drinking tea, and compiling only once every five minutes if it is discovered people produce less errors that way. How do you all work? (Those of you not doing pairs) How do your colleagues? The best programmers that you know? I'm very interested to see if I am on the wrong track so that I can jump if need be. -- <a href="http://c2.com/cgi/wiki?MichaelFeathers">MichaelFeathers</a></em>
<p><hr>
See <a href="http://c2.com/cgi/wiki?AskTheComputer">AskTheComputer</a> for more discussion of this idea. (Probably the whole thread should be moved there.)
<hr>
In response to the above question about applying YAGNI: An example of the flow of thinking would probably illustrate it.
<p>Because of difficulties in gaining access to standard libraries, I was forced to develop some basic data structures. I needed a dynamically-sized data container for keeping track of expected cutoff times of certain events. If the event isn't completed by its cutoff time, do some processing.
<p>I would need to be able to get the next most recent cutoff, and delay until that time. I would need to able to insert into the container and delete from the container.
<p>Ideally this would probably be implemented with a self-balancing tree using time to order it (this reduces the search time for insertions and deletions).
<p>What do I already have available? I have a generic prioritized queue package and a list package. I look at the prioritized queue package. I uses a enumeration for prioritizing. It would take a lot of work to make it handle a non-discrete type. I could easily use the list package to make a queue package with insertion based on a key. I choose this path. The package was named something like Prioritized_Queue. In my interface, I only provide visibility to the routines I need now (Insert, Delete, Top_Element_Of). Since this container will exist for the lifetime of the process, I don't even include a Dispose routine. In the interface I include a warning that this isn't efficient and should later be reimplemented.
<p>Thinking back, I broke the rule a little by making this package generic even though I had need for only one prioritized queue.
<p>I guess the important aspects were recognizing abstractly what I needed, mapping this to conventional programming concepts, and using existing building blocks to implement these concepts. YAGNI needs to be linked with mapping needs to software patterns to create simple, easily understood systems.
<p>I also tried to look at the reasonable needs of the container before starting to implement. I didn't want to choose an implementation which would poorly scale to my actual needs.
<p>Does this answer the question? --<a href="http://c2.com/cgi/wiki?WayneCarson">WayneCarson</a>
<hr>
Sounds like this was an admirable effort to do something lightweight. At the same time, I'm wondering what was wrong with an object containing an <a href="http://c2.com/cgi/wiki?OrderedCollection">OrderedCollection</a> or Vector of events with cutoff times, and a method answering all events with cutoff > timeT. What am I missing? --<a href="RonJeffries.html">RonJeffries</a><hr><a href="http://c2.com/cgi/wiki?edit=ExtremeAdaExperiment">EditText</a> of this page (last edited June 22, 1999)<br><a href="http://c2.com/cgi/wiki?FindPage&value=ExtremeAdaExperiment">FindPage</a> by browsing or searching<p><font color=gray size=-1>This page mirrored in <a href="index.html">ExtremeProgrammingRoadmap</a> as of March 31, 2001</font></body>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -