Category Archives: Development

Creating SWF movies in Delphi

I reviewed Delphi+Flash for The Delphi Magazine: it’s a great product and is especially useful if you need to add animation to your application.

Merry Xmas

Here are a couple of sample animations:

Example SWF 1
Example SWF 2

And some sample code:


var Movie: TFlashMovie;
label1, label2, label3, label4: TSWFOffsetMarker;
EA: TSWFExportAssets;
begin
Movie := TFlashMovie.Create(0, 0, 400 * twips, 200 * twips, 20);
Movie.Version := 6;
Movie.SystemCoord := scPix;

Movie.AddRectangle(0, 0, 400, 300).SetLinearGradient(SWFRGBA($663300), SWFRGBA($CCFF99), 270);
Movie.PlaceObject(Movie.Shapes[0], 1);
Movie.BackgroundColor.RGB := SWFRGB(0,0,0);

{ Text }
Movie.AddFont(Font, false);
With Movie.Fonts[0] do
begin
Size := 2 * twips;
Name := 'Times New Roman';
Bold := true;
end;
Movie.AddText('The Delphi Magazine', cswfWhite, Movie.Fonts[0], Point(0, 100), taRight);
Movie.AddSprite;
With Movie.Sprites[0] do
begin
PlaceObject(Movie.Texts[0], 10);
with PlaceObject(Movie.Texts[0], 9) do
begin
SetTranslate(2, 2);
InitColorTransform(true, -$FF, -$FF, -$FF, -150, false, 0, 0, 0, 0, true);
end;
end;
Movie.PlaceObject(Movie.Sprites[0], 10000).SetTranslate(395, 0);

{ one snow }
Movie.AddStar(0, 0, 3, -3, 4).SetSolidColor(SWFRGBA($EE, $EE, $FF, $DD));

Movie.AddSprite;
With Movie.Sprites[1] do
begin
PlaceObject(Movie.Shapes[1], 1);
With FrameActions do
begin
ConstantPool(['this', '_x', '_y', 'ZielX', 'ZielY']);
Push([400, 0], [vtInteger, vtConstant8]);
GetVariable;
Push([1], [vtConstant8]);
GetMember;
Less2;
_Not;
label1 := _If.BranchOffsetMarker;
PushConstant(0);
GetVariable;
Push([1, 10], [vtConstant8, vtInteger]);
SetMember;
SetMarker(label1);
PushConstant(0);
GetVariable;
Push([1], [vtConstant8]);
GetMember;
Push(0);
Less2;
_Not;
label2 := _If.BranchOffsetMarker;
PushConstant(0);
GetVariable;
Push([1, 250], [vtConstant8, vtInteger]);
SetMember;
SetMarker(label2);
PushConstant(0);
GetVariable;
PushConstant(2);
GetMember;
Push(0);
Less2;
_Not;
label3 := _If.BranchOffsetMarker;
PushConstant(0);
GetVariable;
Push([2, 250], [vtConstant8, vtInteger]);
SetMember;
SetMarker(label3);
Push([300, 0], [vtInteger, vtConstant8]);
GetVariable;
PushConstant(2);
GetMember;
Less2;
_Not;
label4 := _If.BranchOffsetMarker;
PushConstant(0);
GetVariable;
Push([2, 10], [vtConstant8, vtInteger]);
SetMember;
SetMarker(label4);
Push([3, 4], [vtConstant8, vtInteger]);
RandomNumber;
SetVariable;
Push([4, 4], [vtConstant8, vtInteger]);
RandomNumber;
SetVariable;
PushConstant(0);
GetVariable;
PushConstant([1, 3]);
GetVariable;
PushConstant(0);
GetVariable;
PushConstant(1);
GetMember;
Add2;
SetMember;
PushConstant(0);
GetVariable;
PushConstant([2, 4]);
GetVariable;
PushConstant(0);
GetVariable;
PushConstant(2);
GetMember;
Add2;
SetMember;
end;
ShowFrame;
RemoveObject(1);
FrameActions.GotoFrame(0);
FrameActions.Play;
ShowFrame;
end;

EA := TSWFExportAssets.Create;
EA.Assets.Objects[EA.Assets.Add('bot')] := Pointer(LongInt(Movie.Sprites[1].CharacterId));
Movie.ObjectList.Add(EA);

With Movie.FrameActions do
begin
ConstantPool(['max', 'i', 'zufall', 'bot', 'attachMovie', '_root', '_x', '_y', '_xscale', '_yscale', '_alpha']);
Push([0, 100], [vtConstant8, vtInteger]);
SetVariable;
Push([1, 0], [vtConstant8, vtInteger]);
SetVariable;
label2 := SetMarker;
PushConstant(1);
GetVariable;
PushConstant(0);
GetVariable;
Less2;
_Not;
label1 := _If.BranchOffsetMarker;
Push([2, 150], [vtConstant8, vtInteger]);
RandomNumber;
SetVariable;
Push([1], [vtConstant8]);
GetVariable;
PushConstant([3, 1]);
GetVariable;
Add2;
Push([3, 3, 4], [vtConstant8, vtInteger, vtConstant8]);
CallFunction;
Pop;
PushConstant(5);
GetVariable;
PushConstant([3, 1]);
GetVariable;
Add2;
GetMember;
Push([6, 800], [vtConstant8, vtInteger]);
RandomNumber;
SetMember;
PushConstant(5);
GetVariable;
Push([3, 1], [vtConstant8, vtConstant8]);
GetVariable;
Add2;
GetMember;
Push([7, 360], [vtConstant8, vtInteger]);
RandomNumber;
SetMember;
PushConstant(5);
GetVariable;
PushConstant([3, 1]);
GetVariable;
Add2;
GetMember;
PushConstant([8, 2]);
GetVariable;
SetMember;
PushConstant(5);
GetVariable;
PushConstant([3, 1]);
GetVariable;
Add2;
GetMember;
PushConstant([9, 2]);
GetVariable;
SetMember;
PushConstant(5);
GetVariable;
PushConstant([3, 1]);
GetVariable;
Add2;
GetMember;
PushConstant([10, 2]);
GetVariable;
SetMember;
PushConstant([1, 1]);
GetVariable;
Increment;
SetVariable;
Jump.BranchOffsetMarker := label2;
label2.JumpToBack := true;
SetMarker(label1);
end;

Movie.ShowFrame;
Movie.MakeStream;
Movie.SaveToFile('demo.swf');
Movie.Free;

ShellExecute(handle, 'open', 'demo.swf', nil, nil, SW_Normal);

TDD, Visual Studio 2005, Scott Bellware’s blog post

In response to the MSDN Test-Driven Development Guidelines, Scott Bellware has an interesting rant over here.

Update: before I could post this entry, the MSDN posting had been removed, luckily I saved a copy elsewhere. Since I’ve just spent the last few minutes writing this, I’m posting it anyway. Here’s what’s there now:

Guidelines for Test-Driven Development
This topic is obsolete and has been removed from the MSDN documentation.

It would appear that the MSDN posting has hit a nerve in the TDD community, and on first impressions, rightly so. I’m about to embark on a couple of days travel, I’ll be taking some of the material surrounding this posting and rant with me to read, expect to see me follow it up later this month.

To pick on a few posting (on the off chance you’re not following this rant elsewhere): Scott Dockendorf steps up and denounces any involvement in the article over here. Agile guru Roy Osherove is very vocal about the article in his Microsoft fails miserably to explain or promote Test Driven Development in Team System posting. And Julian M Bucknall is all depressed about it over here.

On a separate note, and it’s perhaps why I associated this posting with my “Opinion” category (not that this counts for much, but I feel as if that category lets me write what I like and not get sued! That’ll be right!), as an MVP should I be seen to be criticising Microsoft? Ignoring the relationship that exists, if an organisation did something that was wrong (in the eyes of the majority), I would feel professionally obliged to point out the error in their ways. Even after nearly a decade in the same organisation where such an attitude is pretty much frowned upon, I still maintain this professional desire to see things done properly. However, again on first impressions, I see that the MSDN posting is rapidly becoming MSTDD, so at least the differentiation is there. Hopefully all the TDD newbies will catch up on TDD postings prior to embarking on what amounts to a shoe-horned flavour of TDD.

More when I return from my travels.

Here’s the original MSDN posting:

Visual Studio Team System
Guidelines for Test-Driven Development
If your software-development project uses test-driven development, or TDD, you can benefit from features of Visual Studio 2005, and in particular, features of Visual Studio 2005 Team System. These features include the unit test type of Team Edition for Testers, and especially the ability to generate unit tests automatically; automatic refactoring capabilities that are introduced in Visual Studio 2005, and the Class Designer tool.

The unit test support of Team Edition for Testers is particularly suited to TDD because these Team System testing tools can generate tests from a minimum of production code.

Process Example
In your TDD project, you might want to follow these steps:

  1. Define the requirements of your application.
  2. Familiarize yourself with the feature areas of your application, and decide on a single feature, or the requirements of a feature, to work on.
  3. Make a list of tests that will verify the requirements. A complete list of tests for a particular feature area describes the requirements of that feature area unambiguously and completely.
  4. File work items for feature requirements and for the tests that need to be written.
  5. In Visual Studio, create a project of the type you want. Visual Studio supplies the initial production code in the form of files such as Class1.cs, Program.cs, and Form1.cs, depending on the project type.
  6. Define the interfaces and classes for your feature or requirement. You can add a minimum of code, just enough to compile. Consider using the Class Designer to follow this step. For more information, see Designing Classes and Types.
  7. Note
    The traditional TDD process does not contain this step. Instead, it advises that you create tests first. This step is included here so that, while creating tests, you can take advantage of two features in Visual Studio 2005 Team System: the GUI design capabilities of the Class Designer, and the automatic test-generation capabilities of Team Edition for Testers.

  8. Generate tests from your interfaces and classes. For more information, see How to: Generate a Unit Test.
  9. Compare the tests that have been generated with the list of tests you prepared in step 3. Create any tests that are missing from the list you wrote in step 3. For more information, see How to: Author a Unit Test.
  10. Organize your tests into test lists. You can, for example, base your lists on test use, such as check-in tests, BVTs, and tests for a full-test pass; or on area, such as UI tests, business-logic tests, and data-tier tests. For more information, see How to: Organize Tests into Test Lists.
  11. Update the generated tests to make sure they exercise the code in ways that cover the requirements that you have defined.
  12. Run your tests. For more information, see How to: Run Selected Tests.

    Verify that all your tests fail. If any test produces a result of Inconclusive, it means that you did not update the generated code to add the appropriate verification logic for that test. If any test produces a result of Passed, it means that you did not implement the test correctly; this is because you have not implemented your production code, so no tests should pass.

  13. Implement the interfaces and classes of your production code.
  14. Run your tests again. If a test still fails, update your production code to respond. Repeat until all the tests pass.
  15. Pick the next feature or requirement to work on and repeat these steps.

Lean times for online gambling

Infoconomy’s publication Information Age, November 2005, Lean times for online gambling, highlights a Lean/agile success story.

Mention of “emphasises face-to-face collaboration over documentation”, “product management team sits side by side with programmers so they can see what is needed as they go along”, “Daily five-minute morning meetings review yesterday’s achievements and the day’s plans”.

It’s a short article, but picks up on a few important points.

Visual Studio 2003 and 2005 Service Packs…

Scott Wiltamuth’s C# blog has hinted that we might might see some service packs for Visual Studio 2003 and the recently launched Visual Studio 2005. Rumour has it, the service packs for Visual Studio 2005 might be available during the first half of 2006.

Whilst service packs are usually welcomed, I am a little concerned that there is talk of a service pack for Visual Studio 2005…so soon. I mean, it’s only a matter of hours since it was launched, and days since it reached RTM. I suppose Microsoft had to release the product during 2005 and have enough time to ensure a timely series of launch events, hence early November. Given that revenue shouldn’t be a real problem for Microsoft, I’m pretty confident that this isn’t a case of early release to bring in early profit.

Visual Studio 2005, SQL Server 2005 and BizTalk 2006 launch

Steve Ballmer delivered the launch speech via satellite from San Francisco where he shared an auditorium with 3000 or so guests (developers). The UK launch was held at the London Stock Exchange yesterday. There’s an on-demand web cast available here.

The key launch message that came across revolved around: better decisions, faster results, better insight. These are values/principles that guided the individual product development (Visual Studio, SQL Server, BizTalk) and the broad platform development (encompassing SharePoint, Windows clients, Microsoft Office, Microsoft Dynamics, developer tools, management tools, XML web services, ind std and Microsoft own .net innovations)

Steve went on to highlight some statistics from IDC. Platform momentum, five years after the launch of .NET – when asked what platform are you using for mission critical applications: 35% of customers are using .NET whereas 25% using Java. “35%, number one clearly is .NET”. In calendar year 04, SQL Server out-sold DB2 and Oracle. And with the sheer power provided by Intel and various hardware vendors, the combination of hardware and Microsoft product sets, Steve came out with this quote:

“There is no job that is too big to run on entirely on the Windows and Microsoft platform”

The launch speech saw a student and Brian Goldfarb extol the virtues of the Visual Studio 2005 and SQL Server 2005 Express Editions. What’s important to note about the Express Editions is that fact that they are free. Obviously the Express Editions don’t have all the features of the full product versions, but the projects you create with them are upwardly compatible and they’ll give you great exposure to the Visual Studio and SQL Server family. Aimed at hobbyist and students, the Express Editions are a good way of getting that much needed product experience that will put you in good stead in your first job. Download your Express Editions here.

There seemed to be some arm waving surrounding the introduction of “My” – something that has been introduced into the Visual Basic.net language. I’m not sure what all the fuss is about, but will take this opportunity to remind everybody that Juval Lowy has gone ahead and implemented in C#. There’s some good stuff about the Visual Basic.net version over here. There’s more about “My” for C#, this and that, over here…or you can just download it from here.

I also got to meet Tim Anderson – I shook his hand and that’s about it: three weeks of ‘flu, cold, coughing and sore throat cost me my voice…I was sipping Lemsip all day!

My voice eventually returned…Microsoft’s Phil Cross put up with me for the best part of an hour – we seem to share the same ideas about the concept of feedback. Feedback is important, if you (as a “vendor”) ask your customer(s) for some feedback, e.g. a restaurant owner asking guests for feedback after their meal, please take the feedback and do something with it: don’t turn it back on the customer and make them feel guilty. Towards the end of the evening IT Week’s Martin Banks passed by to say “hello, goodbye”…I shook his hand too! Of course, all this hand-shaking is nothing in comparison to Richard Costall’s experience in this department! (I shook Richard’s hand before I knew where his hand had been…may be something will have rubbed off on me?)

Sign up for the Ready To Launch Tour!

Information Week’s take on the launch is here.

NUnit under Visual Studio 2005

With reference to this, Visual Studio 2005 Professional doesn’t come with the unit testing support that its big brother Visual Studio Team System does…

Charles explains how to get NUnit to work with Visual Studio 2005. Thanks Charles!

If you are planning to move to Visual Studio Team System, James Newkirk has written an NUnit convertor, available here.

One of NUnit’s key players, Charlie Poole, has blogged about the alleged demise of NUnit – read more about it here.

Fresh MSDN content

Courtesy of INETA, here’s some fresh reading material from the MSDN

.NET development
Windows Presentation Foundation Hands-On-Labs
http://msdn.microsoft.com/windowsvista/building/presentation/hands_on_lab/default.aspx

Development; Development tools
Celebrate the 20-year anniversary of C++ with the top C++ speakers in
the world in Las Vegas
http://www.devconnections.com/shows/cppfall2005/default.asp?s=67

Development guide
.NET development

patterns & practices Guidance: Complete Catalog
http://msdn.microsoft.com/practices/compcat/default.aspx

.NET development; Deployment; Design; Development; practices; Scalability

patterns & practices – VB6 to VB.NET Migration Guide: Home
http://www.gotdotnet.com/codegallery/codegallery.aspx?id=07c69750-9b49-4783-b0fc-94710433a66d

Threat Modeling Web Applications
Author: J.D. Meier, Alex Mackman, Blaine Wastell
http://msdn.microsoft.com/practices/default.aspx?pull=/library/en-us/dnpag2/html/tmwa.asp

Register Now for patterns & practices Summits
http://www.pnpsummit.com/_practices.aspx

Generics FAQ: Fundamentals
Author: Juval Lowy
http://msdn.microsoft.com/netframework/default.aspx?pull=/library/en-us/dndotnet/html/Fundamentals.asp (Printed Pages: 51)

Generics FAQ: .NET Framework
Author: Juval Lowy
http://msdn.microsoft.com/netframework/default.aspx?pull=/library/en-us/dndotnet/html/NetFramework.asp (Printed Pages: 35)

Generics FAQ: Tool Support
Author: Juval Lowy
http://msdn.microsoft.com/netframework/default.aspx?pull=/library/en-us/dndotnet/html/ToolSupport.asp (Printed Pages: 5)

Generics FAQ: Best Practices
Author: Juval Lowy
http://msdn.microsoft.com/netframework/default.aspx?pull=/library/en-us/dndotnet/html/BestPractices.asp (Printed Pages: 16)

Multimedia Content
Microsoft After Dark: The Launch Show
http://www.microsoft.com/winme/0510/25540/welcome.htm

Security; Web Services
Web Service Enhancements (WSE) 3.0 and Secure Web Services
Author: Mark Fussell
http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20051027WSE3MF/manifest.xml

Web development
Video Series: Getting Started with Visual Web Developer 2005
http://go.microsoft.com/fwlink/?LinkId=51655

Prescriptive architecture guidance
patterns & practices Developer Center
http://msdn.microsoft.com/practices

Reference
.NET development; Architecture; Development; Development tools; Patterns; practices
patterns & practices for Visual Studio 2005
http://msdn.microsoft.com/practices/VS2005/

.NET development; Development; Development tools; Migration; practices
Visual Basic 6.0 to VB.NET Upgrade Guidance – Community Pre-Release
Author: Edward Lafferty, William Loefler
http://www.gotdotnet.com/codegallery/codegallery.aspx?id=07c69750-9b49-4783-b0fc-94710433a66d

Technical article
Launch2K5: GridView Examples for ASP.NET 2.0
http://msdn.microsoft.com/asp.net/beta2/default.aspx?pull=/library/en-us/dnaspp/html/GridViewEx.asp

.NET development; Audio and video; Development
Non-Destructive Media Edits
Author: Arian Kulp
http://msdn.microsoft.com/coding4fun/inthebox/NDMediaEdit/default.aspx

.NET development; Game development
Kid’s Programming Language: Pong!
Author: Jon Schwartz
http://msdn.microsoft.com/coding4fun/gamedevelopment/KPL1/default.aspx

Debugging; Design; Development; Performance; User interface
Improving the Performance of InfoPath 2003 Forms
Author: Andrew Begun, Dafina Toncheva
http://msdn.microsoft.com/office/default.aspx?pull=/library/en-us/odc_ip2003_ta/html/OfficeInfoPathTroubleshootPerformanceBestPracticeGuidelines.asp (Printed Pages: 18)

DevelopmentNamed Return Value Optimization in Visual C++ 2005
Author: Ayman B. Shoukry
http://msdn.microsoft.com/visualc/default.aspx?pull=/library/en-us/dnvs05/html/nrvo_cpp05.asp (Printed Pages: 12)

Development tools; Security
Adopting Visual Studio Express Within Your Organization
Author: Rudolph Araujo
http://msdn.microsoft.com/vstudio/default.aspx?pull=/library/en-us/dnvs05/html/vsexpresssecurity.asp (Printed Pages: 10)

Mobility
Step by Step: Building a .NET Compact Framework Application for a
Windows Mobile-based Device Using Visual Studio 2005
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnppcgen/html/med201_msdn_netcf_app_vs2005rtf.asp (Printed Pages: 56)

Revised Content
Technical article
.NET development; Web development
ASP.NET Spiced: AJAX
Author: Karl Seguin
http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/ASPNetSpicedAjax.asp (Printed Pages: 17)

Architecture
Architecture Chronicles – Dynamic Modeling: Aligning Business and IT
(Landing Page)
Author: Dave Welsh, with Frederick Chong
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/MSArcSeriesMCSIntro.asp (Printed Pages: 2)

Web Service Deployment: Deploying Web Services in the Northern
Electronics Scenario (Architecture Chronicles – Dynamic Modeling:
Aligning Business and IT)

Author: Frederick Chong, with Jim Clark
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/MSArcSeriesMCS7.asp (Printed Pages: 18)

Web Service Health Modeling, Instrumentation, and Monitoring: Developing
and Using a Web Services Health Model for the Northern Electronics
Scenario (Architecture Chronicles – Dynamic Modeling: Aligning Business
and IT)
Author: Frederick Chong, with Jim Clark
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/MSArcSeriesMCS6.asp (Printed Pages: 46)

Web Service Solution Design: Developing a Solution Design for Web
Services in the Northern Electronics Scenario (Architecture Chronicles –
Dynamic Modeling: Aligning Business and IT)
Author: Frederick Chong, with Jim Clark
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/MSArcSeriesMCS5.asp (Printed Pages: 15)

Dealing with the “Melted Cheese Effect”: Contracts
Author: Maarten Mullender
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/MeltedCheeseContracts.asp (Printed Pages: 11)

Mobility
Step by Step: Migrating an eMbedded Visual C++ Application to Visual
Studio 2005
http://www.msdn.microsoft.com/library/en-us/dnppcgen/html/med303_msdn_migrate_evc_app_vs2k5.asp (Printed Pages: 22)

VistaDB 2.1 database for .NET has been released

This 2.1 update includes over 60 improvements, including new support for .NET 2.0 and Visual Studio .NET 2005. VistaDB is a small-footprint, embedded SQL database alternative to Jet/Access, MSDE and SQL Server Express 2005 that enables developers to build .NET 1.1 and .NET 2.0 applications. Features SQL-92 support, small 500KB embedded footprint, free 2-User VistaDB Server for remote TCP/IP data access, royalty free distribution for both embedded and server, Copy ‘n Go! deployment, managed ADO.NET Provider, data management and data migration tools. A free trial is available for download.

Learn more about VistaDB
Repost this to your blog and receive a FREE copy of VistaDB 2.1!

And of course, if Vista Software would like VistaDB 2.1 reviewed for publication, they’re free to contact me with details of how I can get my hands on a full NFR copy of VistaDB 2.1…over to you!

Whilst you’re looking over 2.1, look at what’s coming in 3.0!

Excel: Column Number to Letter(s)

I found myself working inside Excel this week, doing a little bit of VBA…

It has been a while since I had to work inside this environment, my memory was stretched as I tried to remember what code I had already written (short libraries), etc. My troubles were compounded by the fact that the machine I was using did not have the VBA Help for Excel installed, so I was relying on my memory…which isn’t a good thing!

So I’m grateful for the existence of Dick’s Blog and in particular this post.

I had the need to convert a column number into it’s alphabetic counter-part…e.g. ColumnLetter(1) returns A…I was pleased to find this code snippet over at Dick’s blog:

Function ColumnLetter(ByVal colNum As Long) As String
Dim i As Long, x As Long
For i = Int(Log(CDbl(25 * (CDbl(colNum) + 1))) / Log(26)) - 1 To 0 Step -1
x = (26 ^ (i + 1) - 1) / 25 - 1
If colNum > x Then
ColumnLetter = ColumnLetter & Chr(((colNum - x - 1) \ 26 ^ i) Mod 26 + 65)
End If
Next i
End Function

It was just the ticket – thanks Dick!

David Anderson interviewed by Robert Scoble

Channel 9 do a good job of getting life inside Microsoft presented to the outside world…here’s another fine example.

David Anderson, who has previously spoken at Agile Scotland meetings, was quizzed by Robert Scoble about “Agile Management and what we are doing with MSF for CMMI Process Improvement”.

Download and watch the video here.

The interview was littered with good advice, but I homed in on a couple:

developers don’t like two things

  1. interfering management, i.e. micro-management
  2. management not doing something when something abnormal happens

“Incremental development (Ed.with regard to TDD) only works when refactoring is part of the equation”, Ron Jefferies

It’s well worth the download, do take the time to watch it. Clarke sums David’s style up rather well: “David has a nice way of simplifying complex things”