Monday, July 27, 2009

Ninth Week NewsFeed Update

With the code for the NewsFeed module nearing completion, I'm beginning to focus more on testing and refactoring to increase the readability and general orthogonality of the NewsFeed code. The newsfeed module is unlike some of the other components in the codebase in that outside of the core model, logic, and view code, there needs to be code snippets in each logic and view module that incorporates newsfeed in some way.


That famous Voltaire quote that "the perfect is the enemy of the good" is very relevant to the testing stage of development, since while it can be reasonably easy to be sure that a feature is 95% bug-free, determining that it is 100% bug-free is exponentially harder, since it requires every possible permutation (or at least every significantly different permutation) to be tried, which makes it practically necessary to have automated testing in place. This is especially true for an open source project, where someone else may likely pick up where you left off, and you don't want them to treat your code contribution in the cargo cult manner.

Seed_db serves as a very basic smoke test, since I've added onCreate hooks that in turn create news feed items. While this smoke test does test the creation of new feed items, it does not test the consumption of news feed items, which is at least as important as their creation. Therefore I'll be working on unit tests this week, modeled after the test examples already in the codebase.


I've also done some refactoring, with help from Sverre's code review last week. Instead of a feed item created for each sender-receiver pair, now there is only one entity created for each feed update, with a list of receiver keys. This actually makes it easier to determine which updates should be sent to which users, and reduces the amount of entities that need to be created. Because this makes the feature more simple, it also makes it likely to contain less bugs, and makes it possible to reduce the amount of testing and maintenance required.

No comments:

Post a Comment