Joni's profileData MattersBlogLists Tools Help

Blog


    8/6/2007

    My blog has relocated to blog.jemm.net !

    I decided to centralize all my postings to blog.jemm.net (rss).

    I'm not sure what I'll do with this Live Space -blog in the future, but I'll let it exist to avoid breaking links and to preserve the (few) useful posts here are.

    If you received this through your feed reader, please update your subsription to point to the http://feeds.feedburner.com/Jemm.

    One advantage of this to you is that should the feed url of my blog ever change again, you don't need to do anything as the FeedBurner points always to the right address.

    7/5/2007

    Dependency Injection -pattern

    Dependency injection -pattern (and a related pattern, Inversion of Control, IoC) helps to make code more maintainable and modular. It can be used for replacing implementation on the fly or add functionality at the runtime. If you aim to make code more loosely coupled or want to make a plugins, then you should be aware of the dependency injection. It helps automated testing, too.

    Lately I have been building an architecture for an interesting product at work. As it aims to be a major business for a long while, I have to make sure it is easy to test, maintain and expand later as requirements will evolve. The "let's make complete specs first and then code it" -days are over as the more agile methods gradually take over.

    Loose coupling

    One of the main rule I decided was to make sure that the most important layers are loosely coupled. A data access layer (DAL) is a natural example where it is useful. In this project I decided that we'll use the SubSonic as the object-relational mapping tool until final releases of .NET 3.5/LINQ or Entity Framework arrive.

    While SubSonic creates usable classes, using them directly would tie us to the tool too tightly for years to come. Instead, the goal is to keep our own entities/object model as abstract as possible and separated from actual implementations, like DAL-technologies. It means (with the current proof-of-concept, at least) a little bit more work is required to map classess that the SubSonic creates to own own entities that need to be maintained by hand. However, it reduced lot's of trouble in the future as things can be replaced easily.

    Another example is an integration layer between our business logic and MS CRM API's. When we abstract the integration layer with loose coupling we are safe, should the underlaying API change or MS CRM be replaced with completely different product.

    How to implement

    Before you can add dependency injection to your application, you should know how interfaces work. Essentially, they define a contract that the classes that inherit the interface must implement. As long as two or more classes share the required interface(s), they can be injected to the class that requires one of them.

    Once you have the classes that implement the interface, you need to decide what kind of dependency injection you want to use. Do you want to supply the class being injected via constructor or set it through a property after instantiation? Here is an article at DevX by Joydip Kanjilal that discussess this choice.

    Finally, you need to decide where to store information about the class that should be injected. You can hard code the reference and construction of the dependent classes to the calling code (DI) or add reference to the dependent class dynamically with reflection and configuration file to avoid the need of recompilation (which is really Inversion of Control -pattern).

    I didn't bother writing code samples this time as all the linked resources have plenty of them to give the idea and a simple search gives even more.

    Related Resources
    1/1/2007

    Wii rocks

    I bought us a Nintendo Wii for Christmas as I happened to stumble upon on a pile of Wii consoles in a local store. They are hard to find here in Finland just like everywhere else, so I was a bit surprised and couldn't walk past them...

    The console comes with the Wii Sports that is one of our most played games with the console. No wonder Time picked it up as the best game of the year 2006!

    Other games that I obtained were The Legend of Zelda: Twilight Princess and Rayman Raving Rabbids. Wii Play came with an extra controller, but it isn't that interesting, though quite good for introducing the controls for new players.

    I have already spent several hours with my girlfriend playing with the Wii. Wii like especially the Wii Sports and Rayman Raving Rabbids as they are fun when played together. My girlfriend has always been generally open about computer and console games but we have never before spent together as much time playing something :)

    The Wii is great, but it won't completely replace my Xbox 360 which is a great console, too. Each console have their own advantages. Wii is great for playing with girlfriend or with friends, but often I want to play the games I have for the Xbox 360.

    12/2/2006

    New Remote Desktop client for pre-Vista OS's

    As you may know, Vista comes with an updated Remote Desktop client with some new features.

    I was happy to notice that the updated client is available for previous Windows versions, too. The features include more secure authentication methods, TS Gateway for connecting to computers behind firewalls and NATs, TS Remote Programs for running individual programs over the internet, multimonitor spanning and support for 32-bit colors.

    Here are the direct links from the Knowledge Base article:

    DownloadDownload the Terminal Services Client 6.0 update for Windows Server 2003 (KB925876) package now.
    DownloadDownload the Terminal Services Client 6.0 update for Windows Server 2003, x64-based versions (KB925876) package now.
    DownloadDownload the Terminal Services Client 6.0 update for Windows XP (KB925876) package now.
    DownloadDownload the Terminal Services Client 6.0 update for Windows XP, x64-based versions (KB925876) package now.

    11/7/2006

    .NET Framework 3.0, new VSTO, ASP.NET AJAX beta 2...

    Wow, lot's of great releases from Microsoft!

    Here are direct links to download pages for the just announced releases:

    Microsoft .NET Framework 3.0 Redistributable Package Yes, this is the RTM!
    Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation) RTM!
    Visual  Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November  2006 CTP [unsupported]
    Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System RTM!
    Visual  Studio 2005 extensions for Windows SharePoint Services 3.0, November  2006 CTP [unsupported, for WSS 3.0/MOSS2007 RTM version only!]
    ASP.NET AJAX Downloads (Beta 2 now available!)

    From http://msdn.microsoft.com/vstudio/devsolutions/

    Add 2007 Office System (client & server), some Vista and a bit of those dev tools and you'll be set!
    So many great new dev tools, so little time...
    8/17/2006

    Math support in Office 2007

    After I read this interesting blog entry by Brian Jones, I got inspired to play around with the new equation tool and more! I'll post my findings here.

    First, some interesting trivia about math support in Office 2007:

    • Microsoft investigated using MathML in Office 2007 but found out that it doesn't achieve all the required scenarios.
    • Murray Sargent, who is one of the key persons behind math support in Office 2007, has also worked on the MathML 2.0 targets body. This has helped with interoperability and it shows.

    I started playing around with the new equation tool which is cool by itself. Here are some tests:

    Copying equation as text

    First I tried doing some basic equation and picked a ready-made quadratic formula from the list.

    Then I copy/pasted it into Notepad and it changed automatically into linear form:
    x=(-b±√(b^2-4ac))/2a! How cool is that?

    Easier to ask help from someone via e-mail, for example: "Please, can you help me with this equation: e^x=1+x/1!+x^2/2!+x^3/3!+⋯,-∞<x<∞"

    Copying MathML

    Brian's blog mentioned that you can copy and paste MathML and it gets translated automatically.

    I found a site MathML Central and there was a page that allows generating sample MathML.

    For example, if you copy the following MathML to the Word 2007 (beta2):

    <math xmlns='http://www.w3.org/1998/Math/MathML'>
    <mrow>
    <mi>sin</mi>
    <mo>&#8289;</mo>
    <mo>(</mo>
    <msup>
    <mi>x</mi>
    <mn>2</mn>
    </msup>
    <mo>)</mo>
    </mrow>
    </math>

     It's automatically translated to: sin (x^2)

    Of course, that was quite simple example, but most other tests worked fine, too. Some matrix didn't seem to translate, though.

    I don't really need equations that often if ever. Anyway, the new math support is just one example of the enthusiasm and attention to the detail that the Office team has put into the next version.

    8/16/2006

    Windows Live Writer

    Don't you hate these posts where everyone announces release of a new blogging tool and then tell that the posting is actually written with the specific tool?

    Ok, enough of ranting.

    Microsoft recently released the Windows Live Writer beta which is a new free wysiwyg blogging tool for Windows. You can download it from here (requires .NET 2.0 runtime).

    Go ahead and try it, it is cool! Currently this is a bit better tool for blogging than Word 2007 as you can attach images easily without FTP, there is integrated mapping tools and plugin-support. 

    This blogging tool has also spell-checking! Notice anything funny? :D

    Oh, I almost forgot to mention: This post was written with Windows Live Writer!

    Ok, ok... I am guilty of the practice I ranted about in the beginning of the post so sue me! :P

    8/1/2006

    Great Star Wars -parody

    This fan-made video where Darth Vader shows his meanest side makes me always laugh 
     
     
    Update: Spaces doesn't seem to allow embedding of the [YouTube]-videos , changed to link.
    7/28/2006

    Using Office 2007 for web page graphics

    Office 2007 has very powerful tools for creating and editing graphics. They are powerful enough for doing visually appealing graphics for web pages!

    Even though I prefer simple web pages with minimum amount of graphics, I admit that they often make the web page visually more appealing and often also more usable, if used carefully. As I’m not so visual person, my skills with tools like Paint Shop Pro, Photoshop and Paint.NET are limited.

    When playing around with the Office 2007 I thought, why wouldn’t I use it for doing the graphics? It can save you a lot of time to get Web 2.0-ish effects like gradients and glass table effects (reflection) that are a trend these days. Just take a look at atlas.asp.net, for example.

    The process goes like this:

    1. Start some Office 2007 –program, like PowerPoint.
    2. Go to the Insert-tab of the ribbon.
    3. Insert some shape and adjust its properties like size and text.
    4. Select the shape and go to the Drawing Tools / Format-tab
    5. Choose effects for the shape and/or text. You can combine as many as you like.
    6. When satisfied with the result, right-click on the shape and save it as an image file like PNG.

    Here are some examples that I did with the PowerPoint 2007 Beta 2 in a few minutes.

    Disclaimer: Examples were done quickly just to show how easy they are to make. They are not supposed to be prime examples of web graphics ;)

    5/26/2006

    ODF vs. Open XML discussions continue

    There is a really interesting blog entry in Brian Jones’s blog about competing document standards. Now that Microsoft’s formats are based on XML, there are lots of comparisons and discussions about the ODF and Open XML -formats. Basically for the ODF-side thinks that Microsoft should ditch the Open XML for ODF or at least add support for the latter. Like Brian Jones mentions in the quote below, the arguments are mostly political:

    “Almost every site I visit to find more information focuses almost completely on the marketing or political side of ODF. There are discussions around conformance, logo compliance, getting governments to support it, etc. etc. etc. I'm having a really hard time finding any good blogs or sites that discuss how to actually use it.”

    The article in questions goes into detail about technical differences between the formats/specifications and rises an issue about numbering formats. While it may seem like a little issue, localization etc makes things more complicated.

    There is also a nice set of comments. Check especially this one by M. David Petterson Quote:

    “What I have a hard time understanding is that I often hear people suggest that because Microsoft is a monopoly share holder of the desktop, it has caused them to become less innovative, less feature focused, and instead attempting to lull the users into accepting mediocrity with a smile. What's odd is that it seems to be the same folks who make statements such as this also believe that working together to create one document format is the right thing to do. So on one hand, the lack of competition due to the monopoly is a bad thing because it allows Microsoft the "luxury" of being less innovative, because there's nothing pushing them to do more.  On the other hand, there seems to be a belief that, in fact, lack of competition isn't a bad thing after all, and in fact a better world will result if we could all just focus on being less competitive in the office document space rather than more.”

    Elsewhere there are also heated conversations about ZDNet.com article where “Microsoft claims that the OpenDocument Format (ODF) is too slow for easy use.”

    I think that while a common file format for office documents would be a nice idea in the perfect world, it is still quite impossible to achieve in the real world. There would always be different implementations, bugs etc by each maker. Just look at where we are with supporting of the (X)HTML/CSS standards and browsers. While many latest browsers support them quite well (excluding IE6), there are still lots of minor differences while the specs are much simpler than those of Word, for example.

    Fortunately, due to the nature of the XML and open specifications, interoperability between office suites will be much easier to implement in the future.

    5/24/2006

    The Office 2007 System Beta 2

    Finally installed the latest beta of the Office on my home computer… work laptop to follow soon! I must say that this beta 2 has much better feel to it than the last refresh did.

    Of course, this post was made with Word 2007’s blogging feature. :D

    Now that the writing of the blog entries is much more convenient, I hope to write more often. I just need to think of some interesting subjects (meaning: posts unlike this one).

    3/29/2006

    Script that helps writing stored procedure parameters

    When writing stored procedures (sprocs) for the SQL Server, it is tiresome to write all the parameters for a typical sproc that modifies a table:
     

    CREATE PROCEDURE dbo.Table1_Modify

    @DataID

    AS int,
    @FieldID
    AS int,
    @Title
    AS varchar(100),
    @Value
    AS varchar(255)

    AS

    ...

     
    To reduce some repetitive typing, I did a small helper procedure that gives you all the columns of a given table as a parameter list:
     

    CREATE

    PROCEDURE dbo.GenerateSprocParams

    @TableName

    As varchar(255)

    AS

    --Generates parameter list for the given table

    SELECT

    ' @' + column_name + ' AS ' + data_type +

    CASE

    WHEN character_maximum_length IS NOT NULL
    THEN '(' + cast(character_maximum_length as varchar(10)) + ')'

    ELSE ''

    END + ', ' As 'Parameters'

    FROM

    information_schema.columns

    WHERE

    table_name = @TableName

    Go

     

    After that all you need to do is call the procedure:

    EXEC

    GenerateSprocParams 'MyTable'

     

    And the result will be like:

    Parameters
    -----------------------------
    @DataID AS int,
    @FieldID AS int,
    @Title AS varchar(100),
    @Value AS varchar(255),

    ...

     

    From the results it is easy to copy the list for the CREATE PROCEDURE-script. Be sure to change the result type into text-mode from the Query-menu of the Query Analyzer or Management Studio before executing the script. (The example was tested on SQL Server 2005)

    Next step would be to generate whole procedures similarly, but there are tools for that already.

    Anyway, I hope this gives you at least some ideas how to utilize the metadata of the SQL Server!

    1/31/2006

    Lost on Lost

    The higly popular TV-series Lost started here in Finland last week.

    I had waited for it for a long time and it is indeed very good and gets even better after each episode. How do I know if it just started?

    Well, I bought the first season box that was already available at the Free Record Shop for about 50 euros. That’s bargain for 17 hours and 49 mins of material (+ over 8 hours of extras for those who are interested).

    We, me and my girl, have now been watching it daily, sometimes many episodes and we are already at the fourth dvd of seven discs.

    It is much nicer to have the dvd’s as I can now choose the pace and watch the show without ad’s in dvd-quality (no HDTV here yet).

    Highly recommended for those who got hooked in the pilot episodes 

    11/23/2005

    Reporting made easy

    In case you haven't checked out the ReportViewer control in WinForms 2.0 yet, do it now.
     
    I have been using the SQL Server Reporting Services for a while and the only problem with it is the need for Reporting Server to be installed somewhere in the network. Also, it is hard to integrate it as a part of your own client-side solutions.
     
    After fiddling around with the ReportViewer for a while, it was apparent that there is still all the power of the Reporting Services -reports, but in much more manageable form.
     
    The best part is that it really is stand-alone. You can build, view and print full reports with the Report Viewer from your own Windows apps. It also supports exporting to PDF.
     
    Solves at least all my printing needs
    10/28/2005

    Replacing betas of SQL2005/VS2005 with RTM

    Uninstalling old versions

    If you have any betas, check out first this link about uninstalling previous betas in Aaron Stebner's weblog. There are useful instructions and tools for this delicate process.
     
    When you need the redistributables and SDK's, Aaron's blog (again) has all the relevant links.
     

    Installing RTM's, but in which order?

    After you have cleaned your computer out of any betas and CTP's, you can install the final versions.
     
    I'm not sure if it still matters, in what order you should install the SQL Server 2005 and Visual Studio 2005 on the same machine, but in betas you had to install SQL Server 2005 first.
     
    I recall vaguelly that this was because of the conflicting beta-versions of .NET Framework , so it is probably old issue, anyway.
     
    As of writing this, I hadn't found any definite answer. One friend said, that the recommended order is:
    1. .NET Framework 2.0
    2. Visual Studio 2005
    3. SQL Server 2005

    If you have any corrections, please comment and I'll update this post to avoid any confusions.

     
     
    10/24/2005

    Got some new books

    I just visited a local book store and got some new books.

    This time I picked:

    Framework Design Guidelines

    This should give me some tips how to design better API's for libraries and frameworks in C#. Good help when doing code reviews and such, too. Not to mention when teaching .NET and/or C# to those that are new to the .NET :)

    Visual Studio Tools for Office : Using C# with Excel, Word, Outlook, and InfoPath

    I have always been interested in using Microsoft Office in business processes as part of the user interfaces (I believe there should be many UI's for the enterprise - all tailored to individual roles' needs).
    Hopefully this book helps me to achieve some level of integration of our business with the Office. Especially SmartTags and Task Pane-integration could be useful when making offers and other work-related documents.

    Patterns of Enterprise Application Architecture

    This isn't a very new book, but I have been thinking of getting this for a long time, as my primary interest lies in enterprise applications. Should be good read :)

    Enterprise Integration Patterns

    The last book (for today) was this one. Modern enterprise architectures should have a decent service layer. As my experience and skills still need an improvement in that area, I decided to add this book to my cart. It should also give some good background for preparing for the Indigo... I mean... Windows Communication Foundation.

    It may take a while before I can comment on the quality of any of these books, but I'll probably mention something if some book exceeds my expectations or if it is not so good as I expected.

    10/15/2005

    Tablet blogging

    This is my first post with my new TabletPC, Fujitsu-Siemens T4010. I like it very much, especially when reading rss-feeds etc on bed.
     
    I use NewsGator and Outlook 2003 works well in portrait mode.
    Last weeks have been busy, so my blogging has  lagged somewhat
     
    Right now I'm upgrading my server and preparing for a c#-course (2124) that I'll be teaching next Monday.
    But now I should return to my tasks...
     
     
     Btw, wrote this post with the pen to get more feeling with it. Neat, huh?
    9/16/2005

    PDC05: Show Off

    Yesterday was the first PDC05 Show Off ever.

     

    The idea of the event was to show cool, interesting and/or funny videos submitted by people in advance. The maximum time for each video was 5 minutes. You can read more about the idea from Michael Swanson’s blog.

     

    There were some really cool videos that will be available from Channel 9 in case you didn’t make it to the PDC or the Show Off. My favorite ones were the Tablet PC based labyrinth game, the funny video about internals of .NET (by Microsoft Sweden) and many others.

     

    As I expected, the spirit of in the event was strong and everybody cheered after or even during the videos, if they were especially cool. The PDC Show Off reminded me very much of some small demo parties, where people gather to show their cool and advanced programming skills. I’m sure that in the future we’ll see some WPF-based (Avalon) demos that’ll try to take advantage of all the power of the Windows Vista platform for cool visual effects.

     

    I enjoyed the event very much and will attend it at the next PDC, too. Who knows, maybe I’ll contribute with some video, too. That is, if I come up with some cool enough idea by then

    9/14/2005

    PDC05: Keynote 2 Summary

    Lot’s of new information, again! I’ll just write a short summary here and then split each highlight into individual posts. That way it’ll be easier to refer to in the future.

     

    The second keynote introduced many new technologies and products around .NET and Office 12.

     

    Highlights were:

    • Windows Workflow Foundation (WWF?)
    • Expression family for designers:
      • Acrylic (the drawing program that exports XAML)
      • Quartz (The really cool XHTML/CSS/ASP.NET/XML/XSL designer)
      • Spark (The tool for creating animations and effects)
    • Visual Studio for Applications (VSTA)
    • Windows SharePoint Services v.3
    • InfoPath 12
    • Office Server –products (like Excel)

     Other cool things:

    • All PDC attendees will receive a free SQL Server 2005, when it ships!
    • All PDC-attendees will get access to Office 12 Beta 1 (via BetaPlace), when it is ready
      • And that’s not all! First 100 that submit Watson bug-reports, will receive Office Steak Knives! :)

    I’ll submit my thoughts and notes about the highlights mentioned above as soon as I have the time to write them.

    PDC05: Presentation layer, IIS7

    Last sessions of the Tuesday for me were:

    Choosing the Right Presentation Technology: Windows Presentation Foundation ("Avalon"), Windows Forms, ASP.NET, IE, and More.

    and

    A Lap Around IIS7.

     

    The title says it all about the contents of the first presentation: It compared the ups and downs of each presentation layer technology and had some demos around ASP.NET’s Atlas, WPF/E and WPF -applications.

     

    WPF/E (“Everywhere”) was mentioned briefly at the keynote, but its practical usage was left bit hazy. This session told more about this lightweight version of the WPF, which consists primarily of XAML and DHTML (instead of XAML and C#, for example). Long story short, they showed how an Avalon application worked in OS X’s Safari-browser! How cool is that? :)

     

    Finally there was the presentation about IIS7. Contents were more or less quite similar to the Channel 9’s interview, but still it was very interesting session.

     

    The IIS7 is truly componentized (even more so than IIS6) and practically everything you don’t need can be disabled or replaced with your own modules.

     

    Don’t need authentication or directory browser? Just disable them from the web.config or the completely rewritten UI. Oh, and the IIS7 doesn't need to be restarted when modifying the modules.

     

    Some other highlights from the IIS7-session included:

    • Configuration settings for ASP.NET, IIS7 and WCF (Indigo) can be set in the same file.
    • In one demo he showed how to replace standard directory browser with his own module that rendered image files into an image browser or RSS-feeds with the help of simple HTTP-handlers.
    • PHP worked in one demo simply just by attaching the ISAPI-module that comes with the engine to the IIS7.

    After the sessions were over, I spent some time in the exhibition hall collecting some goodies and t-shirts (this is how geeks get their clothes). Then was the time for the PDC Underground, where the best thing was discovering this site: http://www.GotCodeSnippets.net/.