Offline Web Applications

calendar_sm2_en I've stumbled across several discussions on offline web apps lately and thought I'd share my view on these things.

As a heavy user of GMail, Google Calendar and Goodle Reader I really depend on having a internet connection most of the time. I especially am one of those guys who forgets his timetable the second it gets changed, so whenever I need to make an appointment I either have to search for a computer or postpone the making of the appointment.

So, I find myself too often in the middle of a chat digging out my laptop to look at my timetable.
But although my laptop is starting up quite fast, till I get connected to a wireless (if any at all) I usually have spent 3-5 minutes with meaningless smalltalk and cursing about WIFI and my ubuntu (my laptop is now 4 years, can't prove that the machine got slower over time, but reinstalling XP simply wasn't an option any more).

And then, I stumble across an article by DHH (the guy behind RoR) called: You're not on a fucking plane (and if you are, it doesn't matter)!
So, halfway through I was ready to agree that being able to access web apps all the time isn't necessarily a good thing till I remembered all the hassle I go through when I'm trying to look up my schedule.

For time being, Google did a pretty good job on replacing all my mail/calendar/reading needs by their web applications, and although there are some nice tools like Google Calendar Sync, I really can't use it if there is no network connection available. (Calendar Sync isn't syncing all my calendars, only the main calendar that I only use for personal stuff, university and business calendars are what matters and those don't get synced).
So, Google Gears might be the right way in the right direction, although I still doubt that it's clever to install liteSQL on a client's machine, making all SQL calls through AJAX so that Gears can swap out the real server if disconnected. That's just too much crappy Javascript that needs to be written and executed on the client's side.

Finally, I think DHH has a point in "we're way too online". But there are applications that really need 24/7 availability and those need to be made accessible offline. And while we're at, why not just create something that will work for more than one site?

By the way, my solution to the current calendar problem is already in the works, by June 30th I'll be owning an iPhone, that's gonna be synced with Outlook (that will be synced with my Google Calendar) so that I don't need to get out my laptop any more while also having the calendar offline!

Read more →

Reading suggestion

Sorry for me being so silent for the last weeks. I've been quite busy and for a week or so I am just trying to get my unread feeds back to under 100 again.

That's also why I thought about writing this post.
After I marked 2 consecutive posts as shared on my Google Reader I really had the urge to say this out loud:

Thank you Jeff Atwood for your blog!

I have been following the blog for quite some time now, and I have to admit that there is hardly any other blog I enjoyed reading as much as codinghorror.

It's not really the most informative blog if you are searching for any solid programming hints, but Jeff manages to really keep his focus on geeky - interesting tech topics that can't easily be put in niche like .NET, Java, Ruby, SOA etc..

So, for anyone interested in a really great read you can find Jeff's blog here.

Oh, and the book he derived the term "codinghorror" from, Code Complete by Steve McConnel is a very good read too!

Read more →

LinQ, LinQ to SQL etc explained

I've been talking to a lot of people about LinQ and LinQ to SQL lately and always had trouble explaining them the difference between those concepts. So, obviously I could simply point you to ScottGu's posts on LinQ and Linq to SQL, but that would be cheap wouldn't it?

So, what is LinQ in the first place? People usually mix it up with LinQ to SQL and see it as a new syntax to query databases (but that's LinQ to SQL).

In a nutshell, LinQ stands for Language integrated Query and is a great way to retrieve objects from lists, arrays etc.
Basically, LinQ works an everything that implements IEnumerable, so it's quite safe to say that it works with every .NET collection out there ;).

So, the magic?
LinQ consists of 2 things.

Extension methods

First: By importing the System.LinQ namespace you get some extension methods for your collections.

linq1

The above screenshot shows some of the extension methods you get by importing System.LinQ.
Those methods are very useful when working with collections and have become something I won't want to miss.
Here are my most used ones:

Select: Takes a lambda and returns an IEnumerable<> of all items that match the lambda.
Example:

linqselect

This statement will only return an IEnumerable with Tigraine and Tig.

Single: I love this one! Takes a lambda and returns the single item matching the lambda (failing if there is more than one).
This really shines when doing stuff with unique id's.
Example:

linqselect2

Any and All: Any checks if one or more items of the collection match the lambda, and All returns true if all items in the collection match the lambda.

Query syntax

So, besides all those great overloads the LinQ namespace provides the real magic is a query like this:

linqselect3

Needless to say that this query syntax works on every collection of objects and provides a great strongly typed query syntax for objects.

LinQ to SQL

So, now that we know what LinQ is we could easily go ahead and write tons of boilerplate code that maps objects to database tables etc etc.. And then use LinQ to query all those objects we created.

But that wouldn't ever work, because having the whole database in memory won't work on any fairly large db. So LinQ to SQL jumps in on this.

LinQ to SQL consists mainly of a graphical OR/M designer in Visual Studio 2008 that allows you to simply drag and drop tables from your database to create the mappings.

linqsqlguiOnce the mappings are created LinQ to SQL provides you with a DataContext class that represent the objects in your database.
The Users table from my database to the left result in a new collection in your data context called Users that can be queried either through extension methods or through the query syntax.

linqsql

What happens under the hood is that LinQ to SQL translates your LinQ query into SQL. The generated queries can be viewed while debugging:

linqsql2

The difference to normal LinQ is that LinQ to SQL gets executed once you are using the query data, not when doing the query. The query definition is just the generation of the SQL, while a foreach(var u in users) would actually trigger the query.

And, obviously LinQ to SQL also handles changes to the database through transactions. You just need to modify a value and hit dbContext.SubmitChanges() and LinQ packs any changes back into your database.

Conclusion:
LinQ is a clever way to query objects in memory.
LinQ to SQL is a new strong OR/M that takes advantage of the new query syntax and extending it to a database.

This post was never intended to be an exhaustive write-up about LinQ and LinQ to SQL, if you want to know more about those two please refer to ScottGu's posts.

Read more →

Unfortunate news...

I've been very happy with my project's progress over the last week, so I was totally shocked to hear that a similar project just launched in Germany and appears to be pretty competitive.

It's called pizza.de and is doing pretty much the same thing we were hoping to do. Providing a platform for online food delivery for a whole country.
So, the first design meeting today started with something along the lines of "Why didn't I know".
The research on competitors we did is now almost 3 or 4 months old, and apparently pizza.de launched 3 months ago, slipping through.

They are providing a pretty good platform for online food delivery and service, are using some AJAX to spice up the user experience while providing great branding support for corporations (like PizzaHut, Subway etc... Everything looks pretty solid and it's pretty clear they are working on a far bigger budget than my team currently.

So I had some doubts if we'd carry on our project pizza.at, mainly because pizza.de is almost exactly what we thought we'd have to deliver and we were hoping to be able to expand to Germany in the future.

So, because we can't compete with pizza.de in Germany, we brought up another issue: i18n. Austria is far too small to be the only place where we want pizza.at to be available, so after the initial Austria launch we will be looking into expanding to the east and south.

Now, because of our tight schedule (that just got tighter) hopes are high we'll be launching at the end of march so we'll be first to hit the Austrian market with our site.

Read more →

ASP.NET Security

Ok, reinventing the wheel every time you build an application works great, as long as you aren't on a very very tight schedule. So due to time constraints (and my reluctance for spending time) I figured out this time I'll stick to standard ASP.NET role based security.

I never really bothered with trying, mainly because I usually had complex security built into my data structure (like individual access rights for different records).
So, obviously there is a way to do this with custom ASP.NET security providers, but doing security on my own saved me messing around with doing custom ASP.NET security.

So, this time I figured out, doing custom ASP.NET security isn't going to happen. Obviously there is only one administration website that needs authentication all over the place with no special roles and other fancy stuff. Just some plain .htaccess like security on a file-level basis.
.htaccess isn't the most scaleable solution (and quite impractical on IIS ;)) so I just started off by following the quite simple walkthrough on MSDN.

Now, after doing the user-creation you just need to drag the Login-Control onto your design surface and the user is presented with a pretty nice looking login form:

login So, obviously this saves time. I don't need to drag 5 controls to the surface, I don't need to build some fancy cookie-login stuff for my application and the whole thing works. Great isn't it?

 

Now, where this really shines is when you try to access a folder that ASP.NET security was configured to deny. You get redirected to the Login.aspx file and the Log In control automatically handles redirection to the previously requested page etc.

Now, that's it basically. ASP.NET comes packed with loads of great tools that do authentication for you. Like password recovery dialogs, change password dialogs, create user wizard, login name display etc.
This all combined gives you a very solid toolset to work on from a programming and security perspective.

Read more →

I&apos;m frightening!

Today I really scared the hell out of my co-workers.
Although I don't officially work for pixelpoint I am currently working at their office, and so my fellow co-workers had to witness one of my scarce "I jump up and dance through the room in ecstasy because it works" moments.
No need to say that they where completely shocked and came running with water and tranquilizers :).

Why I am a full of joy currently is because my first prototype of my online food-ordering application works!
I was fighting the whole day with validation and data-binding issues on ASP.NET and finally got it to work.

I'll blog on my experiences with LinQ2SQL and ASP.NET in the future. For now I'll just say that I am very very happy with LinQ2SQL and I am absolutely sure that it saved me almost 3 weeks of development.

The whole application is completely functional after 7 days of development (still lacking a GUI)! I mean, obviously you need to be a programmer to order a pizza through the exposed model, but shopping cart, order checkout and product view functionality is already there.

I will spend next week working on a admin application and meeting with the design guys to get the front-end out.

Read more →

Strange LinQ to SQL oddity

I'm still in the process of doing some research on the tools I'm going to use over the next weeks to build the Pizza.at web app.
So today I tried some LinQ to SQL so I can get used to it a bit. And while doing so I started out with reading through ScottGu's LinQ to SQL series.

I had already some parts of the database schema in place and so I imported it to the ORM, giving me the following model:

linq1

So, this all worked perfectly and I immediately started doing some select statements (while learning how to use and write Lambda expressions - I'll blog about this later).

linq2

And yippie! It worked, although I was very confused that this statement would return a InvalidOperationException in case the Lambda didn't return something. Although I like the fact that it returns an exception, I think the exception given here is too generic. They could have done better in giving the exception a stronger name.

But, after getting over the exception name, everything went smooth from there. Except for me not seeing one thing:
The C and D in CRUD!

ScottGu showed off in his series that doing a simple Categories.Add and an afterwards call to dbContext.SubmitChanges() should do.
In my version of Visual Studio and LinQ I simply don't find this method. All lists I get from the ORM are IQueryable and don't incorporate any Add and Delete Methods.

I'm getting a bit confused, I must be missing something at this point, there must be something I have overlooked. Any thoughts?

Read more →

SQL Server 2005 GUI complexity

You know what?
I really love SQL Server 2005, just because it got rid of the Enterprise Manager stuff and introduced SQL Server Management Studio.

What's bugging me now is that although the Management Studio is great to work with most of the time, there are some tiny little things I really hate whenever I create new databases!

sqldb

Whenever I want a field to be a primary key id field I need to go to declare it as primary key, and then define the identity specification.

And there is the design flaw. You can't just double click Identity Specification to change it from No to Yes, you actually have to first click the + to expand the section in the property grid before I can set the Yes/No value.
I see the added complexity in some points where the increment or seed aren't appropriate, but to be honest, most of our ids start at 1 and increment by 1. So in 99,9% of the cases you don't need the extra complexity.

Read more →

A busy day

At first I didn't want to post this. I'm completely exhausted after 8 hours of doing training at pixelpoint and some computer administration stuff for a friend afterwards.

But, because I talked like 3 hours about the Web 2.0 phenomenon and kept repeating "You should blog" I forced myself into blogging about it.

Although I didn't plan to stay for so long I actually enjoyed the day. I was doing a course on .NET programming in VB.NET and people were very interested and doing very well. Afterwards we had an open discussion (after I showed off some Web 2.0 stuff) about Web 2.0 and how it can be used for various things in the carinthian context.

The Web 2.0 actually got out of hand after we covered WordPress and FeedBurner in detail and we spent like an hours discussing the pro's and con's of WordPress as a CMS system for smaller web sites.

The programming session was far more enjoyable for myself. I think they actually did learn something from the whole thing, although they are still hesitating to write code themselves (I had to force them into writing a small sample application). But I think they now understand the .NET syntax much better and will be more efficient on doing ASP.NET web sites in the future.

Read more →

New job!

Yes, I'm going back to work.

I accepted to work on a new ASP.NET web project as CTO and developer for my previous employer pixelpoint.

So expect to hear new stuff about ASP.NET and AJAX.NET here on my blog during the next weeks.

The project is called Pizza.at and will be a online food delivery service.
I had been working on a previous version that didn't make it to a release while I was working for pixelpoint. Due to time constraints and poor planning the project failed and I was approached some weeks ago to try to get it done during these holidays.

I accepted the deal, mainly because I was offered complete freedom on development (so I can abandon the old codebase).
So, this time around I'm the one to blame if the project goes wrong, because I'm the guy doing all the planning.
I have chosen an agile development process and am currently working on the requirement analysis and some basic design stuff.
Because I want this project to be done fast I decided not to use any fancy new stuff like MVC or Silverlight. The whole project will be done on a SQL 2000 database with normal ASP.NET. Regardless, I'll be using C# 3.5 and some LinQ queries will surely make it into the application.

The whole thing will start later this week after I did another training course at pixelpoint for their employees.

Read more →