Showing posts with label Web. Show all posts
Showing posts with label Web. Show all posts

Wednesday, 14 January 2015

The First Is A Lie

Lately, I've been hyper aware of the first choice in web drop down lists. Yes, yes, I need a hobby.

When unsubscribing from a bunch of mailing lists, I've found I lazily choose the first option for "Reason" when I'm asked. This goes back to me wanting a one-click subscribe but beyond that, I will also choose the first option.

If you are thinking about asking a question and not putting yourself out of business then think about what your first choice in a list is. Don't let it be your worst option, even if it is alphabetical.

Friday, 23 September 2011

A Process for creating an MVC View of Partial View


Developers were adding New MVC Views to the web application project manually and that is an anti-pattern. We want to make sure that Controllers own Actions that own Views that are bound to strongly typed view models.

This is where this process comes from. ReSharper is required in this process.

Monday, 9 May 2011

ASP.NET Naming Containers


You have to understand that ASP.NET naming containers exist and what they change about a page. This affects client side and server side code and often kicks my a** when I forget that I am in one.

A naming container is a marker interface (INamingContainer), meaning that it does not implicitly enforce the hierarchy of controls under it but does create a naming scope for all contained controls.

Any controls that exist inside the naming container have their Ids altered at runtime with a prefix to ensure they are unique and belong to the context of the parent container. When you see a control with a name like TextBox1 change to ct100_xxxxxx then you know that it's in a naming container and has had a naming adjustment. This can make client side scripting a pain but there are many hints around on the web to help you cope with that.

The naming containers you will be most familiar with are master pages, content place holders and data bound controls like GridView.

My latest bottom kicking came when I was using fluent validators that wanted my validation specification to sit in the same naming comtainer as the controls it was validating. I chucked it at the top of the user control and the validation specification wasn't found. Not finding it as a sibling to the controls meant that validation just wouldn't happen. There was no error.

This makes sense when you are implementing server side code that looks up to a certain level in the hierachy to find an optional element on the page.

The thing is to know what your naming containers are and where you should place things.

Saturday, 16 October 2010

When do you not generalise your code?


At the moment, I'm working on a Silverlight project. The best way to learn a technology is to build something in it. Reading books and blogs and the rest will give you a vibe for what the technology is but only getting your hands dirty will make it real. Real is when you understand the beast and all its tides and moods. You also get to know the elegance of it and where the shine in its soul radiates from. Yes, I'm still talking about Silverlight.

One of the simple tasks in this current project requires me to parse a CSV file. That's easy enough to write on your own but anyone who has written a parser knows that if someone else has built one that does what you want then you should consume theirs. They would have handled all the exceptions and possible gotch-yas. This means I don't have to worry about that and I can get the task done quickly.

In this case, Fast CSV is a common choice in the .NET world. I've used it in the past on and it does what it promises. With the MIT license, the price is right too.

Sounds easy right? Well not totally. For my Silverlight application to consume this library, it must be a compiled as a SIlverlight library. Easy enough - I'll port it. Thing is, this code extensively uses the System.Data namespace and as I found out quickyly, there will be no talking directly to a database from a Silverlight application. That makes complete sense.

After looking in to it, the main use of System.Data is in the use of the IDataReader to stream the CSV file. There is also some DataTable usage. Nothing that couldn't be wrangled to use another stream reader and a generalised Linq table, in it's place.

But then I stopped...

When is porting the library more trouble than it is worth? My task is such a small simple one that I might as well write a custom parser that takes each line of the CSV file that I'm reading via normal file IO and push it straight to my view models for display.

Robustness of the code is an issue but I'll test drive it and keep it simple and neat. It doesn't have to be so general that it caters for every possible situation. It is just for my situation.

In this case, I have decided that a quick CSV parser that exists as a helper class in my project is good enough for this task. It is not just good enough but it's the right choice. Get the job done in a thorough way but don't over engineer the solution because it is the funnest way.

This has been a good learning experience and has solidified my resolve that sometimes you can write code that isn't so gold-plated and generalised and that's ok.

Friday, 11 September 2009

Resizing a new browser window


Developers have to stop believing that their web application is the centre of universe.

These days, I easily have ten tabs open in Firefox (or my browser of choice at that moment). Nothing infuriates me more than clicking a link on a website and having another window launch... except if the new window is resized automatically.

That behaviour resizes the whole window and all tabs in it. When the offending tabs is closed, a manual maximisation is required. That annoys the hell out of me.

Optus does this on their Pay a bill (click to be annoyed) link.

Stop it!

Saturday, 15 November 2008

Making your own VS.NET nunit Test Project Template

Returning to .NET has been exciting after a long time away playing in Java and Ruby land. I can't say I'll miss XML config files and all that junk.

First thing I did after creating my first ASP.NET MVC project was to add a template to easily create a project to test it. The new template will create a class library project with MVC, nunit and my mocking framework of choice Rhino included and ready to go.

When you use VS.NET 2008 to create an MVC web application, it asks if you want to add a testing project to go alongside. Unfortunately, the only choice of test project template you get is the Microsoft one and I like nunit much much more.

This is how we do it...

Set the project up the way you want it to appear new
  1. Create a new C# class library project. Give it a general name which will apply to your test project template.
  2. Add a reference to the System.Web.MVC dll.
  3. Add a reference to the nunit.framework dll.
  4. Add a reference to the Rhino.Mocks dll.
  5. Set the Copy Local property for all of the above dll references to True.
  6. Create a Controller folder under the project root.
  7. Add a class HomeControllerTest to the Controller folder.
  8. Add unit tests to cover the About and Index actions.
  9. Build your project to get the binaries.

Export the project template

  1. Go to File --> Export Template and use the wizard to export the template. Call it NUnitTest. You will be told where the zip file is saved to.
  2. Be sure to chose the option to include the icon.
Importing the new template
  1. Move the NUnitTest.zip to %Program Files%\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\Csharp\Test\1033. This might be different for you.
  2. Quit Visual Studio.
  3. Open a command prompt and navigate to %Program Files%\Microsoft Visual Studio 9.0\Common7\IDE.
  4. Execute devenv /setup and go make a cup of coffee.
  5. If you now open VS.NET 2008 and create a new project, you should be able to see your template show up under the C#-->Test directory.
  6. Add the registry key below by copying the text in to a file and calling it nunit.reg. Run this regfile to add the key. You can add it manually also using regedit.


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\MVC\TestProjectTemplates\NUnit\C#]
"Template"="NUnitTest.zip"
"Path"="CSharp\\Test"
"TestFrameworkName"="nunit Test"
"AdditionalInfo"="http://msdn2.microsoft.com/en-us/library/ms243147(VS.80).aspx"
"Package"=""

Monday, 27 October 2008

Don't Embrace Mediocrity

used under the flick creative commons license by caravinagre

I wrote a post a while ago that somehow got on to a few of the IT aggregators and resulted in an influx of readers, many of whom were interested in what was a popular topic at the time. That attention brings out the good, the bad and the ugly on the Interblag.

A friend of mine who regularly blogs about food on our work blog feeder has also recently been attacked by the freak-geek police and told her blog doesn't belong as it isn't technical. Amusingly enough, it wasn't even a work colleague who said this.

After spending an hour listening to Edward de Bono talk about why arguing a point doesn't always produce the best outcome, I'm starting to see that point of view reinforced online. It was probably always there but it seems relevant to me now. So let's discuss it and also annoy the people who think that only code snippets belong in blog posts.

Are any new ideas being added to the blogosphere? Is blogging dead? If it is and there are no new ideas then what or who killed it?

It seems that if you are established, usually not through rising on the Internet but through a more traditional (and rightfully respected) publishing background, then your opinion is rarely knocked online. Social proof or tangible proof. If you are more like the bloggers I see out there with new ideas and different ways of thinking and challenging the established norm, then your words will be hammered. Interestingly enough, it is a small enough group who attacks so it doesn't really matter most of the time. It does however feel like that constant beating at the edges of the blogosphere, is dulling the interesting sparky parts.

It even has the potential to silence any new comers who think they might have something to say and haven't quite found their voice. Instead those who are happy with the way the Internet appears to be to them want to keep it that way. Maintain the average. Silence the creativity. It's an obscure notion to tell someone else not to speak so I will not tell them not to speak as they so happily feel the right to do to others.

Instead, I encourage any of you out there with something to say to stand up and say it. Ignore the push toward mediocrity. I paraphrase the wise and powerful Madonna in saying: Express what you've got, baby ready or not. Express yourself!

Sunday, 24 August 2008

Scrabulous completely gone from Facebook

It's official, I hate Hasbro.

Yesterday, Scrabulous disappeared from Facebook completely after Hasbro sued them. It's been suggested that I sign up to the Hasbro application on fb but I'd rather light fire to my newly painted toenails. It was a good fb community and was well written and presented.

This is a terrible shame. Big companies triumph again. Why can Hasbro do this in Australia?

Apart from status updates and photos, that only reason I went to facebook was to play Scrabulous. Twitter and flickr can replace the others for me. Maybe this is the end of facebook, at least for me.

Friday, 1 August 2008

Degoogling My Life


I've recently started using Google Analytics for my blogs. Yes, I'm watching you watching me.

A few interesting things have emerged from setting this up and from looking at the data it produces. The first is that Google applications are easy to register for, own and use. They make it easy to let them host your data. The second revelation is that a website can collect a surprising amount of information about you as you meander around the Interblag.

Let's go backwards and look at second things first - collecting information about the people who land on your site. Here is a quick summary about what I know about you when you visit this blog:

  • your browser and OS;
  • screen colours and resolutions;
  • flash and Java versions;
  • network location and host name;
  • connection speed;
  • the length and depth of your visit (the pages you read and time you spent);
  • language used;
  • referral sites (search engines, other sites or if you came directly to my blog);
  • and where in the world you are.
There are many valid reasons for wanting to know this useful information. It makes it easier for software engineers that build web applications to know about and cater for the different technologies in use out there. It helps us serve the majority when building a site by knowing what is most commonly used.

This information is collected using a simple script call that looks something like this, which is generated for each of your sites:



<script> type="text/javascript" var="">gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'


<script>pageTracker = _gat._getTracker("xx-xxxxxxx-x");
pageTracker._initData();
pageTracker._trackPageview();
</script>



Now back to the idea of making it easy to give your data to Google. I often roll my eyes at friends (geeks mostly) who avoid getting a Google account at all costs. They don't want a huge company to have so much information about them. Another good friend of mine believes that no matter why information is collected, it will be used for evil. Combine those too ideas and even with a company that promises to do no evil, you may get a little nervous.

Google knows a lot about me. I use their email; docs; feed reader; blog hosting and editor; photo library; web analytics tools; webmaster tools; and their oxygen. OK, not the oxygen but they might own shares in it. They use this information to provide advertisers with targeted advertising. I imagine they have a setup like Gringots, with the servers that store the history of all our virtual wanderings. I like to believe it is protected and will not be used in a bad way.

Of course, I'm not going to jump up right now and stop using google apps due to a passing over-thought paranoia. They are easy to use. Easy to start using. They use one id and one password. They let you do what you want to do without worrying about how. They are free.

As for how easy it would be to degoogle my life, I'm not sure. What are the alternatives?

Email: I could get mail through an ISP and bring it down to my laptop. It already comes to my crackberry;
Docs: Easy, Office on laptop. Everyone has that these days. How would people collaborate on the documents though? hmmm...
Feed Reader: Use Firefox but that doesn't move with me. Maybe another web reader.
Blogging and Analytics: Easy, host a web server running WordPress or use a hosting site and track everything through feedburner.
Photos: I already use flickr and facebook for that too.
Oxygen: It's free.

Will I be doing this any time soon? Probably not, it all seems like a lot of effort. Maybe one at a time. First I need a universal id. Let's see how it goes.

Saturday, 17 May 2008

Ruby on Rails presents WeddingPresents


My friend James, has created a unique wedding registry site written in Ruby on Rails. It took him no time at all and leaves us with a cool site that allows the couple to pick whatever presents they want without signing up to a department store.

Having recently used it for James' wedding last week, I can say that it's simple to use and effective. Also a great help for those of us who shop a little late :o)

" Why YourWeddingPresents.com?

Unlike other wedding registries, Your Wedding Presents is not owned by any store, and does not limit your gifts in any way. Your Wedding Presents:
* is completely free. No strings attached.
* lets you choose gifts from any store or even just say the type of present you want (eg, cutlery set for six).
* lets you ask for contribution presents, where several guests can pool their money to get a larger gift.
* shows you which presents have been chosen and, if guests enter their name, who has chosen what.
* lets you write a welcome message to show guests when they go to your registry.
* is easy to use. There are no big forms to fill in. "

Friday, 25 April 2008

Kill me now because all we need are "Flash Coders"

Continuing with my theme of Crazy People Tell Me How Life Is, here is my recent encounter with a friend I met on the Inteblag a long time ago. We've never actually met but posted to the same newsgroups in the mid-90s. We recently met again when he sent me a reminder and facebook invite.

Last night or this morning, I got up at some ungodly hour to see off a visitor who had spent a week with us in Sydney. My trusty Crackberry was handy and I checked my email, sms and fb messages as usual. The one thing waiting for me was a message asking if I knew of any "Flash Coders" - meaning web monkeys who write action script. I'm willing to admit that they are usually far more artisitically enabled than I am but... and it's a large one, they usually aren't able to pass for coders in any way, shape or form.

I have worked for one start up where the flash guy was a shocking electrical engineer who found solace in being able to make flash movies. Maybe there is more to it but it was common place for devs to show him how to embed his stuff in HTML.

So my friend tells me that Flash devs are worth US$20 000 a week from a business man like him. The Interblag has become so simple that real programmers are no longer required. No one needs hard stuff written anymore. The games and promo tactics used to sell stuff only need Flash Coders (FC).

I sure hope that isn't true. Who writes the stuff whose shoulders FCs stand on? Is it business guys? Is it other FCs? I sure hope there is some need for us sloggers. Those of us who can at the most draw a bath if not draw a picture.

Wednesday, 9 April 2008

Forget Google Apps, use eyeOS

Alex pointed me to an awesome web app that is an entire OS online. eyeOS uses OpenOffice + a small PHP application with mysql that allows you to run an entire computer inside your web browser. Try out the demo on their website to see what I mean. It's cool.

Acknowledge Me

Apple started a user experience trend many iOSes ago when it accepted Settings changes and did not ask for confirmation. Once the chang...