Slashdot Mirror


Unit Test Your Aspects

An anonymous reader writes "The widespread adoption of programmer testing over the past five years has been driven by the demonstrable productivity and quality of the resulting code. Find out why and how to do it, as this article introduces you to the benefits of testing aspect-oriented code and presents a catalog of patterns for testing crosscutting behavior in AspectJ."

130 comments

  1. Unit Testing In The Schools... by __aaclcg7560 · · Score: 3, Insightful

    Why does it seem like unit testing is only taught in Java programming courses? I have never seen this in any C/C++, C# or Visual Basic courses.

    1. Re:Unit Testing In The Schools... by j-tull · · Score: 3, Insightful

      Unit testing, in my limited experience, isn't really taught in any programming course. Testing methodologies are typically taught in software engineering courses.

      My software engineering course was fairly language independent (though most students used C++ since that was the primary language taught at this particular institution). Testing, in general, is a language independent craft.

      I guess what I'm saying is that I disagree with your premise of unit testing only being taught in Java courses. I would guess that it's typically (but not always) taught in the same language as the given institution's introductory/intermediate programming classes.

    2. Re:Unit Testing In The Schools... by TrappedByMyself · · Score: 5, Insightful

      Why does it seem like unit testing is only taught in Java programming courses? I have never seen this in any C/C++, C# or Visual Basic courses.

      Blame it on JUnit. Since it provides a way to make unit testing easier, it's easier to get people to actually do it. When I was in school, we talked about unit testing, but never really did it very well. By employing the latest buzzwords such as JUnit and Spring in your design, it's much less work to build your unit tests that it would be with other languages.

      I also think, for better or worse, the the Java community is much more open to the latest toys than users of the other established languages are, which may explain why the XUnit variants in other languages haven't taken off as well.

      --

      Help me take back Slashdot. When did 'News for Nerds' become 'FUD and Conspiracy Theories for Extremist Nutjobs'?
    3. Re:Unit Testing In The Schools... by Anonymous Coward · · Score: 0

      Why does it seem like unit testing is only taught in Java programming courses?

      Testing is what end users & support centers are for....

    4. Re:Unit Testing In The Schools... by tcopeland · · Score: 4, Interesting

      Dr Stephen Edwards teaches about this in his classes. He's written an interesting paper "Using Software Testing to Move Students from Trial-and-Error to Reflection-In-Action" about his experiences with test driven design at VA Tech. You can see his home page here and that paper is the third one in the list.

      I've recently been working on a BlueJ extension for PMD and he's quite active on the bluej-discuss list.

    5. Re:Unit Testing In The Schools... by Anonymous Coward · · Score: 0

      because it is a waste of time. only peons worry about units and their subsequent testing.

    6. Re:Unit Testing In The Schools... by __aaclcg7560 · · Score: 1

      Unit testing, in my limited experience, isn't really taught in any programming course. Testing methodologies are typically taught in software engineering courses.

      I been taking courses at the local community college for the last five years on a part-time basis. Java is the only language course where the instructors stress that the input/output of functions should be tested/validated when designing the program. The other instructors either don't care much for the language they are teaching to emphasize this point or they expect the book to explain it. I think any programming class should teach unit testing.

      My professional experience is software testing. I see a lot of applications that throw an assertion error because the programmer didn't test for a negative or null value. It's the little things that throws the exceptions all the time.

    7. Re:Unit Testing In The Schools... by John+Betonschaar · · Score: 1

      Blame it on JUnit. Since it provides a way to make unit testing easier, it's easier to get people to actually do it.

      DUnit does exactly the same for Delphi, we are using it at my workplace together with a somewhat more advanced automated testing framework built around it. Works very nicely I have to admit, setting up test cases and collections takes only a few minutes for a new class. Throw in a test-driven XP development model and the result is a very dynamic and flexible development cycle, yet with a very high level of code quality and a significantly reduced number of 'obvious bugs' that manifested themselves every now and then before we starting using this approach.

      Still, I doubt there are many Delphi developers who work this way... They should, seriously...

      ---
      No sigs for you today

    8. Re:Unit Testing In The Schools... by Anonymous Coward · · Score: 0

      Interesting. I was taught Unit testing in C#.
      Although, I have never really been taught testing, it just comes up as a kind of seconds.

    9. Re:Unit Testing In The Schools... by misleb · · Score: 1

      Unit testing is also big in Ruby on Rails (no "courses" for that though). I think it is a matter of whether or not there is a proper framework for implenting tests. If there isn't a framework, I can imagine unit testing becoming more work to implement than it is worth.

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    10. Re:Unit Testing In The Schools... by ScottyH · · Score: 1

      Every computer science class involving programming that I've taken (at the University of Toronto) involves unit testing, regardless of the language used.

    11. Re:Unit Testing In The Schools... by TapeCutter · · Score: 1

      As the GP pointed out, unit testing has nothing to do with language, it is taught in software engineering. All language classes that I have attended (and taught) focus on the language itself. Teaching a programming language is similar to teaching algebra. It is not the correctness of the numerical answer that matters, it is how the student "worked out" the answer.

      I have also worked as a developer and system tester for over 15 years, primarily in C/C++, every single employer has demanded documented unit tests.

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    12. Re:Unit Testing In The Schools... by Coryoth · · Score: 2, Insightful

      Blame it on JUnit. Since it provides a way to make unit testing easier, it's easier to get people to actually do it. When I was in school, we talked about unit testing, but never really did it very well. By employing the latest buzzwords such as JUnit and Spring in your design, it's much less work to build your unit tests that it would be with other languages.

      At this point I'd like to point out the existence of JML, an annotation syntax and set of associated tools for Java that makes a lot of things easier and more convenient. JML allows you to do design by contract in Java and if you compile with the provided compiler jmlc it will automatically include runtime checks based on your pre and post conditions and invariants. Another tool, jmldoc, will generate JavaDoc documentation augmented with the extra specification your provided with JML annotations, making for much better documentation. You also have jmlunit which will automatically generate JUnit test classes based on your annotations.

      That means you get automatically generated unit tests, the constraints of which are automatically included in your documentation (as well as in the actual code as annotations) and the option to use those constraints as runtime checks for debugging purposes. That's an awful lot of cheap benefits just for writing annotations to your code as you go.

      General examples of using JML for DbC can be found here, and examples of jmlunit generating JUnit test classes can be found here.

      Jedidiah.

    13. Re:Unit Testing In The Schools... by Anonymous Coward · · Score: 0

      I've used CPPUnit, and let me tell you, it's an overdesigned piece of crap. It doesn't even catch/report segmentation faults -- I had to implement that myself. The CPPUnit design itself is unnecessarily complicated. To anyone in danger of using CPPUnit, please let me tell you, "DON'T DO IT! IT'S NOT WORTH IT!"

    14. Re:Unit Testing In The Schools... by Thuktun · · Score: 1

      Blame it on JUnit. Since it provides a way to make unit testing easier, it's easier to get people to actually do it.

      Don't forget NUnit, which allows JUnit-style unit tests to be constructed for .NET applications. I have no idea how many .NET developers actually use it, though.

    15. Re:Unit Testing In The Schools... by andyabides · · Score: 1

      Apple's built some nice Objective-C unit testing functionality into recent versions of Xcode.

    16. Re:Unit Testing In The Schools... by zootm · · Score: 1

      If it helps with your numbers, my company uses it (along with NMock — whose site appears to be down, ironically because of a problem with Java — for isolation) for all .NET projects.

      I love how they've used attributes in the implementation, makes things very easy. The Java (1.)5.0 implementation of JUnit uses this approach too, I believe.

    17. Re:Unit Testing In The Schools... by DeafByBeheading · · Score: 1

      My team is using it in a software engineering class project at Cal. It's incredibly straightforward and well put together.

      --
      Telltale Games: Bone, Sam and Max
    18. Re:Unit Testing In The Schools... by timcrews · · Score: 2, Informative

      I don't know anything about the teaching side, but the JUnit framework has an equivalent C++ version, known as CppUnit. See http://cppunit.sourceforge.net/cppunit-wiki/FrontP age for details. NUnit has also been noted elsewhere as a .NET alternative.

    19. Re:Unit Testing In The Schools... by Anonymous Coward · · Score: 0

      It's getting there. The hardest problem is the fact that it's such a pain in the ass to get unit tests around existing code. There's a book out there that deals with that problem: http://www.amazon.com/exec/obidos/tg/detail/-/0131 177052/ It shows you how to get tests around the nastiest code using NUnit, JUnit, and CppUnit.

    20. Re:Unit Testing In The Schools... by JSR+$FDED · · Score: 2, Informative

      Actually, take a look at TestNG if you want to get a sense of where testing in Java is headed (and I mean testing, not just "unit testing", which is just a subset).

    21. Re:Unit Testing In The Schools... by master_p · · Score: 1

      It's not JUnit, it is because Java has garbage collection. JUnit is actually very easy to do in C++; after all, JUnit is a bunch of base classes that are extended and instantiated.

      Writing a test for an algorithm takes x4 the effort for the algorithm itself. Having garbage collection on board makes writing the test much easier than when not having garbage collection.

      The mental effort required to write code with manual memory management is tremendous. Imagine this effort quadrupled for writing the test, and you can see why there is no unit testing for C++ projects.

    22. Re:Unit Testing In The Schools... by StrawberryFrog · · Score: 1

      I've done unit testing in Delphiu (DUnit) and C# (NUnit). Unit testing is not a language thing, it's a good idea across the board.

      The schools will catch up soon enough.

      --

      My Karma: ran over your Dogma
      StrawberryFrog

    23. Re:Unit Testing In The Schools... by dzfoo · · Score: 2, Funny

      >> http://frayspace.com/toomuchtv/isntthatgood/merryf unday.html

      Simple reason:

      C/C++ programmers: It works, dammit! We don't need no stinkin' testing.

      C# programmers: The compiler would warn or fail if it didn't work; if anything goes wrong in production, we'll patch it in the next release.

      Visual Basic programmers: Uh... testing? wuzzat?

                -dZ.

      --
      Carol vs. Ghost
      ...Can you save Christmas?
    24. Re:Unit Testing In The Schools... by $RANDOMLUSER · · Score: 1
      > ...it is because Java has garbage collection...

      That's a really interesting point. My first reaction to the question was to say that Java lets you write code faster, not so much re-inventing the wheel; that the richness of available library functions allows the test writer that much more speed and flexibility. But I think you've actually hit on the real reason that test frameworks for C++ are so difficult, and so unreliable. Since most of the bad (that is non-obvious) C++ bugs tend to be memory related, Java wins because it has garbage collection - and doesn't have pointers.

      --
      No folly is more costly than the folly of intolerant idealism. - Winston Churchill
    25. Re:Unit Testing In The Schools... by Trejkaz · · Score: 1

      Thing is, there is an implementation of XUnit in rather a lot of languages, including C and C++.

      --
      Karma: It's all a bunch of tree-huggin' hippy crap!
  2. Is this statement a joke? by tjstork · · Score: 1

    The widespread adoption of programmer testing over the past five years has been driven by the demonstrable productivity and quality of the resulting code

    The quality of software has been continually declining for the last decade, I think. If anything, we're just better at teaching users to avoid things that don't work.

    --
    This is my sig.
    1. Re:Is this statement a joke? by TrappedByMyself · · Score: 1

      The quality of software has been continually declining for the last decade, I think.

      Software Engineering is making leaps and bounds, so there are many tools available for writing good software. The people who really know what they are doing have more at their disposal. However, more than ever, there are a very large number of incompetent developers out there. It's much easier to get into programming now than it was in the machine language/assembly/C days because things are much easier to use, and the tools are much more accessible. Combine that with the .com influx of bozos and you have alot of people spewing out crap code.

      --

      Help me take back Slashdot. When did 'News for Nerds' become 'FUD and Conspiracy Theories for Extremist Nutjobs'?
    2. Re:Is this statement a joke? by sedyn · · Score: 2, Insightful

      "Software Engineering is making leaps and bounds"
      "However, more than ever, there are a very large number of incompetent developers out there."

      Do you think that these statements are related in any way? I mean, using software evaluation / developmentation method X seems to be the equivilant of having a safety net. And there's definately a lot of developers out there that need one.

      --
      Am I open minded towards open source, or closed minded towards closed source?
    3. Re:Is this statement a joke? by Anonymous Coward · · Score: 0
      The quality of software has been continually declining for the last decade, I think.

      Not that that assertion can't be true, but do you have anything resembling an objective fact to support it?

      In any case, the original claim was that tested code is demonstrably better than "Worship me, I am Hacker!" code, which is different from your point, anyway.

    4. Re:Is this statement a joke? by hswerdfe · · Score: 1

      so...win 95 was more stable then win XP?
      Gnome 0.1 (98 ish) was more stable then 2.12?
      Web pages worked better in Netscape 1.2 then they do in Firefox 1.1?

      The Standard File sytem back then was like Fat32. dude NTFS, ext3, RieserFS are all much better then what was avalible.

      I think you really need to go back an look at the Apps you were using in 95 dude.
      before, posting flame bait like this.

      p.s. you sir are a WANKER!

      --
      --meh--
    5. Re:Is this statement a joke? by mcrbids · · Score: 2, Interesting

      Software Engineering is making leaps and bounds, so there are many tools available for writing good software. The people who really know what they are doing have more at their disposal. However, more than ever, there are a very large number of incompetent developers out there. It's much easier to get into programming now than it was in the machine language/assembly/C days because things are much easier to use, and the tools are much more accessible. Combine that with the .com influx of bozos and you have alot of people spewing out crap code.

      Reminds me of a study done on Taxi cabs in San Fransisco shortly after ABS (Antilock Braking Systems) came out. As expected, the accident rate for those with ABS was quite a bit lower than those without ABS. But the surprise was that the death toll was about the same either way!

      Seems that those with ABS tended to offset the benefits of ABS simply by driving harder, pushing themselves closer to the line for safety as a result of the certainty that they achieved with ABS.

      In other words, people tend to identify "acceptable risk" and when the level of risk reduces, people then engage in riskier behavior in order to gain an advantage. This is not a bad thing - utilizing an advantage is an important part of survival in a "survival of the fittest" universe.

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
  3. hmph by Dominatus · · Score: 3, Funny

    My unit requires no futher testing, thank you very much!

    1. Re:hmph by sgt_doom · · Score: 1

      I find the majority of women to be attractive, therefore most women can test my unit......

    2. Re:hmph by slackmaster2000 · · Score: 2, Funny

      I try to test my unit at least twice a day. So far no problems have been found, knock on wood (pun!).

    3. Re:hmph by Anonymous Coward · · Score: 0

      In which Utopia do you live? It has been my experience over many years of survey, that it is indeed the minority of women who are attractive. Said on the bases of unit testing suitability only :)

  4. I unit test all the programmers I hire... by Anonymous Coward · · Score: 2, Funny

    ...but discard most of them due to faulty design.

      I do inquire if they have any siblings that may be been properly engineered.

    1. Re:I unit test all the programmers I hire... by Anonymous Coward · · Score: 0

      I read this immediately before your comment, and I think I got the wrong idea... At least I hope I did.

  5. Programmer testing? by richmaine · · Score: 1, Informative

    The widespread adoption of English over the past 5 years has been driven by the demonstrable productivity and quality of projects where it has been used to communicate instead of just to write meaningless words. :-)

    Programmer testing? That means testing programmers, as in certifying them? Apparently not.

    From the article, it is clear that they are referring more to testing of programs. Of course, then one might wonder who would think that nobody ever tested any programs prior to 5 years ago.

    Reading a bit more carefully, it appears to really mean testing of programs using a particular testing paradigm.

    I am quite serious in my observation that clearly written documentation is a huge benefit in getting programs to actually work. Clearly and accurately documenting what the program is supposed to do is a huge first step. For example, program documentation needs to be a whole lot more clearly written than the subject article.

    1. Re:Programmer testing? by adrianmonk · · Score: 5, Interesting
      Programmer testing? That means testing programmers, as in certifying them? Apparently not.

      From the context, it seemed pretty obvious to me that "programmer testing" means testing that is performed by programmers, as opposed to by a separate part of the development team that specializes in testing.

      Having the programmer do some of the testing of his/her own code makes sense to me for several reasons:

      1. Coverage. The programmer has a more intimate knowledge of the code and thus has better insight into ways it can fail than people who are looking at the code as a black box, which is basically what testers do. For example, if the programmer knows the code uses his own implementation of a hash, he knows to think about adding a test where the input data has two strings that have the same hash value to see if it properly handles collisions.
      2. Testing efficiency. Because the programmer knows what the code is supposed to do, what the contracts are between classes and their clients, etc., etc., it's easier for the programmer to construct certain tests than for another person to learn these things and then create the tests. (Although on the other hand, the second pair of eyes might find things that the programmer didn't think of.)
      3. Development cycle efficiency. If a programmer does the tests as he's developing things, he will discover bugs much sooner than if someone else is doing them. Perhaps days sooner. In general, the sooner bugs are discovered, the better, for several reasons. One is that code is easier to fix when it's still fresh in your mind. Another is that bugs may indicate a design flaw that will need to be corrected and may affect interfaces and thus require changes to client code (which may be written by other developers), and that creates overhead. Also, it means development versions of the software will be more stable and easier to work with (fewer crash scenarios to avoid when demoing to the boss, checking out if it's as usable as you thought, etc.)
      4. Tracking overhead. If the programmer fixes bugs while still in the process of developing things, then he is the only one who has to know about the bug. Which means it doesn't have to go into a bug database, nobody has to spend 5 minutes discussing it in a meeting, etc.
      5. Finding the source. If the programmer does the testing, it's much easier to trace that back to the source of the problem than if the tester just notices that the software fails in a certain scenario. It takes work to go from a scenario to the point where you know whose code fails (and thus who should fix it).

      I'm sure there are other reasons, but the point is this: in many cases, increasing the amount of testing that the programmer can do is advantageous. (At least up to a point -- you need a second pair of eyes, and you need someone who tests how all the modules interact to see if the system as a whole works as expected.) But still, finding ways to make it possible and to make it easy for programmers to add more tests and better tests is usually a good thing.

    2. Re:Programmer testing? by zootm · · Score: 1

      Clearly and accurately documenting what the program is supposed to do is a huge first step.

      Agreed, but I find that a lot of the time, particularly when working on projects where the requirements can change, unit testing provides a kind of documentation in itself. Even if the programmer has been too lazy to update the documentation for a method, the test itself must have been updated, so the functionality — provided that the tests have sufficient coverage — is described in the expectations of these tests.

    3. Re:Programmer testing? by TapeCutter · · Score: 1

      English: The "other" code.

      --
      And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
    4. Re:Programmer testing? by godglike · · Score: 1

      I have to take issue with this.

      A clearly written and exhaustive SPECIFICATION is the best and only thing required for a successful program. Documentation, architecture, user manuals, and testing all derive directly from the SPECIFICATION.

      Really, it works. Focus your effort on hammering out the speciification and you'll be amazed how easy the rest of the job is.

      As for JUnit: I've never tried it, is it fattening?

    5. Re:Programmer testing? by Anonymous Coward · · Score: 0
      I agree with much of what you're saying, but I do have some comments on each item, mostly from the perspective of testing a new feature or piece of functionality. Testing bug fixes is a little bit different, as you're not always testing a whole new block of code.

      1. Coverage: Ideally, both the developer and the QA tester will have roughly equivalent knowledge of the code, as the developer will have included the QA tester in the code review process and so the developer will have taught the QA tester what they intended the code to do.
      2. Testing efficiency: Positive testing, testing that what should work does work, is very important. Even more important, IMO, is negative testing. Users, especially those who don't have a lot of experience with a piece of software, are more likely to use things the wrong way than to use them the right way. In my experience, sometimes developers are so focused on making sure that the functionality works correctly that their testing is focused more heavily on the positive than the negative side.
      3. Development cycle efficiency: While the developer is working on the specification for the new feature, the QA tester should ideally be working on a test plan for the new feature. When the developer is implementing the feature, the QA tester should be implementing the tests. Then you bring the feature and its test together, and if there's a disconnect between the two the developer and QA work together to figure out what's not conforming to the spec.
      4. Tracking overhead: True, it's better if only one person needs to know about a bug, but having two people know about the bug doesn't introduce that much overhead.
      5. Finding the source: If you have a test that fails, you run through that test one piece at a time, and make sure that each line gives you the results you expect. If a line does something unexpected, that line (or something upon which that line depends) is the source of the problem.

        Developer testing is good. QA testing is good. Having both the developer and QA work together to test is better.
  6. Less time for proper testing by Barkley44 · · Score: 5, Interesting

    As important as testing is, many clients (at least the ones I've dealt with) are willing to place testing on the back burner in turn for more output for the same amount of money. If code works right 95% of the time on the first try, that is a sacrifice they are willing to make. Obviously the more critical the product, the more testing is required.

    --
    KeepTrackOfIt.com - Find the lowest gas prices in your area graphically
    1. Re:Less time for proper testing by TrappedByMyself · · Score: 1

      As important as testing is, many clients (at least the ones I've dealt with) are willing to place testing on the back burner in turn for more output for the same amount of money. If code works right 95% of the time on the first try, that is a sacrifice they are willing to make. Obviously the more critical the product, the more testing is required.

      Yeah, but what is proper testing? Nowadays, really good testing needs to be an ongoing part of the development process. Everything the client sees, even the first demo, should have gone through an organized series of tests. Unfortunately, when a client, and even sometimes managers or any other non-techie, really, sees something doing something, they think those features are 'done'. Developers cannot let themselves be caught in that trap, so they need to test as they go.

      --

      Help me take back Slashdot. When did 'News for Nerds' become 'FUD and Conspiracy Theories for Extremist Nutjobs'?
    2. Re:Less time for proper testing by DoctorPepper · · Score: 1

      I agree. I currently working as a developer for a very large corporation, programming and maintaining life insurance applications, but I don't really "know the business" very well. I receive specs from the clients on what they want and we do our software design based on their specs. The clients review the software designs (called BSD's where I work), but sometimes I don't think they really pay attention to what they are reading.

      Since I don't have a life-time of experience working with insurance (only the past 4 1/2 years), I rely on them and the corporate Actuaries to keep me on track. The only testing I can really perform is just making sure my programs work as per my design docs. Whether or not they actually perform per the client specs is up to them.

      No matter what, there will always have to be interaction between the programmers and their clients, to ensure the resultant software meets everyone's expectations.

      --

      No matter where you go... there you are.
    3. Re:Less time for proper testing by Barkley44 · · Score: 2, Insightful

      Oh I agree - I'm refering to documented, structered testing by a third party. Even though developers can test it, it is more effective to get someone not in the development process to do the testing. You know, that one case you never thought about, no way a user would do XYZ ;) These are the cases where clients are willing to pass on since the budget doesn't allow for it. If they have $1000 to spend, they want as much physical code as possible. Spend $900 on dev, $100 on testing (as in work is done, test and fix bugs). The other option is $500 on dev, $100 on my own testing and $400 on a third party. I personally will do either, but the clients I've worked for always opt for the first option.

      --
      KeepTrackOfIt.com - Find the lowest gas prices in your area graphically
    4. Re:Less time for proper testing by DoctorPepper · · Score: 1

      I meant "I'm currently working as a developer".

      You know, no matter how many times I hit that stupid "Preview" button, I invariably miss something! :-( Perhaps my /. posts need more client review?

      --

      No matter where you go... there you are.
    5. Re:Less time for proper testing by misleb · · Score: 2, Insightful

      Testing, in this case, is a little different than what you are referring to. I dunno about AspectJ, but with Ruby on Rails you basically program in a bunch of use cases and mock data manipulations and run it with a "make" file. Any time you make significant (or not so significant) changes to the code, you can run your tests and make sure it all works.

      And if you really want to get serious about tests, there is technique where you program the tests BEFORE you implement the code. You just keep running the tests until they don't fail and you know you are done (well, almost). It is called test driven development. From that I understand, it saves a good deal of time that would otherwise be spent clicking through an application to see if it works.

      Personally, I haven't been able to get into it too deeply. Writing new tests from scratch in a project for which you've already written a big chunk code is daunting and tedious, IMO. You literally have to go step by step through the program and simulate every forseeable use case. I did write some tests and I can see the benefit. I tested what I thought was some rather simple code and found bugs right away. Bugs that might not have been obvious by simply clicking through the application. Also, writing such tests can give you ideas for features that you might not have thought of before.

      At this point, I think it is more an issue of discipline than man hours. If I could just get myself to spend a whole day getting tests written, I believe I would save myself far more than that in debugging and traditional testing. And I would feel much more confident about my finished product.

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    6. Re:Less time for proper testing by alucinor · · Score: 1

      I'm in healthcare IT, and needless to say, we test the daylights out of our code.

      --
      random underscore blankspace at ya know hoo dot comedy.
    7. Re:Less time for proper testing by dubl-u · · Score: 3, Informative

      If code works right 95% of the time on the first try, that is a sacrifice they are willing to make.

      That may be a possible choice with traditional QA testing (which you do right at the end), but that's not the notion with unit testing. I don't write tests to increase quality as such; I write them to increase my development speed. If the code usually works, I spend very little time debugging. When I do make mistakes, the test coverage means I generally find out right away about bugs, so the problems are easy to find. And when I'm doing new work, the existing suite reminds me of all the little details that went into the existing code base, meaning I have to spend a lot less time on design archeology before ading new features.

      I don't do test-driven development just for better quality. I do it because it helps me go faster, and with less stress to boot.

    8. Re:Less time for proper testing by Ramses0 · · Score: 1

      My (personal) experience is that doing testing while development is ongoing adds ~10-20% more time (not including find-fix for either tested or non-tested dev. methodologies).

      When you add a find-fix cycle to either one (ie: prior to shipping to a customer), times can increase quite dramatically.

      I would further state (in my experience) that find-fix cycles on code that does not have automated, repeatable tests (be they integration or unit) ... the find fix cycles are larger and can cause more "trauma" if you have separate "finders" v. "fixers" (aka: QA v. Dev).

      For example, consider the following histograms of time:

      No Tests:

      0123456789

      Automated Tests (30% longer):

      0123456789ABC

      Including Find/Fix @ 4 points, no tests:

      0123456789/FFFF

      Including Find/Fix @ 2 points, automated tests:

      0123456789ABC/FF

      ...These numbers are personal experience and could be way off, but it's interesting to map what's happening on the Automated Tests' "ABC" points. You're still developing, while "find/fix" is ongoing in the second no-test scenario... but my question is: Can you reliably release to your customer during the "FFFF" time-period with no tests? What about releasing to your customer during the "FF" time-period with automated tests?

      Assuming that it's "easier to add a feature to code that has automated tests", let's add another feature to both...

      Another feature, no tests @ 4 points:

      0123456789/FFFF/FFFF

      Another feature, automated tests @ 2 points:

      0123456789ABC/FF/FF

      ...these are personal experiences, and make some assumptions, but I'd like to hear feedback from people who also have experience with automated testing (JUnit / NUnit, etc...) I think my numbers are right, but I'm interested in other perspectives too.

      --Robert

    9. Re:Less time for proper testing by Q2Serpent · · Score: 2, Interesting

      A good idea to get you started would be to write testcases for the problems you debug and solve manually. This has a few benefits:

      - You are now familiar with the functionality of that piece of code, so writing a test should be easy.

      - Having a test ensures that no future code changes will cause the same bug (it is very embarassing to re-introduce a fixed bug).

      - Having a test also ensures that other code changes don't affect anything related to this functionality working. This can also help uncover unnecessary coupling - when this testcase fails in the future because something seemingly unrelated changed, you can investigate what is really going on because you will be alerted to it much sooner.

    10. Re:Less time for proper testing by Anonymous Coward · · Score: 0

      "I'm in healthcare IT, and needless to say, we test the daylights out of our code."

      So... you work on 'darknets', then?

      *** rimshot ***

    11. Re:Less time for proper testing by stg · · Score: 3, Informative
      Personally, I haven't been able to get into it too deeply. Writing new tests from scratch in a project for which you've already written a big chunk code is daunting and tedious, IMO. You literally have to go step by step through the program and simulate every forseeable use case. I did write some tests and I can see the benefit. I tested what I thought was some rather simple code and found bugs right away. Bugs that might not have been obvious by simply clicking through the application. Also, writing such tests can give you ideas for features that you might not have thought of before.


      A great book on the topic of adding tests to old code is Working Effectively with Legacy Code. There are a lot of techniques there that I've found very helpful while refactoring projects done before I started using automated tests (in my case, using DUnit).

      Writing tests really helps reducing excessive coupling in your code, too. If you need to use and initialize a lot of classes for a simple test, it's usually a sign that they are a bit too dependent.

    12. Re:Less time for proper testing by cerberusss · · Score: 1
      Yeah, you spend weeks on security only to find out that GPs get an ADSL line and put all sorts of data on the mail.

      Keep testing!

      --
      8 of 13 people found this answer helpful. Did you?
  7. Ironic by snevig · · Score: 5, Funny

    There's a javascript error in the article. Line 8, Char 76: Unterminated string constant

  8. QUITE INTERESTING. by Anonymous Coward · · Score: 0

    I also liked this gem:

    "This oft-overlooked distinction is crucial. Freedom is being able to make decisions that affect mainly you. Power is being able to make decisions that affect others more than you. If we confuse power with freedom, we will fail to uphold real freedom."

    This leads us to a conundrum:

    Information is power. Information wants to be free. Therefore, freedom is power. But according to GNU, freedom is not power.

    Kidding aside, I don't really agree with GNU. I mean, if you license your software under the GPL are you not asserting your power over other developers to abide by that license? Whatever license you choose, others must follow it; so in terms of affecting more people or only yourself I fail to see the relevance of the license you choose. If you want real freedom, shouldn't you put your source in the public domain? Having no license makes the software available to everybody and restricts nobody. The only difference is that people are not forced to contribute back. And isn't forcing people to contribute back asserting power over them?

    Now I will sit and wait for some "intellectual" to explain how I have confused things and am incapable of understanding and properly interpreting the GPL, which apparently is the only license that software developers should choose.

    1. Re:QUITE INTERESTING. by Anonymous Coward · · Score: 0

      "Now I will sit and wait for some "intellectual" to explain how I have confused things"

      Hope you didn't have to wait too long.

      The freedom in FOSS software is freedom for software users, not freedom for developers.

      Now piss off and troll somewhere else.

  9. How to always get your post on developers.slashdot by hexghost · · Score: 1, Funny

    1. Find an article on a development-oriented site. Possible sites include: www.ibm.com/developerworks, www.macdevcenter.com, devx.com, and persiankitty.com.
    2. Pick a recent article on your chosen site.
    3. Paraphrase the article in a few sentences, or if thats too difficult, just cut and paste the first few sentences of the article.
    4. Post your paraphrase/cut and paste, along with a link to the article, to slashdot.
    5. Bask in the glory as people attribute your ability to find an article with actually knowing what the article is talking about.

  10. Thank God for the 2000 tech crash! by xxxJonBoyxxx · · Score: 1
    The widespread adoption of programmer testing over the past five years..."

    Thank God for the 2000 tech crash! Any programmer who doesn't do some amount of their own testing is a moron. I think the lack of testing is a leftover from the time when English majors were getting dev jobs at dot-coms...

    1. Re:Thank God for the 2000 tech crash! by shmlco · · Score: 2, Funny

      I actually had a degreed developer tell me, with a straight face, that he didn't do testing, as his professor told him it's the job of the QA department...

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
  11. For .Net Developers... by jferris · · Score: 4, Informative
    ..take a look at NUnit, if you haven't already:

    http://www.nunit.org/

    Then, read Marc Clifton's series on Advanced Unit Testing in C#. The code is easily ported to VB.Net, as well, although not required. I am working on introducing the practices outlined in the article where I am currently employed.

    http://www.codeproject.com/csharp/autp1.asp
    http://www.codeproject.com/csharp/autp2.asp
    http://www.codeproject.com/csharp/autp3.asp
    http://www.codeproject.com/csharp/autp4.asp

    As if CodeProject wasn't slow enough. The readthroughs on this post should bring it to its knees in no time at all. If you have a chance, look at some of Marc's other postings, as well. Very high quality stuff.

    In regards to Unit Testing in general, I don't know why it isn't given more weight in college coursework. Honestly, it would make a great course, or series of courses. I've been out of school for just a wee bit though, so maybe some are offering it already. ;-)

    --
    You are in a maze of little twisting passages, all different.
    1. Re:For .Net Developers... by jlarocco · · Score: 1

      This is slightly offtopic, but does anyone know of a site similar to codeproject.com that's less Windows specific or more Linux specific? Code Project has a lot of useful code and interesting articles, but even the OpenGL and Java Programming sections are mostly Windows specific, so they're less useful than they could be. So far the closest I've found is Artima.com.

  12. Aspect-oriented? by jshaped · · Score: 3, Interesting

    ok, I'll take the hit and be the first.

    wtf is Aspect-oriented programming?
    how does it relate to object-oriented programming?

    1. Re:Aspect-oriented? by Trevahaha · · Score: 5, Informative

      From Wikipedia:

      In software engineering, the programming paradigm of aspect-oriented programming (AOP), also called aspect-oriented software development (AOSD), attempts to aid programmers in the separation of concerns, or the breaking down of a program into distinct parts that overlap in functionality as little as possible. In particular, AOP focuses on the modularization and encapsulation of cross-cutting concerns.

    2. Re:Aspect-oriented? by Peter+La+Casse · · Score: 5, Interesting
      The basic idea behind aspect-oriented programming is that you write code that will execute whenever a certain part of your program is reached. The most common example I've seen is that of a debug message that prints when every function is called; you could write the debug message in a separate function or file, and then via aspect-oriented programming not include code to call it in every single function. Instead you'd define an aspect, or something, and have your debug message print whenever the situation that defines that aspect occurs.

      The promise of this is that you can save some effort by reducing repetitive function calls. The risk is that control flow can be very difficult to trace. Some people argue that aspect-oriented programming is similar to programming with goto, and I'm inclined to agree with them. It's useful under certain tightly defined circumstances and harmful otherwise.

    3. Re:Aspect-oriented? by Anonymous Coward · · Score: 2, Insightful

      aspect-oriented programming is a sure way to write spaghetti code.

      What you do is you write a piece of code where part of it is a regular expression that matches one or more methods in your existing code, and another part is either the symbol "before", "after", or "both".

      When you compile the code, the aspect's code is inserted before, after, or both before and after, the existing code. Your source isn't changed, just the binary.

      So if every time the method Foo() is called you want it to call Bar() before and Baz() afterwards, this is a great way to do it.

      The downside is, if you look at the source code at the place Foo() is called you will have NO IDEA that Bar() and Baz() are being called, because the code is inserted at compile time. If you debug the executable the call becomes obvious, but it's caused many a WTF on my part.

      Lisp has had this sort of thing for years, with it's :before and :after directives.

    4. Re:Aspect-oriented? by Anonymous Coward · · Score: 0

      Essentially, it's splitting objects into distinct functional units that are combined at run-time or compile-time to produce the desired functionaility. A toy example is a class that does something, with an aspect that handles logging. Aspects generally are class like contructs that are "woven" together at particular, well defined places (called join points). Join-points are places like the beginning of a method, or the start of a class instantiation. To go back to the toy example, the logging aspect would be defined to insert a logging statement at the beginning and end of each method. The cool part of AOP is that the "weaving" can be done at runtime. This allows you to modify how your program works without restarting it. To go, once again, back to the toy example, say you thing your webserver has a bug, you can turn on your logging aspects to determine the cause of the error.

      Google for AspectJ for a working language using AOP.

    5. Re:Aspect-oriented? by justasecond · · Score: 1


      Here's a better question for the AOP crowd: Can you *possibly* come up with a new example usagage? Since its introduction, AOP snake-oil types have been dragging out the now-threadbare "logging" example (see the other replies to the parent). Are there any more uses for this thing?

    6. Re:Aspect-oriented? by archevis · · Score: 4, Insightful
      >> wtf is Aspect-oriented programming?

      Aspect Oriented Programming is actually just a remake of the old comefrom pun. However, AOP is not a pun. It's a real life atrocity that should have been slain at birth. It can be visualized as having a piece of code "steal" the instruction pointer from somewhere inside another piece of code. And some morons seem to think that this constitutes good software engineering...

      No, I'm not shitting you here, it's actually true! It just sounds like a joke.

      And for the record: No, I don't hate Java. Quite on the contrary, I love Java. Furthermore, I am a heavily certified and devoted Java-only developer, and have been for 7 years. But AOP is a big-time fuck-up.

      >> how does it relate to object-oriented programming?

      It doesn't. Then again, most developers don't even know exactly what OOP really is, and what conceptually separates it from other paradigms. Hell, most "developers" don't even know what a programming language paradigm is.

      So it all boils down to the buzzword factor.

    7. Re:Aspect-oriented? by ggwood · · Score: 2, Informative

      There is an attempt at a jargon-free explanation here.

      --
      a war on terrorism? How can we end a war on a method?
    8. Re:Aspect-oriented? by cerebis · · Score: 1
      Sure.

      Mixins are a good example of AOP doing something powerful. AOP is a particularly good way of augmenting the functionality of objects without actually having to make those objects aware of that functionality by explicitly inheriting an interface.

      You can find a good example using a Lockable interface -- to make an y object temporarily immutable -- in the Spring reference documentation.

    9. Re:Aspect-oriented? by ajs · · Score: 4, Informative
      "modularization and encapsulation of cross-cutting concerns."

      And it's just that kind of buzzword-to-noise ratio that makes people ignore AOP.

      In reality, AOP is a structured way for a programmer to modify existing classes an an OO system without sub-classing. So, here's AOP in Perl, just as an example:
      package SomeClass;
      ...
      sub somemethod {...}
      ...
      # And then later in your code:
      my $oldmethod = \&SomeClass::somemethod;
      *SomeClass::somemethod = sub {
        print "Invoking somemethod...\n";
        goto $oldmethod;
      }
      I used Perl's stackless-invocation goto semantics here for two reasons: it's the most efficient way to do this; but it's also an eye-catcher that (because of the bad blood programmers tend to have with respect to C or BASIC style goto) highlights what I think the problem is.

      I tend to try to avoid this kind of thing in my programs, regardless of language, except where I make it very clear that functionality can and should be added, in which case I provide a mechanism. So, I'm not sure how AOP could work well (it's supposed to be used in those cases where the original author didn't have any idea about what you want to do). Sub-classing or re-writing such code has always seemed the right way to go to me.

      How, for example, are you supposed to maintain code where a substantial change to any library routine's internal behavior could cause catastrophy for someone who has tried to add behavior to it? I suppose you could lexically scope such constructs, which would be reasonable, but no... I think this is just an attempt to get a small portion of what smalltalk or ruby style mix-ins/traits would give you.

      Then again, I guess the problem really stems from trying to use a high-level language (Java) which attempts to simulate the constraints of a low-level language (C or C++) while users attempt to use it as if it were high-level (like Smalltalk, Haskell, Python, Perl or Ruby).

      In the end, it seems to make more sense to use Java the way it was intended to be used, and use high level languages where you want dynamic features like the ability to reach into someone else's code and do whatever you like.
    10. Re:Aspect-oriented? by Bloater · · Score: 2, Funny

      > you could write the debug message in a separate function or file, and then via aspect-oriented programming not include code to call it in every single function. Instead you'd define an aspect, or something, and have your debug message print whenever the situation that defines that aspect occurs.

      Is that like intercals "COME FROM" construct.

    11. Re:Aspect-oriented? by Peter+La+Casse · · Score: 1

      I'm not familiar with intercal, but it sounds very similar.

    12. Re:Aspect-oriented? by Anonymous+Brave+Guy · · Score: 2, Insightful

      Sorry, my mod points just ran out, or you'd have been (+1, Insightful).

      Speaking of moderation, the fact that a post quoting the phrase "modularization and encapsulation of cross-cutting concerns" was modded (+1, Informative) is itself (+1, Funny). :-)

      Maybe it's just me, but I've never appreciated what's supposed to be so great about aspects. Yes, it might be useful to be able to introduce some debugging diagnostics at the start and end of every function automatically. We use a pretty powerful instrumentation system in our code at work, but having to stick a macro at the start of every function to make it work is tedious (though hardly the end of the world).

      But what else is it good for? I've looked into AOP a couple of times now out of curiosity, made the effort to read some of the background papers, and now placed it firmly on the level of so-called extreme programming: much hype, toy examples, few to zero real world case studies showing measurable benefits. I haven't read every single post in this discussion yet, but probably the majority, and I've yet to see anything other than the same old example (or thinly disguised variants of it) repeated ad nauseam. Maybe one of the AOP advocates can tell me what I'm missing?

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    13. Re:Aspect-oriented? by rbodkin · · Score: 5, Insightful
      First off, it's quite ridiculous to claim that an open source technology with no marketing behind it is somehow a "buzzword." AOP is gaining interest because of the success of those who are using it. When I was with the AspectJ team at Xerox PARC we did a workshop with IBM and they decided to invest significantly in the technology for internal use (not for marketing). AspectJ is now shipping inside WebSphere.

      Aspects are great because the provide a useful means to abstract the relationships for policies, so we can finally cleanly capture hard problems like performance monitoring, consistent error handling, enforcing data security, or allowing product line variability for changing features in an application. This last one is the strategic reason for IBM investing: they can open source components but still integrate with different runtimes.

      Obviously you've considered this really carefully. I can just imagine your intellectual predecessors sitting there 25 years ago fuming about how polymorphism makes it impossible to tell where a call in the program goes. "Leave my line numbers ALONE"

      Aspects are great because the fact is that traditional OO just doesn't do a good job of modularizing (look it up) these hard but important problems. Of course, you also should consider the real world consequences of this problem (code gen, overweening frameworks, fragile code, etc.) Aspects promote good maintainable software for the real world. Just as was the case with OO, this new level of indirection requires some learning and good tools support.

    14. Re:Aspect-oriented? by rbodkin · · Score: 1

      Feature variation, usage metering, Error handling, error isolation, performance monitoring, account suspension, role-based and data-driven security, transaction management, failure injection for integration tests, performance monitoring, dirty tracking, relationship integrity management, architectural enforcement, raising business events, caching, prefetching ... Need I go on?

    15. Re:Aspect-oriented? by kavi_3 · · Score: 2, Insightful

      I have to say, I can tell you've never seen a good example of AOP in action. It's a very powerful tool for certain kinds of problems. Crosscutting concerns is not just a buzzword. There are certain requirments in many software projects that cut accross many modules and sections; examples being security, transactionality, policy enforcement, the list goes on and one. One example is any problem that could be solved with the Visitor pattern can be solved with aspects in way that is far simpler and maintainable.

      I work on a very large software project that uses aspect in several different ways. On example is for transaction management. We have an aspect that is able to start a transaction at any method marked with a @Transactional annotation. And you can create aspects that do things like inject a caching system objects in a way that doesn't force the object to be aware that it is being cached. Catch business events that should happen at certain times without littering your code with calls to raising that event. It an extremly powerful tool.

      The problems with aspects are the lack of tool support. It can slow down compiles and mess with debuggers at times (I know, I've had to deal with this). However this will improve over time. Another improvement is runtime weaving, where the aspects are woven into the code at runtime. This allow you to run the aspects when you actually need them (production, integration testing) and not when you don't (unit testing).

      And the compaint about not knowing where the flow of control is going is similar to the complaints about OO and ploymorphism. Yes, it can make it a little harder understand a program at first, but with the proper tools and some time, it will make the program far more maintainable.

      You have to know when and where to use it.

      --
      "Attention Citizens, 2+2 now equals 3.947547175. Please recalibrate your equipment now" --The Computer
    16. Re:Aspect-oriented? by sapgau · · Score: 1

      So far as I understand it, AOP is a way of implementing a kind of "policy" that is shared at different levels or classes in your code.

      One of the major applications that convinced IBM into AOP was to implement a new logging technique into a big system. Obviously it would take thousands of man hours if you went and did it manually (even if it was outsourced to India!). With AOP IBM realized that they can define the cut-crossing concern, for example, at the end of all methods that communicated to an IO device, run the "post-compiler" and insert it into the existing system.

      This way, you can add new functionality that can be easily understood as being necessary all over your code base.

      The challenge here is to show in the existing code that it will be affected at some time (beginning, end, middle of your methods) by a cross-cutting concern. Some kind of introspection (meta-introspection?) would be needed here to highlight specific entry points in your code. Otherwise maintenance would be a biatch, not knowing why or when your code is behaving the way it is.

      I beleive that is still a topic for research and there are some Eclipse plugins to highlight your code when it is being affected by aspects.

      0.02

    17. Re:Aspect-oriented? by olemartin · · Score: 1

      In our current java project we are using AOP to a certain degree, and I love it.. AOP comes in two flavours: - Introductions - add interface and implementation to your existing classes (kind of support multiple inheritance, as java doesn't) - Advice - add functionality before, after, around your exisiting code. Your existing code in this example may be a method call, a static block executing, a read or write of a class variable. In our projects we are only using advices on methods. We have developed a system that is quite stateless and integrates to a backend system that requires login. So we developed a loginAdvice. Some of the data we retrieve from this system is rather static, so we implemented a cacheAdvice.. We want to track how our customers use our system, so we implemented a loggingAdvice.. None of the code in our aspects are core to the functionality of our system, so it doesn't belong in our core business classes. They are aspects of our system..

    18. Re:Aspect-oriented? by Anonymous Coward · · Score: 0

      C is a HIGH level language.
      Assembler is a low level language.

      (oh why bother...)

    19. Re:Aspect-oriented? by tootlemonde · · Score: 2, Informative

      And some morons seem to think that this constitutes good software engineering...

      The "moron" in question here is Nicholas Lesiecki, author of Java Tools for Extreme Programming: Mastering Open Source Tools Including Ant, JUnit, and Cactus. This review in Dr. Dobb's Journal calls it "original and useful".

      He is also a contributor to Cactus, "a simple test framework for unit testing server-side java code", part of the Apache Jakarta project.

      He is currently a software engineer and programming instructor with Google.

    20. Re:Aspect-oriented? by Anonymous Coward · · Score: 0

      Obviously you've considered this really carefully. I can just imagine your intellectual predecessors sitting there 25 years ago fuming about how polymorphism makes it impossible to tell where a call in the program goes. "Leave my line numbers ALONE"

      That's nothing. I once had an older guy complain about functions. He liked his functions to be very long, with as little helper functions as possible.

    21. Re:Aspect-oriented? by ajs · · Score: 1

      C is a HIGH level language.
      Assembler is a low level language.


      The distinction is not firm, and in reality it's a relative assessment of the scope and abstraction of a language which varys with respect to time. In 2100, we might well consider Perl or Smalltalk to be "low level languages" because they have no constructs for directly representing the state of the programmer's brain. That's hyperbolic, of course, but you get the idea. "High level" is whatever "low level" isn't, and right now, that's languages like Perl, Python, Ruby, Haskell, LISP and Smalltalk. Languages like C, C++, Objective C, Fortran and Pascal, are generally thought of as low-level languages. Some ambiguity comes up for modern languages like Fortress, which stand in the middle somewhere. Even Java is hard to nail down. It's high-level in that its specification requires a virtual machine, but it's low-level in that it lacks many of the abstractions of modern high-level languages.

  13. Related Reference by under_score · · Score: 4, Informative

    I've written up a brief introduction to the qualities of an ideal test. The great thing about unit test frameworks such as JUnit, NUnit, CPPUnit, etc. is that they manage to satisfy all of these qualities: Decisive, Valid, Complete, Repeatable, Isolated and Automated. (Although it is possible to break some of these qualities with poor test creation practices.)

    1. Re:Related Reference by Anonymous Coward · · Score: 0

      That's something I've noticed (poor test creation). When developing large projects, it seems it can be possible to 'test against the script' and there can be some big holes that are left because the QA team isn't checking it and the developer isn't aware of it, or worse, not worried about it being checked.

    2. Re:Related Reference by under_score · · Score: 1

      I've done a lot of work with testing and on occaision, I have had to test tests. It's a funny thing - the whole notion of the ideal qualities of a test is something that very few people seem to have even thought about (unlike, for example, the ACID qualities of a database). The vast majority of QA/QS people that I know have a very limited theoretical framework for testing. Testing is not thought of as "proving" software, as it could be. Holes in quality can easily come in if development is being done that is not directly tied to a test. TDD, ATDD (Acceptance Test Driven Development), and continuous integration, if done rigorously, can pretty much guarantee zero defect rates on new development. Adding these into an existing project after the fact is very difficult, but still has substantial benefits.

    3. Re:Related Reference by Anonymous Coward · · Score: 0

      That's why at my work we do design (with POC), design reviews, coding, code reviews, then QA actual tests the product. If there are defects, it goes back to code, gets reviewed again and back to QA team. Not that unique, but really emphasized to have the design review intense and "proving your theory."

  14. Aspect Oriented Programming... by Anonymous Coward · · Score: 0

    ...does not deliver. It turns out that there aren't that many cross cutting concerns in any most applications. Even when there are a number, aspect composition makes code difficult to understand. Aspects also make code much harder to understand.

    Chalk it up as yet another failed silver bullet.

  15. Unit Testing, Extreme Programming, Agile by under_score · · Score: 1

    Using automated unit test frameworks such as JUnit is one of the most important engineering practices in the whole suite of agile practices. Many agile practices that don't explicitly ask for test-driven development still will insist that Agile is enabled by technology that allows for fluid, testable work. I'm very interested in Agile applied outside of software, and the underlying principles and practices of Agile. The situations where it can apply best have some sort of technological support for automation, and in particular automation of tests. I have seen situations where spending >$50,000.00 to build a custom automated test harness is money well spent in order to avoid mistakes in the first place. One of the main principles of Lean (a heavy source of influence for Agile), is that you can only go fast if you have exceptionally high quality. Any source of defects slows a project/team/production line down.

  16. Nice examples by msbsod · · Score: 1

    The examples shown on the mentioned web site illustrate very nicely what is wrong with software development. First, iReallyHaveAHARDtimeToRead->thisStuff. Second, when will people give up Fortran programming, such as private variables, global variables or COMMON blocks? Testing is good, but it becomes a Sisyphus task with side-effects based concepts.

  17. Edsger Wybe Dijkstra's qoute by Device666 · · Score: 3, Insightful

    "Program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence."Quote - Edsger Wybe Dijkstra. I get the "jibbies" in knowing that code is tested but not proven correct by design (program derivation).

    1. Re:Edsger Wybe Dijkstra's qoute by msbsod · · Score: 2, Interesting

      Edsger Wybe Dijkstra truly understood the virtue of the Lambda Calculus. IBM software developers who advocate aspect-oriented Java code obviously still do not understand the concept, as the examples on the cited IBM Java web page show (see use of private variables).

    2. Re:Edsger Wybe Dijkstra's qoute by Dionysus · · Score: 2

      I'm not sure I understand. What's the problem with using private variables?

      --
      Je ne parle pas francais.
    3. Re:Edsger Wybe Dijkstra's qoute by Device666 · · Score: 1

      Yes. It is so strange the software industry has problems with delivering quality. Ofcourse code should be as faultless as possible. And ofcourse that means programmers should be educated enough to feel responsible and use some form of formal verification. If it's so poor understood even at the bigger companies, it shows that if anyone who can construct some if-else-construction is easily considered a programmer. I had a little bit of programming education when I did my study of interaction design at an at academy. I have learned myself programming. And it is strange that I had to delve so deep to hear of this very important man Edsger Wybe Dijkstra. Fortunately I found his name and all interesting things he did. I am now learning myself predicate calculus as he first step on the way to program derivation. I would advice every programmer to do so.

    4. Re:Edsger Wybe Dijkstra's qoute by Felonious+Ham · · Score: 1

      I think (functional programmers correct me) OO code is not "mathematically provable" because of state (private) variables.

  18. Forget N-Unit or J-Unit testing by Anonymous Coward · · Score: 0

    What we need is G-Unit testing.
    http://www.ggg-gmail.com/
    Who's gonna step up to the plate?

  19. Another methodology bandwagon by syousef · · Score: 1, Insightful

    We have a brand new buzzword^H^H^H^H^H^H^H^Htechnology that will save you millions and make all your technology function correctly. It's called AOP. It'll make your code more complex, probably force you to use non-standard implementations of Java, but it will be worth it in the end. We promise. Trust us.

    Bring back the concept of RAPID application development. The only thing that was missing over 10 years ago was scalability. Today's frameworks are bloated and horrible. Testing will be much simpler, and require less tools when it's QUICK to build screens, and you don't have to propagate changes by hand to 15 layers of damn code. You may also need to employ a test team that has an understanding of how the code works, as well as the business requirements. It can and has been done.

    --
    These posts express my own personal views, not those of my employer
    1. Re:Another methodology bandwagon by Anonymous Coward · · Score: 0

      I'd agree about being wary of buzzwords and marketing hype, but your following paragraph is misleading and inaccurate.

      In case you missed:

      Agile based on the RAD concept.

      What was so great about 10 years ago? A shitload of poorly written VB, PowerBuilder, and Delphi applications.

      Which bloated frameworks are you referring too? As an example, the Spring framework weighs in at less than 2MB.

      "Testing will be much simpler, and require less tools when it's QUICK to build screens"

      Will it? I write test very quickly( due to AOP, OOP, Agile, etc. Good design goes a long way... ) and have automated test builds/runs done via Ant. It doesn't get any simpler.

      "...and you don't have to propagate changes by hand to 15 layers of damn code."

      If this is the case, perhaps your designs are poor and not the test framework.

      Writing good software will no come from the latest tools and trends alone, it requires good people too. Picking the best of both will ensure success.

    2. Re:Another methodology bandwagon by syousef · · Score: 1

      You know what I don't miss powerbuilder (unstable) or VB (disorganised mess), but I do miss Delphi.

      Agile is not at all based on RAD. I crave the days that you could drag a dozen components onto a frame, write a few lines of code and have an actual well behaving prototype sitting on the screen. I have an honest question for you. Did you ever work with VB, Delphi or perhaps CBuilder?

      Spring is awful. Inversion of control is a silly concept. Yes you write less code, but it's all externalised where it's hard to debug. If you do change the behaviour through the externalised files it'll probably break more than you realise. Besides there's a lot to be said for the visibility and simplicity in following explicit error/exception handling.

      Struts is awful. Get anything wrong in the config and you get a nice blank screen. Then spend ages debugging because you're forced to rebuild an EAR file containing a WAR file...etc. etc. Same with all J2EE. Layer upon layer of wrappers, interfaces and plugs, all of which have to be changed to propagate anything to the screen.

      Hibernate is woeful. Ever tried writing a complex query using hibernate? Hint: HQL has severe limits (for example try grouping by an agregate function). Or debugging null sessions? Horrible.

      Half the problem with design is that esign patterns are all the rage. Good ideas in theory but in practice it means every half decent programmer finding a similar problem to the one you're solving and cobbling on the solution whether or not it fits, instead of actually ANALYSING the problem in the first place. Then lets abstract everything out as much as possible so it's pluggable. (Never mind that we'll never actually switch or plug in anything else). J2EE design "best practice" in recent years is a mess of overengineered nonsense.

      --
      These posts express my own personal views, not those of my employer
    3. Re:Another methodology bandwagon by Anonymous Coward · · Score: 0

      A lot of the over-engineering is due to the desire on the part of businesses to make software development as much like manufacturing as possible.

      Specificlly, this means that the *process* is supposed to supply the intelligence, not the programmer. This theoretically means that you can save money on programmers, since anyone who can 'follow the process' can be a developer.

      It's not as efficient as using skilled people, but in theory it can be cheaper - hire a couple of gurus to set up the 'process' (to add a page, insert a JSP here, mod this XML file there, etc.), then hire folks right out of 'intro-to-programming' classes to follow it. They will make a lot of mistakes, but if the process is solid enough, they will (eventually) produce something that functions well enough to meet the requirements.

      With this kind of structure in place, and a generation of folks who confuse a language (Java) with an overengineered, bloated platform (J2EE), you can even forget that there is any other way to build software than that which is supported by the frameworks (build a webapp without using Struts ? How is that possible ? Validate software without using JUnit ? How is that possible ?).

      The software technology stack continues to evolve at a tremendous rate, but it is still not 'manufacturing', and, given the rapidly changing requirements that software is supposed to meet, may never be.

    4. Re:Another methodology bandwagon by syousef · · Score: 1

      If you honestly believe software can be anything like manufacturing you're part of the problem. Manufacturing involves setting up _repeatable_ processes. Writing software, the code is different each and every time. It is not unskilled work. There is no process "solid enough" to deal with the infinite variability of the software which will be written.

      JUnit, J2EE and all the frameworks that surround this technology are nothing more than tools. The tools can be good or bad, suited or unsuited to a task. Unskilled IT staff applying these tools without any concept of what the tradeoffs are gives you the slow messy development we're seeing today.

      In any case, it takes a lot to learn the myriad of frameworks and technologies, only to misapply them because the process of writing software is being boxed into the manufacturing mentality you describe. The skill required to use these tools at all, let alone effectively, requires a good understanding of the tools, their applicability and their limitations.

      I've seen a team of 2-3 SKILLED developers outdo a team of 20-30 "let's put bums on seats" developers.

      --
      These posts express my own personal views, not those of my employer
  20. Not sure about the example... by DrEasy · · Score: 1

    The author uses a text highlighter as an example of an aspect. I don't see how this is a cross-cutting feature. Why not just put that logic in a TextHighlighter class, and use it via a simple method call? Or use it in a Decorator pattern?

    I got nothing against Aspects, but I just think they should be used when they make sense, like everything else I guess.

    --
    "In our tactical decisions, we are operating contrary to our strategic interest."
    1. Re:Not sure about the example... by mark_lybarger · · Score: 1

      aspects have a lot in common with decorators, IMO.

      i guess the author (i didn't read it of course) wanted to use something a bit more colorful than the typical logging example. there's many many places where aspects make sense, and most of those places have to do with extracting the layers of cruft we've added to our software layers. most of that cruft serves a usefull purpose, but gets in the way of application logic (security, logging, transactions, framework baggage).

  21. Perl's xUnit vs Test::Harness by spottedkangaroo · · Score: 1
    I can't really see the light until I find the perl version of it. I guess I've been spending too much time in perl land. I had to look at Catalyist to figure out RoR. Heh.

    But perl has Test::Class which does a whole xUnit type thing inside the Test::Harness framework. Nice. However it also tells me on that page, not to bother with it unless I'm reduplicating the same code over and over in my tests -- which I usually do not.

    I guess Test::Harness is plenty for average joes like me.

    --
    Imagine if you weren't allowed to use roads because a bus company complained about your driving 3 times. --skunkpussy
  22. Because Fortran programming works in some contexts by Richard+Steiner · · Score: 1

    The flight ops system I worked on at a major airline only a few years ago is written in Fortran and runs in a mainframe transaction environment that gets rid of common problems like buffer overflows and that provides a nice event-driven environment in which users obtain or enter data on quick-hitting text screens.

    For what it's used for, the general environment is very well tailored for the task, and the code in question tends to be a mix of simple text parsing and fairly complex computations, so a language like Fortran with a few specialized text parsing library routines turns out to be an excellent choice!

    With appropriate coding standards (e.g., make all variables global, but equivalence them to a single integer array so one can easily initialize all variables in a given program at the top to avoid reentrancy errors) it isn't all that hard, but one *does* have to create and then FOLLOW a decent set of coding standards to make it work.

    This is true of all languages, not just Fortran.

    We had some pretty good automated testing/scripting facilities on the mainframe in the late 1980's when I first started coding professionally at Unisys, and it's a shame that more developers aren't made familiar with such tools. They can make regression testing a lot easier!

    --
    Mainframe/UNIX Bit Twiddler and long time Windows/Linux Hobbyist.
    The Theorem Theorem: If If, Then Then.
  23. Re:Because Fortran programming works in some conte by msbsod · · Score: 1

    Absolutely, one can write reliable code in Fortran, too. Excellent supporting tools like SCA (Source Code Analyzer) and DTM ( DEC Test Manager) have been around since a long time, not to mention the superb VAX/VMS Fortran compiler.

    I just would not agree with you on the global variables and initialization. Complexity of data exchange via global variables beats every attempt to debug such code. Your initialization helps to avoid some mistakes, but the basic problem remains. Exchange of information through side-effects (global, private, doesn't matter) is always more complicated to understand than exchange of information through a list of input and output arguments at every function call.

    People also tend to think that bad things happen because variables were not initialized. I have heard more than once from OOP advocates that constructors are important, because they allow the software developer to implement an automatic initialization of variables. The truth often is that worse things happen if they are initialized, typically with something like zero, than having a random value. Because, if they are initialized with zero, then chances are that your code runs through without any obvious problem, although the result may be worthless. And you may not notice it. I completely avoid global variables (or private variables in classes). For testing purposes I initialize local variables with NaN's instead (for floating point variables), which happen to be huge integer numbers, too. Of course I also rely on the compiler's ability to detect the use of variables which have not been assigned a value before, something that cannot work with global/private variables. But the compilers have their limitations. However, a dummy intialization, like the method you mentioned or a typical C++ constructor implementation, would completely defy the compiler's test for uninitialized variables (that is initialized with a correct value, not with something like a zero). In any case, my favorite ultimate test utility is a debugger. From my own past experience (almost 3 decades, more than a dozen languages) I find any whateveryounameit-oriented black box concept less useful for debugging (say "testing step-by-step").

    One can make the same mistakes in Fortran, Java, C++ etc.. The more things change, the more they stay the same; as the mentioned example on IBM's "aspect-oriented code" Java web page shows.

  24. "Programmer Testing" - Is That New ? by Tetch · · Score: 1
    The widespread adoption of programmer testing over the past five years

    OMG - you mean .. when I tested all that code I wrote between 1973 and 2000 I was doing something *different* from all you guys ?!

    Why didn't someone tell me I was doing it wrong ?

    (Seriously, WTF does that sentence even mean ?)

    --
    If you don't pray in my school, I won't think in your church.
    1. Re:"Programmer Testing" - Is That New ? by Anonymous Coward · · Score: 0

      Most programmers have always tested their code.

      The sentence refers to systematic automated unit tests. Where you write an automated test for everything (or most everything). Where you can run the tests at the push of a button. And where the tests, by design, run in a manageable time so you can edit-test-edit-test all the time.

      If you have been doing that systematically since 1973 (color me doubtful) you should be kicking yourself for not writing a book about it, showing how easily such tests can be written and how much they help.

  25. Re:Makes me wonder by symbolic · · Score: 1

    Developers cannot let themselves be caught in that trap, so they need to test as they go.

    Does the typical programmer code s significant chunk of programming before testing, or are there short spurts of code, then test, then code...?

  26. dead simple by Anonymous Coward · · Score: 0

    Verbiage aside...

    Aspects add behavior to OO programs, like new members and new code. The main benefit is being able to say in one place what you would say in many places - easier to write, test, and change.

    AOP is well-accepted in many forms. AspectJ is in MySQL connector/J, WebSphere, etc. JBoss/AOP is in, well, JBoss, i.e., everywhere. Many OO techniques are AOP precursors, and some handle AOP applications happily. So if you don't need or want aspects, don't use (or promote) them.

    To test common behavior throughout a program, try an aspect. To test an aspect that affects a lot of your program without having to write lots of tests, then read the article. If you're interested in how to write tests that affect a lot of your program, but don't want to use aspects, read the article anyway since the problems are the same.

    Happy coding...

  27. There is a suprise in Aspect-J by metalotus · · Score: 2, Interesting

    Having tried Aspect-J in a production environment, I found an unhappy surprise.

    When you move beyond the trivial examples, you will encounter Aspect-J's long-standing bugs that simply crash your IDE every five minutes. For example, this P1 critical bug makes Aspect-J unbearable:

    https://bugs.eclipse.org/bugs/show_bug.cgi?id=4421 5

    I've heard of JBoss AOP being used successfully in production (http://www.jboss.org/products/aop).

  28. AOP vs Lisp tracing by greenash · · Score: 1

    The only solid, persuasive cross-cutting concern in all AOP literature is logging (e.g. logging when a method is invoked and such). This would be properly solved by having an easy-to-use "tracing" infrastructure in the language, like Lisp has.

    1. Re:AOP vs Lisp tracing by efuzzyone · · Score: 1

      Are there any lisp libraries/packages for logging, which will log the function name and probably the line number, etc.

      So far I have been logging in lisp only using a homewritten trivial 'tracer' macro.

      --
      Creativity uninhibited www.kreeti.com
    2. Re:AOP vs Lisp tracing by Anonymous Coward · · Score: 0
      The only solid, persuasive cross-cutting concern in all AOP literature is logging ...

      I have worked as a coder in online banking and stock trading.

      Logging there was important. Important as in government ordered, lose your banking license if you can't show what a customer did over the web on a given day two years ago.

      Logging as externally injected comefrom statements? Shudder! No way! When logging is important it is like any other property of a piece of code: the programmer must be able to look at the code and tell exactly what happens. What gets logged and when.

      Moving logging out of the code makes as much sense as moving every for loop to some external "for loop aspect management comefrom injector" module.

      The only use case for AOP I have seen that makes the least bit of sense is method tracing while debugging. But that's a job for a debugger, not for a programming language feature.

  29. Unit testing versus other methods of debugging by panth0r · · Score: 1

    I really wish I could have caught this one sooner, unit testing is a great idea if you want a generic, vanilla way of testing a program or function, I'll grant it that, it is extremely useful, in a vanilla and pretty standard way. However, I'd really like to point out that there's no better form of debugging than sitting down with a few friends (or an associate of some kind, if this is in a work environment) and reading over the source, and you'll learn more from this method, also. I honestly think that unit testing has, in fact, taken over debugging as the battlefront aganst bugs in code, but no step should be left out, the program should be tested, debugged, and eventually evaluated by a group of other professionals, I just thinkt his step is essential.

    --
    I like suggestions, but I don't like contributing towards them.
  30. Interesting by Anonymous Coward · · Score: 0

    Sounds like a good way to debug, might have to try it. Oh yeah and the title sounds dirty.

  31. Worked with AOP by El_Muerte_TDS · · Score: 2, Insightful

    I worked with AOP a bit (AspectJ and Compose*) and I can tell you this. I have mixed feelings about the use of it. For example AOP is simply awesome if you want to add debug code to your whole application so you can easily add\remove call tracing\logging to find where the program craches (ofcourse you could do the same with in C\C++ with some macros, but it's a bit more work). On the other hand you will completely lose overview on how your AOP changes affect the program in a whole. Even with the visualisation tools that come with AspectJ is not easy.

  32. in JAVA you test, in C/C++ you debug by ysegalov · · Score: 1

    And these are two different martial arts. Java is for Internet kids who have the luxury of running over an operating system (even MS-Windows included..), but real programmers, who have to squeeze into some 128K of flash memory an entire communication application on a lousy 16-bit DSP CPU with tight power consumption budget, will always do some dirty tricks no quiche-eaters unit-testing module will help. Startup idea anyone? A CPU that runs Java. JVM in hardware, that is.

  33. Software Patents Considered Harmful by -_broken_watchman_- · · Score: 2, Insightful