Home
About
Contact
Tuesday, June 23, 2009

Recently I worked with a colleague on some code using decimal.TryParse() and tried to find a better way of using it. Specifically I had a string value representing a currency amount entered by a user in a web form. The amount needed more than just normal validation, so I needed to do some stuff with it.

Here's the code I started with:

public void SomeMethod(string userEnteredAmount)
{
    decimal amount;
    if(decimal.TryParse(userEnteredAmount, out amount) {
        //Do some stuff with amount
    }
    else {
        //Show message to user about invalid amount
    }
}

I've recently found many cases where I find the use of Value Objects to be very applicable. I found this case to be a particularly interesting example. Anyway, I created a Value Object called Amount to abstract away the TryParse stuff. Below is the class I created.

public class Amount
{
    private readonly decimal _value;
    private readonly bool _isValid;
    public void Amount(string amount)
    {
        _isValid = decimal.TryParse(amount, out _value);
    }
    public decimal Value
    {
        get { return _value; }
    }
    public bool IsValid
    {
        get { return _isValid; }
    }
}

See how clean it got? At least I think so. The important part though is that it's usage is so much easier to understand and read:

var amount = new Amount(userEnteredAmount);
if(amount.IsValid) {
    //Do some stuff with amount.Value
}
else {
    //Show message to user about invalid amount
}

It's more code, but cleaner. Or did I say that already? :-) And of course it's reusable other places where amount has a meaning.

Tuesday, June 23, 2009 12:17:10 AM (W. Europe Daylight Time, UTC+02:00)
Thursday, June 04, 2009

As I’ve previously twitted through @nnugbergen and also through the invites I sent out yesterday, Scott Hanselman and Jeremy D. Miller is coming to NNUG Bergen Monday the 15th of June (Jeremy) and Saturday 20th of June (Scott).

Jeremy will do two talks. The first being Software Design and Testabillity and the second will be about StoryTeller, his take on integration testing. Scott will do his Deep Tour of .NET 4 talk.

To sign up or see the full agenda, use the links below:

Jeremy: http://nnug.no/Avdelinger/Bergen/Moter/NNUG-Bergen---Juni-2009---Jeremy-D-Miller/
Scott: http://nnug.no/Avdelinger/Bergen/Moter/NNUG-Bergen---Juni-2009---Scott-Hanselman/

In case you don’t know, all events going through NNUG is free, including these two! I’m already now worried how we’re going to top this next year. Maybe we should just close down NNUG Bergen after 2009 ;-)

Events | NNUG
Thursday, June 04, 2009 1:08:05 PM (W. Europe Daylight Time, UTC+02:00)
Sunday, May 17, 2009

image When so called secure institutions like banks, insurance companies and others ask you to create a password, you expect them to allow strange characters like ,.$#@{}[] to make the password stronger. To my surprise on several occasions I’ve experienced that they did not accept other than plain letters and numbers! What!? Didn’t the developer that implemented that logic raise a flag??

One specific case is with BankId (a national authentication mechanism for all banks in Norway), where I know the underlying implementation support strong passwords. However, when prompted by my bank to create the password, you’re not permitted. Actually I had to type in a temporary weak password and then change the password in the login screen which support the expected behavior!

At some point there had to be a discussion like this:

Developer: What type of password should we support?

Product Owner: What do you mean?

Developer: Should we allow people to make up their password from everything that they can find on their keyboard?

Product Owner: No, the normal alphabet and numbers should be sufficient. Or else people just forget their passwords.

My above experience with BankId was just an example from today, and in that case there were a workaround, which is not the common case. I always get puzzled when this happens. What puzzles me even more is that to prevent people from entering strong password, you actually have to code a business rule for exactly that! And what about those who only permit numbers!? What’s that all about?

Sorry for this rant, but I think it is important that we as developers, architects and technically skilled people take responsibility to avoid stuff like this to happen. I just can’t see one single good reason for limiting the users choice when it comes to passwords.

Sunday, May 17, 2009 4:48:33 PM (W. Europe Daylight Time, UTC+02:00)
Saturday, May 16, 2009

Trek1_5 This is a non technical post to add even more pressure on myself than the actual investment of my new bike and associated equipment.

I found it was about time to add some physical fitness to my life other than moving from the computer to get coffee or to and from the car on my way to work :-)

So this is a promise to myself (and now to the rest of the world I guess) that I will ride my new racing bike to and from work whenever the weather permits (read not snow or ice).  However, I might need a few weeks of training to actually physically be able to get to work on a bike :-)

Other | Work
Saturday, May 16, 2009 6:27:10 PM (W. Europe Daylight Time, UTC+02:00)
Sunday, May 03, 2009

Are you using InfoQ? I found InfoQ to be a great source of information long before I started to write for them. During this time I’ve discovered some tips and tricks on the site.

As a user of the InfoQ website you can either just browse news or you can take advantage of some of the more advanced features the site has to offer.

Disclaimer: This information is based on my personal usage of the InfoQ.com website. There might be more functionality available (and probably is) or I might be wrong about some functionality I’ve covered here.

Website functionality

InfoQCrop3

Not functionality per say, but in the top left corner you see how many visitors InfoQ has on a monthly basis. Here showing almost 400.000 visitors for March 2009, which I think is pretty good!

 

InfoQCrop1

On the left hand side there is a list of all the communities that InfoQ writes about. Un-checking communities let you filter out stuff you’re not interested in. Clicking on any community you will see all content from that community.

 

 

InfoQCrop10Based on your community selections above you can get a personalized RSS feed, that of course gets updated whenever there are new content on InfoQ.

InfoQCrop6

On the right hand side of the site, there is a box with tabs showing Articles, Presentations, Interviews and Books and one tab showing All.

This is a great source of info which I learned to appreciate quite late. Today I use it very often, especially to find recent presentations and interviews.

Note: All content you see here will also be announced as news items.

 

 

  

InfoQCrop4

InfoQ publish content in four different languages: English, Chinese, Japanese and Portuguese.

InfoQCrop5In the top right corner of the news section there is a button for contributing news. Use this for suggesting tings you want InfoQ to cover or maybe you have an interesting article that you want InfoQ to consider publishing?

Other options

InfoQCrop7

If you are a registered logged on user, you can go to Preferences and check the box for the InfoQ Newsletter. This will give you a summary of the content for the past week. If you don’t have time to monitor the website on a regular basis, this is a nice option for many.

InfoQBookshelfInfoQ also have it’s own bookshelf written by several different authors, many of them being editors for InfoQ. Books currently available for free online reading (print version at a small cost):

URLs

Community
By adding the name of the community behind the infoq.com URL you get a page displaying featured content, news, articles, interviews, presentations and books about that particular community. For e.g. NET you would use http://www.infoq.com/dotnet.

Topics
By clicking on a topic, e.g. InfoQCrop8 you get a box like this:InfoQCrop9

It’s quite self explanatory, but the Exclude might need some extra explanation. On InfoQ you can exclude topics you don’t want to show up on the website. So let’s say I want to follow what’s going on in the .NET queue, but I don’t want to see anything about Windows Forms, I can do that by selecting a topic as showed on the left or go the Preferences and add that topic to my exclude list.

Tags
Tags work much in the same way as Topics, except they’re tags and not topics :-)

Twitter

InfoQ is also present on Twitter. You can follow at http://twitter.com/infoq or just add @infoq to your Twitter client.

Planet InfoQ - Opinions and Perspectives from InfoQ Editor’s Personal Blogs

The title kind of says it all :-) Check out http://planet.infoq.com. Here you’ll also find Tweets from all the editors on Twitter.

InfoQ | Web
Sunday, May 03, 2009 12:06:04 AM (W. Europe Daylight Time, UTC+02:00)
Saturday, May 02, 2009

image About a month ago I was contacted by Kjersti Sandberg at Programutvikling. She asked if I knew about any companies in Bergen that would be interested in having a full day seminar with Mary Poppendieck. I figured this was a great opportunity and contacted some of the companies I knew in Bergen. Webstep found this very interesting and invited customers and employees for a full day seminar with Mary.

At the same time I asked if she would be interested in doing a talk at NNUG, which she did! So, If you haven’t seen this already, the invite is out, so go sign up (for free!).

Mary is well known for her experience and knowledge within the Lean and Agile community:

Mary Poppendieck has been in the Information Technology industry for over thirty years. She has managed software development, supply chain management, manufacturing operations, and new product development. She spearheaded the implementation of a Just-in-Time system in a 3M video tape manufacturing plant and led new product development teams, commercializing products ranging from digital controllers to 3M Light FiberTM.

Mary is a popular writer and speaker, and coauthor of the book Lean Software Development, which was awarded the Software Development Productivity Award in 2004. A sequel, Implementing Lean Software Development, was published in 2006. A third book, Leading Lean Software Development, will be published in late 2009.

Please feel free to forward this to anyone within your company or to your friends, because this event has a much broader crowd than the usual NNUG crowd of developers and architects. At least your manager should have this in her/his inbox by Monday morning :-)

Agile | Lean | NNUG
Saturday, May 02, 2009 11:38:19 PM (W. Europe Daylight Time, UTC+02:00)
Thursday, April 30, 2009

A good friend of mine, Mark Nijhof, will be doing a presentation on FubuMVC at the next European Virtual Alt.NET meeting. Mark is actively involved with the alternative MVC framework for ASP.NET together with Chad Myers and Jeremy D. Miller. Mark will also do a Fubu presentation at NNUG Bergen 27th of May (invitation will be available soon).

If you want to know more about FubuMVC you can check out the interview I did with Chad on InfoQ and of course their public website. I encourage you to download Fubu and try it out, cause it has some interesting differences which I personally like compared to ASP.NET MVC.

Also, Jeremy Miller is coming to Bergen and NNUG in mid June just before NDC (thanks Mark for organizing this!), so I’m really looking forward to that. A lot of stuff happening at the local community in Bergen at the moment!

.Net | ASP.NET | NNUG | Patterns
Thursday, April 30, 2009 9:07:29 PM (W. Europe Daylight Time, UTC+02:00)
Tuesday, April 28, 2009

image Is there anything more annoying than standing on a red light, when there is no car, motorcycle or carbon life form in sight? Maybe traffic lights elsewhere in the world are more intelligent, but at least where I live this happens from time to time. So what have this to do with developers? Good question, but let me first try to answer another one: Why do we have traffic lights?

From Wikipedia:

Traffic lights, also known as traffic signals, stop lights, traffic lamps, stop-and-go lights, robots or semaphore, are signaling devices positioned at road intersections, pedestrian crossings, and other locations to control competing flows of traffic.

I read: bla bla bla bla… control competing flows of traffic. I would probably have said something like this:

To avoid cars running into each other and avoid have people run over in a cross road. It’s a very logical way of saying stop or drive (red and green). Yellow is the same as green, but for taxis only. Traffic lights are regulated by sensors in the ground detecting where there is traffic and not + a algorithm to give green lights in a predefined order.

Now back to the first question, answered by asking a new one: What’s the equivalent of traffic lights in development? No, not red, green, refactor :-) I was thinking about frameworks, internal DSL’s and the like. Stuff that good developers create, which the not so good developers should use. To keep them from “hurting” themselves or the company they work for. Do you find that to be ok?

Tuesday, April 28, 2009 7:35:35 AM (W. Europe Daylight Time, UTC+02:00)
Monday, April 27, 2009

Just a reminder that it will be Geek Beer tomorrow (Tuesday 28th) at Biskopen Pub (Neumanns gate 18) from 19:00. No official signup, but by leaving a comment here I can make sure there is enough seats for everybody.

See you all there!

Events | NNUG
Monday, April 27, 2009 12:21:17 PM (W. Europe Daylight Time, UTC+02:00)
RSS RSS - Comments Twitter LinkedIn
         
SEARCH
 
 
         
TOP POSTS
   
         
NAVIGATION
   
         
CATEGORIES
  .Net (49) Agile (27) Ajax (5) Architecture (9) ASP.NET (1) Blogging (12) Books (1) BPEL (1) CloudComputing (6) Community (1) CSharp (7) DasBlog (5) Database (2) DDD (3) Deployment (13) DSL (1) Events (34) ExtremeProgramming (6) Fun (6) Gadgets (4) IIS (6) InfoQ (1) Java (1) Lean (1) Linq (2) MemoryLeaks (5) Microsoft (37) NDC (2) NNUG (35) Other (10) Patterns (6) Performance (1) Scrum (17) Security (3) Silverlight (4) Software (18) TeamManagement (11) TechEd (7) Testing (4) Tools (21) TvGuide (1) Vista (15) VisualStudio (16) WCF (7) Web (15) Windows (8) WiX (7) Work (15) Workflow (3)  
         
ARCHIVE
   
         
BLOGROLL
   
         
ON THIS PAGE...
 
Refactoring TryParse Into a Value Object
Scott Hanselman and Jeremy D. Miller to NNUG Bergen!
Password Security Annoyances
Geek On Bike
The InfoQ Website
Mary Poppendieck to NNUG Bergen
Mark Nijhof on FubuMVC at the next VAN meeting
Developers and Traffic Lights
Geek Beer tomorrow in Bergen