The blog of Tobin

Tobins nerd blog on .NET, Software, Tech and Nice Shiny Gadgets.

Friday, December 31, 2004

Hello Podcasting


After buying myself a nice 1GB MP3 Player for christmas, I've decided to poke my nose into the world of podcasting. This is great stuff! I can basically add informative and interesting broadcasts to my MP3 Player for listening to on the move. Of course, I can also just listen to the shows in Windows Media Player without leaving my desk!


The nice thing about this technology is that you can chose what you want to listen to by subscribing to your chosen feeds, and then listen to it when you want to.
I'm using Doppler to automatically pull down the feeds I'm interested. This is written in .NET, and is a nice and tidy piece of software.

Doppler has a built in feed search, but in my view it doesn't give enough information about the feed. so, I'm using http://www.podcastalley.com for finding feeds of interest. This place has handy "Top 50" and "Top 10" lists, and also user reviews etc.

So far I've subscribed to the Dot Net Rocks show (which I love), the "engadget" feed, and "Software as she's developed". I've yet to listen to the latter two.


So far I'm loving this podcasting stuff, it's really neat. In fact, it actually makes me *want* to just go our for walks whilst listening to stuff, so I could argue that podcasting is even good for the health! Ok, I'm currently in Nassjo, Sweden, so it could also be the beautiful scenery that makes me want to walk 8-)

Wednesday, December 29, 2004

.NET Code Generators (2)


Unfortunately the project requiring a code generator went on hold! But, I did manage to try out Deklarit before this happened. Deklarit seems like a very sexy piece of software, but unfortunately it just didn't do the business for me. I was most upset about it wanting me to use certain naming conventions so that it could derive relationships between entities using thier field names.



On one side there is a beautiful simplicity to this approach in that less meta information has to be maintained. On the other side, I think the Deklarit team have created an unnatural dependency between to orthagonal issues. This has made working with legacy schemas a pain in the rear! I do know that Deklarit offer a reasonable approach to circumnavigating this problem, but to be honest I didn't have time to understand it. Furthermore, I had other problems too, and couldn't work out if they were down to me being a muppet or problems with the tool. Probably the former. To be fair, there are lots of great things said about Deklarit (clarity in documentation, snazzy look and feel, clever schema migration etc), and perhaps I'll try it again in the future.



In my virtual travels I still keep hearing good things about LLBLGEN Pro. Many people seem to love this tool, and I'm definately going to give it a trial. I'll admit that I have installed it already, but not used it. That said, I did read some of help documentation, and this alone worth the install without even loading the program up! I spoke to one guy who said this:




I conducted a very detailed research looking for a powerful, easy to use, flexible, configurable and near perfect data layer. I compared the following -



1. Wilson OR Mapper

2. Entity-Broker

3. LLBL Gen Pro

4. Custom code generation template



Of all I ended up selecting LLBL Gen Pro. This is the only one that is easy to use, comes with amazing support and documentation and is configurable to support a lot of corner cases, like supporting an ASP hosting with multiple database instances with similar schema; changing connection string at run time; providing complex joins for views, drop downs etc right as part of the application design. The learning curve is a about a week but worth the buck!!



My second favourite is the Wilson OR Mapper but they need to improve the following

- documentation

- cover corner cases for real projects with decently large budgets

- prepare the code generation wizard to handle more than simple OR Mapping between directly related tables; provide the concept of LLBL Gen Pro's TypedList.


Tuesday, December 28, 2004

Cuyahoga .NET Web Framework (using NHibernate)


I haven't looked at this in detail, but this CMS looks tidy I thought.


http://www.martijnboland.com/cuyahoga/1/view.aspx.


In particular, if you look at the admin screens in the screenshots section you'll see what I mean. As a bonus, this also uses NHibernate to manage it's persistance, so could be a good reference application for best practices? I'm going to take a closer look and publish my findings...

Tuesday, December 21, 2004

Domain Driven Development


I've recently been reading Domain Driven Development (by Eric Evans). This is an excellent book I think, there's some really good advice to those looking for good techiniques to deriving their object models. In fact, I'm wondering if it's the best book I've read on the subject!


Eric recommends focusing on communications, and developing a single, consistent and ubiqoutous set of terminology with which all team players can talk about the business and the software. Furthermore, this language should be used in the code also, so that the domain model completely mirrors terminology that appears in business conversations. This sounds simple, but how many times do you find yourself naming classes in such a way that don't really reflect anything that's come up in conversation?


Today I started applying this technique on an existing code base, and the results are quite startling. Suddenly my domain model is looking much more understandable, because it completely reflects the concepts that myself and the client have been discussing and exploring. I can also see where my code is straying from the "real" business model, which tells me I have some work to do to bring it on track.


Another nice aspect of the book is that it describes a system of names for software designers. Eric talks about the different types of classes that can appear in and around your domain model. He gives us a set of object "types" that broadly abstract the roles your classes play inside a software system. Examples are:


  • ENTITIES: These are usually long lived objects that have an identity. They are usually persisted in a database of some kind.
  • VALUES: These are value objects that don't really have an identity, may be immutable, and are used for messaging or to describe aspects of ENTITIES.
  • FACTORIES: Rather than having complex initialisation logic inside ENTITIES, Eric recommends using factories to create them instead. This is basically the Factory pattern.
  • AGGREGATES: This one is a great idea. Eric recommends distingushing between entities that are "root" and those that are not.
  • REPOSITORIES: These represent root collections of ENTITIES. Basically save and load points.
  • SERVICES: Behaviours that do not belong in any IDENTITIES can be packed into services. He also talks about the difference between application and domain services.


Anyway, I won't waffle on. I thought this is a great book and would recommend it to all!

Wednesday, December 15, 2004

FOP FOP FOP!!!


A new project has got me lookign into the world of XSL-FO and FOP for .NET based PDF generation.



Things didn't look to good to start with, and I was having problems finding an XSL-FO engine. More specifically, I was having troubles finding a FREE one! 8-) This isn't me being a skin-flint: basically, my client had manually achieved what they needed using the Java based Apache FOP. We need to use it within a .NET environment, which either means calling it externally or sourcing a good, FREE .NET component for the job. I haven't started the evaluations yet, but here is a list of candidate .NET components


FREE/Open Source XSL-FO













nFOPLooking promising. It relies on referncing the Java dll in VS.NET (vjslib) wheras pure c# would have been nice. Then again, I shouldn't be so picky, this is a good java port, and I'd much rather have that than nothing! The forum has had some activity, and some posts show examples of usage which is handy. The real problem we've hit is that it only supports .jpg images, and we need gifs. This is a shame because it was looking promising. Also, it hasn't been developed for ages by the looks of things, so it's falling behind the Apache FOP from which it was ported.
dotnet-fopDead in the water by the looks of things
Dandy (aka xslfoproc)works on mono too. lots of documentation. However, couldn't get a build working (its written in c and c#)!
Apache FOPOk, this is a Java thing, not a .NET thing. However, it's open source and it is a really good FOP which has matured over the years. We're considering bundling this along with our .NET app and then calling it from the command line (using the Process class in .NET).

Commercial XSL-FO









Chive Apoc

This one is good and works straight out of the can. However, no price info available yet, so don't know if it's a winner!

I'll post up my findings once I've finished the reviews!


Friday, December 10, 2004

Change your Passwords!

Wow, sometimes I learn something great that's so simple, it makes me feel stupid for not having thought of it before.



This time it's something written in a blog post by Robert Hensing about how you should not use passwords. Instead, he says use PASSPHRASES! A typical password for your windows/email/blah login might be "t0b1n996", but apparently this is very easily cracked by brute force despite being hard to remember and looking complicated!

A typical passphrase is virtually uncrackable by brute force and is much easier to remember. An good example might be "And she's buying a stairway to heaven", which is longer than the recommended 14 characters.

So, the general idea is to use long passphrases rather than short complex passwords. Simple eh!? I'm off to go and uypgrade all my passwords!... And, I'm off to update all my login forms/pages columns to say "Please enter your passphrase", rather than "Please enter your password". Then I'm gonna get out more 8-)



As an aside, this approach reminded me of how I need to apply lateral thinking techniques more often. I'm pretty sure that the label "password" is responsible for ones tendency to chose single words over long phrases. I should have challenged that lable a long time ago!

Wednesday, December 01, 2004

TextBox Auto Fit to Size

I was recently trying to get a textbox to grow depending on how much text there was in it. This is quite simple if you're NOT using word wrap - but if you are it's a real pain in the arse!

The basic approach is to capture the TextChanged event, and then work out how many lines there are, and then how high each line is. This is all really easy, except working out how many lines there are. The textbox has a .Lines.Length property, but this won't be adjusted if you have word wrap on.


Anyway, after ages of searching and trying out different things, I stumbled across the most simple thing that just seems to work!


Here it is...


public static int GetLineCount( TextBoxBase textbox )
{
const int EM_GETLINECOUNT = 186;
return SendMessage(
textbox.Handle, EM_GETLINECOUNT, 0, 0 );
}

Once you have this, you can do something like this to get make your text box grow to the correct size.


Graphics g = _textBox.CreateGraphics();

float size = _textBox.Font.GetHeight(
_textBox.CreateGraphics()
) * (float) 1.075;

_textBox.Height = Convert.ToInt32(
( TextBoxMeasure.GetLineCount(
_textBox ) 1) * size
);