Skip Navigation Links.
 

Look to windward!

by svante@axantum.com 2006-05-27 13:16

I've now had had AxCrypt2Go available for download for quite some time, but received very little feedback. Perhaps it's already perfect... It does work! It's not easy to get time for development, the last couple of months have been very busy. The last couple of weeks I've been working on an OEM-version of AxCrypt, and that's very nice since revenue somehow does tend to result in making it easier to find the time.

The experience from this round of OEM deal is very positive, I'm quite happy that the code is still possible to work with, in fact it's quite easy and so far the changes and additions even if minor have been implemented without too much trouble. This is really one of the important measures of code quality in my mind, it's ability to adapt to new situations and be worked with for a long time before you just have to make that decision to rewrite it from scratch...

I'm eagerly waiting when I can drop all support for Windows 98/ME/NT and convert to full Unicode support. There are currently some issues with texts and file names that would be nice to get rid of. I'm still happy that I originally was so careful to make the code prepared for Unicode, so I'm not really expecting any big troubles. The only regret so far is that I decided to encode filenames and passphrases as ANSI. This will require some legacy code for a long time to support even in a full Unicode implementation. Too bad.

So the lesson for today is that if you are aware of a future technology shift, don't just prepare your code for it - ensure that your persistent data already takes it into account from the start, if at all possible. I could easily have done this with AxCrypt, but didn't - a fact I'll now regret for ever... ;-)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

AxCrypt2Go | Programming

auto_ptr revisited

by svante@axantum.com 2006-01-27 02:00

Hooray! AxCrypt2Go can now display icons for AxCrypt-files (although just the small one right now). Anyway, it's a proof of concept, now I'll have to refactor that code into something I can publish. That's one of the advantages of open source - it can't look too bad, so it has to be fixed. But that's not what I want to write about today, not really. I realized that I was not running the compiler at the highest warning-level (4), but only 3 and that's normally a principle I want to follow. Highest warning level, and treat warnings as errors. This actually led to a good thing today, because I just clarified something a little bit in my mind about how to use std::auto_ptr to the best effect. As it turns out, the compiler will complain about the following construct:

auto_ptr<char> s;
// Do something...
s = auto_ptr<char>(new char[100]);

The reason this is not a good idea is rather subtle, but basically it's due to the fact that the temporary object is not a reference to an object, it's an object, and you can't really make a reference to a temporary object like that. At least it's pretty bad form... It's a similar situation where you can't use a temporary object as a parameter for a non-const reference formal parameter to a function.

The way to do this is of course:

auto_ptr<char> s;
// Do something...
s.reset(new char[100]);

This led to some other code being affected, specifically code where methods had the following type of signature:

auto_ptr<char> Func() {
    auto_ptr<char> t(new char[10]);
    // Do something to set t to something
    return t;
}

This looks neat, and is apparently a good idea to ensure that allocated objects are automatically delete'd as part of the auto_ptr destructor. However, this messes things up in other parts of the code since once again for similar reasons as above.

The resulting pattern rule is:

  • Always return a pointer, not an auto_ptr, when an object is allocated.
  • Never store a pointer, always wrap it in a auto_ptr object when it's kept around for more than passing on in the same statement.

Now we get the best of both worlds, and less things to send up via function return. The above is not guru-level C++, but it helped me to clarify things.

I'm a strong believer in what I call "code policy". Code policy is about formulating rules of coding, a bit like design patterns but more generic small snippets of wisdom accumulated through experience. I use probably 50 - 100 such "code policies" whenever I write code, and it's certainly been extremely useful. It takes the burden out of making many small decisions, and I may start document them for peer review in the future - that could be fun!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

AxCrypt2Go | C++ | Programming

Open source pros and cons

by svante@axantum.com 2006-01-02 15:12

Started going through lots of old feature requests on SourceForge, incorporating them into the feature list of the next version. It seems I won't have any trouble keeping busy this year either! There are so many nice things to implement - if I get around to 50% of the features and ambition, AxCrypt2Go will be a very nifty and useful little utility!

In the background I'm also thinking about whether the *nix gettext library really is the right way to go. First of all I have not managed to convince the maintainer that programming defensively against memory leaks is a good thing - so it leaks (or rather permanently allocates and does not free on exit), messing up my chances to make a proper program without investing time and material into tools and stuff. I can see why C/C++ programs traditionally have such problems with leaks with that view. It's really frustrating, as I do not want to keep a custom version of code in my code base. Did that once with zlib - been there, done that. Not again. Also, I'll have to delve deeper into gettext to figure out a way to place language packs in smarter location than ..../se/LC_MESSAGES/AxCrypt2Go.so . Haven't really tried either - anybody out there who just knows? Send me a mail.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

AxCrypt | AxCrypt2Go | C++ | Programming

Programming it real

Name of author

When I'm not riding my bike, I keep fairly busy trying to make a living as a self-employed programmer.

E-mail me Send mail

Recent comments