31 Aug 2009 @ 8:49 PM 

For me, today is the last day of the summer holiday period ( :( ). School will start at the 21st of September, but I decided to follow some extra courses meant to bridge the knowledge gap between people who had a lot of maths and sciences, and those who didn’t. These courses start tomorrow, and then continue for 3 weeks.

Posted By: Jeroen De Dauw
Last Edit: 31 Aug 2009 @ 08:49 PM

EmailPermalinkComments (0)
Tags
Tags: ,
Categories: Uncategorized
 28 Aug 2009 @ 12:26 PM 

I just finished creating the developers manual to extend Semantic Maps. Like the manual for Maps, it targets developers who want to add support for a mapping service to one of the features Maps and Semantic Maps support. It goes over all the key aspects of the PHP code, like how to add your own service, how to create a query printer or form input class, and what the most notable differences with the parser function classes are. Examples and out-takes are also provided. The manual does not cover the JavaScript aspects of adding your own mapping service, since that code really depends on the API it uses, and although the overall structure might be similar, the code itself most likely is not.

Posted By: Jeroen De Dauw
Last Edit: 28 Aug 2009 @ 12:26 PM

EmailPermalinkComments (0)
Tags
 28 Aug 2009 @ 12:20 AM 

While translating some of the C# code of MyDownloader to VB.Net for the .Net download library, I’ve already come across quite some awkward code. IMHO, the underneath example could go into the code horrors section of The Code Project.

        private void RestartDownload()
        {
            int currentTry = 0;
            Stream stream;
            RemoteFileInfo newInfo;

            try
            {
                do
                {
                    lastError = null;

                    SetState(DownloaderState.Preparing);

                    currentTry++;
                    try
                    {
                        newInfo = defaultDownloadProvider.GetFileInfo(this.ResourceLocation, out stream);

                        break;
                    }
                    catch (Exception ex)
                    {
                        lastError = ex;
                        if (currentTry < Settings.Default.MaxRetries)
                        {
                            SetState(DownloaderState.WaitingForReconnect);
                            Thread.Sleep(TimeSpan.FromSeconds(Settings.Default.RetryDelay));
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                while (true);
            }
            finally
            {
                SetState(DownloaderState.Prepared);
            }

            try
            {
                // check if the file changed on the server
                if (!newInfo.AcceptRanges ||
                    newInfo.LastModified > RemoteFileInfo.LastModified ||
                    newInfo.FileSize != RemoteFileInfo.FileSize)
                {
                    this.remoteFileInfo = newInfo;
                    StartSegments(this.RequestedSegments, stream);
                }
                else
                {
                    if (stream != null)
                    {
                        stream.Dispose();
                    }

                    RunSegments();
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception ex)
            {
                lastError = ex;
                SetState(DownloaderState.EndedWithError);
            }
        }

Why? It uses breaks and returns in the middle of the code, like if C# is some lame generic language without selection structures. The use of the try-catch bloks also seems odd. Also have a look at the condition for the do while loop – lol. The only thing missing are a few GoTo statements, which would have convinced me to print this out and torture fellow geeks with :D

I started off translating this literally, but got so annoyed by the bad coding practice I decided to attempt to rewrite it. I say ‘attempt’, cause code written like that is not easy to understand, esp for people who are used to ‘decent’ structured code. I splitted the code into 2 subs instead of one, removed all breaks, returns, the insane do while true and put only the required code in try catches.

        Private Sub RestartDownload()
            Dim tryNr As Int32 = 0
            Dim stream As Stream
            Dim newInfo As RemoteFileInfo
            Dim reachedMaxTries, hasError As Boolean

            Do
                m_lastError = Nothing

                Me.SetState(DownloadState.Preparing)

                Try
                    newInfo = Me.ProtocolProvider.GetFileInfo(Me.FileLocation, stream)
                Catch ex As Exception
                    m_lastError = ex
                End Try

                hasError = m_lastError IsNot Nothing

                If hasError Then
                    tryNr += 1
                    reachedMaxTries = tryNr >= Me.Settings.MaxRetries
                End If

                If hasError And Not reachedMaxTries Then
                    Me.SetState(DownloadState.WaitingForReconnect)
                    Thread.Sleep(Me.Settings.RetryDelay)
                End If
            Loop Until Not hasError Or reachedMaxTries

            If hasError Then
                Me.SetState(DownloadState.EndedWithError)
            Else
                Me.SetState(DownloadState.Prepared)
                Me.RestartSegments(newInfo, stream)
            End If
        End Sub

        Private Sub RestartSegments(ByVal newInfo As RemoteFileInfo, ByVal stream As Stream)
            If Not newInfo.AcceptRanges Or newInfo.ModifyDateTime > Me.FileInfo.ModifyDateTime Or newInfo.FileSize <> Me.FileInfo.FileSize Then
                m_fileInfo = newInfo
                Me.AttemptToStartSegements(stream)
            Else
                If stream IsNot Nothing Then stream.Dispose()
                Me.RunSegments()
            End If
        End Sub
Posted By: Jeroen De Dauw
Last Edit: 29 Aug 2009 @ 01:46 PM

EmailPermalinkComments (0)
Tags
 27 Aug 2009 @ 7:45 PM 

Today I again did some work on my .Net download library project. I added some stuff to the main class, Download, and also created the base of the DownloadManager class. This class will allow you to work with multiple downloads at once, by putting them in a list, and providing a variety of methods and properties that enable you to gather info or work with all or selections of the downloads.

I’m getting close to actually be able to start debugging the code, something which can take up quite some time with so much untested code.

Posted By: Jeroen De Dauw
Last Edit: 27 Aug 2009 @ 07:45 PM

EmailPermalinkComments (0)
Tags
 26 Aug 2009 @ 6:04 PM 

Today did quite some work on .Net download library, the successor to my current FileDownloader class.

I started off with finishing the protocol provider code (see revision 4), and then went on adding a lot of the still missing stuff to the Download class (see revision 5), which now counts almost 800 lines of code. Most changes I made are pretty much C# to VB.Net translation from MyDownloader, one of the projects I’m basing this library upon. Doing this translating also comes with the challenges of leaving out code that’s not needed (for example a hook system for protocol providers), holding into account all the name changes I’ve made, and at some points revising the logic layout of the code, since I don’t agree with the original design. I also had some great fun with working with SyncLock statements and interfaces.

Although the project is still far from a first release, the basic structure is taking form, and I’m beginning to see where and how future features will need to be added :)

Posted By: Jeroen De Dauw
Last Edit: 28 Aug 2009 @ 04:12 PM

EmailPermalinkComments (1)
Tags
 25 Aug 2009 @ 5:19 PM 

I’m about to release a new version of Maps and Semantic maps. Since it does not feature any mayor structural changes, it’ll be added to the 0.3.x branch, and so become version 0.3.3. This version features some small, but important bug fixes, some code improvements, and also some new features.

New features

  • GeoNames geocoding support. Since the initial release, me and Yaron have been searching for an open source geocoding service that’s completely free to use. Such a service is needed cause a lot of people do not want to use Google Maps or Yahoo! Maps cause of their licences. We did quite some searching, but didn’t find anything decent. While discussing an issue about DMS notation on one of the wiki mailing lists, Joel Natividad suggested using GeoNames.
  • Wiki mark-up support for the title and label parameters. One common request for Maps has been to add the ability to display images in pop-ups. The value of both parameters now gets parsed as wiki text, enabling you to pass along links, images and other wiki mark-up. I’ve created a to-do related to this: enable to pass along complex wiki mark-up. This is currently not possible, since Maps can not determine if a property separator (|) is part of one of it’s parser functions, or one nested in it. This makes you unable to specify the location, width, height, and other properties of an image.
Maps displaying an OpenLayers map with a pop-up containing wiki markup rendered to html

Bug fixes

  • Some very small bug (a = b instead of a == b) in a function used to determine the geocoding service. This caused the ‘default override mechanism’ that I put into place, to prevent Maps from using a licensed geocoding not together with the related mapping service when no geocoding service was provided. Cause of teh error, it always got set the the Google geocoding service.
  • Implemented missing method getName in the Query Printer handler for the map result format. The absence of this function caused some errors to be displayed on the Special:Ask page.

Refactoring

  • I refactored up some common functionality from the geocoder classes to the base geocoder class, after Yaron suggested doing this. Not a big deal, but still nice.
  • Yaron changed the default zoom for OpenLayers maps.

If no more small, or easy to fix bugs or feature requests trun up, the next release will be 0.4, which will feature some big new functionality, like defining custom base layers (for OpenLayers), custom overlays, lists of points next to the maps and probably also a thoroughly revised hook system.

Posted By: Jeroen De Dauw
Last Edit: 25 Aug 2009 @ 09:53 PM

EmailPermalinkComments (7)
Tags
 24 Aug 2009 @ 6:37 PM 

Like every self respecting geek, I have a collection of science fiction books, mainly Star Wars. Today I found a bunch of Star Wars books in a second hand English book shop in Gent. Surprisingly, quite some of the books where pretty recent, including ‘The new Jedi order‘ and ‘Legacy of the force‘ books. Even Timothy Zahn’s just released novel Allegiance was present.

I bought 14 books, and will probably go back after I’ve checked some stuff about some other books. The funny thing is that each book was €3. So the total was €3*14. WIN! (That’s 42, for those who don’t get it!) I managed to get a discount though, but it still stays a win :D

Posted By: Jeroen De Dauw
Last Edit: 24 Aug 2009 @ 06:37 PM

EmailPermalinkComments (2)
Tags
Tags: , ,
Categories: Uncategorized
 21 Aug 2009 @ 2:37 AM 

Now the Google Summer of Code coding period has finished, I can divide my attention between multiple projects again. Since I’ve been doing PHP and JavaScript only for over 2 months now, I’m starting off with taking a PHP-break. This means I won’t do any development of mayor new features for Maps or Semantic Maps, and definitely won’t work on any other PHP project. Of course I’ll still ensure bugs get fixed for my mapping extensions, and help people out with code when needed, but that’s about it. So basically I’m closing my Zend Studio, which has become one of my most used applications in the last months, and starting my Visual Studio again. Now I think of it, this is really awkward. I used to start my VS practically every time I booted my computer for over a year, and then only opened it a handful of times in a 2 month period.

So, what am I going to work on now? One of my last projects before I started GSoC was a VB.Net background file downloader, of which I released an article on The Code Project, and later on created a C# version. I got quite some positive feedback on this project by people, although it was initially created with the sole purpose of helping that needed a simple downloader someone out, to improve my own skills, and to demonstrate how to create a simple to implement downloader. I’m now continuing this project, by rewriting it from scratch, to both add some mayor new features, and mess around with some multi-threading stuff I’ve been wanting to try out for months now.

The mayor new features that will be added are simultaneous downloads (the current classes only support one download at a time), segmented downloads (woot!), download priorities and bandwidth limitation options. This will require a nice OOP approach, with some more advanced multi-threading. I’m basing part of my code on MyDownloader, an extremely nice C# downloader, which has quite some more functionality then what I’m doing. It’s more extensive then required for most people though, and not all that easy to implement. I also don’t really agree with some naming choices, and it lacks both code docs for devs that want to modify it, and devs that want to implement it. So clearly, I’ll put a lot of effort in keeping the new project as small and to-the-point as possible, and pay attention to easy of implementation, and usability. Another obvious difference is that this project is in VB.Net and not C#.Net. This has more advantages then disadvantages IMHO. If the project is compiled to a .dll or is used in a multi-project solution, it simply doesn’t matter what language it uses. A lot of casual programmers don’t know how to handle either, and the majority of these uses VB.Net, and not C#. And the ones that do know C# are more likely to know VB.Net then the other way around.

I’ve created a project on SourceForge to host the code, and be able to commit to the project’s SVN. Since the project now contains multiple classes, I renamed it to .Net DownloadLib.

After that project I’m planing to put some real effort into my mapping extension for MediaWiki again, and possibly to have a look at Python and Ruby. When school starts again, somewhere half way through September, some new project opportunities will probably arise for me, but I guess I’ll see that then. I’m also looking forward to ‘learning to program’ at school, which is destined to give me some great laughs. Luckily for me I’ll have to learn C++ at university, so I won’t be totally bored with it. I hope they don’t drive the low-level aspects of the language to far, since that’s pretty useless in today’s world IMHO.

Posted By: Jeroen De Dauw
Last Edit: 21 Aug 2009 @ 05:29 AM

EmailPermalinkComments (0)
Tags
 19 Aug 2009 @ 9:17 PM 

I just created a new home page for bn2vs.com. It’s based on (read as ripped off) the layout of my forums, and contains links to the most important sub domains, including this blog, and some external links.

The new home page for bn2vs.com

Posted By: Jeroen De Dauw
Last Edit: 19 Aug 2009 @ 09:18 PM

EmailPermalinkComments (0)
Tags
Tags: ,
Categories: Programming
 16 Aug 2009 @ 10:41 PM 

Today I finally announced the new releases of my extensions on a few wiki mailing lists. I also gave the Semantic Maps documentation another overhaul, and created a manual on how to extend maps.

This manual targets developers who want to add support for a mapping service to one of the features Maps and Semantic Maps support: parser functions, query printers and form inputs. I still have to create the manual for the later two features though. Currently, the subjects of adding a new mapping service, adding parser function support and creating new geocoder classes are covered.

I hope to get the Semantic Maps part done by tomorrow, as a nice conclusion to my GSoC project.

Posted By: Jeroen De Dauw
Last Edit: 16 Aug 2009 @ 10:41 PM

EmailPermalinkComments (0)
Tags
Change Theme...
  • Users » 101
  • Posts/Pages » 132
  • Comments » 85
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About me



    No Child Pages.