Friday, October 28, 2005

 

Charles Petzold is no novice programmer.  Nor is he one of those developers who never actually writes useful code.  He's a published windows forms development author who knows the technologies and from whence they derived...

This article entertains the idea that the wonderful things that visual studio does for us makes us less capable programmers. 

interesting...

I think, although I could be wrong, that this article was half satirical.

In complaining about the behavior of visual studio and what it forces a developer to do, he pointed out what sorts of things it does for us: validates spelling and references, stubs out boilerplate, repetative code, provides inspection into available libraries and associated documentation, etc.  I'm just scratching the surface. 

Whose got vs 2005?  Holy crap!  Refactor - nice!  Generate tests.  wow!  Class diagram - YES! 

I've written several utilities to do primitive things that I did over, and over, and over, ad naseum...    For example, when authoring entity classes, I always create private or protected member variables to hold state and public accessors to provide an external interface.  I have gotten in the habit of using the public property from internal methods except, occassionally, in the constructor.  Early on, I usually don't have much logic to include in the property.  Later on, however, I often find I need to set a dirty flag or include some other logic in the setting of a property.  Therefore, everytime I expose a field as public, even for simple entities, I  eventually have to replace the public field with a property and update any references and spend a non-trivial amount of time refactoring the access to that field.  So I wrote a utility that parses my c# file.  It finds all public fields using a regex and replaces the variable name with a PASCAL cased, protected field, prefixed with an underscore.  It then creates a public property of the same type having the fileds former name, and maps the property value to the new protected variable.  Now I can create my classes with public fields where I want properties and private or protected where I don't.  When I am satisfied with the structure, I execute said utility and, viola, I have what I prefer for my class file.  It saves me a significant amount of time when developing large sets of classes. Visual Studio 2005 "re-factor - encapsulate field" - freakin' outstanding. 

So I don't really think visual studio makes me less of a developer.  I can, and have, done much of what it does for me.  If I had to develop in notepad and compile with csc.exe, it would be a slow but successful endeavor.

I do, however, understand his point.

If I am on a machine without visual studio or an internet connection and someone asked me to write a windows forms appliication that says, "hello world" with nothing but the command line c sharp compiler, or, even more challenging, java, it would take me all day. The speed of my development would be directly proportional to the speed of my internet connection.  No internet connection?  It'd be like sawing through a redwood with a butter knife.  It is physically possible...  If I had to do that often, I'd go to the book store, get a good reference book, and eventually, I'd be very proficient.  I'd wow and amazed people with my notepad skills and they'd say, "he must really know what he's doing because he doesn't use intellisense."  They'd scratch their heads when it wouldn't compile because it would be unfamiliar and foreign and the feedback wouldn't be there.  When it did compile and run they'd wonder how I learned how to do all that really deep, low level stuff.  I'd be a super-guru.  I'd be the notepad man.  When I first learned how to program, I didn't have a computer.  That didn't go so well. I had a C++ book and a macintosh at work that I'd try to experimnet on about once a week.  Then I got fired from that job and I had nothing but the book.  So I'd do the exercises on notepaper and manually work through the logic.  One quarter through the book, about the time I hit the #include definitions and advanced libraries, the notepaper  approach broke down.  I really needed notepad.   So I enrolled in a programming class gauranteed to get me head first into the programming industry.  I studied my ass off and stayed late into the night using the school's computers.  I went straight from notepaper  to Visual Basic IDE and SQL 7.0 enterprise manager.  I learned to develop databases diagram first.  I LOVE visual studio and all it does for me.  I don't even mind the things it makes me do, although I probably don't even know what those things might be. Sometimes I think I want to learn Ruby or Lisp.  I usually get as far as opening notepad and reading an article but then I desperately miss VS. Most of all, I get an idea and think, "I could do this in five minutes in Visual Studio" and I'm back on the crack. 

So, no, I don't believe Visual Studio rots the mind.  I think it enables the mind to produce efficiently.  I have yet to cross something that I cannot  do in Visual Studi using C#.  The really slick things usually end up as part of the next Visual Studio or framework release.  Evolution will eventually make the being unaware of the individual parts.  I don't know how to make my stomach digest food.  Why would I learn all about that when I can just eat?  ..and it happens.  I can focus on making tasty creations.  If something goes wrong, I have a doctor in the family, actually, a few of them.  I'd rather focus on writing and designing useful applications of software, not the low level details of the software language...  Its all virtual anyway!  It all boils down to IL.  Should I learn IL?  hell no...  Use the tools.  Use the.  Swallow the pill.  Drink the Koolaid. 

 

10/28/2005 3:39:54 PM (GMT Standard Time, UTC+00:00)  #    Comments [3]  |  Trackback
Monday, October 24, 2005

First I'll get to the point, then I'll elaborate.  When designing something for broad consumption, start with an example of a simple implementation and work backwards.  Imploy a test-driven-development approach to your interface and you might avoid several mistaken paths...

 

And to give credit to the source of the advice:

 

CHRIS ANDERSON Each developer has his or her own methodology,

and although there isn’t anything fundamentally wrong with using other

modeling approaches, the problem generally is the output. Starting by writing

the code you want a developer to write is almost always the best

approach—think of it as a form of test-driven development. You write the

perfect code, then work backwards to figure out the object model that you

would want.

 

 ...and now more fluff!  Mostly, this is stream of consciousness but perhaps someone will have something to say or may just find inspiration!

 

For those who aren't privy, I am now a fulltime employee of HPCi.  The reason for hanging up the independent hat and accepting the shackles of fulltime employment is that we mutually want to allow me to have more responsiblity and involvement in higher level deceisions and direction.  Basically, I am incresing my architecture role within the company. 

 

That being said, my involvement in code should migrate upwards such that many of my deliverables are used across the organization.  Sometimes my deliverables are nothing more than design and sometimes, merely suggestions. 

One complexity I am trying to resolve is a continous dependency built into our products on the underlying search technology used.  This goes beyond a traditional Oracle vs. SQL Server agility and the abstraction of data interaction from the business logic and presentation tier.  We use a web-based search product that handles all the details of denormalization in a consistent manner.  It is great at some things, really great.  At other things, like relational data, not so good.  The websites that use this product call directly to the tool's library API to execute searches.  The result of which is woven all the way up to the presentation code so that changing the search mechanism would require extensive modification across all tiers.  What tiers?  exactly!  More importantly, to accomplish otherwise simple things, we often have to write complex logic against the data to shoe-horn in functionality that isn't natively supported.  To further muddy the waters, controls that live on a page are loaded dynmically in an IBuySpy portal sort of way so they are not aware of each other and the page is completely divorced from any specific functionality such as searching.  There are many other reasons why I want to create a proxy class that can handle all this complexity and provide a simple, consistent interface for searches.  My goal is that the synchronization of multiple searches, plus the complexity of search manipulation, could be encapsulated in addition to allow the searching engine and its datastore to be swapped out where the class that consumes the search would not need to change (unless it relied on the internals of the search product, which I also want to expose).

 

My first iteration preceded reading the blog-post-subject-suggestion (write client pice first).  I started a two way eventing model that would broadcast a search intention, via an existing page event model, passing a delegate to a synchonization method, which would then wire the control to a search execution control.  The search execution control would send its search exectution intention through the same eventing system and the controls interested in .  The result is that all controls would then be wired to either execute a search or receive a search.  It worked but it was a mess.  It was immensely complicated and not easy to communicate or document.  scratch that one...

 

I went through several modifications before I finally realized that developers create objects and execute methods and asking them to do much else is instructing them, "please don't use this, its too complicated."  All this eventing and delegate nonesense needs to taken off the developers' plate.  I implemented a singleton search executor and a search manager class that orchestrates the execution and synchronization of the search.  When I was finished, it was much simpler but I was still passing back the very propriatary search results class to the client.  It was still impossible to get the search from another datastore and pass it back through this framework.  

 

That's when I read this short tip and the light bulb lit like the warm glow of a 12AX7 on an old Fendar Twin. 

 

I deleted all the code in the display control that passes the selected criteria to the search manager with the ideal world.  It immediately identified that I not only needed a search result object that was not directly tied to a search tool or data store but I needed a criteria object that could be sub classed for each implementation. 

 

Since the selection of criteria values and the search itself cannot easily be seperated, it is unrealistic to think I could create a completely generic search object hierarchy without completely rewriting the entire website.  However, it is realistic to think I might create a WebsiteCriteria class that internally creates a search specific criteria class and passes the details to the search tool.  Then the search result can be wrapped in a generic search result container.  At this time, the front end requires some of the details of the proprietary search as the listings that are returned are all dependent on the search tool that generate the results.  Therefore, I expose the underlying deatils for those that need them.  Eventually, I'd like to move more and more into the abstraction layer so tat a listing is a listing no matter where it came from.  I think I'm on the right track.  Regardless, the code to use this new structure is incredibly simple.  Create a search manager object.  If you care about synchronizing with other searches, pass a synchronization delegate to the constructor.  Call the execute method, passing a criteria object as your selections.  You will get a search result back.  Any onther class interested in synchronizing will be notified by the single search executor.  Its getting there.  Its much better then every control executing the same search and depending on page events and session for search details.  Baby steps.

 

 

 

 

10/24/2005 6:32:47 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]  |  Trackback

Theme design by Jelle Druyts

Pick a theme: