UK Vista and Office Developer Launch – Register Now!

As I have mentioned before, Microsoft UK are holding their own Vista launch event in Reading on 19th and 20th of January.  Registration for this has now opened. http://www.microsoft.com/uk/launch2007/dev/default.mspx

On the 19th, they have some great presentations including a Keynote from Sanjay Parthasarathy (vice president of the Developer and Platform Evangelism Group at Microsoft Corp).  They then have two tracks, one for Vista and one for Office with some great looking sessions.

On the 20th they are holding two coding sessions, the morning is focused on Vista with the afternoon focusing on Office.  Some prizes are on offer here!  Ian Moulster says this about the Saturday – “Well, we’re really keen to allow you to get your hands on these products as developers. So we’re building a huge room full of machines and inviting you to come along and write some code with us. We’ll brief you on an assignment then give you help to write the code in a two hour period, making sure that you get real experience of the platforms. And we’ll have some fun too, seeing as it’s a Saturday.”

Not only are they doing the launch in Reading, but they are also putting everything online ON THE DAY! (no need to register for this, information will be on the launch page on the day) On the Saturday you will be able to interact with developers via chat rooms, forums and the blogs.

Sounds like a lot of fun!!  I’ve registered.

 

 

Technorati tags: , , ,

Singleton and Observer Pattern in Java

This has been done a million times before, but I just wanted to do it myself in Java.  Also has given me chance to use IntelliJ IDEA which is a great Java IDE on the mac – shame its not free,  but it does make doing java that bit more enjoyable so might be worth the $99.

Basic model.

  • Main class – Creates everything, sends messages which the observers should output
  • Feed and AnotherFeed – Observers registered to listen to the Alert object for messages, outputs any messages to console prefixed with their name.
  • Alert – Observable, receive message and notifies observers (feed and anotherfeed).  This follows the singleton pattern, so only one object is ever created.
  • Alerter – sends a message to Alert to trigger change.

Simple but effective (for a simple demo).

The main class contains the following:

//These will be used to listen for alerts and output them to the console
Feed f = new Feed();
AnotherFeed f2 = new AnotherFeed();

//Say they want the alerts
Alert.getInstance().addObserver(f);
Alert.getInstance().addObserver(f2);

//Call an object, which inturn calls Alert that something has happened.
Alerter.Alert(“DON’T PANIC”);
Alerter.Alert(“This is a test”);
Alerter.Alert(“Thanks”);

 

The alert class looks like this:

static Alert instance = null;

private Alert(){}

public static Alert getInstance()
{
if(instance == null)
{
instance = new Alert();
}

return instance;
}

public void postMessage(String message)
{
//push model
setChanged();
notifyObservers(message);
}

If you do not call setChanged(), then it doesn’t work.

Alerter looks like this

public static void Alert(String message)
{
Alert.getInstance().postMessage(message);
}

 

Feed and AnotherFeed do this:

public void update(Observable observable, Object object) {
System.out.println(“AnotherFeed Alert: ” + object.toString());
}

 

Because I send the message as a parameter of notifyObservers(), it gets sent to the observers as the object parameter.  This is the push model, in the pull model the observer would have had to gone and received the message for itself.

 

The final output to the console should be this:
AnotherFeed Alert: DON’T PANIC
Feed Alert: DON’T PANIC
AnotherFeed Alert: This is a test
Feed Alert: This is a test
AnotherFeed Alert: Thanks
Feed Alert: Thanks

Notice AnotherFeed outputs first, this is because it was added second, so the observers get called in the opposite order than what they where added.

 

Hope this helps someone, any questions leave a comment.

 

Code can be downloaded here : http://www.benhall.me.uk/code/Observer.zip

 

WPF/E Hello World

Today I had a little bit of spare time so I started to play around with WPF/E and Cocoa (OSX programming language).  After a morning reading about Cocoa (need to spend more time with that) I decided to spend the afternoon with WPF/E.  This is the first time I have tried to do WPF and XAML animation so it was very new to me.

View the sample here http://www.benhall.me.uk/helloworldwpfe/

First things first:
Using Beta 1 of Blend
First CTP of WPF/E
XP SP2, Visual Studio 2005 with Templates installed

 

To start with I created a new project using the VS templates.  Note, if you have VS SP1 installed then you may have some problems with the samples.  John Rayner has a guide on the templates.  http://blogs.conchango.com/johnrayner/archive/2006/12/05/WPF_2F00_E_3A00_-Setting-up-your-workstation.aspx 

The sample creates a html page, javascript and a xaml button.   On mouse events, the button changes colour and on click it displays an alert.  For my hello world, I wanted to extend this a little bit.

 

First thing I did was copy the XAML into Blend, however this doesn’t work as Blend does not yet support creation of WPF/E XAML. Instead, I created a new project in Blend and built my button up using that.  Blend is cool, very drag and drop and you can click the interaction, set when stuff will happen and using the timeline you can say where you want stuff to be at certain times in the animation and blend works out the movement for you.  Very cool.

After I created the XAML I had to modify it to work with WPF/E.  Mike Harsh replied to my post on the forums on how this should be done.  http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=986587&SiteID=1

Just to quote it here:
“For the Expression issue, current CTP of Blend does not yet support the “WPF/E” XAML namespace (http://schemas.microsoft.com/client/2007).  However, the “WPF/E” runtime supports but the WPF and “WPF/E” namespaces.  To open the plugin.xaml file from the “WPF/E” template in Blend, just change the XAML schema to http://schemas.microsoft.com/winfx/2006/xaml/presentation“.

For coping animations from Blend to “WPF/E”, you’ll need to take these steps:

 – Copy the Canvas.Triggers block to the “WPF/E” XAML file

 – Remove the Storyboard attribute from the BeginStroyboard tag

 – Copy the Storyboard block from the resources section of the Blend XAML and paste it into the “WPF/E” BeginStoryboard tag.

 – Change the x:Key attribute to x:Name

This will give you an animation that works in “WPF/E”.  This workflow is not ideal, but keep in mind that the current CTP of Blend isn’t yet optimized to output “WPF/E” friendly XAML.

The next thing you’ll want to do is change this animation to start when some other event is triggered.  To do this, change the BeginTime of the Storyboard to be “1”.  This maps to one day.  Then, in your eventhandler, get a reference to the Storyboard by calling findName(““) and then calling the begin method on the Storyboard.”

 

After following this, and also removing the RoutedEvent tag, it worked!! Because I removed the Event handler it doesn’t work when I moved my mouse over like it should.  To solve this, we need to jump into javascript.  At the top of the canvas there is the  Loaded=”javascript:root_Loaded” statement, together with in the HTML we now have full access to the world of javascript.

In the loaded event, we setup the event handlers so we can access all the events in javascript.

function root_Loaded(sender, args) {
var button = sender.findName(“button”);
button.mouseEnter = “javascript:handleMouseEnter”
button.mouseLeave = “javascript:handleMouseLeave”
button.mouseLeftButtonUp = “javascript:handleMouseUp”
button.mouseLeftButtonDown = “javascript:handleMouseDown”
}

An example of this is when the mouse enters the button, and the code is executed.

function handleMouseEnter(sender, eventArgs) {
var gradientStop1 = sender.findName(“gradientStop1”);
var gradientStop2 = sender.findName(“gradientStop2”);
gradientStop1.offset = 1;
gradientStop2.offset = .403;
var wpf = document.getElementById(“wpfeControl1”);
var o = wpf.FindName(“sbMouseClick1”);
o.begin();
}

First get access to the WPF control

var wpf = document.getElementById(“wpfeControl1”);

Then it get access to the storyboard we created in XAML.
var o = wpf.FindName(“sbMouseClick1”);

Then we can call methods on the storyboard such as begin and stop.
o.begin();

This then links everything together allowing for animations and completing my hello world application.

 

I think this covers most of the issues I had with getting a Hello World application created.

Sample is online at : http://www.benhall.me.uk/helloworldwpfe/

Code at: http://www.benhall.me.uk/helloworldwpfe.zip  This also includes the original xaml created by blend so you can compare how I changed it.

 

NOTE: When I uploaded the sample onto my hosting, I was/am having problems with caching of the XAML, in IE7 I used the Developer Toolbar to disable caching and clear the cache for my domain but still didn’t seem to work.  Working locally it was fine.  Just something to be aware of.

 

I hope this helps you, any questions post a comment and I will get back to you.  Any other comments as well.

 

Technorati tags: ,

WPF/E CTP Released

Just thought I was say that WPF/E has been released.  Just downloaded and installed it onto my iBook – very good (and works!).

Look out of more info soon, hopefully I will blog more about this as its something I think is really cool.

Think its still very rough and ready, but it will give a good idea where its going.

More information here:

http://blogs.msdn.com/bardak/archive/2006/12/04/excitement-is-in-the-air-wpf-e-is-finally-here-well-at-least-a-ctp.aspx 

 

 

Technorati tags: ,

DDD4 – Post Event

On Saturday I attended DDD4 at Microsoft HQ UK, Reading. This is a event run by the community for the community.  I had been looking forward to this event for the past few months, so I was excited that it had finally arrived.  Luckily I managed to grab a lift off Jeff from UsingTangents (Thanks!).

On arrival everyone was greeted to sausage and bacon rolls with loads of coffee which was a great start to the day.

First session was on AntiPatterns and writing crap code.  This could have been a really good session, but I think Ben must have been overrun with work (plus he had another session to plan for) and he used a non-admin account meaning his demo failed to work and kept referring to his notes throughout – good general discussion.

Next up was intro into Robotics studio which was great, shame bluetooth didn’t connect to the NXT but was still very good. I think I have managed to get Sarah to buy me one for Christmas 😀

Richard Fennell then gave a talk on continuous integration which was about the best talk I have saw.  Two great demos with a good discussion about the use of the technology.  Really good!!

At lunch time there was Grok Talks and a Park Bench discussion. I think this was a bit more popular than they thought so 60+ people where sat on the floor making it difficult to listen to, shame they didn’t use the empty Memphis room next to it – maybe next time.  But definitely good use of the time!

I also got dragged kicking and screaming (ok, maybe not) into a back room my Matt Duffin and Mark Johnston (DPEs) for an interview for Channel 9 site.  Think it could have been a lot better (:( sorry guys) but keep an eye out for it.  Was going to try and get on the NxtGenUG podcast but I didn’t get chance to see Dave in the afternoon 🙁

Aspect Oriented Programming was next, but have to admit a lot of it went over my head.

Finally, DataAccess Layers – Convenience vs. Control and Performance? was up, this was the one I was looking forward to most but the projector failed for the first 15 minutes which was a shame.  Still a great talk, but might need to follow up on a few things which wasn’t discussed.

BUT WHERE WAS THE SWAG?? Apart form in Richard and Dave’s session where they had 17Kg of the stuff wasn’t anything about.

Overall, Very good day.  Maybe i’ll do a presentation @ DDD5.

 

Technorati tags: , ,

Microsoft Student Supremo

Microsoft UK have launched a new competition aimed at University students.  Answer 10 technical and non-technical questions and the top 3 people at the end win a prize!

Prizes include Alienware Aurora M9700, Xbox 360 and Microsoft Zune.  The University with the most points win an on campus Xbox day with food, drinks and loads of games.

Link:  http://www.microsoft.co.uk/studentsupremo

I got 1148 but I’m sure you could do better…

Good Luck!!

 

Technorati tags: , , , , , ,

Imagine Cup Korea 2007

Imagine Cup 2007

 Registration for this years event is now open!! They have now updated the sites with more information about this years competition and now you can setup your team for the different areas.

The competitions this year are:

  • Software Design
  • Embedded Development
  • Web Development 
  • Project Hoshimi – Programming Battle
  • IT Challenge
  • Algorithm
  • Interface Design
  • Short Film
  • Photography 

Some are group based, while others you can work on individually.

The main competition (for me) is software design where teams of upto four students are invited to design software based around a theme.  As previously posted, the theme for this year is Imagine a world where “technology enables a better education for all”.  This is the one I am planning on entering, just need to find a team.  First you have to win the UK based round, before being invited to Korea.  Can’t wait!

Think I am also going to try my hand at the Algorithm as well.

So why should you enter?  Over the past four years the imagine cup have grown to a massive event with lots of publicity, its a great thing to discuss in interviews, you can showoff your knowledge and plus its FUN! Oh and there is $25,000 plus other ‘money can’t buy benefits’ on offer for the winning team.

I’m sure you will be hearing a lot about this event shortly as MSPs will soon be promoting it around the various Universities.

For more information visit:

http://www.microsoft.com/uk/academia/imaginecup/2007/default.mspx

http://imaginecup.com/default.aspx

 

I strongly recommend you look into entering.  If you are planning on entering, or have any questions please post on the comments and I’ll get back to you ASAP.

Windows Powershell RTW

Windows Powershell has been released to the web, with downloads now available for Vista RC1, XP Pro SP2 and 2003 Server.

“Microsoft Windows® PowerShell is a new command-line shell and scripting language designed for system administration and automation. Built on the .NET Framework, Windows PowerShell enables IT professionals and developers control and automate the administration of Windows and applications.”

To download visit : http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx

 

I’ve just installed it and looking forward to having a play as everyone keeps saying it is really cool.

 

Technorati tags: ,

MySQL logging queries under OS X

I really wanted to get MySQL logging all the queries rails was producing.  After a good hour of messing around I have cracked it!

Mac OS X has a startup file which starts mysql on startup.  This needs to be modified to turn on logging support.

This can be found in /Library/StartupItems/MySQLCOM.  The file required editing is MySQLCOM.  Open it up using your favorite text editor.  The the StartService() method, and then after the start command add

” –log=/var/log/mysqld.log”

To create the log file, use the following commands

sudo cd /var/log

sudo touch mysqld.log

sudo chown mysql mysqld.log

Once that has been done, restart the server

sudo /Library/StartupItems/MySQLCOM/./MySQLCOM restart

You can then tail the log file and see all the queries in real time

tail -f mysqld.log

 

Bobs your uncle! Done

 

Technorati tags: , ,