PITADEV
Curiosity killed the developer's project.

We All Laugh in the Same Language

Wednesday, 28 January 2009 15:09 by aj

As I've continued coding in VB.Net at my new(ish) job, the "WTF!!!" factor has reduced substantially, although I still do a lot of backtracking to insert Dim statements.  For the most part, I've realized I can do all the same stuff in VB that I did in C#, along with a couple of nice things like the great pile of VB snippets that ship with Visual Studio compared to the meager offerings for C#.  Don't get me wrong, I'd still rather be coding C#, but I've come to terms with the fact that they really are the same thing when it comes down to the CLR, and except for a few small differences, it's really just a matter of personal preference.

Or is it?

It's certainly not my personal preference, in this case.  So I guess it's enterprise preference.  But wait, who decides enterprise preference?  Someone obviously does, someone who probably makes a helluvalot more money than I do, and probably doesn't code any more if they ever wrote code in the first place.  What I've been wondering lately is this: if both VB and C# compile and run on the same .Net runtime, why do enterprises care which language its developers use to write .Net applications?  Just because I've been coding VB for the last three months doesn't mean that my C# skills have atrophied off like an unused extremity.  I can still read and write C#, and when I coded C# for a living ("enterprise standard" at my old job) I could still read and write VB.  Once folks understand the simple syntactic differences between the two, square brackets for arrays, angle brackets for generic type identifiers, "Dim thing as type," Function and Sub, etc., it's really not hard at all to read and understand both.

The common answer I hear to this question is that the enterprise wants everyone coding in the same language to...

  1. Promote code reuse.
  2. Make it so that if department A happens to be on a team building exercise at the archery range and they all get impaled on crazy boomerang arrows, department B can "seamlessly" pick up where the dead folks left off.

 

Superficially, these reasons make a lot of sense.  Code is easier to share and recycle if it's all in the same language.  Joe Developer coding VB in the Wonky Department on the 12th floor can read Jane Developer's code, even though she works on entirely different stuff in the Hinky Department on the 3rd floor.  And that's good, because Jane wrote a really cool snippet for connecting to the company mainframe and screen-scraping something or other.  But wait...why does Joe even need to read Jane's code?  It seems to me that if Jane wrote that functionality in C#, she can simply bundle it up into an assembly, compile it, and offer it to Joe as a referenceable DLL. 

OMG! But that DLL was written in C#!

All Joe sees are the members of Jane's object after he references, and Visual Studio translates that to VB for him anyway. 

IntelliSense even formats the tooltips in VB

 

Joe doesn't even see "public string CSharpMethod(string inVal)."  Pretty nifty runtime conversion there, if you ask me.  Another example of the inherent quality built into the Visual Studio IDE.

Can somebody please tell me why I can't write my applications in C# even though my boss wrote applications in VB?

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Code Aphorism 2 - Ruined by VB

Thursday, 11 December 2008 19:41 by aj

William Wordsworth

I'm in the process of re-learning VB.Net.  I started with VB a long time ago, moved to C# with a career change, and now, due to another career change, am switching back.  I am unhappy about it, but am trying to keep an open mind.  Today was one of those days where my open mind slammed shut.

It was a situation similar to my first aphorism.  I had an array that I needed to get into a List<string>.  This time, however, the array was of an object provided as a return value from a method in a referenced API.  And the string I wanted to put in my List was a property of that return object, not that object itself.  Here's the long way:

Dim vendorAPI as new Vendor.API()
Dim things() as Vendor.API.Thing = vendorAPI.GiveMeThings()
List(Of String) stringsFromThings = new List(Of String)()
For i as Int32 = 0 to things.Length
   stringsFromThings.Add(things(i).StringField)
Next

I knew there had to be a cooler way to do this.  So I dinked around with it a bit, being rusty with VB and having never known these new tricks when I was writing in VB anyway, and couldn't figure it out.  With a little help from Kevin, I was able to Lambda-ize it in C#:

List<string> stringsFromThings = 
   things.ToList().ConvertAll(t => t.StringField);


Lovely, isn't it?  So I set about trying to do the same thing in VB, and so far this is the best I can come up with:

Dim stringsFromThings As List(Of String) = _
   things.ToList().ConvertAll(Of String)(Function(c _
      As Vendor.API.Thing) c.StringField)

After another day of cussing every time I tried to declare something as "Type varName" instead of the banner-of-VB "Dim varName as Type," I felt a little disgusted.  The main problem I have is that the VB compiler doesn't seem to have the ability to interpolate the type of "c," even though "c" has to be of type "Vendor.API.Thing."  And I'm still getting over the syntax thing, of course, but hopefully my open mind will open more.  If there's a better way, please tell me. I feel more like Wordsworth than I ever wanted to.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Aphorisms | Rants
Actions:   E-mail | del.icio.us | Permalink | Comments (2) | Comment RSSRSS comment feed

The Myth of OOTB (Part 1-The Rant)

Tuesday, 11 November 2008 18:42 by aj

Author/Editor Note: Originally, I thought this post would stand on its own. But after reading it again, it's become apparent to me that this is more of a rant than anything useful.  I will be writing follow ups in the future on the OOTB Compromise and vetting OOTB products.

A while ago, my cube-mate at work (we have double-cubes that make us feel all the more disrespected, even though I like my cube-mate) was forced to devote all of his time to building an application with an "out-of-the-box" piece of vendor software.  A few months earlier, he had received a bonus for "Technical Innovation," rewarding him for an excellent framework he had written to update the way we retrieved content from our ECM system. I called him "The Innovator."  Working on this new application, he became "OOTB" (pronounced ootbah).

Life was difficult for OOTB.  The project suffered from massive scope-creep, and the project manager had consistent problems communicating requirements, which often forced OOTB to have to redo pieces of the solution.  But the biggest obstacle was the vendor software itself.  Its intent was to provide a simple way to organize a Java-driven UI sitting on top of a business process workflow.  The workflow processes "cases," which are comprised of faxed documents for various transactions.  The basic concept is good: map UI controls to fields and decisions in the underlying workflow.  The implementation is sorely lacking.  Rather than a WYSIWYG editor, the vendor offers an MMC snap-in with loads of configuration requirements.  All of this configuration information is ultimately saved to a "metastore," which manifests in a convoluted Oracle database.  In order to make the workflow information available to the MMC snap-in you have to run an import utility; essentially an open file dialog with an "Import" button.  To operate on different deployment environments (Dev, Integration Testing, User Acceptance, Production), you have to manipulate (manually) a series of registry keys.  I can go on and on.  The bottom line is that the end-user functionality of this software is laughable.

OOTB attempted to put a good face on this, but kept running into fundamental design flaws, along with plenty of niggling little problems that drove him nuts.  He stopped shaving and started listening to old Slayer albums all the time.  He worked long hours attempting to configure user-interface functionality that would have taken him a fraction of the time in ASPX pages.  The client continued to throw curve balls, and OOTB kept having to stretch into more ridiculous positions to catch each wild pitch.  In the midst of it all, on his own time, he designed a beautiful framework that would have allowed the entire system to be coded and deployed in very little time, compared to the several-hour-long deployments he faced with every design change.  I'm pretty sure that the time he took to architect this framework kept him from killing someone.

Months have gone by, and through some magnificent mystery of corporate reorganization, I have become OOTB.  I inherited this project.  Having heard all of Original OOTB's complaints, I embarked on the project with a "C'mon, it can't be that bad" mentality.  Oh it was, and still is, that bad.  I've grown a big, bushy beard and spend my days listening to music that would make grandma cry.  But, instead of doing something productive, like design a framework for the way this thing should work, I'm writing this post instead.

As a developer, I can't count the number of times I've been asked by my higher-ups to look at a piece of software that is supposed to solve all of our problems with out-of-the-box functionality.  This amuses the hell out of me, since I'd be out of a job if these things actually lived up to their marketing.  Think of a world where software developers dance on the streets with organ-grinders, where monkeys wear business casual and spend their days pointing and clicking and dragging and dropping.  This will never happen, of course.  Not because all of us developers would get jobs making the OOTB software, but more because every time I've been asked to evaluate OOTB software, it never does everything we need it to do.  Some vendors promise improved functionality in future releases, others ignore you or look at you like you're crazy.  Some are smart enough to offer good APIs, others go so far as to sell you their source code.  No matter what, good software companies realize that they can never offer everybody everything they want, and good software companies realize that they must, somehow, give the users what they want.

The frustration for management-types that are trying to trim their budget fat is that they don't understand why we need all of these developers around.  "Why can't we just buy some software and hire some hourly people to do this instead of paying x developers y salary?"  Developers are the first people they target.  We're socially awkward, expensive, demanding pains-in-the-company-ass, and it's very, very simple to see us as overhead.  Vendors market their software as magic programmer bullets, and with this viewpoint in mind, it's easy to see why management might be quick to sign the purchase agreement.

A good application development team understands that repeated tasks should be consolidated into reusable code.  This takes more time up front, but saves gobs of code in the long run.  When OOTB software is brought in, there's a pretty nasty honeymoon as well, what with installing, distributing, and learning to use the software.  In the end, a well-designed, custom-coded solution is going to serve the enterprise better 100% of the time, because it directly addresses the needs of the business.  The OOTB software may make it easier to set up 95% of a solution, but I tell you, that remaining 5% is going to slaughter your bottom line.  So, in the end, why do enterprises sink so much money and time into pushing square blocks through round holes?

Probably because OOTB stopped wearing deoderant.

Coming soon: The OOTB Compromise.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Dev Theory | Rants
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

[esc]1GAvi, the web, HTML, script, and content[esc]

Thursday, 11 September 2008 15:39 by kevin

(hint: á a vi keystroke sequence)

 Just a sort of random thought that's been brewing in the back of my mind for a while, and exacerbated by playing with the editor built into this blog: it's a bad thing that we need to sanitize user inputs to make sure they're not malicious HTML or script.  It's a bad thing that thousands of projects and millions of web developers have to even think about this.  It's an unconscionable drag on productivity.

Possible solutions:

1)  create a post-spammer, post-troll utopia where no one even wants to enter malicious text into the entry boxes.

2)  differentiate markup and code from content.

Considering the amount of work that's gone into the Web as we know it, #2's not a likely option, so we're stuck with #1.

Seriously,  I'm sure somebody could come up with a reason why this wouldn't work, or would be counterproductive -- it literally is something I just thought of -- but it seems to me there ought to be a better way. If it wasn't clear from the title, my model is vi. (For the uninitiated) it centers on a very basic idea: different modes for commands and content.  Typing "G" in text mode gives you the letter "G".  Hitting "G" in command mode brings you to the bottom of the file/buffer.  "4x" in command mode will delete the next 4 characters after your current cursor location.  There are many keystrokes that will put you into text mode, but only one (AFAIK) that will put you into command mode (ESC).

So, wouldn't it be nice if you could count on a "<script>SendInfoToEvilPerson(document.cookie)</script>" rendering as text content, and not executing as a script?  Should this really be so hard?  Discuss.

 Update: Ugh.  Tags: "Vi" and "Xss"?  (I typed in "vi,XSS")  Ugh.  I mean, I like case-insensitivity as much as the next guy, but saying that searching for "VI" should return a match with "vi" isn't the same as saying that any rendering of these terms is as good as any other (if you click the tags, you'll see that the URL has them in all lower case, which would honestly be much better than "proper case" for both of these terms).  Kind of weird, coming from a blogging tool by programmers, and probably mostly for programmers.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Dev Theory | Rants
Actions:   E-mail | del.icio.us | Permalink | Comments (2) | Comment RSSRSS comment feed

The CodePlex Learning Curve

Monday, 25 August 2008 14:47 by aj
 This morning I fired up Google Reader and was excited to see this post on DotNetKicks about a new "Image Generator" control in ASP.NET 3.5.  I do a fair amount of image manipulation for my current position, and displaying images to clients is always an issue.  Currently, we're using a Java viewer that works nicely on the client, once it's been finally loaded in the browser.  Unfortunately, the load time is prohibitive, what with a nearly 1.5 MB download, not to mention the time it takes for the JRE to fire up and load the plugin.  So I'm always on the lookout for new ways to display images in a browser.  This tool is advertised as a "speedy way of generating, transforming, caching images in ASP.net."  All right!  I've worked with several APIs that are available from various vendors, and though a couple of them have solutions that are quite good, a freely available tool would be great.  I hurried over to CodePlex and downloaded the assembly and examples.

One thing I always find strange about downloading stuff from CodePlex is that I often have trouble figuring out where to put it.  Like many developers, I'm sure, I have a huge directory tree packed with all of my code, which is organized to me, but would probably be impossible to dig through for anyone else.  After downloading, I attempted to drop the assembly into the GAC, but got the ubiquitous "Assembly <xxx> is required to be strongly named" error.  OK, then.  I settled on creating a "strongly named" folder in my code-maze, dropped the DLL into it, and created a website project to play around with it.  Then I remembered the sample projects, and happily using my new two-monitor setup at work (finally!!), I opened the example "SimpleGeneratedImage" website on one monitor and my test project on the other.  After jockeying the referenced assembly to get it pointed at the right file, I F5'd the example project and was a little startled to see this error:

Could not load file or assembly 'System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Hmmm, I don't see that reference anywhere.  Ah, there it is, in the web.config.  OK, what the hell is that guy?  As you can probably tell by now, I haven't had the time to keep up with the super-huge pink elephant sitting in the middle of the virtual ASP.NET room that is MVC.  So I plugged "System.Web.Abstractions" into a Google search and the first hit I get is Microsoft's page for ASP.NET MVC Preview 2.  Ah ha.  I have done a little poking around on the MVC framework, but always get interrupted with "real" work. I do know enough that CodePlex is probably a good place to start.  So I headed back over to CodePlex's ASP.NET section and found a download for ASP.NET MVC CodePlex Preview 4, which I figured would suffice, since 4 > 2.  Upon clicking the link for the application download and agreeing to the license, I watched Firefox download an .msi file.  Awesome!  An MSI!  Someone had the brilliant idea of creating a deployment project to simplify the integration for me, the lowly tool user!  I happily ran the MSI and watched the install, then switched back to my VS2008 IDE with the sample project loaded and rebuilt.  

Could not load file or assembly 'System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

What the hell?  Shouldn't the MSI have taken care of all of this?  Maybe I have the wrong MSI?  Wait, it didn't even ask me where to install itself.  I find the install folder in Program Files\Microsoft ASP.NET\ASP.NET MVC CodePlex Preview 4\Assemblies, and there's the elusive System.Web.Abstractions.dll.  I switch to view my GAC, assuming I'd find the files registered there.  Nope.  OK, then, I'll do it the old fashioned way.  I gacutil the three "System" DLL's, and they don't give me any "strong naming" issues and appear to register fine.  Except, I notice that the version on the System.Web.Abstractions assembly is "0.0.0.0."  Hmm, that's odd.  Must be a weird refresh thing.  I switch back to my IDE and rebuild.

Could not load file or assembly 'System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Son of a bitch!

Now, I know this isn't really a big deal, but it really burns my ass that these uber-developers can't take a few minutes and 1) let me know that there are prerequisites and 2) make an MSI file that actually does something.  This issue keeps coming up for me with the various plugins and toolkits I "install."  In a deadline-driven developing world, I do as much as I can to keep up with emerging patterns and practices.  But when I run into roadblocks that could be eradicated with some simple forethought by the developing team, it stifles my ability (and my desire) to use this stuff.  I understand that CodePlex is generally for open-source, bleeding edge code that might eventually get included in the framework, and hence isn't "polished."  But when did developers forget that their audience is probably going to like them a lot more if they make their stuff easy to integrate?

After complaining more to a friend, he made me feel really stupid by pointing out that I just needed to install .Net 3.5 SP1.  After this install, I was able to build everything just fine.  Of course, I haven't had the time to actually do anything with it.  So, lesson learned: When downloading and installing stuff from CodePlex, make sure the framework is the latest and greatest.  

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , ,
Categories:   Dev Info | Rants
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed