Refactor! Pro and SA1503

I’m busy as blood-engorged zombie locusts tearing into each other until one standsatop the heap like Jet Li in The One. I’ve been fixing my code files one by one toconform to the rules in StyleCop.Luckily I have Refactor! Pro from Developer Express.

StyleCop rule SA1503 is that “The body of the if statement must be wrapped in openingand closing curly brackets. The following is a no-no:


if (isTrue)doAnAction();

Instead, write:


if (isTrue){ doAnAction(); }

or:

if (isTrue){ doAnAction(); }

Is it anal? Sure. But that’s what code style is all about. Making your code look thesame so that your eye flows across it smoothly and quickly. Meaning should be standard.Beating a different drum doesn’t mean you can’t keep in lock-step. At least with yourself.

The cool part is that Refactor! Pro makes this a three-keypress action. Place thecursor right after the if statement and before the “doAnAction”. Press the R!P key.Press Enter.

You just used the “Add Block Delimiters” action, and bam! Perfect code.

Now if I just need to find (or create) the actions to put proper white space aftermy code blocks, use “this.” before accessing an field, and alphabetize my “using”statements. I think it’s too much to ask that an inexpensive developer tool get ridof the zombie locusts.

What’s on my development laptop?

Fingerprints. A little peanut sauce. A Cthulu ’08 sticker (why vote for the LesserEvil?).

Oh yeah. I also have these program which are little anthropomorphized series of datawhich fight each other to death on a giant battlefield inside my computer in orderto keep Norton Antivirus from controlling my internet connection. I’ve upgraded mymain computers to Vista x64 (UAC OFF!), mainly because I like pain. Now that I’vebeen hostage to Vista for a while, I must say this about my captor: it’s not as asbad as people say. As long as you’ve got a steaming hot lap warmer with 4gb of RAM,it performs just fine and with UAC off, it’s not really annoying. Second….I don’tknow what MS was thinking with this thing. It’s got exactly ONE feature that I givea sh– about as a user. For all of the pain of a new operating system and Microsoft’scompulsion to MOVE EVERYTHING AROUND SOMEWHERE ELSE,Vista doesn’t really offer much to give you a better user experience. I like the command/search/launcherbox in the Start Menu. That’s it. That’s the only reason I don’t just run back togood old XP. One feature.

Anyways. We were talking about tools….

Development Tools

  • Notepad++: MonolithicIDEs and design surfaces and friendly talking A.I.s notwithstanding, coding is stillabout text. Notepad++ is a solid replacement for the pathetic text editor dumped inthe O.S. by ‘One Feature’ Vista. Syntax highlighting. Regex search and replace. Tabs.If I’m not in Visual Studio, I’m editing text in Notepad++.
  • TortoiseSVN: All of the ‘new developer’resources I read seem to beg their readers to use source control. I was using sourcecontrol before I started working in code. Having a system that backs up your information…andit’s changes…is magic. The amount of pain saved for very light cost is amazing.TortoiseSVN is a windows UI for the Subversion source control system. I use hostedSVN at Beanstalk even though it’s simple to run your own repository. A couple of bucksa month is a bargain value for not worrying about the safety of your data.
  • CodeRushand Refactor Pro!: Currently I use CodeRush primarily for it’s templating engine.I think this is because I’m a bit too lazy to figure out a code generator. I may needto give that a little bit of thought. I like MyGeneration,but it’s CSLA templates seemed to be inadequate for my needs…perhaps I haven’t paidthe right attention. Anyways. CodeRush is like Code Snippets on Spinach! At the flickof your fingers it creates classes and properties and all of the boilerplate codethat we seem to write constantly in our development processes.  Writing in ahigh-ceremony language like C# can be a pain. CodeRush takes the pain away. And itdoes a million other things as well. CodeRush will amaze you in your first 10 minutes.And then you’ll still be learning amazing new things months later.
  • Nullsoft Installer System: I starteddeploying my projects with the MSI project built into Visual Studio. Maybe it wastoo wizardy. Maybe I just never learned how it worked well enough. The fault was probablymine. However, what I ended up with was installers that wouldn’t upgrade to new versions,that were overly complex, and that I had to manually work with in deploying. NSISis an installer from a simpler day. It zips all the files together and then copiesthem to where they belong on the users system. Some simple scripts define the filesto include, where to put them, and where to put shortcuts. Upgrading is simply aboutrunning a newer version installer. Building is as simple as running a script. NSISmade my deployments simple and understandable.
  • NUnit: Test Driven Development seemsto be talked about everywhere these days. It’s an awesome methodology for making bettercode. I don’t do that. TDD means writing well architected code from scratch, all thetime. I’m not sure what well-architected code is yet. I keep learning new things,and I’m coming along, but starting with perfection is a bit hard for now. However,Test-Enabled Development? I can see if the things I’m writing without firing up aGUI or IIS. I can make changes and check for breakage. I can refactor. And…well…makingtests makes me thing about how my code could be better designed. Occasionally I doa little Test Refactored Development. That just makes me a better coder.
  • Telerik RadControls: The basic .NET controlsleave your application looking so generic, and while you can develop serious functionality,it’s a lot of work. Telerik’s UI controls make your product look beautiful, and mostadvanced functionality is just a matter of doing a good data binding. Grab your CSLA.NET objects, and you’re riding a giant rocket mounted to a railway sled! Exhilarating. 
  • Mailbee .NET: I have barely used these, butI bought them to create a IMAP automation tool, and the result was quick, easy, andreliable. If your application needs to interact with email, I recommend these components.They aren’t very expensive, and the developer keeps updating them (updates are freefor the folk who have paid).
  • StyleCop: Code which iswritten to a formatting standard is easier to read, faster to understand, and saferto change. I’m not particularly religious about the Code Style you choose, but youshould have one. Style Cop takes the uncertainty out of the process, since it hasa ‘OneMicrosoft Way‘ standard style for you to use, and it will check your code foryou. Start checking your code with it, and your code will look better for the process.Plus it gives you some cool busywork to do, when you’re staring blankly at your screenafter the boss yells at you for showing up late to work after you chase that rabbitaround all night.

That’s my list for now. There’s more stuff added  to it all the time. The focusof the next installment will be selecting the proper athame and grimoire for writinga daemon. Or maybe something having to do with cake.

The CSLA of the Maltese Falcon

She sat down in my office, batting those beautiful blue eyes behind little girl glasses.Her only makeup seemed to be a bit of lip gloss that made her thin expressive lipsshine as if moist and waiting. “Rockford Lhotka isdead, and I need you to find out who killed him!” she said, a bit breathlessly, fingeringthe Microsoft logo on the form-hugging knit polo shirt she wore over her waifish figure.Her mousy hair and shy expression made clear she was the geek girl they’d all havea crush on, come the next product launch. I took the case, accepting a free copy ofVista Ultimate as a retainer.

My old buddy Lt. Hamilton, down at the eastern precinct was no help at all. He toldme that Rocky Lhotka, wrote the code and the documentation for CSLA. “What’s CLSA?”I asked.  “The primary goal of CSLA.NET is to enable you to build a rich, powerful, and flexible business layer foryour application.” Man. The L.T. can be a dick when he’s hung over. Talk English man!I took off, rather than listen to more marketing-speak from that hack.

Luckily, Maggie, who works in the stacks down at county record-keeping knew more.“What does CSLA .NET do? What doesn’t it do, honey.”

“Make it simple for me?” I asked.

“Pay attention, and I’ll boil it down: CSLA Data Binds beautifully!I’ve worked with all sorts of objects that I could supposedly bind to my .NET userinterfaces. nHibernate objects. Castle ActiveRecord objects.Generic Lists of things. On and on. What did I get? Bugs and wonky stuff that didn’twork. Bind that puppy to a DataTable and you’re listening to big band jazz, but bindto objects and you’re singing the blues. Even the new LinqDataSource only really workswith LINQ to SQL, not the other flavors.”

“So you can’t bind your UI to objects?”

“Try it with a CSLA business object. It’s like butter. These objects work so well,so completely, that you barely need to write any more code”

“But you said it did more than that?”

“Once you have that foundation, all of the other magic that the framework does isjust icing on the cake. Thick layers of fabulous icing. The fabulous business objectsthat link automatically with your UI layer also have built-in facilities for datavalidation, authorization, and permissions. There’s a whole stack of automatic undo functionalitythat you can have almost for free.”

“Wow. That’s something. You want a drink?”

“On top of all that, is an Active Record pattern implementation and ‘data portal’which allow you to use almost any remoting technology to link between applicationlayers. The code that runs on the server and that which runs on the client is exactlythe same. Your objects move magically from one to the other. Ol’ Mr. Lhotka calledthese ‘mobile objects.’”

“Seriously. I need to go and get a beer. Maybe read the sports section.”

“Coming in the next version are better LINQ query support, data access layer standardizationwith externalized object factories, and async data access. Also coming is CSLA Light,which provides mobile objects to your Silverlight Apps. I’m excited to start playingwith these feature…we’re just waiting for the manual.”

And the light dawned. Rocky hadn’t finished the manual. A tell-all confessional likethat could keep people from buying MSDN magazine and certification manuals for months!The mousy little booth babe had killed poor Rocky, and then had the nerve to hireme to find the killer! I ran out of County Records, raced round the corner, and Iheard thunder. Light flashed behind my eyes. My knees buckled. What a sap I was!

Tune in next week when you’ll hear Rocky say, “That wasn’t me, I used a mocking framework.”

Two Factor Authentication with your Cellular Phone

The whole two-factor authentication system is a fantastic idea. However the idea ofgiving a new device to every person who needs to login to my site? Well, that justseems expensive. And given the fact that I’ve thrown out all of my grocery membershipcards and refuse to shop at those places because it makes my wallet too heavy…Idoubt that people really want to carry that stuff around.

The solution? Use the device we all have with us: our cellular phone. PhoneFactor hasa platform that does just that. It’s also free to use for an application of your choice.You can set it up for RDP, VPN, or program your web app against it. When your userslog in, they get a call on their cell phone and have to press #. If you want to tryit out without setting anything up, try getting a free MyOpenId andusing PhoneFactor as your authentication mechanism.

Personally, I still think the barrier to entry is too high, what with configurationand licensing and user training and edge cases where it doesn’t work…but hopefullygood technology options like this will push out the absurd technology options likeRSA keys and press the pricing down to the point where it really is everywhere andeveryone accessable. Then if we could just get Microsoft and Apple to build it intothe OS so that we really can authorize everywhere using easy tools from any provider.

Installing Visual Studio 2005 on Vista 64

Wouldn’t you know it? I have my shiny new Vista machine all built and hopping alonghappily, and I need to do a quick recompile of one of my old VS2005 projects. Luckilymy 2005 disc is right here. This should be easy, right?

Things you’ll need:

  1. Visual Studio 2005 install media and key.
  2. 30g powdered aluminum.
  3. VisualStudio Team Sweet 2005 SP1 (KB 928957). You might think you need an x64 versionof this…but you don’t so don’t worry about it.
  4. 80g iron oxide powder.
  5. VisualStudio 2005 SP1 Update for Windows Vista (KB 929470). Again you only need thex86 version.
  6. A length of magnesium ribbon.
  7. A brazing torch or other high-heat fire producer.

The process:

  1. Insert the VS2005 disc, and start up the setup. Enter your keys and the like. Getthe thing started.
  2. This is going to take a while, so if you haven’t gotten the other ingredients listed,now’s the time to get on eBay and order some up.
  3. At certain points during the install, Vista and the setup will complain that it’snot compatible with Vista and ask you to confirm that you should run certain command.Go ahead and accept/allow all those warnings.
  4. Run the installation to completion.
  5. Execute the Visual Studio SP1 installer.
  6. By this time, the packages will have arrived from eBay, unless you used UPS, in whichcase, there will be a sticker on your door and the packages will be available until1pm at the local depot. Go pick them up.
  7. When you get back the installer should be done.
  8. Run the Update for Vista.
  9. While this is working, mix the aluminum with the iron oxide. They aren’t reactiveat room temperatures, so you really don’t need any special apparatus, but I alwaysrecommend using a filter mask and eye protection when working with powdered chemicals.The mix is unbalanced by weight, but should be about even by volume. Mix them togetherin a bowl or styrofoam cup until very even. If you’d like, you can then mix the resultingmixture 4:1 with playdoh (more thermite than dough) for portability, or just leaveit in the cup.
  10. Once that installer is done, you should be FINALLY able to run Visual Studio.
  11. Place the magnesium ribbon into the cup of thermite, and tape over the top to preventspills. Leave the cup on top of your computer, with the torch handy. I find that havinginstant flaming death hanging over my machine’s head keeps the poor thing in a stateof terror. It prevents so many of those lazy blue screens and has really improvedmy Vista file copy performance. (I think it’s afraid to run that darned search indexernow.)

[youtube http://www.youtube.com/watch?v=62WRdfyzXXc&hl=en&fs=1]

Recursive Erudition

Programmingshould be more than just defending the world from aliens, trying to score with hotbabes, and killing all thegrandmothers in the nursing home. Programming, coding, problem solving, creating,and making the world better are all united concepts. When you scratch a place in theground for a plant to grow, or change the pH in your fish tank, or tell your childrenthat cows are called ‘horses’ so that they confuse the other kids in school when theyask for some horse milk with their lunch…when you do those things, you’re programming. Recursive erudition isa log of adventures in understanding what problems can be solved, and what riddlescan be expressed. It exists to teach and, by so doing, to learn. It exists to learnand, by so doing, to teach.

This weblog will contain explanations of how to perform various tasks with code. Iwill discuss design principles, best practices, and those evil little programmingmind viruses that spawn from head to head across the wire like something from a SandraBullock movie. There will be reviews of tools and services that I find useful. I willaggregate the more interesting articles I find around the web and provide links tothe ones I’d like to remember or share, or I may just copy a bunch of links from myRSS feed so that it looks like I’m posting (mock me if I do this). Occasionally, therewill be something funny, newsworthy, or personal…but I share those things elsewhere,so that should be rare. This weblog will mainly contain boring technical readoutsfor my world-demolishing super-weapons.

I expect to receive four benefits from writing and sharing here:

  1. A greater depth of learning: it takes a greater understanding to teach something thanit does to learn it. I will clarify my understanding of what I learn by sharing thetechniques and philosophies from the giant fire hose in my pants called The Internet.(Did you know they make those hoses out of tape? Freaky.)
  2. An opportunity to give back: there are so many folk out there who have helped me learnwhat I know so far. Their efforts have made it easier for me to get started in a demandingfield. I’d like to give something back–and I don’t just mean fart jokes. I doubtwhat I write here will be groundbreaking, or even new. However, so many of the fundamentalshave been covered completely by those who have gone before…and they’ve moved on.A rehash of years-old technology with a viewpoint from the present day may be a worthwhilerefresh of the tutorials that taught me what I know.
  3. A repository of documentation: I’m learning things faster than I can remember them.I need a place to look up the things I’ve learned and accomplished already. I willwake up every morning, like Drew Barrymore, and read my blog. I will find out thatmy parents were really hamsters, and that I married a spatula after 100 dates anda good spanking. But most of all, I won’t forget how to use a regular expression todetect valid email addresses. 
  4. Relaxation: David Allen has taught the worldthat things in your head give you stress. I want to let those nasty little Thetansout of my head. Once it’s written here, I can forget about it in safety. Writing isalso a great creative outlet, and that’s a piece of peace as well.

We’ve almost reached the top of the hour, here, so it’s time for our human interestpiece. Since I’m the only human here, I guess you’ll just have to take an interestin me. My name is Josh Rivers. I’m 35, have been married for just over a year, hopeto have my first son–or at least a lizard–in the next year, and have worked in thecomputer field for more than a decade. Half of my career has been as an independentbusiness owner and contractor. I’ve been coding since I was 10 (if-you-call-writing-password-programs-for-my-computers-using-my-first-name-as-a-password-because-it-was-cool-in-War-Games-to-keep-the-girls-from-getting-into-my-computer-programming),but my real professional focus started about 2 years ago when I started developingweb and Windows Forms applications for my I.T. Services clients. Since then, I’vegone through several memetic confusions of explosive learning, and I’ve got severalmore building on the horizon. There is so much to learn, and I love every moment ofit.

This site was made with dasBlog, ColorScheme Generator 2, and some notes from SteveTrefethen.