« August 2005 | September 2005 Archives | October 2005 »

Reader Questions

| 0 Comments
Ahsan Askari asked the following in a comment to one of yesterday's posts: Just like to know whether you use external libraries specially 'BOOST' in your commercial projects and related pros-n-cons ? Also i like to know your initial strategy of Software development. I mean you've written a lot about your coding and tsting techniques but i like to know how you start the project, whether you believe in UML and how you carry out analysis. Here's the answer...…

Make sure you are doing RAII properly

| 0 Comments
There's an interesting post over on the Joel On Software forums about RAII in C++. The original poster's problem is clearly stated in the first line of their question: When the constructor for CTheClass runs, I want to acquire 3 resources. These 3 resources will be freed in the destructor (that's RAII, right?) Wrong.…

How refreshing

| 0 Comments
One of the things that I've always been a bit unsure of is the claim by dynamic languages crowd that static typing buys us nothing as the unit tests solve the same problem. It's a nice idea but I'm a bit scared that the unit tests required would have to be quite a bit better than my unit tests usually are... Anyway, it's nice to see Brian Marick posting about how his usual retort of 'the unit tests will catch the bugs that the static type checker would' was wrong...…

I've been lazy this week

| 4 Comments
As I mentioned in an earlier posting I've been working on a tool this week. I'm too lazy to do a job manually and so I decided to write a tool to help me do it... Note: the deadlock detector mentioned in this blog post is now available for download from www.lockexplorer.com. The tool is designed to help me track down deadlocks in code. I decided I needed this tool because I wrote a piece about debugging deadlocks in Visual C++ and realised that using trial and error to locate deadlocks in some client code simply wasn't good enough. The…

It's Friday, so...

| 0 Comments
This G'n'R/Beatles mashup works surprisingly well, and brought a smile to my face earlier in the week - via Code Circle. And whilst we're on the subject of music, Filip has started uploading some of his techno mixes...…

Observing lock contention

| 0 Comments
The deadlock detection tool that I was working on last week is coming on nicely. I managed to locate two potential deadlocks that had never caused any problems in code that is running live on a client's site. Once I had a report from my tool it was relatively easy to fix the problems. Both of these were real bugs that just hadn't bitten yet. Today I added some rudimentary lock contention monitoring to the tool and the results seem to be quite useful... Note: the deadlock detector mentioned in this blog post is now available for download from www.lockexplorer.com.…

Lock Free

| 2 Comments
I just ran my OpenSSL echo server test harness and ran the server under the deadlock tool. The results are interesting and show that the main source of lock contention on the server is for the lock that protects the buffer allocator. Every read or write requires a buffer to be allocated and released. The SSL server actually requires more than one buffer for each read and write as passing the data through the SSL connector causes further buffer allocations. Way back when we first started developing our server framework I boosted the performance quite a bit by having the…

Viewing lock lifetimes

| 0 Comments
I added some more monitoring to the deadlock tool. You can now view the entire life cycle of the locks, from initialisation, through usage to destruction. The lock usage figures put the contention figures in context as you can see how often the lock was acquired by each thread and compare that to how often there was contention... Note: the deadlock detector mentioned in this blog post is now available for download from www.lockexplorer.com.…

What's with CreateProcess and managed exes?

| 1 Comment
I have some code that launches another process in a suspended state, does some stuff (tm) and then resumes the process. This uses CreateProcess() and works fine on unmanaged exes. When I try and launch a manged exe with the same code the process starts up in a running state rather than in a suspended state. The docs for CreateProcess() don't mention any strangeness. Does anyone know of any docs that explain what's going on?…

Lots of answers but little help

| 2 Comments
I don't read many newsgroups, I don't have the time, but I take notice of the Windows networking ones as they're low traffic and they're relevant to a lot of the work I'm doing at present... I've noticed something that's starting to bug me a bit and I'm not sure if it's specific to Microsoft related technology newsgroups but I have a feeling that it might be... Anyway, the thing that bugs me is that there are some very active people who feel that they have to answer almost all new messages yet actually add very little value.…

Change is good

| 0 Comments
I like to experiment with new coding practices. Not too many at once mind you. I tend to add one new thing to how I work, operate in the new way for a while and then decide if the new way is worth adopting as a habit going forward. By adding new practices every so often I push my work habits in new directions; some of it is good, some is not so good, but all of it is an opportunity to learn. Sometimes during these experiments I try and go back to first principles; everyone says goto is bad,…

In summary, don't summarise too soon

| 0 Comments
I've been working on my deadlock detection and lock monitoring tool quite a lot this week; that and fixing the issues that it's been highlighting. Yesterday I decided that I was drowning in data and that I really needed a GUI and, as I thought about how the GUI should work, I realised that I really didn't have enough data. Note: the deadlock detector mentioned in this blog post is now available for download from www.lockexplorer.com.…

Pimp my hide

| 0 Comments
As some of you may have guessed, the fact that I've spent the last week working on a tool for my own use means that I'm a little light on client work right now. If anyone needs a Windows C++ guy drop me a line. There's plenty of samples of my work on this site and more on CodeProject. I'm more than happy to quote you a fixed price for stuff if you know what you want. I'd prefer to be writing new code for you, ideally internet server style stuff, but I can turn my hand to most things…

More thoughts on change and typedefs

| 0 Comments
Of course, now that I'm well into using the "option 4" I start to remember why I kept sliding back from options 2 and 3 towards 1. Although option 1 uses native types instead of typedefs which is bad for all the reasons I listed in the previous post, the other options only give the illusion of type safety because they use typedefs...…

Assert is evil

| 13 Comments | 1 TrackBack
Christopher Baus has been away and whilst he was a away his HTTP proxy shutdown due to a bug which caused an assert and his site was unavailable. Personally I abhor assert; but I completely agree with what Chris is talking about.…
Google have a beta of blog search engine up and running here. It looks good, seems to work and does pretty much what you'd expect. I'm left wondering why it's needed though... After all, how to you define a blog? How is a blog different to a product company's web site that happens to publish news and information via an RSS feed? Now that Google has categorised part of the search space as "blogs" I wonder if they intend to move these sites off of the main Google search; much in the same way that Google Groups separates news group…

Rootkits

| 2 Comments
Just saw a mini review of Rootkits: Subverting the Windows Kernel over on Ted Neward's blog. Looks like the perfect follow up to Undocumented Windows 2000 Secrets as I continue my slow progress towards being able to write Windows device drivers... From the sound of Ted's review it's written in a similar way to the Undocumented secrets book; showing you how to write drivers which aren't for real hardware... Anyway, I popped over to Amazon and it was being recommended on the front page for me due to my past purchases. It's now ordered, more once it arrives.…

Overriding virtual functions, C# is better than C++

| 2 Comments
I've been merging my UDP framework development branch back to main, building all of my example servers and running all of the "black box" server tests for The Server Framework. In doing so I've experienced the pain of changing virtual function signatures. This is one area where C# syntax is definitely better than the C++ syntax...…
There's a lot of noise coming out of the Microsoft PDC right now. Something that interested me was the future direction of C#; you can grab the spec from here. It seems they're adding "extension methods" which, to me, appear to be just syntactic sugar to make up for the lack of free functions...…

Thoughts on testing COM objects

| 5 Comments
Ben over at Code Circle is thinking about unit testing COM objects. I did quite a lot of this back in 2000 when I was working with an investment bank. The first thing you need to realise is that COM is just an interface layer; so lots of your unit testing should be done on the code that the COM interface layer calls into. You can test pretty much all of the actual functionality of a COM object without bringing COM into the mix at all. This keeps the tests nice and fast. So, rule one for testing COM objects…

Sacrificing precision for ease of use?

| 6 Comments
I'm probably jumping the gun a little here as I can't find Herb Sutter's slides that Matt Pietrek is referring to, but... Once again I find myself asking why is it actually useful to repurpose the auto keyword in C++... The idea seems to be that rather than this: foo::iterator i = myList.begin(); You can do this: // Type of 'i is inferred from the assignment auto i = myList.begin();…

Whilst I'm on the subject of code communication

| 0 Comments
I've never really got to grips with the STL's algorithms; actually that's not strictly true, it's really just for_each() that I have most problem with. To me, code that uses for_each() simply doesn't communicate as clearly as code that uses an old fashioned loop.…

Concepts and C++ Templates

| 0 Comments
The slides from Herb Sutter's C++ Futures talk (TLN309) at this year's PDC refer to "Concepts" in C++ templates; for me this is a much more useful addition than the auto keyword repurposing. I'm sure this is something that would make Chris Baus happy...…

Restricting the use of extension methods?

| 2 Comments
Having looked through the slides that Vagn pointed me to in a comment to my recent post about C# v3.0 Extension Methods I can understand, a little more, about the reasoning behind the change to the language. Given that the C# v3.0 spec contains the following warning: "Extension methods are less discoverable and more limited in functionality than instance methods. For those reasons, it is recommended that extension methods be used sparingly and only in situations where instance methods are not feasible or possible. Extension members of other kinds, such as properties, events, and operators, are being considered but are…

Cool

| 2 Comments
Sometimes I think programmers find the wrong things "cool"... This cartoon kinda sums it up ;)…

Three reprints from when COM ruled the land

| 0 Comments
I've just finished posting three reprints from back in 1998 and 2002 when I was working on lots of COM stuff. 1) Sinking connection points in C++ objects - shows you how to use the least COM possible to connect to Connection Points and provides a C++ template that does all of the hard work for you. 2) Designing asynchonous COM components for VB - This example COM component provides three COM objects for using the Win32 Mailslot IPC mechanism. The component may be useful if you need to communicate from VB using Mailslots. However, the reason I wrote it…

New C# v3 features explained in context

| 1 Comment
Ted Neward has a very nice piece about the new language features in C# v3 and how they work together to provide something quite powerful. Go read it! Given that implicit typing, object initialisers and extension methods are all designed to allow LINQ to be a be able to generate classes on the fly and extend existing classes I'd still be happier if they could be optionally restricted from use on 'normal' classes to help prevent the less experienced running amok with these new language features and creating code that has interesting maintenance properties...…

AdSense preview tool

| 0 Comments
The Google AdSense Preview Tool does exactly what it says on the tin. So it's very useful for working out what kind of ads you'd get if you added Google's AdSense to your pages.…

Opera lover

| 1 Comment
The Opera web browser is now free. It's worth giving it a try. I downloaded it after Barry sent me a link to the free registration codes that they were giving away a few weeks ago to celebrate their 10th birthday and I've been using it as my browser of choice ever since. It seems faster than either IE or Firefox and I just feel more comfortable in it than in Firefox; no idea why. I like the tabbed interface, I like the fact that it can remember my last session and I know you can do all of this…

Good stuff

| 4 Comments
I use BlogLines to read my RSS subscriptions. It's pretty good, and now that the performance issues I had initially seem to have gone away, I like it a lot. It's very handy to be able to read my feeds from anywhere and always have them up to date and synchronised. One of the features I like is the little "keep new" check box that each item has; check it and the item stays unread. I use this to keep the interesting stuff on top so that I can write about it later. This week I've been busy with my…

Barry's take on Assert

| 2 Comments
Barry Lapthorn has a response to my Assert is Evil posting where he concludes that assertions aren't needed if you have tests... He also raises a point that I missed which is that the typical assert on Windows machines causes a dialog box to pop up and stop your program giving you the option of debugging it or ignoring the assert, etc. This kind of response is not especially useful if you're writing code that doesn't interact with a user, such as a service, as the code may not be able to show a dialog box ...…

Common knowledge to many, but...

| 0 Comments
Alexis Smirnov has just written a piece on why you shouldn't try and use STL's map::operator[] to find out if a map contains a particular element. It's probably common knowledge for most people using STL, but it's worth repeating for those new to the std::map interface.…

More from Mark and Barry on Assert

| 9 Comments
Mark responded to Barry's response to my post on Assert. Barry then responded to Mark and Kim and I added a little more in the comments. I did have some more to say, but Barry's said most of it... Anyway, so far only Vagn Johansen and the guru's over on comp.lang.c++.moderated disagree with us... Anyone else fancy joining in? What I'd like to see is for someone who's defending to show a situation where the alternatives that we're proposing don't work; but lets try and stay out of the realms of "what if the compiler is broken" and "what if…

Book review: Rootkits by Hoglund and Butler

| 3 Comments
I've just finished reading Rootkits: Subverting the Windows Kernel. Overall I enjoyed it but I'm in two minds about its usefulness...…

Is Raymond Chen's use of Assert valid?

| 16 Comments | 1 TrackBack
I'm sure you're all getting bored on my views on using Assert in modern C++ code by now, I'll try and make this the last one. Last time, I asked if anyone had what they'd consider to be an example of the use of assert in C++ where the usage was valid given my objections to assert. Mark updated this recent posting on the subject to include a link to Raymond Chen's blog where Raymond is discussing COM object destruction and uses an assert... Given that everyone knows that Raymond is a seriously good programmer doesn't his use of assert…
« August 2005 | September 2005 Archives | October 2005 »

About this Archive

This page is an archive of entries from September 2005 listed from newest to oldest.

August 2005 is the previous archive.

October 2005 is the next archive.

I usually write about C++ development on Windows platforms, but I often ramble on about other less technical stuff...

Find recent content on the main index or look in the archives to find all content.

I have other blogs...

Subscribe to feed The Server Framework - high performance server development
Subscribe to feed Lock Explorer - deadlock detection and multi-threaded performance tools
Subscribe to feed l'Hexapod - embedded electronics and robotics
Subscribe to feed MegèveSki - skiing