This article talks about how you can use Visual Studio and Clearcase in combination in order to provide more effective team integration and operation.
Visual Studio has 2 important features that facilitate this:
- Grouping project configuration with the project.
- The ability to split the configuration of the IDE between team settings and personal settings.
One of the great things about integrating with a source controller is that the more configuration you put into it the easier it will be for everyone who uses it. Shared files can be added to the source controller instead of being placed on network resources because you want them to change as the projects move along.
Variables can be used in the project definition file to point to various places e.g. for header files or pre-compiled libraries:
If you have a set of variables that map to the latest versions of a supporting package you would expect those variables to change as the code base moves forward. If you looked at a version from last year you would like those variables to point to what they pointed to a year ago.
I currently work for a company that uses normal environment variables in order to get around this problem. As far as I can work out there are no advantages of doing this and several disadvantages:
- Every user needs to set up all the variables on their PC, or their new PC, or the dedicated PC they are using as a build machine.
- Every user has to keep track of when these variables are modified or new ones are created.
- Once an environment variable is set up you can’t have a different definition, for that environment variable, per project.
- You need a master document to hold all these configuration options, so that when you are trying to use a new machine you don’t miss anything out.
- Don’t know about you, but I use ten’s of supporting libraries, and so the more you have the longer it takes to configure a machine and the more error prone this process can be.
As a consequence of not being able to change what an environment variable points to, per project, it has meant that they needed to set up an environment variable for each version of each supporting library:
So when someone updates the support library:
- They must get every developer to add a new environment variable
SUPLIB_3_0=z:\lib3.0to their machine.
- They must also update a master document containing all the configuration items that must be configured to do a build.
- All the projects that use this supporting library must have their project files changed to use this new location to pick up the latest libraries.
Visual Studio has a solution file and one or more project files. The solution file is just a container for project files, their inter-dependencies and what kind of build you would like to do (Debug/Release). Project files hold all the settings required to build the project including locations of header files, supporting libraries, etc. A single project may appear in many solutions, so you may need to be careful about what you add because it will be applied to all solutions that use that project. This is ok because you want all the projects to move forward at the same time. It’s a developer’s nightmare to have to support many different supporting library versions; particularly when it comes to finding bugs.
Irrespective of whether you use snapshot views or dynamic views these supporting library locations can change significantly. A good trick is to use relative references to the supporting libraries but thanks to Microsoft that doesn’t work if you want to change to a different drive letter.
The best way to share project information across the source is to use user defined macros. This is quite simple to set up.
- Firstly navigate to the location of the solution file ending
- Create a file called
SolutionProperties.vspropsin your favourite editor.
Enter the following definitions. You can see that ZDRIVE is defined as the first macro and it is used in subsequent macros. Under Clearcase (and every other source controller) everything is relative to the root. It’s just that the root can change its location.
<?xml version="1.0" encoding="Windows-1252"?>
- Check in the
- For each project file:
- Load the solution/project into Visual Studio.
- Right click on the project and select Properties.
- Under Configuration Properties, click General.
- In the right hand configuration panel change Inherited Project Property Sheets to:
- Save project configuration file.
- Check the project files into the source controller.
$(SolutionDir)\SolutionProperties.vsprops’s location is defined using a standard Visual Studio macro and so it becomes independent of file system paths.
There is a precedence order to the configuration files, newer variables overwrite predefined variables. Now instead of having a multitude of variables defining all the versions of a supporting library, you just need one to be defined in the
SolutionProperties.vsprops. The project needs to be updated to change the
SUPLIB, but once that is done there shouldn’t be any other need to update the project file again.
When you need to update the supporting library the person in charge of doing it can update their local copy of
SolutionProperties.vsprops, build and test the new library. When they are happy they check in their local copy of
SolutionProperties.vsprops. The change to the new library is reflected in all the other developers views without them needing to know or care. They have been decoupled.
Team configuration in the IDE
There are many options that should be set up in a team configuration file. These settings should apply to everything and everyone. The best example of this is TABs or spaces. If you checkout a file with spaces making up the indentation and your IDE is set to use TABs then when you check it in, every line (or the line you have edited (depending on the preference)) will be different to the last version which makes spotting differences between files that bit more difficult. You may have a code formatter that needs to be allied to code before it’s checked-in, or want extra warning flagged switched on (warning free code - is good code!).
Unlike library and header locations there will be a lot of personal preferences that will have to be contended with. You will have to arbitrate between what you consider team settings and personal preferences. The easiest thing to do is:
- Set up a Visual Studio installation the way you want.
- From the menu bar select Tools -> Options
- From the Options panel, select Environment -> Import and Export Settings
- The Automatically save my settings to this file option will point to your current settings file.
- Copy the current settings file to the solution directory of the source controller and call it
- Edit it, only keep the settings that apply to the team and remove everything else.
- Check in the team file.
Send notification to your developers. Each developer must:
- Inside Visual Studio, click the Tools -> Options
- From the Options panel, select Environment -> Import and Export Settings
- Check the Use team settings file
- Unfortunately macros are not supported here, although they maybe in the future. Edit the location box to point to the team settings file.
- Click OK
Like projects, there is a precedence to these settings so they may be overwritten by a user setting. If everyone is overwriting a team setting then it’s a really good candidate for updating the team settings file so everyone doesn’t have to do it. The next time you colleague launches Visual Studio it will pick up the new team settings and you will have saved them a bit of time.
I’m working on a PHP web site and I want to add a user authentication component. In the past I’ve written hundreds of these things and couldn’t be bother to write the same code all over again. You know the story: create user table in the database, add a load of database table management web pages to create, modify and delete users, then add the concept of a logged-in user to each page. It’s a lot of work. Those of us in the “know” call this boiler plate code and it is basically a laborious distraction away from writing our application.
I thought I’d check out some of the PHP Framework tools available to see what there is out there that could handle this for me. This is by no means a comprehensive list. I wanted to briefly look at a couple and choose; I didn’t want to spend all day trying to pick holes in each one. I figured that for such a small requirement it wouldn’t take long to implement the user authentication. If one of my short list didn’t shape up then I could just swap it out.
My only goal is to find something that will handle users for me. The framework that gets me closest to this wins.
There is a handy web site called PHP Frameworks that lists the majority of the frameworks. It has a really handy table that describes which features are supported by which frameworks. The features it tracks are: PHP4, PHP5, MVC, Multiple DB’s, ORM, DB Objects, Templates, Caching, Validation, Ajax, Authentication Module, Modules and EDP.
The Akelos framework describes itself as a Ruby on Rails port for PHP. I’ve used Grails before. Although they can save you a lot of time, you lose the time benefits in trying to learn all the commands. One just seems to spend all of ones life trying to figure out why it didn’t work and hunting for bizarre error messages in forums.
There is a “Creating a blog in 20 minutes using the Akelos PHP Framework” screen cast. A Spanish guy with an unpronounceable name whizzes through the tutorial. It’s quite comprehensive but you really need to run through it with him feeling your way along with the application and trying different things. There are many commands to create controllers, models and views, but if Grails is anything to go by, there are a host of other things you can create which will slowly suck the life out of you! There just seems to be loads to do and read before you can do anything.
Verdict: Once bitten twice shy. Anything which uses convention over configuration requires you to learn all the conventions which are often not obvious or conventional. I don’t really want to spend the rest of my life doing this. For what I need this is too much effort and work.
Dingo on the other hand has a really simple website. This project works less like a framework which is all encompassing and more like a set of classes that can be slotted in. You need only learn and use the helper classes that suit you. Dingo is still an MVC framework but it is so unobtrusive you should be able to fit it in to an existing development. If you need a nice simple example of how an MVC system works then this is a really good starting point. Documentation is clear, the examples are straight forward and simple. The project probably doesn’t have a million options to fulfil everyone’s requirements but if you want to use the more general cases then you should be more than happy. There was several modules to help handle XML, pagination, Capcha, Sessions and user authentication. Reading through the project’s Twitter feed suggests that the project is struggling to find developers. It would be a real shame if development stopped on this project.
Verdict: I definitely liked this. It was what the Spring Framework is to JBoss. The project is still in it’s infancy (version 0.7.1 at the time of writing this) and there also didn’t seem to be much in the way of example projects, but it kind of doesn’t matter because what there is there should be enough to get anyone up and running.
The best introduction you could have is to watch the 4 tutorial presentation screencasts. Each one is 5 to 7 minutes and takes you from downloading the application to writing a Hello World program where the Hello World text is stored: in the page, in a template and then in a database. This application is also an MVC but unlike Akelos many of the steps have helper web pages to guide you through, rather than expecting you to remember all the options. The user interface helps with the setting up and configuration of Models, Views and Controllers. The Class Reference documentation looks generated and as a result it’s comprehensive and easy to navigate with a similar feel to JavaDocs.
Verdict: After watching all the videos I am raring to go. From the outside it has probably the same amount of features as Akelos or CakePHP but my fears have been allayed by a very good support web site and a set of accompanying books.
I did like Dingo but I’ve decided to go with Yii because it looks like I can just use it for a small part of my site and yet there is plenty of scope for it to grow if needs be. My next blog post will probably be along the lines of setting up a user authentication system in Yii. So watch this space.
I’m very black and white when it comes to buying things and doing personal shopping. I almost take it to the extreme: a £20 t-shirt should be twice as good as a £10 t-shirt with regards to build quality. If it is not twice as good I’m paying for the brand. The trouble with the brand is that it is only perceived value. Perceived value is not the same as actual value and in reality bares no relationship to build quality.
I had a girlfriend a while back who spent an awful lot of money on shoes, bags and clothes. It was a constant bone of contention that a Gucci hand bag that cost £500 cost that much because it was made from quality components. Whereas a similar looking bag made by an independent was cheaper because it was made with sub-standard materials. “You’re paying for the quality” she kept saying. Amazing, such is the power of marketing!
While there may be other things that effect the price, such as after sales support, the majority of the cost comes from the perception that if it is expensive then only a select few will be able to afford them and so with that comes exclusivity. There is no way that a pair of Emporio Armani jeans are 5 times as good as a pair of Levi jeans even though their price tag is five times more. So what am I paying for? It costs a lot of money to advertise in exclusive magazines and even more to advertise on television. I expect it costs quite a bit to push their wears on celerities and sponsorship. But none of these expenses have anything to do with the actual product. I don’t expect these companies are pouring money into R & D to design the latest bags; market research isn’t that expensive and because it’s fashion, what ever they say the latest fashion is - then that’s what it is. So no money spent there either.
Maybe I’m taking a simplistic view on this, but is that just it. Is everyone being duped in to paying twice the price for nothing?
Edgar Watson Howe:
One of the most difficult things in the world is to convince a woman that even a bargain costs money.
I ended up with a house full of things I didn’t need or want that my girlfriend had bought because they were cheap. For some reason I couldn’t convince her that just because they had knocked 50% off the price didn’t mean that it was a bargain. It only became a bargain if we needed it and more often than not it was just used as ammo for her argument about buying a bigger house!
One of my current projects requires me to use Sentinel RMS within a Microsoft .NET framework using C#.
I had a couple of problems setting up the example solutions SafeNet gave out, so I thought I’d document them here. There’s probably not that many people who will use Sentinel RMS but I did run into a problem that might well be generally useful:
API call fail with message:System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000
API call fail with error-code:501
While the manual for Sentinel RMS was pretty good it was all about the API’s and how to call them. The documentation was missing a How to get started section that would describe how to set up Visual Studio. There is a brief few lines saying which version of Visual Studio are supported but that’s about it.
- Download SDK RMS 8.5.0 Windows 32 and 64-bit GA release (you can get this from your support representative)
- Download the Sentinel RMS 8.4.1 .Net Interface (you can get this from your support representative)
- Unpack and install the SDK.
- Add the following DLL folder to your PATH:
C:\Program Files (x86)\SafeNet Sentinel\Sentinel RMS Development Kit\8.5\English\MsvcDev\Lib\MSVS2008\Win32\DLL\
- Unpack the .Net Interface.
- Navigate to
RMS 8.4.1 .NET Interface\Examples
- Create a folder called
- Copy the contents of
RMS 8.4.1 .NET Interface\Libraryinto the
RMS 8.4.1 .NET Interface\Examples\Librariesfolder
- Navigate to
RMS 8.4.1 .NET Interface\Examples\VisualC#\AddRemoveLicense
- Double click the solution file (.sln) to launch Visual Studio. The documentation says that only Microsoft Visual Studio 2003/2005/2008 is supported so make sure its one of those.
- When the solution loads in, right-click on the project name and select Properties.
- Under the Application tab change the Target Framework to 3.5.
- Under the Build tab change the Platform Target to x86.
- Then save, clean solution, rebuild solution and run.
I found that if you didn’t add the DLL folder to the
PATH then I got the following error message, and in order to fix it I had to manually copy the lsapiw32.dll into the Release/Debug folder. There didn’t seem to be anywhere in visual studio that let you add extra DLL search folders because it is rubbish.
API call fail with message:System.DllNotFoundException: Unable to load DLL ‘lsapiw32.dll’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
API call fail with error-code:501
The other problem, which is probably more generally useful, was that of the System.BadImageFormatException exception. This occurs when the Common Language Runtime (CLR) tries to load an assembly that contains unmanaged code built targeting a different platform (thanks Dave).
In my case with Sentinal, the
lsapiw32.dll was compiled with the platform x86 for the 32-bit version of the DLL. Visual Studio defaults to building for a target platform of Any and this discrepancy is what causes the error. Equally if I had chosen to fill the
Libraries folder with DLLs from the
Library(x64) folder (and the corresponding
C:\Program Files (x86)\SafeNet Sentinel\Sentinel RMS Development Kit\8.5\English\MsvcDev\Lib\MSVS2008\Win64\DLL) instead then I would have had exactly the same problem.