How else do we earn l33t respect? May 12, 2008
Posted by reddogaw in Developer Life, Uncategorized.add a comment
I want to preface this post with a statement: I don’t think I’m l33t (meaning an elite programmer for the less nerdy of us). Having previously worked at a Sydney software consultancy where I can assure you the standard of the young consultants was very high such that I felt constantly in the shadow of an incredible 16 year old prodigy, an organised “old-timer” who just knew how to get things done (and fast!), or the respected industry speaker and rule maker… So the question beckons, how do developer’s talents get recognised?
I think it’s fair to say that not all programmers are equal so what does it take to be considered one of those hyper-productive folks that we nerds might call l33t?
In any software development team with more than a few people, you’re almost guaranteed that your manager is no longer technical… They used to be, but by the very definition of management they’ve shifted focus onto broader topics such as staffing, team morale, project delivery, process management, financial risk mitigation, and project funding. So are they a good judge of your development skills? The way I see it is they are if you can do some of the following:
- Have the ability to d3-l33t1fy your conversations (talk non-technical)
- Are seen as a teacher or mentor
- Are social with your management team
- Can communicate with the big picture in mind
- Can understand that development costs money, lots of it
- Follow change management, timesheeting, task tracking procedures
- Contribute to collaboration and knowledge sharing
- Estimate well
- Gain industry certifications
- (Cynically) Can spin when things go wrong (which we know will happen a lot!)
But how does this correlate with what makes a good developer from another developer’s point of view? Or even a software quality point of view?
Almost certainly developer’s opinions of other developers are influenced by the personal, creative, social and technical sides of software development. Perhaps including some of the following:
- Are social with your coworkers and make them feel happy at work - you enjoy a good laugh, are fun to be around, you don’t smell, and you can go to lunch or drinks together
- Can put time aside to help when you should
- We’ve all been super focused on our task at hand to find someone whom is trying to debug your code asking you a million questions which feel unreasonable, but really they’re not. You should help them… Don’t let them deplete their life-force.
- Document your code where necessary
- Incidentally, I would typically go for a minimalist approach where code should be self-documenting
- This mostly includes code organisation and following coding standards
- Write simple code that uses chosen frameworks to their best intentions
- They know when to fix vs. when to extend vs. when to roll your own
- They use inheritance and polymorphism well
- Truly understands all code that they produce and “write”
- Gets things done with a gist for how to do things better in the future
- Did you ever notice a good coder will often leave many TODO’s in their code?
- Has a broad knowledge of system components, technologies and frameworks
- Somewhat similar to a good architect in that regard
- Continually improving old code with fresh ideas
- Isn’t afraid to throw things out
- They have a good “code smell” for dud code and don’t mind re-engineering if need be
- Develops a quick familiarity with new technology rather than a deep understanding
The reason I bring these points up is that I recently was chatting with Dr Neil about MS certifications as a resume filler and then stumbled onto thoughts about whom is your best referee when going for a job… The answer is almost certainly the 360° profile including a manager (for the business smarts), coworkers or peers (for the developer smarts), and possibly system users or peers (for the common sense/usability smarts).
The other question we should ask ourselves once we’ve settled into a job is whether the way we see ourselves in our own careers is similar to that of our managers and coworkers… (Remember, you must consider it from their view point rather than your own). Is that a problem? Does that highlight some goals you could set yourself for the next year?
What do you respect in other’s programmer skills?
Love,
Reddog.
Which lobe are you? May 8, 2008
Posted by reddogaw in Fun, Uncategorized.add a comment
Unexpectedly, I see it clockwise… Though more worrying was that it took me 30 seconds to remember which way is clockwise!
Using SiteMap for external links and additional attributes May 8, 2008
Posted by reddogaw in ASP.NET, WCSF.Tags: not a valid virtual path, SiteMap
add a comment
In a website we are currently developing we are using the WCSF (from the Patterns and Practices group) and we wanted to inject in some links to a few external websites. The WCSF uses a custom SiteMapProvider that is part of its framework. A coworker highlighted how he solved the problem by simply overriding the URL as part of the TreeView (our menu) databound event handler within a master page.
I wasn’t especially happy with this solution since it separated the URL information from the code that created the information in the first place.
Since the problem originated a “not in virtual path” when the sitemap node has a URL that’s external to the application, I decided to route the external links through a redirect page (Redirect.aspx). The other important thing is to use HttpUtility.UrlEncode and HttpUtility.UrlDecode to take care of making the URL suitable for a querystring value.
(Note: don’t use escaped characters in the input string - e.g. +, %2f, etc. since this makes HttpUtility.UrlEncode assume the string is already encoded).
The redirect page is simply this:
if (!String.IsNullOrEmpty(Request.QueryString["url"])) { string url = HttpUtility.UrlDecode(Request.QueryString["url"]); Response.Redirect(url); } else { Response.Redirect(“~/Default.aspx”); }
Then when inserting the SiteMapNodeInfo nodes into the collection I instead formatted the URL with:
string url = String.Format(“~/Redirect.aspx?url={0}”, HttpUtility.UrlEncode(“http://www.myexternallink.com”));
The rest is specific to WCSF SiteMapNodeInfo nodes, but additionally, I wanted the external link to pop-out into a new browser window (target=”_blank”) so we need to pass in NameValueCollection with key/values for all the attributes you want converted in the final SiteMapNode instance (in our case we simply need Target):
NameValueCollection attrs = new NameValueCollection(1); attrs.Add(“Target”, “_blank”); SiteMapNodeInfo externalLinkNode = new SiteMapNodeInfo(“ExternalLink1″, url, “My External Site”, “Check out the external site”, null, attrs, null, null);
Then as was pointed out earlier, in order to take advantage of those additional attributes within your Menu or TreeView we will have to do so within our master page (or page).
protected void MainMenu_TreeNodeDataBound(object sender, TreeNodeEventArgs e) { Debug.Assert(e.Node.DataItem != null); Debug.Assert(e.Node.DataItem is SiteMapNode); e.Node.Target = (e.Node.DataItem as SiteMapNode)["Target"]; }
You could use the same method using additional attributes on the SiteMapNode used to include little images or icon’s (e.g. ImageUrl) next to the menu node.
Hope this helps some lost soul…
Love,
Reddog.
Tiny Tip: Use Consolas font pack for Visual Studio May 4, 2008
Posted by reddogaw in .NET General, Tips, Visual Studio.add a comment
This one has been often blogged but a good tip came around on email to use Consolas mono-spaced, clear type font inside Visual Studio. I’ve been using it for a little while and think it looks great. You can download it from MSDN. A good visual comparison between Consolas and the standard Courier is here.
One thing to add is that it’s optimised as a clear-type font. In Vista all fonts are enabled in clear type by default, but at least on my XP machine they weren’t. To enable this you need to go to the display properties dialogue (right click -> Properties on the desktop). Then on the Appearance tab, hit the Effects button to find this dialogue to enable it.

In Vista you can find this dialogue under Control Panel\Appearance and Personalization\Personalization on the Window Color and Appearance item. Use the link to open the classic properties box.
Archive: ASP.NET impersonation and SQL Server May 3, 2008
Posted by reddogaw in .NET General, Archive, SQL Server.Tags: ASP.NET Authentication, Impersonation, SQL Server
add a comment
From: http://blogs.ssw.com.au/andrewweaver/archive/2005/03/11/3968.aspx
Its a frequent situation where you want your ASP.NET application to connect to the SQL Server using the integrated security account. For example, you have all of your roles setup on the SQL Server and want your web application (secured via IIS integrated authentication) to get data specific to your role on the server.
In a windows application this is easily achieved by just making your SQL connection string use the integrated account (whichever windows account is running the app). But in a web application, the account that your SQL Server will open the connection under is the \ASPNET [or \Network Service in IIS6] not the account that is used for IIS authentication. To make it use the authenticating account you could turn on impersonation within your web.config file with the following:
<authentication mode=“Windows” /> <identity impersonate=“true” />
When I ran it with impersonation = true it just seemed to work perfectly (you can run a SQL trace to spot who the connection is coming in as). But be warned it doesn’t work for all server configurations apparently. I’ve just formatted and have a fresh install of SQL (running under the local system account) so I would think that I’ve got a “default” install…
An MSDN article sheds some light on why it won’t always work:
Why can’t I enable impersonation for the Web application, so that I can secure the resources accessed by my Web application using ACLs configured against the original caller?
If you enable impersonation, the impersonated security context will not have network credentials (assuming delegation is not enabled and you are using Integrated Windows authentication). Therefore, the remote call to SQL Server will use a NULL session, which will result in a failed call. With impersonation disabled, the remote request will use the ASP.NET process identity.
You will notice that it says that “assuming delegation is not enabled” (which it isn’t by default) these problems will occur. So obviously we might want to work out how to get this enabled… Keith Brown wrote an article detailing what you need to do to get this enabled - which should in theory get things working seamlessly.
A key problem with using impersonation is that you might now have security considerations that you weren’t thinking about, e.g. access to file resources, etc… Remember that all of your code is now executing as that user - not the ASPNET account…
Archive: Windows Impersonation in C# - Handy when debugging with ExOLE DB May 3, 2008
Posted by reddogaw in .NET General, Archive.Tags: DllImport, Externs, Impersonation, LogonUser
add a comment
From: http://blogs.ssw.com.au/andrewweaver/articles/186.aspx
While working on our new product SSW Exchange Reporter, the need to impersonate users (mostly for debugging purposes) arose. The reason being that unlike most of the other OLE providers you can’t provide login details with the connection string when trying to connect to Exchange with the ExOLEDB provider. For example an SQL connection string you can have “user=sa; password=xxx; ….” but you can’t for an ExOLE connection string. Therefore the ExOLE provider will not do any impersonation for you, it will always run under who ever is executing your application code. That is, whoever your service runs under or whoever is logged on and runs your .exe or whoever you run the .exe as using the ‘Run As…’ context menu item. Additionally the user we run under needed read permissions to all mailboxes.
Use some of the following code to do some impersonation.
Firstly make use of the windows LogonUser() function in advapi32.dll. Note that username and passwords are passed as plain text…
public const int LOGON32_LOGON_INTERACTIVE = 2;
public const int LOGON32_LOGON_SERVICE = 3;
public const int LOGON32_PROVIDER_DEFAULT = 0;
[DllImport("advapi32.dll", CharSet = CharSet.Auto)]
public static extern bool LogonUser(String lpszUserName, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
Then you can call this method to get the handle (the last parameter) for the user and use this to create a WindowsIdentity (in the System.Security.Principle namespace) and then begin impersonation with this handle.
IntPtr userHandle = new IntPtr(0); bool returnValue = LogonUser(name, machine, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref userHandle); if (! returnValue) throw new Exception(“Invalid Username”); WindowsIdentity newId = new WindowsIdentity(userHandle); WindowsImpersonationContext impersonatedUser = newId.Impersonate();
You would probably wrap all this code, along with some additional verification code into a function called “BeginImpersonate“ or similar that would return both the user handle (so that you can free it later) and the impersonatedUser object so that you can end impersonation later via and “EndImpersonate“ function… End impersonation with the following code.
impersonatedUser.Undo();
Free the userHandle with a call to another windows function.
[DllImport("kernel32.dll", CharSet = CharSet.Auto)] public extern static bool CloseHandle(IntPtr handle);
Better examples can be found on the MS .NET documentation on WindowsIdentity.Impersonate method, but I hope this helped a little… In this document they actually duplicate user handles that they use for impersonation, though I don’t exactly understand why… You duplicate your handles via:
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)] public extern static bool DuplicateToken(IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);
Archive: Getting the Date portion of a DateTime type in SQL (T-SQL) - Use Floats and Floor! May 3, 2008
Posted by reddogaw in Archive, SQL Server.Tags: Convert, DateTime, SQL Server
add a comment
Update - 2 May 2008 - Watch out for SQL Server 2008’s new Date and Time data types!
From: http://blogs.ssw.com.au/andrewweaver/archive/2006/06/19/8262.aspx
Something that comes up quite frequently when dealing with reporting and DateTime fields on a data table is grouping by the Date portion only of the field or filtering for a full day of data.
If you were to filter DateTime values where the actual time portion is used then doing: SELECT * FROM Sales WHERE Sales.TransactionTime = '19 Jun 06'
Then you will only be getting the sales that were created at midnight!
Often you will see people wanting to only get the date portion by using a string conversion or a convoluted mix of SQL DateTime functions. For example: SELECT * FROM Sales WHERE CONVERT(varchar(10), Sales.TransactionTime, 101) = '2006-06-19'
But this is somewhat slower and more memory intensive than a way in which two co-workers (Mehmet and Mark) have suggested (I don’t think it was ever posted by them, but I’m sure its on the net somewhere). They say that you should convert the DateTime field to a float and floor it in order to get the date portion. This is will work as when the DateTime is converted to a float the date portion can be found as the whole number representation of the float, the time is the fractional portion.
For example:
-
Convert date to a float: SELECT CONVERT( Float, GETDATE())
-
Floor (take only whole number value) the float value to get only the date portion: SELECT FLOOR( CONVERT( Float, GETDATE()))
-
Convert back to date time (if needed) for display purposes: SELECT CONVERT(DateTime, FLOOR( CONVERT( Float, GETDATE())))
There are tonnes of posts regarding this, so checkout a few of them.
Archive: TIP: Shrinking / Saving / Compressing your big digital images May 3, 2008
Posted by reddogaw in Archive, Tips, Uncategorized.Tags: Compress, Images, IrfanView, Shrink
add a comment
Update - 3 May 2008 - IrfanView now has a batch save/edit mode that you can use to achieve a similar result…
From: http://blogs.ssw.com.au/andrewweaver/archive/2004/06/02/234.aspx
In order to share (via email or web page etc) your digital photos, you really should compress them (and shrink them a bit too) first.
One of the easiest ways is to use a freeware application called IrfanView. It’s great to use for viewing slideshows, and doing basic image editing (such as cropping, resizing, saving to different formats etc). It’s only like 800 KB so it’s small as well…
You can then use it’s command line options to make a simple bat file, that will take all files in a directory, shrink them a bit, knock down the compression quality and re-save them into a sub directory. I use the following bat file (which you can simply place in any directory that you want to shrink the files in).
@echo off set IViewDir=C:\Program Files\IrfanView set CurDir=%cd% set OutDir=%CurDir%\web "%IViewDir%\i_view32" "%CurDir%\*.jpg" /resize=(0, 600) /aspectratio /jpgq=75 /convert="%OutDir%\*.jpg" @echo on
This will put save all jpeg’s in a directory into a subdirectory called “web” (same filenames), change the jpeg quality to 75%, and resize the image to 600 pixels high (and width will scale according to the original aspect ratio).
Archive: Evil Bug - Serialization of TimeSpan object. May 3, 2008
Posted by reddogaw in .NET General, Archive.Tags: .NET 1.1, Serialization, TimeSpan
add a comment
From: http://blogs.ssw.com.au/andrewweaver/archive/2004/05/22/201.aspx
I’m using XML Serialization to get the XML for one my classes for public storage. This class has a public property of type TimeSpan… My evil bug is that despite the doco saying that the timespan would get serialized, it didn’t!
Resolved it by making the main property be ignored by serializer, and then a new property based on the Ticks for the TimeSpan:
[XmlIgnore] public TimeSpan DailyInterval { get { return m_Interval; } set { m_Interval = value; } } public long DailyIntervalTicks { get { return m_Interval.Ticks; } set { m_Interval = new TimeSpan(value); } }
Some other dude had the same problem (along with many others) and attempted to explain it…
Getting back amongst it… April 27, 2008
Posted by reddogaw in Uncategorized.add a comment
I was at least temporarily a blogger, but then it kind of just fizzled out - largely due to blog spam and laziness at upgrading our ancient version of dotText. There were at least a few decent technical posts on there, but sadly I don’t lack the patience to work out how to export/import the feeds over to here.
I also had a short stint as a ghost writer/drafter on a blog that shall remain nameless…
I’ve decided to call it Left Lobe Logic in honour of the left cerebral hemisphere of the human brain which is where a majority of a software developer’s key skills would appear to originate. The irony is that hopefully the very act of blogging here can help exercise my right side too!
So, as with any new venture I think its best to always define your lofty ideals (we’ll call these goals or even my vision statement) then, based on some learning in a future post I’ll outline a few resolutions.
- To achieve continuous self learning through blogging and reflection
- Share my .net development experiences
- Share code that may help other developers
- Increase my connection to the development community
Cheers! I guess we’ll see how I do in round two!
Love,
Reddog.