KIS Systems, Inc - Contract Programming for Unix/Windows/Web in C++/C#/PHP/Qt/.NET and other technologies.

KIS Technoblog

Technical ruminations from our chief codemeister – Rick Berger

Archive for the 'software' Category

Namespaces – A Good Thing

Posted by rickb on 30th November 2007

I’m becoming more of an advocate of namespaces.

Traditionally, they’ve been defined informally by prefixing function and/or variable names with some unique mnemonic – such as ‘Q’ for Qt stuff, ‘wx’ for wxWidgets stuff, or even something as potentially ambiguous as ‘C’ for MFC stuff.

All well and fine and helpful, but you can still run into name collisions. For instance, I was browsing the mac utility headers a while ago and ran into a raft of ‘QT’ names – for QuickTime. Dangerously close to ‘Qt’.

The newer languages, such as C# and Java, enforce namespaces. In C#, you can’t write a single line of code, unless it’s wrapped in a namespace.

The usefulness was heightened for me in a recent project with C#: we were attempting to use an underlying module for statistical binning and drawing. But, we needed a highly optimized version so we could dynamically select bins and draw the results on the fly.

Some customization was in order.

Now, in an ideal world, we would go to the creators, explain what we needed, and collaborate with them to get the enhancements we needed. In the real world, though, the creators are off doing something else highly urgent, and we’re not on their ‘to-do’ list.

So, we did the undesirable: clone the module and get the modifications in, ourselves.

Of course, we didn’t want our version to collide with the older version. How to avoid? Simple: since it’s C#, there’s guaranteed to be a namespace associated with the module. Just change the namespace of our cloned module and proceed.

Voila! (I’m writing this in Paris, so I get to stick in my bit of francaise.)

Of course, things aren’t quite so simple – the binning module used several namespaces (a bit of fragmentation overkill, IMHO), and relied on other underlying modules, which had to be detected and determined if they needed cloning, namespace changes, et al. It still can get pretty ugly. But the namespace feature helped.

Another time when namespaces would have been useful was when a somewhat recalcitrant vendor provided a package with a modified libjpg. Naturally, none of our stuff that relied on libjpg worked any more after we integrated their new code…

After the initial shock and dismay, we had to come up with a solution – the vendor was in Germany and were perfectly happy with the solution, as it was, so were disinclined to make changes. In that case, I think we isolated their libjpg into a fully resolved dynamic library along with their system, and didn’t export the jpeg functions. A pain in the ass, to be sure.

Back then, namespaces weren’t widely supported in the compilers (notably, Microsoft), but had they been, it could have been a better solution. Granted, libjpg is in C, but it can be compiled as C++ and then wrapped in a namespace that would prevent it from colliding with our libjpg (assuming we could get the vendor to cooperate.)

As software grows, and applications become more of a ‘mash-up’ of different modules, namespaces can become an increasingly important construct to eliminate conflicts. For instance, if Trolltech wrapped everything in a ‘TT’ namespace, or, better yet, a ‘TT_QT’ namespace, it would disambiguate them from any other code that might just happen to start with ‘Q’. Like ‘QT’ for QuickTime.

So, in my current effort (creating an extension for Qt), I’m wrapping everything in a namespace (’KIS_QX’). It means users will have to sprinkle ‘using’ statements in their code. A bit onerous, admittedly, but I think utimately that namespace usage is a good habit to get into.

Posted in .NET, C++, CSharp, Programming, Qt, Software Development, software, wxWidgets | No Comments »

MacBook Saga, Cont’d

Posted by rickb on 28th November 2007

So, I think I finally have the MacBook situation stabilized. The machine is running well, and I’ve been working it pretty hard, usually running two Parallels VM’s and the MacOS, itself. I normally have a second monitor hooked to it for development purposes.  My only complaint is the ‘chicklet’ keys sometimes don’t register a hit.  I have to be somewhat deliberate in my typing.

Been compiling Qt4.3 in various configurations for all platforms, and the huge disk is just gobbling them right up. That’s nice. I understand I can upgrade the memory to 4gb. Have to future that – it’s not in the budget, right now. But I wonder if getting it would allow me to run three VMs at once? I’d like to have the FBSD server, XP, and Ubuntu Linux running simultaneously alongside the MacOS. That might take the next generation hardware leap (which should be out in, what? A week or two?)

I do assiduously avoid getting any liquids near it…

rickb

Posted in Mac, MacIntosh, Parallels, Qt, Virtual Machine Software, software | No Comments »

Just When I Thought Things Were Fine…

Posted by rickb on 22nd October 2007

While constructing the previous post, I noticed a number of things I didn’t like, particularly in the list editing – the lists are cramped together, the lineheights aren’t right, and there’s no way to ‘paragraph off’ a list, like so:

  • This is a list item.
  • This is a continuing thought within the list item.
  • This is another list item.

Notice the break in the continuing item. That’s achieved with a special list item (using <br/> is crude – hard to style.)

If you specify a css rule for a continuing list item like so:

li.continue { list-style:none; margin-top:0.4em!important; }

you can define a ‘continuing list paragraph’. Problem is, when WordPress sees such a thing, it strips it out.

So, I’ve had to crawl through the code and figure out what the heck is going on. Way down deep inside, there’s a file that lists ‘allowedposttags’ – an array of arrays following canonical rules. A bit of a hack, and I’ve got <li> behaving the way I want.

Just have to save off the changes in case of upgrade.

Another thing I like is a stand-off paragraph – something to introduce a new thought in the text, without having to use something like a header. That’s how this paragraph is defined. Again, another class description:

p.class  { padding-top:2.0em; }

Or some such thing, and now I have a stand-off paragraph.

As usual, packages are great – they get things going. But, to get what you want, you have to dig inside of them and control them by the tail. WordPress is no different.

Posted in PHP, Programming, css, software, wordpress | No Comments »

Let Chaos Reign!!

Posted by rickb on 22nd October 2007

Ok, I’ve got about ten things going at once, here. I’m the incarnation of Andy Grove’s pre-commitment exploration dictum: Let Chaos Reign!! Of course, the other side of that dictum is that when you’re committed to a particular direction, you apply the inverse: Reign Chaos In!!.

Well, it keeps me from getting bored between gigs, anyway.

The top four things (as of the moment) are:

  1. Getting the Zend IDE up and running for PHP. Ostensibly, this would seem to be simple, but things are complicated by virtue of the fact that Zend has created a second IDE based on Eclipse. Eclipse is a good thing – it not only supports PHP, but HTML, CSS, XML, and the rest of the alphabet soup of net languages, for development on the net. But, it supports application development languages, as well, most notably C++ and Java.
  2. Assiduously avoiding Java (don’t like things that consume half the machine’s resources to run a ‘hello world’ program), but C++ is right in there.
  3. Ubuntu VM configuration. Ok, I like ubuntu bunches. I hate to say it’s almost ‘Windows-like’ in ease of use, but it is. It has what must be the best update manager in the open-source world – it really does ‘just work’.
  4. Qyoto investigations: C# and Qt – what I think may emerge as the best cross-platform agile development environment, ever. C# has all the advantages of Java, without the overhead penalties. Qt is the best cross-platform windowing environment, albeit the cost is almost usurious, at least for small developers. Maybe in the future there would be a wxSharp effort? Not sure how that would work with wxWidget’s message map architecture…
  5. I’ve put this up under monodevelop on the ubuntu system, but it’s not working (even though monodevelop says it is. Just copies down the reference .dll’s.Real anxious to get this working on as many platforms as I can.
  6. Getting the WordPress rss feed plugin working. That’s the last piece of this blog. It’s installed, it’s recognized, I can set things up, but it doesn’t output anything.
  7. Getting that done will finish up the blogging system.

It sounds like a lot, and it is, but it interleaves – a lot of these are embryonic efforts (especially Qyoto) and they require some feedback from forum query’s before I can continue. So, I can drop one while waiting for a response and pick up another. Or pick up the other when I get a neuron spark.

Posted in C++, CSharp, Linux, Mac, PHP, Platforms, Programming, Qt, Virtual Machine Software, software | No Comments »

Back to PHP-land – Zend Environment

Posted by rickb on 18th October 2007

Enough playing around with the Ubuntu installation – I have to fix up a website.

PHP has been great for coding up web apps and even general website stuff. Debugging has been a bit wanky, though – up to now, my methodology has been to include a ‘debug’ class, sprinkle a few statements around (glorified print statements), and then remove them when it’s done. By removing the easily identifiable debug include (do a global search on the .php files), the various debug statements come up unresolved and I can insure they don’t dangle around in the production site.

Honestly, since there’s no heavy compilation step, doing this sort of thing in PHP is blindingly fast – make an edit, refresh the page, and you see the change, instantly.

But, you have to modify the code – sometimes extensively to get down to the problem – and then you have to re-modify it back to where it was minus the bug, once you have the fix.  It’s also a bit tough to do hidden form-response pages, and the like.

A real debugging environment would eliminate those issues.

Zend IDE

So, I popped for the Zend Pro IDE — the pro version supports remote debugging (which I think is essential vs. local. Pages may or may not behave correctly in a local installation, especially on Windows (where the IDE has to reside.) That’s why I put up a developer server – it’s a very close mirror of the production server. Thus, I want to debug on the development server.)

Obviously I use IDE’s for other development environments, but the fact is the edit and turnaround cycle for PHP has been so fast, I’ve put it off, for a long time. Now that I’ve decided to bite off the effort and cost, I’m finding it’s a bit of a hassle to set up, especially for virtual hosts.

Hopefully, it will be worth the effort and cost, once it’s up.

Posted in PHP, Programming, Web Development, server, software | No Comments »

If You Want It Done Right…

Posted by rickb on 15th October 2007

So, there I was – happily using the Google Blogger to keep things on my site, and keep me from having to install yet another piece of software on my server. It was all working fine, until Google’s Blogger facility to host the pages here (to drive the search engines) broke.

And, gathering from comments from others who were experiencing the same problem, Google did not appear to be inclined to fix it – at least not anytime soon.

What’s a diehard techie with a penchant for wordsmithing to do?

Install my own, of course. Thus, a subsequent installation of WordPress to this site, importing the Blogger version into it via the .rss feed, a bit of server redirection to go from the old file-based to the new database-based format (and new sub-domain to serve it), and lo and off – we’re running again with a self hosted blogging system.

Of course, I need to activate the .rss feed stuff, activate tags, get the keywords right, and do something about this theme…

It never ends.

Update: 16-Oct

Voila!

WordPress is up and running, blogs are transported over, a reasonable theme is selected, and overall, things look pretty reasonable. This is the ‘mu’ (multi-user) version of WordPress – I chose it in the event I want to put other blogs up for various domains on the server (I have several.) It’s a bit wanky, but I can make it do what I want.

Only issue left is the pic – it’s a bit scruffy looking. have to clean that up, a bit.

Onward…

Update II: 18-Oct

Chose a different them – no picture issue, after all. I like this one, a lot. It still took some tweaking, but it’s a nice, semi-formal techie look. And there’s room on the side for something or other…

rickb

Posted in blog, server, software, wordpress | No Comments »

wxWidgets and COIN: The Zero Cost Way To Write Demos

Posted by rickb on 15th November 2006

I’ve extolled the virtues of Qt extensively, and will continue to do so – it’s a great toolkit for cross-platform UI development.

Same for Open Inventor (TGS’ version, particularly), for the 3D graphics world.

But, getting those environments is costly: enough to consider having to mortgage the baby and the house, if you don’t have the backing of a major corporation.

Thus the dilemma I faced when needing to write an architectural feasibility exploration program. What to use?

We had Open Inventor, but no Qt. And I needed it longer than a month, so the trial version was not a consideration. The first attempt was to use our OIV with the straight Win32 API.

Yeah, ok, you can do that, but it’s a lot of lines of code, and it isn’t quick. Not exactly an agile environment. Need to do something better.

The Solution

Web investigations led me to wxWidgets for the UI. wxWidgets might be considered the poor sister to Qt (although devotees would argue that.)

And, for an Open Inventor solution, there is either the horse’s mouth – SGI themselves – or the COIN implementation from the Systems In Motion folks in Finland, who provide an open-source version. The SGI is open-source, too, but it doesn’t come with an SoWin implementation, so COIN looked like the better answer.

And, they’re both free – completely free in the case of wxWidgets – less free, but ok for internal/demo use in the case of COIN.

The Conclusion

They worked great! I had to hook up the SoWin directly into the wxWidgets idle loop, but that’s not onerous. Create an SoWinExaminerViewer, parent it with a win HANDLE (available from the widget), and things were spinning, soon enough.

More to discuss in this line, but they look very promising for low-budget investigations or even products that can’t sustain the full investment of their much more expensive counterparts. This is much more true in the case of wxWidgets, since it’s use is free and completely unrestricted. If you’re going to use COIN in a commercial product, you will have to pay…

More to come…

rickb

Posted in C++, COIN, Open Source, Programming, Qt, software, wxWidgets | No Comments »

Win32 API – Can’t Get Away

Posted by admin on 27th September 2006

Ran into a window controlling problem with C#/.NET – a couple of things in the API aren’t exposed. The first is (are, really), the messages WM_NC* (used to detect non-client mouse hits, etc.) The second is the ability to set window settings via the SystemParametersInfo call. In this case, I want to use SPI_{SET/GET}DRAGFULLWINDOWS. C#/.NET exposes the GET functionality, but not the SET.

The first case is handled relatively painlessly – simply a matter of putting a message filter on the app and then watching for the hwnd and WM_ message of interest. You don’t want to get too carried away with message filters – every message that goes through the message pump is forwarded to the filter, first, once installed. So, you install it only when you need it, and remove it when you don’t. And just do minimal processing, while you’re in there.

The second problem requires an interop call to the user32 dll and getting that all set up properly. Not terrifically taxing, but not perfectly straightforward, either. It’s unfortunate the named constants for the SPI_, WM_, etc values aren’t available in the toolkit. You have to redeclare them in your code, somewhere (don’t want to use raw numbers, for sure.)

On one hand it points out the shortcomings of a kit like C#/.NET – on the other, it’s always nice to know I can get under the cover/lift the hood when I need to.

rickb

Posted in .NET, Programming, Win32 API, Windows, software | No Comments »