November 22, 2018
This morning instead of the daily kata, the apprenticeship team and myself watched Jonas Bonér’s talk ”Designing Events-first Microservices” on youtube. The purpose of the talk according to the abstract was to “explore the nature of events, what it means to be event-driven, and how we can unleash the power of events and commands by applying an events-first domain-driven design to microservices-based architectures.”
The presentation was well conducted but I didn’t quite get a full grasp of the subject as the analogies upheld by Bonér such as commands being nouns, events being verbs where to abstract. Eventfully we paused the video talked about it and decided it would be best not to continue watching the video until we understood the topic more.
Next up on this days items to attempt was setting up RSS feeds for this blog https://marc.netlify.com/rss.xml and trying to help Lewis set up his (no help needed his blog already automatically generates an rss feed). Getting slack to update the feed on the other hand seems to be more tricky there is a usefull tool for validating rss feeds at http://validator.w3.org/feed/ i’ve pass this information along. If mine is valid, so you should be getting updates on a regular bases :).
Today from learn-c-the-hard-way I wrote / used Duff’s device. Duff’s device is an old optimisation of copying one string / array over to another string / array. It’s no longer considered an optimisation and usage of it is not recommend. But it does work in an interesting why.
// normal way for copying elements from one place to another
int normal_copy(*to, *from, count) {
int i = 0;
for(i = 0; i < count ; i++) {
to[i] = from[i];
}
return i;
}
// Duff's method of copying
int duffs_device(*to, *from, count) {
int n = (count + 7) / 8;
switch(count % 8) {
case 0:
do {
*to++ = *from++;
case 7:
*to++ = *from++;
case 6:
*to++ = *from++;
case 5:
*to++ = *from++;
case 4:
*to++ = *from++;
case 3:
*to++ = *from++;
case 2:
*to++ = *from++;
case 1:
*to++ = *from++;
} while (--n > 0);
}
return count;
The end result of both functions are the same, but while the normal_copy function loops for every element / character of the string / array one at a time. Duffs device chops the works on 8 or less per iteration, stating with the smallest number of elements to make the total left a multiple of 8 then iterating away 8 at a time.
As neat as the program is, i don’t full understand why the author Zed Shaw would introduce a program like this and then say never to use it.
The final activity for today aside from writing this blog revolved around a presentation I’m doing about solving a word-chain kata, picking the presentation software was tricky then I remembered I’ve got a framework sitting in my old blog that I’ve still to use after taking so much time integrating the library into the blog then abandoning the project entirely.
Written by Marc McIntosh Find him on github