Agile Spices for Classical Process
2015-03-08
In this day and age every programmer and his dog know that well implemented agile processes are more efficient and create an environment where you actually want to work. Unfortunately many organisations are not ready to implement agile processes. This resistance unfortunately is somewhat well founded, when you need to comply with regulations, it is really hard to explain how traceability is implemented when all you have to document your requirements are index cards. Although it is possible to implement traceability in an agile process, such as Scrum, that even the FDA will approve of, getting the upper rungs of management to agree, can be an impossible task.
But not all hope is lost, there are a few things you can take from the agile play book and seamlessly integrate into a classical model, like waterfall or the V-model.
Compose (Variadic Template Function)
2015-02-06
I have used a string composition function for quite some while. It is a reimplemented and simpler version of the String Composition Library.
std::cout << compose("Wrote %0 objects into %1.", objects.size(), filename) << std::endl;
"Wrote 548 objects into level1.jsn."
The problem with C++'s stream library is that is almost impossible to localize strings with the stream insertion operators. The core of the problem is that they chop up the sentence into fragments, such as:
std::cout << "Wrote " << objects.size() << " objects into " << filename << ":" << std::endl;
When you use something like gettext the strings that may be translated are:
"Wrote "
" objects into "
"."
Not only is it really difficult for translators to understand what is meant (they see the strings within hundred others), but it also does not allow them to reorder the sentence, as it may be necessary. For example in German I would reorder to to be:
"%0 Objekte wurden in %1."
So it makes sense to keep the string together. This is one of the reason why the printf family of functions still is so popular when it comes to localisation.
Worker Pool
2015-01-26
I have recently been asked to write a worker pool and that is what I did. The goal is to have a thread pool, that you can throw at arbitrary functions and they will be executed as resources allow.
The worker pool has the following interface:
class WorkPool
{
public:
WorkPool(unsigned int concurency = std::thread::hardware_concurrency());
~WorkPool();
template <typename Res, typename ... Args, typename Fun>
std::future<Res> enqueue(Fun func, Args... args);
private:
// ...
};
To use the worker pool you would use the following code:
WorkPool pool;
addrinfo* google_com = nullptr;
std::future<int> fgcom = pool.enqueue<int, PCSTR, PCSTR, const ADDRINFOA*, PADDRINFOA*>(getaddrinfo, "google.com", NULL, NULL, &google_com);
if (fgcom.get() == 0)
{
// do something with the result
}
else
{
// print error message
}
But you can enqueue anything function like into the work pool; basically anything that goes into a std::packaged_task. Like with std::async, it is important to capture the future, even if it is void. The problem is that the call will hang at enqueue until the function finishes, which renders the entire concept of a worker pool moot.
User Stories are Half the Story
2015-01-21
There are many ways in which you can capture requirements. The current "en vogue" method is to writ down user stories on index cards and stick them on a white board. A structured approach to requirements is key if you want to ever finish your project, unfortunately user stories fail to capture all aspects that define a piece of software.
The first and obvious contender to missed requirements are the non functional requirements. Non functional requirements are the ephemeral requirements that encompass maintainability usability, performance and memory footprint. Many methodologies try to skirt the issue by defining "quality metrics" or "common values". The idea here is, that by creating the cleanest and optimal code you actually implement the non functional requirements because the code is is such an awesome state. The problem is that the optimal solution solution for ten elements is not the optimal solution for one million elements.
Iterative Waterfall
2015-01-13
Although agile processes are becoming commonplace in many organisations, many developers and projects are still stuck in some form of waterfall and classical project management, especially in large organisations. (Like me.) But within the constraints of classical project management, some agile practices can be applied. In the case of this post, I will look at iterations.
Iterations are not something new that agile processes brought to the development scene. But they make it a core mechanic of the process. The core idea is to reduce the feedback loop. One thing that the water wall fails to do well.
Revised EventEmitter
2015-01-05
I wrote a C++ incarnation of node.js' EventEmitter. But as things are, when you communicate a subject, often you find new insight and flaws in the topic. One of the reasons why rubber ducking is a useful tool, while designing software.
My insight was that the listeners are stored is optimized in the wrong way. I used the standard way when you have handle to things, the handle is the key into a map that holds things. This makes sense when most of the time the outside world calls functions with this handle. But in the case of the EventEmitter, the handle to the listener is only relevant when you want to remove it. But what is done most of the time is emitting events. So it just plainly makes sense to order the map by the event.
EventEmitter in C++
2014-12-29
Note: While writing this article I noticed in flaw how the listeners are stored. You can read everything about the Revised EventEmitter.
When it comes to C++ callback / event handling I have for a long time relied on
sigc++. But since the release and mainstream adoption of C++11, I have more
and more relied on lambda function for event handling. I have mostly just used
the pattern where a std::function
is stored for each event and you can set them
through a on_event
function, like so:
class Widget
{
public:
void on_something(std::function<void (int)>cb)
{
something_cb = cb;
}
void do_something()
{
if (something_cb)
{
something_cb(42);
}
}
private:
std::function<void (int)> something_cb;
};
widget.on_something([&] (int info) {
// react to event
});
This takes some queues form node.js and has a high degree of readability. The pattern only has one severe drawbacks. First you can only register one handler at any time.
Overhaul of Page Generation
2014-12-02
When migrating from jekyl to gulp.js I was basically following jekyls lead, purely to ease the migration pains.
Some point later Daniel Naab adapted my aproach. Although he build ontop of my ideas, he played the ball out of the park. What really stuck me as ingenious is the integration of prose.io. The combination of travis-ci and prose.io, means that novice users can author the website without knowing what git and a text editor is. The result is something close to a high end CMS with static generated HTML pages.
The ACME Protocol
2014-11-19
... is the best thing since sliced bread the invention of SSL/TLS.
The Electronic Frontier Foundation (EFF), Mozilla, Akamai, Cisco and IdenTrus have partnered to create a free Certificate Authority (CA), Let's Encrypt. But the real twist is that they have removed humans form the certificate signing and revocation process. Finally the cherry on the cake is that Bruce Schneier thinks it's an "absolutely fantastic idea".
Enough of appeal to authority, first let us look at what is broken with existing certificate signing process. The way to get a valid SSL certificate is to create a signing request and have that signing request turned into a certificate by the CA. This certificate is then signed against the CA's certificate.
The SSL signing process is quite solid from a technical and cryptographic standpoint, but commonly fails on the human front. The problem is how does the CA know you are who you claim to be and that you that you actually own the domains the certificate is for?
Star Citizen Adverts
2014-11-03
One aspect of Star Citizen's marketing is genius, the ship adverts.
When you are marketing a game it is really difficult. What do you tell the potential players? More graphics, more spaceships awesome fun? Pulling this off is really hard, without coming over as a cheesy use care sales pitch. The best so far are the cinematic trailers, but these are often lauded for their lack of actual game footage.
Newer Posts Older Posts