Despite it has the word “Lite” in its title, the C++ FAQ Lite by Marshall Cline has loads of valuable information about all aspects of C++.
Archive for August, 2008
C++ FAQ Lite
Microsoft FxCop 1.36
Microsoft has released FxCop 1.36 (see MSDN Documentation). This version provides support for .NET 3.5 SP1.
Work Chair
I am thinking about a new work chair for myself, and found two very interesting options (gosh, both are not cheap!) – Bambach Saddle Seat and Aeron chair by Herman Miller.
Thread Synchronization: Wait and Pulse Demystified article on CodeProject describes low-level synchronization between threads in terms of Monitor class and its Wait, Pulse, and PulseAll methods. The MSDN documentation for these methods explains what they do, but not why or how to use them. This article fills this gap and demystifies them.
The Periodic Table of Videos
This is not software-related, but cool nevertheless… The Periodic Table of Videos has a short video about each chemical element. This is work-in-the-progress – videos are constanly updating with new stories, better samples and bigger experiments.
PowerCommands for Visual Studio 2008 is a set of useful extensions for the Visual Studio 2008 adding additional functionality to various areas of the IDE. Examples of commands: Format document on save, Remove and Sort Usings on save, Remove and Sort Usings, and many more.
Debugging Attributes
Improve your debugging: Debugging Attributes to make your life easier post talkes about several interesting attributes that make debugging easier - DebuggerStepThroughAttribute, DebuggerNonUserCodeAttrbute, DebuggerDisplayAttribute, and DebuggerBrowsableAttribute. Really nice.
ACorns.Debugging – The .Net Deadlock Detector is able to detect and report a deadlock inside a running .Net process in a production environment (without a debugging tool like Visual Studio) or even out of a memory dump.
Introduction to D3DImage
Dr. WPF published Introduction to D3DImage on CodeProject. The release of .NET 3.5 SP1 made possible a whole new level of WPF-DirectX interop: a custom DirectX scene can now be composed with a WPF scene using the new WPF’s D3DImage feature.
Just that I will remember these:
- Alexandria Media Library is a loosely coupled suite of media applications written in C#. The architectue of Alexandria allows plugins to be designed to perform any function imaginable and then integrate these with the existing plugins to provide a full application. Plugins exist for: media playback, playlists, tagging with metadata, search for media and metadata, etc.
- FMOD with FMOD Ex Programming API is a revolutionary multiplatform new audio engine featuring e.g. fantastic sounding DSP audio engine, choice of low-level or data-driven API, built-in DSP effect suite and VST support, as well as advanced features such as 2D/3D morphing, 3D reverb support and geometric occlusion, etc.
- MusicDNS by MusicIP provides a method for acoustically identifying digital music and acquiring the correct metadata. MusicDNS consistently identifies the same digital music recording, regardless language or audio file format. Track level fingerprints are finely tuned for accurate matching, and eliminate the cost and challenges of legacy CD data. The database is kept current as new albums are released. Sounds cool!
- MusicBrainz is a community music metadatabase that attempts to create a comprehensive music information site. You can use the MusicBrainz data either by browsing this web site, or you can access the data from a client program — for example, a CD player program can use MusicBrainz to identify CDs and provide information about the CD, about the artist or about related information. You can also use the MusicBrainz Tagger to automatically identify and clean up the metadata tags in your digital music collections.
Google Code University
Google Code University provides tutorials and sample course content, so computer science students (and not only, I would add!) can learn more about current computing technologies and paradigms, e.g. AJAX programming, algorithms, distributed systems, web security, languages. In the Tools 101 section you will find a set of introductions to some common tools used in Computer Science such as version control systems and databases.
Today’s Blogs
- The Old New Thing by Raymond Chen – really nice blog with a lot of in-depth info, e.g. wonderful posts about The implementation of iterators in C# and its consequences (part 1, part 2, part 3), The implementation of anonymous methods in C# and its consequences (part 1, part 2, part 3), a lot of native Win32 topics (e.g. DLLs, processes, controls, etc.), etc. Probably there is no aspect of Windows that would not be covered at that blog! :)
- jaredpar’s WebLog by Jared Parsons – blog of the author of RantPack – a library that features functional programming patterns (tuples, immutable/persistent collections), threading utils (futures, cancelable futures, active objects, various other primitives), etc. The blog is very interesting, and there are many insights into software development topics
I have blogged about it already earlier, but now, when I needed it, I could not find it easily, so I decided to do a bit of “rehashing”…
MSDN Magazine Marshaling between Managed and Unmanaged Code article goes into deep details about marshalling and not only. The cool part: the article has a reference to the P/Invoke Interop Assistant GUI Tool that is handy for doing simple conversions. The tool is now available here, at the CodePlex.
The tool has three tabs: SigExp, SigImp Search, and SigImp Translate Snippet:
- SigExp converts managed signature to an unmanaged signature. It reflects over managed assemblies to find all P/Invoke declarations and COM imported types, and produces the corresponding native C signatures.
- SigImp Search and SigImp Translate Snippet convert unmanaged signatures to managed signatures. SigImp Search allows users to select a native type, procedure, or constant to perform the converstion from – it will display a list of supported types, methods, and constants collected from Windows SDK header files. SigImp Translate Snippet allows users to write their own native code snippet in the tool and then it will generate the managed code equivalent.
The snippet translators work well for small snippets of code, but if you need to translate a larger code base, you should use the command line version of the tool – sigimp.exe (included). It is designed to process several header files and produce a mass output.
The .NET Framework 3.5 Enhancements Training Kit includes presentations, hands-on labs, demos, and event materials, that help learning utilization of the .NET 3.5 enhancement features including: ASP.NET MVC, ASP.NET Dynamic Data, ASP.NET AJAX History, ASP.NET Routing, ADO.NET Data Services, ADO.NET Entity Framework, WCF 3.5 SP1, and the .NET Framework Client Profile. I would wish they would cover more technologies in it though…
The long awaited SP1 for .NET 3.5 and Visual Studio 2008 are finally here! ISO is available here and EXE – here. Before installing you need to run Visual Studio 2008 Service Pack Preparation Tool in case you had SP1 beta or some hotfixes installed earlier.
There are also Visual Studio 2008 Service Pack 1 Remote Debugger and Visual Studio 2008 Service Pack 1 Stand-Alone Profiler.
And, of course, here is the .NET Framework 3.5 Service Pack 1 itself, either as a bootstrapper or as a full package. Note, that you do not need these if you are installing VS2008 SP1 – .NET 3.5 SP1 is already included with it.
Today’s Links
These are mostly related to systems’ programming:
- Professional System Library – a free, open-source COM library that offers a simple, generic and logical API for accessing most commonly used information about the system and the environment in which the client application is running, e.g. security, privileges, processes, threads, drivers, services, network, memory, etc. There is also Professional System Library: Introduction article at CodeProject giving brief introduction to the library.
- Authors of 32 OpenMP traps for C++ developers article did really good job. I have not use OpenMP (multi-platform shared-memory parallel programming API for C/C++ and Fortran) myself yet, but can easily imagine that this article can save many hours of painful digging into the non-working code.
- A Fiber Class (and Friends) (C++) is introducing fibers and illustrates the implementation of round-robin scheduler for fibers.
- Telling The Difference Between CD and DVD Drives (C++) – might save some time if needed eventually
- Using Raw Input from C# to handle multiple keyboards – despite the article is in C#, it is 1:1 translating to C++.
- Tracing Events Raised by Any C# Object presents the simple-but-general event hooking/tracing class.
A Few LINQ-related Links
All of these come from CodeProject:
- Understanding LINQ (C#) – a short introduction to LINQ, good for beginners
- Dissecting LINQ to SQL – a bit more advanced reading
- LINQ Challenges and SQL Server Compact Edition
- And, finally, LINQ to Life shows how to use LINQ while writing the Life game – a very interesting application of LINQ if you ask me
OMFG! One guy (OK, OK, he partially reused the work of another guy) made what whole Expression team was unable to do for ages – IntelliSense for Expression Blend add-in! WOW! Works in Blend 2.5.
Tools for Framework Architecture Verification is a suite of tools primarily aimed at validating the architecture of a framework. Currently, there are three tools:
- Deps: produces dependency diagrams between assemblies, based both on implementation, as well as API-only.
- Layering: verifies that a layering and grouping diagram is indeed satisfied by a set of assemblies
- PotentialCallers: lists all the methods that call, directly or indirectly, a set of methods.
New Tools for Framework Designers Published by Brad Abrams sheds a bit more light on these tools. By the way you will need F# to run these :).
Interesting Microsoft Tools
- Microsoft SharedView – little known Microsoft remote desktop tool. Allows to connect with up to 15 people in different locations and show them what’s on your screen. You can share, review, and update documents with multiple people in real time. Have tried it, and it really rocks – no idea why Microsoft is “hiding” it from people.
- Windows SteadyState 2.5. Microsoft says, “Whether you manage computers in a school computer lab or an Internet cafe, a library, or even in your home, Windows SteadyState helps make it easy for you to keep your computers running the way you want them to, no matter who uses them.” SteadyState provides a more effective way to help defend shared computers from changes by untrusted users and unwanted software installations, as well as safeguard system resources. Features include: Windows Disk Protection, User Restrictions and Settings, User Account Manager, Computer Restrictions, Schedule Software Updates. I have not used this tool yet, but I guess it might be really cool in some circumstances.
- SyncToy v2.0 – helps you copy, move, rename, and delete files between folders and computers quickly and easily. Again, have not used it myself yet, but needed such a tool million times in the past.
DirectShow Resources
There is no need to say anything about any of the following:
- Geraint Davies Consulting Ltd or GDCL – the home of Geraint Davies, the author of DirectShow, and famous GMFBridge. The site has a lot of interesting information about DirectShow, e.g. introduction to filters, technical Q&A, as well as some pretty elaborative samples like demuxers
- The March Hare – the guy is always present at DirectShow forums :) . Filter Graph Library, despite being written by another guy can be downloaded from this site as well
- Alessandro Angeli’s Programming FAQ – a lot of useful DirectShow tips and tricks
- GraphEditPlus – is GraphEdit done right :) . Especially nice time-saving feature is its graph code generation – you build the graph and GraphEditPlus generates its C++ creation code
Mocking Frameworks
Today was Sunday and I took a “day-off” from the project :) and decided to look into the world of mocking… Before I start, I should admit, that while I understand (or at least I hope so) principles and benefits of Test Driven Development (TDD) and mocking, I have never used them in my work. There are a few reasons for this:
- Currently I am developing a digital TV feature and infrastructure for an advanced set-top box (running on Windows XP Embedded), and simply do not get how I can use TDD and mocking with needs like processing 25-40+ megabit transport streams and doing something useful with them. The code that I would be able to test using TDD and mocking is way too simple for this, and the code I perhaps would be interested in testing automatically, is not really “testable” for the abovementioned reasons.
- Unit testing and mocking frameworks for C++ and C++/CLI, the two languages I use 80% of my time nowadays, are quite “anemic” at best, and it is really no fun to use anything like those frameworks.
- On top of that, to be honest, I never felt the need to use TDD and mocking in my own practice. Retrospectively thinking, I do not remember any project where TDD or mocking would substantially improve the quality of my code and/or reduce the number of defects (although I definitely know cases where it would not harm to use TDD and mocking) – I am not “boosting” myself, but there is an order of magnitude difference in performance among developers, and even bigger difference in quality of the code they write. In fact, I think TDD and mocks were invented to somehow compensate for this difference.
- I somehow have a weird feeling about adding to my project as much testing/mocking code as there is “normal” code. And then, I am definitely not “purist” but rather “pragmatic” – I agree that it might be wise to have unit testing/mocking in some parts of the system, but definitely not everywhere.
So, now that I explained my background, I am ready to continue. After spending quite much time on Google and other development-related sites I managed to narrow the list of available .NET mocking frameworks down to three: Typemock Isolator, Rhino Mocks, and Moq. All frameworks support .NET 3.5 (Rhino has it in version 3.5 RC).
Typemock is definitely the most powerful of these frameworks, but this property of Typemock is often mentioned in the cons section. The argument is, that while allowing mocking everything and everywhere, Typemock is not really helping developers to design loosely coupled code – for example, you do not have to “resort” to Inversion of Control (IoC) principle to use Typemock. I think Typemock is as its best when you try to introduce TDD and mocking into legacy project to get better understanding of that code and to have easier time modifying it. The framework has a free version, but to get e.g. its Natural Mocks feature (allowing to define expectations by recording them in a type-safe manner) you will have to cash out 349€ for Professional or 449€ for Enterprise editions.
Rhino Mocks is likely the most used .NET mocking framework. The framework looks quite powerful, is type-safe, supports generics, and is actively developed.
Then, there is Moq – a newcomer to the scene. Some people criticize it for being too simple. Some accuse it of not being “pure”. From what I have seen today, I should say that I liked it most (second being Rhino). It has rather elegant type-safe API built around lambda expressions. This API allows writing shorter and more concise code than Rhino does. What sets Moq apart from other mocking frameworks is that it is not using the record/playback model.
I will definitely give TDD and mocking a try on my next project. On the other hand, my C++ part of our current project is much smaller than our C#/.NET 3.5/WPF code-base, so I might introduce mocking into our current project if there will be not too big “opposition” from the development team and other project stakeholders – we are under heavy time pressure now, and adding some new concepts at this moment will probably introduce significant delays. I think that the framework of choice will be Moq, although it is just a gut-feeling at this moment.
And here is the list of interesting blogs/sites about the mocking:
- TDD : Introduction to Moq by Stephen Walther
- Moq: Linq, Lambdas and Predicates applied to Mock Objects by Scott Hanselman
- kzu Weblog by Daniel Cazzulino, the author of Moq
- Comparing Moq to Rhino Mocks by Phil Haack
- Ayende @ Rahien blog by Oren Eini, the author of Rhino
- Inversion of Control Containers and the Dependency Injection Pattern by Martin Fowler
- Mock Objects – Steve Freeman and Nat Pryce are writing a book, let’s call it “Growing Object-Oriented Software, Guided by Tests”. So far two chapters are available online.
NGenerics
NGenerics is a class library providing generic data structures and algorithms not implemented in the standard .NET framework, e.g. queues, deques, matrices, trees, graphs, various sorting algorithms, etc.
Duck Typing Project
Recently I has been looking at various mocking frameworks, and found Duck Typing Project (by David Meyer AKA “deft flux”) – a .NET class library written in C# that enables duck typing for any .NET language. Current release is a bit oldish, but David promised to finalize version 1.0 and start working on 2.0, which will include a name change to something along the lines of “dynamic typing” instead of “duck typing” to reflect the implementation of more dynamic typing concepts than just duck typing, as well as add some .NET 3.5 features like extension methods.
How Duck Typing Benefits C# Developers by Phil Haack provides quick into to duck typing and its benefits.
Well, Josh Smith is always producing good stuff: his Using RoutedCommands with a ViewModel in WPF at CodeProject is really cool!
