Jan 28, 2005 / Are Unit Tests Always Useful?
2 commentsI think they aren't.
Unit tests help me to think about what I want exactly from a method (for example). But there are times when I know what method should return me, but very aproximately. For example, there are several acceptable results, but I just do not know what is the best in my case. Unit test will not solve this problem. Even more, if I choose one way from start and create unit test, I may miss a better way, so unit test may suppress my creativity.
This may sounds strange, but think a bit about this. A possible solution in this case is prototyping. Try several approaches without unit tests and the choose the most appropriate. Any other ideas?
UPDATED Jan 28:
I really do write tests first, but sometimes I wonder if this is always good for system architecture. Well, in most cases it is. The basic flow is like that: 1. write a code (for example, controller). And just realize that existing API is insufficient. 2. think a bit about possible extension and make a decision 3. write a test for this new desired method. 4. write a code for this test. 5. review the code and refactor on a "lower level" (rename, extract method, ...) 6. after awhile, review API and refactor on a higher level (new interfaces, classes) I don't think that this process really suppresses my creativity. Refactoring is a key. Discussion about this topic at Artima
Jan 19, 2005 / NEO Framework - Strength and Weakness
1 commentsAs you maybe know, TargetProcess built with NEO framework. During last several months I had a good chance to dig into NEO. NEO is good indeed, but it has some weak areas. See details below.
Strength:
- Allows to test without database (mock objects are already there, so it is very easy and cool). Initially I wrote tests with database, but then try to use in-memory data. It worked great and tests results were the same. So NEO really resolve UnitTests-Database problem.
- Provides code-generation for SQL and Entity classes. In fact, I need more flexibility and going to modify code-generation templates and main xml dtd (which is the source for code-generation). But modifications seems to be easy.
- Works very stable. I did not found any bug yet.
- It really speeds-up development. I can't say exactly, but I feel that my performance increased by at least 20-30%.
Weakness:
- There is no entity inheritance in NEO. In my case additonal effort was required to workaround this issue and still that workaround was not very good.
- A little of documentation, so learning curve is pretty high (however, tutorial is on the way, so the situation will change in the near future).
- Query mechanism is poor. No joins, no group by, no sum. I appreciate domain model, but in some cases SQL provides much more power and I want to have such an option at least.
- Queries like TitleList matchingTitles = factory.Find("PublicationDate < {0}", new DateTime(2003, 1, 1)); have hardcoded field - PublicationDate. If I change the name of the field, this will not throw an exception. So I should replace them by hand (well, IDEs do have good find tools). But, anyway, this should be resolved during compile-time. NEO has templates for entities, but templates are slightly cumbersome and I don't like them as well. Maybe there is not good solution for this problem.