Monday, August 11, 2008
Exceptions, return value checking, pre- and postconditions
As I remember it in Eiffel you can write your method/function/procedure (whatever it's called) and define some conditions that must be met before and at the end of that. E.g. you could define a precondition for a function that will ensure that a passed parameter is larger than zero. For the remainder of your code you can assume that the passed parameter IS larger than zero.
Now, whenever I write a function/method I do the same. E.g. if I do a typecast somewhere in my code, I try to check for the correctness of the object that is typecast as soon as possible in my code. Something like this (from the top of my head, forgive me typos, simplicity of the examples and such):
procedure Foo(const aControl: TWinControl);
begin
// Beginning of preconditions
if not Assigned(aControl) then exit;
if not (aControl is TEdit) then exit;
// End of preconditions
// You can now safely execute the code below
TEdit(aControl).Text := 'foo';
end;
The above works fine if there actually is something that you can check at the beginning of the code. But, what if you cannot, until right before you start to use an object? Like below:
procedure Foo();
var
aControl: TEdit;
begin
(**
A Whole Bunch of Code Here
**)
aControl := MyFunctionSomeWhereThatReturnsTEdit();
if (not Assigned(aControl)) then exit;
if (not (aControl is TEdit)) then exit;
aControl.Text := 'foo';
end;
In this case you would add your check just below the aControl := line. And if you have a lot of those, your code can become complex and hard to read. And you would end up with a lot of not so interesting code which in the end doesn't really matter to your program.
Now, until now I used assertions for this type of checking, mainly because you can turn those off easily using a compiler switch.
aControl := MyFunctionSomeWhereThatReturnsTEdit();
Assert(Assigned(aControl));
Assert(aControl is TEdit);
But, of course, this doesn't work if the 'failing conditions' might be ligitimate circumstances in your code. So, for those types of checks I used the if..then constructions from the first example.
But, I am now thinking that I'd better use exceptions for this. Currenlty I only use exceptions for 'error circumstances' and never really used them as a way to signal pre- and postconditions. It would go like this:
procedure Foo();
var
aControl: TEdit;
begin
try
(**
A Whole Bunch of Code Here
**)
aControl := MyFunctionSomeWhereThatReturnsTEdit();
aControl.Text := 'foo';
except
on E: MyConditionException do
begin
// This will be an exception raised from within MyFunctionSomeWhereThatReturnsTEdit
end;
on E: Exception do // There probably are seperate exceptions for nil and class type mismatch exceptions, but this will do for the example
begin
// Something else should be done.
end;
end;
end;
This will work (and I think I will give it a go in some small program to see if it works our for my style of programming), but I'd much rather see the concept of pre- and postconditions introduced in Delphi.
What do you think? If..Then constructions at the beginning? Exceptions? Push Embarcadero for pre-/postconditions? Something else?
Please let me know; I'm really curious.
Bye,
Bart
Thursday, August 07, 2008
FinalBuilder it is...
The pain is caused by the memory of some great experiences with ABS. So I feel a little sad to leave them. But, to my joy I was up and running (for the project that gave me problems for the last week) in about 10 minutes (really!) time with FinalBuilder. I can't tell yet if it's quicker/better/easier to use than ABS, but the fact is that I now have an automated build script for one of my main products in just a couple of minutes time. With almost all the things in there that I want (I will have to tweak it here and there to do some script based automated things).
So, yes, it's a joy to say: I'm in the FinalBuilder camp too.
Thanks to everyone responding to my previous post about this. It really helped to make the decision to move over.
Bye,
Bart
Wednesday, August 06, 2008
Thinking about switching from Automated Build Studio to FinalBuilder
From the word go I ran into problems. I got access violations and had problems with search paths that were used when compiling Delphi software. It took me some intensive emaling with the support department before I got our most important projects compiling again. The access violations still happen intermittedly and a solution was never provided.
Now, I started using a new component pack some time ago (VideoLabs) and the problems with the search paths were back again. Things compile fine using the IDE or from the command line, but using AutomatedBuildStudio I get some unexplainable errors. I emailed support a couple of time, but they all seem to be on holiday: I can't get a reply.
So, I'm thinking about switching to another tool. Even though I have created a workaround (calling a batch file compiling the projects, using another tool to update the version numbers of my software), I don't want that as a permanent solution on my build system.
I found quite a lot of praize about FinalBuilder. It seems pretty affordable too (maybe there's even a competetive upgrade prize available if I ask).
What's your experience? What build systems can you recommend?
Thanks for letting me know.
Bye,
Bart
Monday, August 04, 2008
I now get anonymous methods: but I really dislike them already...

After examining this example for a couple of minutes (yes, really it took me that long...) and looking at the other example in his blog, I think I've made my mind up. I detest anonymous methods already. IMHO (of course as always), I can only conclude that using anonymous methods make your code less readable (to me at least) and don't add any real value to the language. Still, I haven't found examples or explanations that help me to get into the anonymous camp. Even Craig Stuntz's doesn't help me get there.
I also realize that there is one principle that I live by that renders some of the 'advantages' of anonymous methods useless. Sure, using anonymous methods can help you to limit the amount of 'real' code in a method and thus make it a bit more easy to overview. Or, at least, that's one of the reasons give to use anonymous methods.
However, this 'advantage' is only of use if you write really long methods and functions. The more code you have, the sooner you will find yourself repeating things and the quicker an anonymous method can help you reduce your code. But, if I look at my own coding style, I try to make small methods and functions, archieving only a couple of things in it. That hardly ever takes more than 10-20 lines of code per method. If you are writing longer code, chances are that you better start that refactoring utility and split your code up. Most of times that will make your code better reusable and easier to maintain.
As for Craig's argument of being able to do things that a designer of a framework didn't think of: I think you are working against the principles in that framework or the framework simply is not well designed. But, that's maybe another personal style of programming. If I use somebody else's framework, I try to use it as intended. Maybe the 'hacking' you are talking about becomes a bit easier, but I for one are against hacking.
The last sentence reminds me: due to some technical problems, you might have missed my posting on why a developer wants to be a CIO (or not). If you are border tonight, you might want to have a peek.
Bye,
Bart
Saturday, August 02, 2008
Why would developers want to become a CIO?
5 Reasons why a developer would want to become a CIO
and
8 Reasons why a developer would never want to become a CIO
They are about reasons why a developer might want to or might not change his position for a position as a CIO.
Now, I'm going to discard all the financial arguments. I'm not interested in money, at least not to the level that it will make me decide in favor of or against a job. Maybe it's because I'm Dutch and not American, I don't know. But I couldn't look at myself in the mirror if I would take a job just for the money. I would deny a job if they wouldn't pay what I'm worth though, but I think that's another matter. Bottom line: money couldn't get me into a job, but could keep me out of it.
Now, for the other reasons that a developer would want to be a CIO (only 2 of the 5 arguments remain after removing the financial reasons...) #2 is bullocks. It tells us that you want to be king of the company because you will have power over the people. To me, that's not a reason to be the king. I want to have the power over the faith of the software, not the people. I want to be able to tell which directions we need to take with the software. That's the real beauty of being king, not that you can tell people they need to fill in form A,B, or C.
Reason #5 (you get tired of solving the bugs) is bollocks too. Every programmer knows solving bugs is part of the job and you want to improve your software each day to give your customers a better product and toe get you less bugs on your todo list. If you are solving bugs each and every day and nothing but bugs, you're a bad programmer and you won't survive the business. If you have to do that because you're the bug solving programmer, you probably are just starting (solving bugs is a great way to learn the software and learn programming) and chances are you're not CIO material yet.
So, a nice article that draws some attention but, IMHO of course, full of nonsens.
As for the other article: the 8 reasons why you DON'T want to be the CIO, it's much the same.
Reason #1: we live to write code. True, but I guess that CIOs that have a developer background still continue to write code, or at least will research (new) code developments. You will be the senior in the company (after all, you started as a developer) and chances are there will be some hungry young dogs trying to learn from you. You won't leave your code: you only get to pick the nice pieces to be involved in.
Reason #2: seeing the fruits of your labor. Being a CIO for once you can make the decisions that you think are good for the software and the company. If you have sound ideas, the company will improve with your leadership and you will see the best measurable results possible: an increase in turnover. The results of a days work as a programmer is a nice piece of code that makes it through the unit test cleanly. The results as a CIO will show in the daily sales of licenses and positive customer feedback. I'd rather have the latter.
Reason #3: being able to speak Java/C/et cetera is a must for a CIO. That's the only way you won't get fooled by the developers that tell you that something isn't possible (anything is!). But, sure, you need to be able to express yourself as a human too, but I require that from my programmers too! If you can't talk Dutch (or English :-)) you would have a hard time surviving in my company. It's not a CIO-only requirement: it's a human's requirement to be able to express yourself.
Reason #4: there probably are a couple of people that want to be remembered for their hacking capabilities. But, again IMHO, hacking is stupid. If you are such a good programmer that you can do some facinating stuff, apply your abilities to do some good and useful work. It's a waste to spend your talents at stuff that gets people mad. You can do a lot better in making people happy.
Reason #5: sucking up to other people with jobs beginning with C's. What nonsense. If you are a good CIO, you will be taken as an equal amongst those C's. If you're not, you're not in a technology company and/or you're no good. If you find yourself sucking up the whole time you probably did it before (and you might even have gotten the C-job for it), but you won't make it.
Reason #6: the reference in the article to point #1 is a good one, because the same counter arguments apply. As the CIO you for once get to pick the directions and you will be able to do some real innovation that has an impact in the company. As a developer you will find you write just a bit more clever code that nobody will see. You'll take pride in that, but it will only matter to yourself.
Reason #7: not liking Powerpoint. If so, use something else: easy. Use video, music, exotic dansers. You're the guy with the 'C': pick your own tools. Now you can!
And for reason #8: that will all change, once YOU are the CIO. All the other developers will think: thank god, we now DO HAVE somebody that has a clue.
Again, Just My 2Cents Worth.
Bye,
Bart
Friday, August 01, 2008
I don't get anonymous methods...
During the presentation we could ask questions and mine was: what's up with anonymous methods?
We've probably all seen the example of anonymous methods shown at http://blogs.codegear.com/davidi/2008/07/23/38915.
I just don't get why you want to use anonymous methods and I'm afraid Adreano and David were not able to explain it to me.
Why wouldn't you use a private class method? Or an local procedure? I really tried but I can't think of a situation where you want to use an anonymous method.
Who can explain this to my satisfaction? Why would I be happy with those???
Bye,
Bart
What are those prizes in the race - (part of) part 3
Impressions from the webcast by Embarcadero
Wednesday, July 30, 2008
And the winner is: Werewolf
First and second prizes were won with Delphi programs. Third place Tom Glenn made a fine contribution using C#.
Congratulations to them and thanks a lot to the contenders that didn't win a prize. To me, it was a lot of fun to be involved in this, albeit not as a contender. Who know, this might become an anual event. I will keep the website alive for the next year or so.
Bye for now,
Bart
Monday, July 28, 2008
Two days of voting left...
Bye,
Bart
Friday, July 25, 2008
Races within the race
You can still have your say about the entries and make a difference for the contenders, so go the the website, try the published programs and vote the winner. The published programs are all well worth looking at and you might even find them usefull. I know I have one of them as a startup utility installed already - I will tell you which when the race is over :-)
Bye,
Bart
Wednesday, July 23, 2008
You can now vote for the winner of the race...
Go to the website and check out what the participants did and how they did it. On 30 July the winners to the competition will be announced and prizes will be handed over.
Bye,
Bart
Monday, July 21, 2008
Hans Starborg submits his entry
Bye,
Bart
Wednesday, July 16, 2008
Late entry Werewolf publishes his solution too...
Go check his work out.
Bye,
Bart
The first multi clipboard utility is in...
Yogi is till thinking about making the sources available, but for now you can go and have a look at the end result.
Bye,
Bart
Saturday, July 12, 2008
What are those prizes in the race? - Part 2
Installing
Installing was like it should be: no hassle and flawless. SmartInspect can be used in Delphi, Visual Studio and Java. I've only looked at the Delphi implementation: I guess VS and Java implementations will be compareble.
Using SmartInspect
Basically SmartInspect is an advanced logging tool. You start a session, send out information and that is caught by either a server, a file or in memory. When logging to a server (which is built in into the viewer) the logging information is displayed live while running your program. When logging to a file, you can later view the file with a viewer.
You can of course log a simple string, but more usefull things can be done. You can log objects, the properties of which are available in the viewer. You can log images, stacks traces, system memory information, a screendump of the current window or the desktop window. There's a lot too choose from.
For more advanced debugging tracing methods/functions can be quite helpfull. Now, it basically is a minor thing, but I found the TrackMethod statements vary valuable. The working is comparable to the EnterMethod/LeaveMethod combination. But, EnterMethod/LeaveMethod must be used in pairs. And that means you best add a try/finally construction to your code to make sure the LeaveMethod is executed alwas.
TrackMethod however works with an interface and relies on the reference counting of the interface. This means you only need to add one call at the beginning of amethod/function to track it. There's no need for the try/finally construction. To me, that is a good thing because it won't clutter the readabilty of your code as much. Nice.
The console
Until now CodeSite and SmartInspect are about equal. The only real difference I found was the TrackMethods in SmartInspect, but CodeSite has functionallity to log to the windows event logs. So, the scores are equal at half time. But the real difference is in the console. While the CodeSite viewer isn't bad at all and gives you good possibilities to view and filter log messages, I think SmartInspect wins on points in that department. You have various viewers (a watch pane, some detail panes) for information from you log file. There's plenty to filter and various ways of finding specific information in your log file.
Conclusion
SmartInspect is just a very good product. From experience I can tell you that having these kinds of logging capabilities out of the box helps you to debug your software immensely. I couldn't program without them anymore. CodeSite and SmartInspect are comparable products with (about) equal prices. Download the trial versions to see what's your favourite.
Bye,
Bart
Thursday, July 10, 2008
What are those prizes in the race? - Part 1
I've written about various parts of the DevExpress components before. If you've read those postings it's not a great surprise to you that I am a big fan of the DevExpress components. This posting is basically a song of praise. I've written before that the standard that DevExpress works on, is what we strive for in our company. That sums it up really...
DevExpress website
While technically not a part of any of their packages, the first thing that you experience is the DevExpress website. I thought I'd mentioned this because it can make a huge difference in the first opinion that you have about a company and their products. The DevExpress site is beautifully layed out (although a bit bombastic for my taste) and you can find any information that you like very quickly. Their support sections is up there with the best to be found on the web. All of this gives you great confidence about the products you are about to buy.
VCL subscription
Now, here's a tip that will actually save you money. Go for the VCL subscription package immediately instead of buying that one companent pack that you think you are looking for. I started with the navigation controls first, purchased the grid controls later and ended up buying the VCL subscription. Although you get some discounts of you ask for them, in the end you will pay more money. If you go for the VCL subscription in the first place, you get the lot immediately. And you will get all the beta releases of new components first, so you can immediately dig into those.
Overall quality
The overall quality of the controls is really excellent, with good online help and examples. All the components have plenty of properties to tweak them to your liking. Special attention is given to the look and feel of the controls. There's about nothing that you can't reconfigure with regards to the way the controls appear in your program.
However, a couple of things can be said. There are some components that haven't been updated in a while. I found myself using the navigation controls, the grid controls, the editors of course and the cxLayout components a lot. The other controls I don't use that much.
Look and feel
Recently DevExpress released the ExpressSkins libray which is used to apply skinning to your controls. That means you can give your application a very unique look and feel. There's a skinning editor to create your own skins and of course there are plenty of ready made skins to choose from. It took me about a day to add a user configurable skinning option to our software so each end user can select the look and feel of their choice. Great stuff.
Grid controls
I think DevExpress is best know for their incredibly good grid controls. DevExpress grids are very versatile, very fast, user friendly and offer unrivaled filtering and sorting capabilities. The only 'negative' thing that somebody told me once is that you can configure too much. True, it takes a bit of time to learn all the properties of the grids, but once you've got the concept behind the properties, it's not that difficult to find your way. And of course, a lot of properties also means that the control probably can do what you want.
Layoutcontrols
On different occasions I wrote about one of the frustrations of the last year or so. I started looking at the layoutcontrols once we got the VCL subscriptions. Before, I had read about the layoutcontrols, but to be honest, I didn't believe what DevExpress put up on their website. How could a set of controls relieve me from all the positioning that I was used to do on my dialogs? Not in a milion years a set of controls could do a better job than I did.
That was one of the biggest mistakes I made the last couple of years. I should have had a look before. If I had done, I would have started to use the Layoutcontrols ages ago. They are SO good that I still am amazed every time I use them. Positioning controls on a dialog has been removed from my tasks completely. The DevExpress layout controls take over all the hassle of making sure my dialogs look good.
The Layoutcontrols don't get much exposure but I honestly think those are the best controls that I ever worked with. You're a fool if you still are positioning your controls yourself. Go on, have a look at those and your life as a user interface programmer will change completely.
Schedular controls
Now, I haven't actually used the schedular controls yet from in demos and experiments. But, everytime I use them I am amazed at what I find. You can literally with adding one component implement a calendar feature to your application. There's not much more to it that adding the control and filling it with data. Of course to use the information in your software you would need to program a bit more, but the actual calendar and storing the calendar data is all taken care of. An excellent component that - if you have any use for it - will be much appreciated by your end users.
Navigation controls
The navigation controls (menu bars, navigation panes, ribbon controls) is what started me as a DevExpress user. Needless to say that using them is dream. Using the navigation controls means it's a no hassle, painless way of implementing a professional navigation interface to your software. One excellent thing is: there is a cxImageList control that supports PNG images. If you use PNG images (like http://www.famfamfam.com/lab/icons/silk/) you get excellent results. Much better than that old Win95 icons that you might be looking at in your software right now.
No trial version
I've seen comments on the web complaining that DevExpress doesn't offer trial versions of their software. That is true for the VCL components, although there are demos and there is a 'money back guarantee'. The .Net controls do come with a trial version though. To me, a money back guarantee is good enough but I think it would be better for DevExpress to see if they can implement a trial systems for their controls. Especially if you have large development teams, purchasing the controls means serious money and I think one is 'entitled' to be able to test the controls in real life. But that of course is a business decision DevExpress needs to make.
Summary
I'm not a dxExperience user, although I am using the ASPx packages. To summarize the C#/.NET packages: IMHO they are at least of equal quality to the VCL components, if not better. I think that the comments I have on the VCL package should be applicable to the dx components too. I've use the dx-components in their trial version and I really like what I saw. Very familiar way of working compared to the VCL controls.
All and all I couldn't give more praise to a company than what I did here. I truly believe (and not because they sponsor the race) that DevExpress has a great philosophy, offers unrivaled value for money and actually will save you a lot, a lot of time as a programmer. Their support is great and the VCL components still get their updates and new features. I only whish they had even more programmers working on the VCL components (it's quite obvious that their money is in the C#/.Net controls).
Bye,
Bart
Race on in its way: first reports are in...
Bye,
Bart
Tuesday, July 08, 2008
DevExpress donates a great prize for the contest
For more information point to http://www.darwinraceoflanguages.com/.
Bye,
Bart
The race has started: 8 contenders rumble for the prizes
They will work on the problem that they picked and will keep a record of things that come up, documenting their experiences while programming. After two weeks (the duration of the race) their software and experiences will be published on the website for all of you to judge.
If you want to enter the race, you still can. You won't get more time, but if you think you are up for the challenge, please drop me a note.
Best of luck to all of them and I will post their notes when I get them during the race. So go check the website every now and then to read about their progress.
Bye,
Bart