/// Frank Hagen: Professional Web Developer, C# User, Reformed Über-geek RSS 2.0
# Thursday, May 07, 2009

I have a need to take large random numbers (on the order of 20 digits) and encode them to easily typable strings.  I created a quick method to do this in C#.  This is the code:

private string ConvertToBase(ulong id)
{
    // Seed replacement characters for baseX values
    string NumericBaseData = "0123456789ABCDEFGHJKMNPRSTUVWXYZ"; // this string may be in any order as long as each char used only once
    ulong OutputBase = Convert.ToUInt64(NumericBaseData.Length); // baseX determined by number of unique chars in seed string
    string OutputValue = "";
    ulong In = id;
    while (In > 0)
    {
        ulong tn = In % OutputBase;
        OutputValue = string.Concat(NumericBaseData.Substring(Convert.ToInt32(tn), 1), OutputValue);
        In = In - tn;
        In = (In / OutputBase);
    }
    return OutputValue;
}
 
For simplicity, I used unsigned longs (64bit), since I am dealing with really big numbers.  Performance is reasonable, I am able to generate a large System.Random, mod it against an arbitrary number of DateTime.Now.Ticks, datestamp it, and convert it using the method above in under 9 ms each.  (I also have an algorithm to test for uniqueness against previously generated values, but the timings grow with greater sample size as expected.)  This method can be modified with any number of cipher characters as long as they are only used once.  This particular one uses all letters and numbers except 'O', 'Q', 'L', and 'I' to avoid confusion to end users and is URL freindly.
Thursday, May 07, 2009 10:23:13 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | Programming
# Friday, March 20, 2009

I am in the market for some quick, effective training in Oracle Development focused on consumption from a ASP.NET development point of view.  I don't need to know how to admin the Oracle server, just how to write effective, efficient queries, setup performant data models, optimize data access and fix our overabundance of foreign keys, indexes and CLOBs.  I am advanced in SQL Server development, but need to know the nuances that differ in Oracle.

Any recommendations?  Thanks in advance!

Friday, March 20, 2009 8:33:59 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Oracle | Programming
# Wednesday, March 04, 2009

The following code should be failed by the C#.NET compiler:

if (eventName != null && eventName.Length > 0)

It should never be used.  People, always use this instead:

if (!String.IsNullOrEmpty(eventName))

It is much more compact, clearer, singleton, and as a String class method, more efficient.

So stop it!  You will thank me later.  Not to mention:  Where are your parentheses?  Block your code.  Other people have to read it too!

That is all.

Wednesday, March 04, 2009 10:43:27 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.NET | Programming | Rant
# Wednesday, February 11, 2009

FLAC may be the perfect format for music storage with its far superior quality, hardly any players support it.  Especially my OEM in-dash player in the car.  So it is necessary to convert.  The batch file below will convert the FLAC to MP3 via WAV and tag from the original, assuming the correct pieces are installed as demonstrated.  I have it loaded into a batch file which I have placed in my Send-To folder for easy right-click/convert use.

"C:\Program Files\FLAC\flac.exe" -d %1 -o temp.wav
"c:\program files\lame\lame.exe" -V2 temp.wav %1.mp3
del temp.wav
"C:\Program Files\Lame\Tag\tag.exe" %1.mp3 --fromfile %1     
pause

By the way, do go out of your way to find the version of LAME that is compiled for your specific CPU.  My Q6600 does VBR2 at 28x.  I literally cannot rip as fast as it encodes from CDs.  (Note: while there is a multi-threaded version, mp3 encoding is really a single-threaded operation, so quad-core just means I can encode 4 streams at once.)

Wednesday, February 11, 2009 8:47:19 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Programming
# Tuesday, October 14, 2008

VisualStudioLogo subversion_logo-200x173 There are a few articles online covering SVN and VS, but many are out of date and a bit more complicated than necessary with advances in both products.  For a current install (Oct 2008:  SVN 1.5.2 / VS2005), you only need 3 files:

Subversion is, of course, the Source Control server itself.  The MSI install contains everything needed to run on a Windows server.

TortoiseSVN is a plug-in for Explorer that gives a great deal of control to the source repository using the right-click context menu.  Check-ins, updates, merges, etc. can be done through this interface as well as full repository browsing and maintenance.

AnkhSVN is the most important tool for the .NET developer.  It integrates the controls needed for team development directly in the environment.  Much like the integration offered through VSS, but much better.

Installation of Subversion itself is very easy.  Just run the installer.  I installed into C:\SVN\ instead of the default "Program Files" directory, but I am lazy and hate spaces in filename on the command-line.
NOTE:  The installer only puts the files in place and sets the important environment variables.
Once installed, the following command is used to setup a repository:

svnadmin create "D:\SVN\Repository"
You can create as many repositories as needed, but one for now.  Before we activate the server, two config files need to be edited.  They were created with the repository above.  They are svnserve.conf and passwd in the conf sub-dir of the repository.  Uncomment the following:
~/conf/svnserve.conf
[general]
anon-access = read
auth-access = write
password-db = passwd

~/conf/passwd
[users]
harry = harryssecret
sally = sallyssecret

Now the installation can be tested. Execute the following command in a command window:

svnserve --daemon --root "D:\SVN\Repository"

To create a project, execute:

svn mkdir snv://localhost/newproject

Now would be a good time to install TortoiseSVN if it hasn't been yet.  Connect to the running server from within an explorer window by right-clicking and selecting TortoiseSVN > Repo-Browser.  Enter the name of the server to see the interface using the following URL:  svn://servername/  The project "newproject" should be viewable there.

And now the most difficult part of all:  Installing SVN as a service in windows.  The following command will accomplish this.  Syntax and proper spacing is critical.  (I was having problems until I realized the space after each '=' in the command.)  Here it is:

sc create SVN_CSTeam binpath= "c:\svn\bin\svnserve.exe --service --root D:\SVN\Repository" 
displayname= "Subversion Repository for CSharp.NET Team" depend= iisadmin

And that is why I do not use the default paths.  Spaces have to be delimited with quotes, which have to be escaped, and it just is not worth it.  All on one line of course.  Also note that the name after the "create" parameter can be anything desired and allows for multiple repositories on the same server, along with unique displayname.  I chose to use iisadmin as a depend, not because it necessarily is, but because it is sure to load other depends such as Tcpip and such.

The last step is to load AnkhSVN; a solution I leave to the reader.  It's not hard.  If you are familiar with source control at all, it is pretty obvious.


I'd like to thank the following sites for very useful information in helping me through the installation and the creating of this post:

Tuesday, October 14, 2008 4:42:27 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | Programming
# Thursday, May 08, 2008

It amazes me in my travels how many people feel the NEED Photoshop for web development.  And, of course, they only use about 1% of its total capability.  It is true that years ago, it was the only game in town for Image creation and manipulation.  But not for a while now.  There are many free alternatives that suit the web developer much better.

Paint.NET My favorite for most tasks is Paint.NET.  It greatest feature is its price:  absolutely free!  It started life as a college project and was so successful, that it lives on as a great piece of Freeware development.  It is not Open Source, however.  Some of the other features include layering, filters, great image processing tools, alpha transparency, PNG, and many, many more.  All put together in a small, efficient package that is both easy to use and very powerful.  And hundreds of dollars less than Photoshop and lacking the disturbing Adobe trend toward spyware.  And as the name suggests, it is built on C#.NET, so I feel like I am supporting the community I am a part of.

GIMP If you need more, there is the GIMP project.  Much more complicated, far more powerful, still free, but not nearly as user friendly.  It resembles Photoshop in many ways, including the powerful plug-in model that PS uses.  I use GIMP 2.2 for things I cannot do in Paint.NET, which really isn't very often. 

You know, between the two, I don't at all miss the copy of PS I had at my last job.  Not at all.  Of course, I am not a graphic designer or a heavy Photographer either that needs the power of PS, but I haven't worked with many people who really were either.

One last note.  For those that have been heard to say, "[MS] Paint is good enough.":  Do yourself a favor and get Paint.NET.  MSPaint hasn't been good enough since the '90s.

Thursday, May 08, 2008 11:02:01 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | Programming | Work
# Wednesday, April 09, 2008

Just why do I hate Flash requirements on sites so much?  I mean, every time I see a nice webpage marred by some Flash applet, I cringe and wonder why they decided to make that choice.

It used to be that requiring a user to have Flash installed just to visit your site was an inexcusable arrogance on your part as a web developer.  And then there was the bandwidth requirements for the content; after all, you are developing locally, so who cares that the end-user has to wait?  Well, you should, for starters.  And many times I see Flash, even still, being used as an easy way out or to simply animate a graphic. So historically, there were many, many reasons to never use Flash except for very specific applications.

Today, many of those arguments are not valid.  I believe all browsers have Flash preloaded, and bandwidth concerns are almost negligible anymore.  So why do I still find Flash to be a over-bloated gorilla on an otherwise clean design?  After all, I find the exclusion of PNG support on many browsers today to be inexcusable, but the inclusion of Flash a mere convenience.

Unfortunately, I don't have any clear answers.  To me, Flash doesn't belong on most websites I see today.  Yes, Flash does have it place in many online applications, but not as a graphic element.  And I believe that is the crux of the argument:  it is not a good replacement for some well designed image elements.  I am an old school developer that believes that good, solid, static design will always be superior to flashy, dynamic design in the long run.  Do not mistake that statement as a call to return to HTML as the primary development tool.  I refer to design; not content, which should always be dynamic, save of course for documentary content.  In my opinion, as a former CBT developer and current Intranet developer and BI Programmer, all design should be restricted to good use of CSS, PNG/GIF/JPG, and XHTML.  And there is also the fact that it is a closed standard.  Or actually, not a standard at all.  Flash is owned by Adobe, and is subject to their whims.  I just don't think that belongs in general web design from an end-user perspective, much the same way that I don't think it's right to use PDF as a publishing medium for web documents.

And don't even get me started on the crapware/bloatware/spyware that is a mark of Adobe products lately.  I flatly refuse to use Adobe's PDF reader anymore, but use Foxit Reader instead for any PDF files I might need to read.

Wednesday, April 09, 2008 10:54:36 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Programming | Rant
# Tuesday, October 09, 2007

This really should have been more obvious to me, so why did I have to look it up?  If you need to check for NULL in a returned field from SQL (or any other datasource), you should the .Equals method on System.DBNull.Value.  I usually prefer the "==" notation for conditionals, but that's just me.  This is more efficient.  The code follows:

if (!dsSpecQuery.Tables[0].Rows[0]["device_type_end"].Equals(System.DBNull.Value)) 
{
    _EndDate = Convert.ToDateTime(dsSpecQuery.Tables[0].Rows[0]["device_type_end"]);
}

Of course, dsSpecQuery is a DataSet, and the field in question is DateTime out of SQLServer (not that it matters for the conditional).

Tuesday, October 09, 2007 9:38:06 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | Programming | SQL
# Monday, August 20, 2007

Last week, I posted an entry about a simple call to an MS-SQL database with a warning that it should only ever be used in a quick and dirty scenario.  By that I mean when it doesn't make sense to integrate or create a Data Access Layer or class to do the heavy lifting for you.

The advantages of creating classes to do the data calls behind the scenes are many, not the least of which is easier development in the long run.  Take a look at the following code:

    Query qEmplQuery = new Query(); 
    qEmplQuery.ConnectionSettings = ConfigurationManager.ConnectionStrings["EmployeeDB"]; 
    qEmplQuery.StoredProcedure = "DW.PKG_HRPORTAL.PRC_EmployeeInfo"; 
    qEmplQuery.AddParameter("P_EmployeeNumber", szEmplNum); 
    qEmplQuery.MinutesCached = 12 * 60; 
    DataSet dsEmplQuery = qEmplQuery.RetrieveDataSet("P_EmployeeInfo");

Much easier than even the "simple" call I posted earlier, isn't it.  The beauty of this is that it is also an Oracle call (database agnostic:  the same call for Oracle or MS-SQL makes for easier and standardized development) and is cached for 12 hours.  We also have a coding standard that only parameterized Stored Procedures are used for any kind of data access. 

But the most important advantage is that the Query class contains all of the complex coding needed to make this as efficient and "correct" as you know how and never have to think about it again.  This is basic abstraction and Object Oriented Programming fundamentals.  I have used Enterprise Library factories for my calls in Query because of the desire for its good caching and efficient data and network layer calls, but you can use whatever you want. 

In my next series of posts, I will present details of the Query class in order to help build your own.

Monday, August 20, 2007 11:08:46 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | DataBase | Programming
# Wednesday, August 08, 2007

Below is the most simple database query for C# to populate a GridView object:

int nItemID = 1; try { using (SqlConnection oSQLConn =
new SqlConnection(ConfigurationManager.ConnectionStrings["UserInfo"].ConnectionString)) { oSQLConn.Open(); using (SqlCommand oSQLCmd = new SqlCommand()) { oSQLCmd.Connection = oSQLConn; oSQLCmd.CommandText = "SELECT DisplayName, EMail FROM Users WHERE UserID = @PARAM_ItemID"; oSQLCmd.Parameters.AddWithValue("@PARAM_ItemID", nItemID); SqlDataReader oSQLReader = oSQLCmd.ExecuteReader(); GridView1.DataSource = oSQLReader; GridView1.DataBind(); } } } catch (Exception ex) { Label_ErrorMsg.Text = ex.Message; }

There are actually many reasons to never use this, including performance, caching, safe SQL, code reuse, standards, proper exception handling, etc, etc.  But sometimes you need a quick and dirty, non-production, piece of code for testing and/or development.  This is it.

Wednesday, August 08, 2007 4:18:44 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | Programming | SQL

Almost everything I read regularly online now is through an RSS feed.  The few things I don't get through RSS are either not suited to RSS or don't come in a feed, but are too important to me to skip.  I use SharpReader to collect and browse all of these feeds.  It is not a perfect reader but does what I want it to do better than anything else I can find (for free).

I have always enjoyed comic strips and much prefer them on the web than any other format.  I have been reading Dilbert online since the old days when Scott Adams posted them himself on Usenet.  But not all comics online are available in an RSS feed.  And none of them were a few years ago (before RSS, of course).  I have tried over the years to script or code different ways of collecting strips with some success, into webpages or browsable collections, but something was always lacking.

Today I use a app I created to collect the img tags from the hosted sites and put them into RSS feeds for each strip.  It works for me.  The only problem is the RSS library for .NET that I used doesn't clear the old entries correctly, so the XML file get big over time.  Not huge, just big.  Now I can load my feed into SharpReader and have all of the feed-y goodness such as tracking which entries I've read, notification of new ones, and locking or saving the ones I want to save.  I have about a dozen strips now, including the fabulous XKCD all RSSed up.  If you'd like to use some, let me know and I will email you the link.  I will not post it here as I don't want them abused. 

Oh, the other problem:  I'm always looking for more webcomics.  Most that I like I just stumbled on, so I always take recommendations.  And yes, I will feed up a strip, even if I don't like it, for someone else.  Just the way I am, service-oriented.

Update [10 Aug 2007]:  Ha ha!  When I went to XKCD.com today, I noticed that he's put up an ATOM feed himself.  So I can remove that one from my collection list. 

Wednesday, August 08, 2007 10:15:42 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Programming
# Saturday, August 04, 2007
I really haven't posted many code-related posts lately.  There are a few reasons for that:  Primarily, I have been working on SharePoint 2007 branding.  Sheesh!  Once I figure out the guts of that, I will post what I learned.  I have also been maintaining VB.NET code, which I am not at all interested in posting about.  The goal here is to post useful or interesting information for myself and others.  What I have been doing in VB.NET 1.1 is neither.  And I have been taking a business C++ class for my major, and boy it's close to worthless.  So a bit of a code break.
Saturday, August 04, 2007 12:24:18 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Blog | Programming
# Friday, July 20, 2007

A colleague and I were discussing desktop systems, and agreed in confusion about the seemingly typical cost-cutting measure of giving developers underpowered systems to work on.  This got me thinking:

First of all, with todays prices, how expensive would it be to really outfit a developer with a truely powerful rig?  You don't need tons of storage or a fancy 3D gaming card or high-end sound (unless, of course, that is your line of business) so you should be able to get a really powerful machine for under $2000.  It shouldn't be hard to do an ROI for that, just in productivity gains.

Second, it would make your true developers, the propeller-heads that love this stuff, very happy.  That is also a great productivity gain.  After all, a happy coder is a working coder, not one that is standing around bitching.

Finally, I always felt it a truism that it is worse to have a better system at home for development than at work.  This is more an intangible.  After all, you can't constantly be polling people about their personal systems; not to mention, most of us have more than one.  I have 4 functioning and a few not.  I personally will feel more compelled to work on the better system; for management's sake it ought to be on my desk at work.  

So, you management types:  we developers love the hardware, we want to play with it, we want to use it, we want to possess it.  It's a cheap win to give us toys to play with.  We will want to exercise them.  It's in your best interest.

Friday, July 20, 2007 8:09:03 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Programming | Work
# Thursday, May 31, 2007

I have hired a few people in my time.  Not many, and I'm not an expert, but I have learned a few things.  In my experience, the best programmers exhibit obvious enthusiasm in 3 specific areas. 

The first is their hardware.  Truly great programmers take great pride in their setup, although not in the same ways.  If you can get the gleam in the eye when off-handedly talking about the latest CPU, the home network, or custom case, or skinned interface, you have found proof that they really are into what they do.  For me, it's my computer.  I have never bought a computer.  My dad purchased my first PC in 1991, and I have upgraded it ever since.  My x386 is now a P4 and soon to be a Core2Duo.  Of course, I love my home network I've been fiddling with since 1998 and I can't use a stock XP installation for more than a few minutes before I have it all modified up.

The second area I borrow from Jeff Atwood of Coding Horror.  Yes, again.  The interviewee should have a favorite piece of code that they have created.  Not usually an entire application, but a class, algorithm or routine that they are especially pleased with.  Don't blame them if they can't put their finger on a single one, I have a hard time there too.  Either my frequent implementations of Linked Lists, the automated Secure File transfer / Content Management solution, auto-validation in C# from custom attribute assignment, or my comic strip collector... It's especially important to me that they have some personal code they love too, not just professional.

The last area I think is important is probably the most controversial:  gaming.  Find out what kind of games they play, it may say a great deal about the kind of coder they are.  FPS gamers tend to be very direct, task oriented, focused coders.  RTS guys are more big picture, and turn-based strategy players even more so and very methodical.  If you find a Civ Addict, hire him now!  MMO gamers are probably good at maintenance or grind programming.  And the ones that love them all will not be exceptional in any one area, but will be very versatile.  That's where I lean, though I LOVE Civ; so much so that I can't leave it on my PC for long before it becomes a problem.

These generalizations are just that.  Not to be taken too seriously, but they have never let me down.  I have found that I cannot even consider someone who doesn't exibit much in any of the categories, or prefers XBox gaming, or doesn't own a PC (!). 

There are always exception, these are just my observations.

Thursday, May 31, 2007 7:45:10 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Programming | Work
# Friday, May 04, 2007

"You're an amateur developer until you realize everything you write... sucks, basically."   
--Jeff Atwood on .NET Rocks! podcast #232 (23:44) - 26 Apr 2007

"The minute you realize that then you've crossed the threshold.  Now you're a professional developer..."

Friday, May 04, 2007 9:23:11 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Programming
# Friday, April 20, 2007
One best practice I insist on is codefile headers, especially since VSS makes this stupid easy.  Below is the format I currently use for C#.NET:

 

#region Version Header
/// <remarks>
/// ----------------------------------------------------------------------------
///   Application: XXXXXXXXXXXXX
///     $Workfile: Default.aspx.cs $
///   Description: Start page for XXXXXXXXXXX.
///        Author: Frank Hagen
///       Created: 11/22/2006
///     Copyright: © 2007 XXXXXXXXXXXXXXX.
/// ----------------------------------------------------------------------------
///      $Modtime:  $
///     $Revision:  $
///   Mod $Author: XXXXXXXXXX $
///  VSS $Archive: /XXXXX/XXXXX/XXXXX/Default.aspx.cs $
/// ----------------------------------------------------------------------------
/// </remarks>
#endregion
Friday, April 20, 2007 10:22:45 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [1] -
.NET | Programming
# Friday, March 09, 2007

Some background:  A few months ago, I decided to put a little AJAX in an app I inherited.  The problem was a huge form that used post-back to fill some dropdown boxes based on values in other elements.  I coded the AJAX all from scratch, or near scratch anyway, mainly because ATLAS was still in early beta and this is a 1.1 app.  Anyway, everything worked well enough, or so I thought. 

This is where good end-user testing is so important.  You see, since I inherited this beast, I don't know how everything is supposed to work.  Some of the nuances are not always apparent to me and I might miss them.  For example, when creating a new form, a set a parameters will autofill the main form.  When I inserted my AJAX streamlining and tested, everything worked great from my perspective, a new form was created with some of the values prepopulated.   What I didn't realize was that the dropdown list was not being read correctly by the codebehind, because from it's perspective, it was empty the last time it saw it and was not reading the form post value.  I don't know yet whether this is my fault or the friendly designer who wrote this screaming... thing, but the end result is that not all of the values were filled that were supposed to.

So here's where my post title comes in:  When I put the AJAX calls in, I did not change the code-behind.  I simply added my JavaScript and disabled the elements' autopostback attributes.  When developing systems I don't understand, I make as little impact as possible and comment like hell, so someone can come in behind me and fix what I broke.  I also CYA in comments for who requested what changes and why.  Fixing broken code reminds me constantly about the importance of good commenting, despite that I don't do very good job of that in my original code.  Anyway, the implementation of some business logic features and these got rolled up, tested of course, and deployed late yesterday.

Well, this morning I get a frantic call and a HD Ticket:  Yep, the form is not populating all of the values.  It needs to be fixed immediately!  And behold!  It only took 15 minutes to find the cause and simply turn on the autopostback and disable the JavaScript.  All in the aspx file!  If I had removed or commented the methods in the code-behind, I would have had to recompile everything and risk version conflict; I had started on the next set of changes, of course.

So there's a lesson here, I think.  Although it is not the most efficient coding technique in the world, there is ample reason to not remove a method that you think is unused, especially if you do not understand the total impact of a change.  Let it sit there, all it is hurting is a tiny amount of overhead and some compile time.  This time it really saved my bacon!  Next time it will probably bite me.

Disagree?  Send me your exeriences in comments!

Friday, March 09, 2007 1:50:44 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.NET | AJAX | Programming | Work
# Thursday, March 01, 2007
I Believe...  that all database connections should be opened immediately before using them and closed immediately afterwards.
 
I Believe...  that if you are going to create a data layer, and you should, and you also create a data access layer, and you should, that the connection.open method be put in the lowest level and handled as abstractly as possible.  Yes the connection.close should be called before returning results.
 
I Believe...  that if you open the connection to the database in a method and pass that connection as a variable to another object, you should be shot.
 
I Believe...  that if you open the connection to the database in a method and pass it as a variable to another object, and forget to close said connection, you should be stabbed.
 
I Believe...  that if you open the connection to the database in a method and pass it as a variable to another object, and store the open connection in an ASP.NET session variable, you should be stabbed in the eye.  Twice.  With a spoon.
 
I Believe...  that if you store the results of a large query in ASP.NET session so you can page it back to the user, they haven't devised a painful enough punishment for you yet.
 
 
With special thanks to Blue Collar TV for the "I Believe..." concept.
Thursday, March 01, 2007 6:27:35 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.NET | Programming | Rant
# Friday, December 01, 2006

Inheritance is a good thing.  It offers a great way to simplify coding through rollup of repetitive tasks and common attributes.  It is one reason why OOP is superior to most other programming methods.  It's a beautiful thing.

It also offers great job security.  Nothing endears your successor more than trying to figure out properties that are inherited 5 levels up in the abstraction with NO commenting or clue where to look.  And don't even get me started on N-Tier programming when N > 5!  Solutions get a bit unwieldy with 8+ projects attached.

Friday, December 01, 2006 10:24:33 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
.NET | Programming | Work
# Wednesday, November 22, 2006

When you are looking at someone else's code, at what point can you definitively know it is bad code?  I'm sure everyone has their metrics.  Here's mine and so simple too:

Server Timeouts

Yep, real simple.  Here's the thing:  Nothing else, in my mind, shows a greater lack of understanding of the basic architecture of a system than poorly set timeouts.  For instance.  while not a bad idea to adjust the timeout of the SQL connection to fit what you are doing, setting it to 1200 means you don't realize that it means seconds and you just told your application to wait 20 minutes before doing any damage control.  I don't know about you, but ANY application that makes me wait 20 minutes for anything (without showing me real progress) is broken; I am impatient after 20 seconds!  Another example:  setting an ASP.NET app to use a session timeout of 300 minutes means you don't care about your server at all.  Why not store user specific information (full DATASETS!) in memory for 5 hours after the user has left the page.  5 hours!

These are real examples of code I am working on today.  I don't care how elegant your architecture is, Server Timeout abuse has always been a very simple indicator of developer incompetance.  Oh, and it seems to be in direct proportion of scale too.  I have actually seen an ASP session set to 3000000.  Yes 3 MILLION minutes.  That is 50,000 hours.  5 years, 8 months, 14 days, 13+ hours.  Yeah, that'll work.  I was not well loved because I wouldn't allow crap like that to run on my servers.

BTW, 3M minutes was by the same coder who thought LastName is a good primary key on a DB.  And when that didn't work, how about a composite key on LastName, FirstName.  Yep, World Class programmer.

Wednesday, November 22, 2006 3:03:20 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Programming | Rant
# Tuesday, August 29, 2006

Jeff Atwood of Coding Horror, one of my favorite blogs, recently posted his list of Programmer's Bill of Rights.  While I completely agree with his enumeration, I think he overstates things a bit.  The list, editing out the links, is below:

    1. Every programmer shall have two monitors
    2. Every programmer shall have a fast PC
    3. Every programmer shall have their choice of mouse and keyboard
    4. Every programmer shall have a comfortable chair
    5. Every programmer shall have a fast internet connection
    6. Every programmer shall have quiet working conditions

I would add to that the ability to alter or modify my workstation in order to make it more productive to my style of programming.  Not trash the system or make if vulnerable to exploits, of course; but to allow me to load any little utility that I need to make coding easier, faster, or cooler.  I will get into some of these utilities in a later post.

I don't think it's our right to have these things, but the employers obligation to provide them.  Follow me here for moment:  It is my duty to do the best coding I can do given the tools I have.  That includes clear requirements, necessary hardware/software, and decent working conditions.  However, if my employer wants to get the greatest amount of productivity out of me, the above conditions should be met.  If they wish to pay me for substandard conditions, they should expect substandard output.

As GC says, If you go out and hire the greatest distance hauler you can find in order to guarantee the delivery of goods between LA and NY, you don't give him a pickup truck to do it with.

I am fortunate; after six years, I finally have a decent system:

  • A 21" Viewsonic Gfx monitor with a 17" Viewsonic sidekick
  • Dual CPU 3.4GHz Xeons with 2GB RAM
  • Crap keyboard, but I bought me a MS Wireless Laser 5000 mouse
  • Grabbed this comfy chair my first week and never let it go
  • Stupid fast Internet (OC style)
  • Could be quieter, but has been much worse.

So I am pumping out some great code.  At least I am not wasting any significant amount of time trying to coax my system into doing what it's supposed to be doing.

Tuesday, August 29, 2006 4:00:41 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Programming
<%--
--%>
Statistics
Total Posts: 186
This Year: 0
This Month: 0
This Week: 0
Comments: 72
Locations of visitors to this page
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Frank W Hagen
Sign In
All Content © 2010, Frank W Hagen
Custom DasBlog theme based on 'Business' by Christoph De Baene