www.codinghillbilly.com   kyle.baley.org  Subscribe / Contact
 
 
 
 
LATEST POSTS
Sunday, April 29, 2007
The following is an offshoot of my recent Sony troubles. In summary, I bought a Bravia in Miami, shipped it to the Bahamas, had a technical problem and called tech support. The full version is sexier.

The inevitable customer satisfaction survey came the next day. I was pretty fair I think, commending the CSR on her politeness and troubleshooting skills while making it clear I still have a problem. But I had to take the survey twice. The first time, I received the following when I submitted it:

Astute readers will recognize Firefox's open dialogue and that Firefox is trying to open an ASPX page as an external file type. I retook the survey in Internet Explorer and everything went through fine. Tried a third time in Firefox and got the same dialogue.

Not quite sure what's happening but you'd better believe I opened that page in VS2005. It is attached below. You'll notice it's a .NET 1.0 or 1.1 page and that there isn't any actual server-side code in it. No technical reason for it to be an ASPX page although I'd probably make it one myself in the chance server-side code needs to be added to it later.

Also note that the page that launched this, the actual survey, is a plain old ASP page. Not sure why Firefox isn't able to open the page while IE is. If I had to guess, it would be because ASPX pages aren't registered properly at Sony in IIS and IE is being forgiving. Actually that doesn't sound right now that I think about it.

Regardless, it seems Sony's survey site doesn't support my version of Firefox. But here is the URL for the survey (with the EventID stripped) if you want to play around with it yourself.

And Sony really should invest in a default page for http://www.survey.sony.com.

** UPDATE **

After taking a look at the original survey page's HTML, it might be a .NET page, evidenced by the fact that the submit button has runat="server" attached to it.

CISC_Survey_2.aspx (5.51 KB)
Saturday, April 28, 2007

There's a good chance I'll lose some credibility with this post and that many people will file it under "stating the obvious". But a wise man once told me, "There aren't any stupid questions, are there?" so I'll proceed assuming someone has had the same trouble I did when I was learning mock objects, and more specifically, Rhino Mocks (or RhinoMocks or Rhino.Mocks depending on who you talk to).

My main conceptual stumbling block was in the use of the term "expectation". To explain, here is the introductory example from the Rhino Mocks documentation:

1  [Test]
2  public void SaveProjectAs_CanBeCanceled()
3  {
4    MockRepository mocks = new MocksRepository();
5    IProjectView projectView = (IProjectView)mocks.CreateMock(typeof(IProjectView));
6    Project prj = new Project("Example Project");
7    IProjectPresenter presenter = new ProjectPresenter(prj,projectView);
8    Expect.Call(projectView.Title).Return(prj.Name);
9    Expect.Call(projectView.Ask(question,answer)).Return(null);
10   mocks.ReplayAll();
11   Assert.IsFalse(presenter.SaveProjectAs());          
12   mocks.VerifyAll();
13 }

(Note: The example is a little dated due to Rhino Mocks' new CreateMock<T> but that wasn't the confusing part. Nor was the typo in line 4. Read on, reader, read on.)

I read/scanned the surrounding text several times trying to determine where the magic was happening. Focussing on line 8, here was my interpretation:

  • At some point during this test, there will be a call to projectView.Title. When that happens, I expect it's value to be identical to prj.Name. If it isn't, the test fails.

That is, I thought the expectation itself was doing the testing. Ya, ya, stop laughing. Sue me for assuming the English definition of "expect". (OK, so the expectation is on the .Call, not the .Return; I'm using Reverse Polish Notation, SOP in the Coding Hillbilly handbook.)

What line 8 *really* says is (to the best of my knowledge at least):

  • At some point during the test, I expect a call will be made to projectView.Title. When that happens, return prj.Name as its value. If the call isn't made, the test fails.

The good part is, realizing this made ReplayAll and VerifyAll that much less confusing particularly around the Replay State that the documentation assumes I know anything about.

It took a while for me to understand the Replay State. As far as I can tell, MockRepository.ReplayAll turns on a switch. When that switch is on, all calls to methods/properties on the mock objects are recorded and compared to the expectations (set before ReplayAll is called). Then when VerifyAll is called, the switch is turned off and we check to see if all expectations have been met.

Put another way:

  • Create your mock objects
  • Tell the mock framework which properties/methods you expect will be called. Along with this, you can specify which values you want to return when those methods/properties are called.
  • Start recording (see line 10). For all code executed after this, start comparing it with our expectations.
  • Execute code to be tested
  • Stop recording (see line 12). See which expectations have not been met and fail the test if any exist.

So again, the test will fail if you set an expectation that a method will be called and it isn't. I believe the reverse is true as well. That is, if a method is called and you *haven't* set an expectation on it, the test will fail also. But don't quote me on that.

I'm sure all of this is being explained much more clearly as I type this at the Calgary Code Camp at either James Kovacs' or Terry Thibodeau's sessions but I'm posting it anyway to justify the time spent ignoring my daughter.

Tuesday, April 24, 2007

Don't know if April brings out the esoteric nature in people or if it's just the tweaks I made to my blogroll but I've been reading a lot of "peripheral" posts lately. That is, posts related more to the art of software development rather than the science. A lot of that comes from the addition of Mike Griffiths' Leading Answers blog which is a gold mine of information though I don't mind admitting that more than a few of the posts are over my head. After reading his top five software risks, along with Justice Gray's career security and Tim Heuer's avoidance tools, like my clients often say, one might wonder if I write software at all.

I do so like reading these posts for the same reason I took a Computer Ethics course back in university in the middle of my courses on graphics and assembly: you can't ignore the people factor in computer science. And this is kind of an underlying theme in any post/essay/book that strays from bits and bytes.

But I also get a sense that these topics preach to the choir a little. For example, one should get the team more involved in scheduling to help mitigate schedule slippage. That may not necessarily be common sense but put yourself in the (highly unlikely) position of someone who is in charge of a software project and the schedule starts slipping. What would your natural reaction be? I'd like to think mine would be to get the team together and hash things out, even without reading this post. It seems like the natural thing to do, not a revolutionary shift in project management.

I get the sense that most of the people I respect and follow online would do something similar. Maybe that's just the type of person I am and maybe that's just the type of person I gravitate toward. Or maybe the business culture has evolved to the point where openness with your team/client/shareholders is the natural reaction.

Or maybe I'm being naive in assuming that the majority of people would do it this way. And that's very likely given my overly optimistic nature.

Let's talk about Justice's career security. I'm sure there were a lot of heads nodding knowingly while people read that post. But I'll bet that all those bobble-heads were very bright people. People that don't necessarily need to worry about where their next paycheque comes from even when the price of oil drops to $3. These are people that will always be in demand and their advice will reflect that.

But as I've often said, you can't save everybody. There exist in this world people who are not particularly good at what they do, who don't want to better themselves, and who are in it merely for the paycheque at the end of the week. The problem is: are these people reading posts claiming you should involve users more in the software development process? Because they are the ones that should be.

The point is, I'll read The Pragmatic Programmer or Beyond Code and agree with pretty much everything. And a lot of it (I hope) is stuff I would normally do. But what about the people who *should* be reading it?

Or maybe I'm missing the point. I was listening to a podcast whose name escapes me (statistically speaking, probably Hanselminutes or DotNetRocks) where the speaker said this stuff wasn't really groundbreaking but that now you could use it to justify your actions to someone who doesn't know any better. E.g. Of course I'm going to starting soliciting advice from my team members when my schedule starts to shift. But if my boss starts railing on me for burdening them with these "petty problems", now I can point to a number of resources saying this is the thing to do. Alas, I'm not a huge fan of having to justify myself in such a manner because it's pretty easy to shoot down with other, more traditional literature.

I've kind of arrived at a point that makes it sound like I think I'm better than other people and that I should try to fix them. So I'll close off by clicking Undo and saying that I think the point isn't necessarily to overhaul someone else's perspective but to tweak your own. I.E. Rather than upgrading JoeCranky to version 2.0, just work on CodingHillbilly 1.2.5. That's where the value comes in. Sure, you may think a lot of it is common sense. But not all of it. And very often, the act of "codifying" this fuzzy aspect of software development helps you become more conscious of what you're doing.

Bah! Too many maybes. I'm going to write a QuickSort.

Wednesday, April 18, 2007

Achtung, Internet service on Hillbilly Island has been as spotty as granny's back these days. So much so that I have, once again, followed in the footsteps of James Kovacs, this time by switching to GoDaddy for reasons similar to his own.

Based on his experience, I went directly with a virtual dedicated server but quickly decided that it was going to be insufficient for my needs and I'm now the proud owner of my own bouncing baby dedicated server.

The main (and upon reflection, only) downside to the virtual dedicated server was the physical limit of 10Gb for the disk space. That is unupgradeable. The only way to get more disk space is to get another virtual dedicated server. (Note: This is for a Windows 2003 server; the Linux packages could be upgraded to 50Gb.)

And since two virtual dedicated servers is almost the same price as a single dedicated server, it doesn't take an actuary to add up those numbers. Twice the price for over ten times the disk space. Assuming you need the disk space.

Among the reasons for increased disk space:

  • One of the apps currently hosted on the Bahamian server is a web-based document repository of almost 1Gb of word documents (oil & gas-based contracts and fiscal terms from around the world)
  • An app I'm building for a client/my dad that will host, among other things, AutoCAD files
  • My online music library, which currently stands at 12Gb alone

Yes, the last one isn't exactly mission critical but it helps my argument so I'm using it. In addition to these apps are the many other little web apps I have built and/or plan to build (including possibly turning my dad's app into a Sharepoint site).

Early impressions of GoDaddy are good to excellent. Startlingly prompt (i.e. almost no hold time, especially compared with my recent numerous calls to Expedia who are perpetually, "experiencing an unusually large number of calls"), friendly CSRs, timely service, and great prices. The only minor complaint I have is that the server I was provisioned had Windows Server 2003 installed but not service pack 2 or the .NET 2.0/3.0 runtimes.

Anyway, it's good to be back in civilization, if only virtually. As it is, I still haven't been able to get my old dasBlog site.config file or the log files moved from the cess pit that is Cable Bahamas yet. But to you, my faithful reader(s), who have been wandering Hillbilly-less these last three days, thank you for not forsaking me.

Saturday, April 14, 2007
Since none of you responded to the challenge implied at the end of my last post (the fact that it was made a mere four hours ago notwithstanding), I have foregone billable work in favour of seeing if I could do it myself.

When installed (instructions below), this will add a Class Library Wizard template to your C# project templates list. When selected, it brings up a small form asking for the name of the first class, then creates said class in a class library project.

Installation
It's not as smooth as it could be. In order to display a form, I needed to create an assembly that has to be installed in the GAC (or some other location in the Visual Studio folder but I don't remember where). And as far as I can tell, .vsi files won't install things to the GAC.

Here are the steps:
  • Run the .vsi file to install the project template. It won't work until the other file is installed in the GAC. You'll get a warning during the installation that it might not be safe. HEED THAT WARNI--er...I mean, it should be fine.
  • Install Suvius.ClassWizard.dll into the GAC: gacutil -I <path to assembly>
Issues
  • It should complain if you enter a blank class name but I forgot to test
  • Not sure what happens if you enter a name with illegal characters
  • It really should have a cancel button
  • I haven't tested this on a machine that is not my own
I wouldn't mind extending it so that it creates two projects: a class library and a test project. The test project would have a reference to NUnit and Rhino.Mocks and both projects would contain a class with the specified name although in the test project, it would have Test appended to the name. It would also be nice to be able to create the class using the ReSharper template just in case someone has modified it, rather than using a hard-coded, and very spartan, one.

There is much more that could be done and luckily, it ties in with the Tree Surgeon app that Bil Simser was nice enough to let me join so hopefully this little side project won't fall by the wayside as they are prone to do. (That will require CodePlex to fix their little server crash problem but I'm optimistic.)

Source code is available on request for the moment. I'll probably post it in the coming days when I rap about what it was like implementing the IWizard interface to build this sucker.

Suvius.ClassWizard.dll (20 KB)
ClassLibraryWizard.vsi (2.94 KB)
Saturday, April 14, 2007

One side effect of TDD seems to be a moderate to gargantuan increase in the number of projects in one's solution. And with almost half of those being Test projects, it was with no small amount of gratitude that I tracked down Steven Rockarts' post on creating a project template with references to NUnit and Rhino.Mocks built-in.

One of the things Steven did when creating his template is something that has become automatic for most of us. To wit, the first step in creating a class library is to delete Class1.

So after creating my project template (which by the way, required me to go to Tools | Customize, then the Commands tab, File menu to add the Export Template... menu item to the IDE first), I got to thinking that maybe I'd create my own Class Library template which doesn't include Class1.

But being a forgetful Hillbilly, I would inevitably forget to use my template the first couple of times and creating a class library would take longer as I'd have to go through the extra stages of deleting my new project, cursing, then creating a new one with my template.

Better to modify the master. Which on my machine, is located at: C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplatesCache\CSharp\Windows\1033\ClassLibrary.zip

Once there, I did the following:

  • Deleted class1.cs
  • Opened classlibrary.csproj in a text editor and deleted the <Compile> element that referenced Class1.cs in the last <ItemGroup> element
  • Opened csclasslibrary.vstemplate in a text editor and deleted the <ProjectItem> that referenced Class1.cs in the <Project> element at the bottom

Now my class libraries are created free of Class1.

In addition to this, I also went to C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplates\CSharp\Windows\1033 and made the same modifications to the contents of the ClassLibrary.zip file. I'm not 100% certain but I think this is necessary if you ever need to re-install the VS templates (using devenv.exe /installvstemplates), which I did have to do earlier today when my Web User Control template stopped appearing in my list.

In an even more ideal world, creating a class library would automatically prompt you for the name of your first class, doing nothing if you leave it blank. Haven't found a feature like that in ReSharper but I can't imagine this isn't possible in some third-party tool somewhere.

Friday, April 13, 2007

On the heels of Bil Simser's question, "What Gets You Up In the Morning?" (and I'm paraphrasing to tie in with this post), I'm wondering, "What Winds You Down At Night?" Do you hunker down with a good book? Toss on The Celtic Show and cuddle with Andy Donnelly? Do an inventory of your knife collection?

Recently, my evening wind-down has evolved into a semi-routine: sit out on the patio with a cup of tea and the missus while the young 'un frolics somewhere in the vicinity. Some days we'll watch TV in the background (usually HGTV or the Food network). We've gotten into the habit of reading before bed too, which is something I'm glad I've gotten back into, even if my current choice of book, Che, is taking me freakin' forever to finish (damn biographies and they're lack of skippable descriptions). And on nights where I don't feel so revolutionary, there are plenty of crossword puzzle books lying at arms length in any given room of my house.

Related question: What's your depressant of choice for getting to sleep at night? 'Cause you see, ever since undertaking my recent professional development rampage, my mind has been abuzz with new concepts and techniques at the end of the day. And when my mind latches on to an interesting puzzle, it's tough to drift off.

Usually this isn't such a bad thing. I do most of my best creative thinking at night. But the offspring has been off school the past two weeks and let's just say, it's thrown off my sleep patterns.

So lately, I've taken to a variation on counting sheep. Namely, I'll lie in bed with my eyes closed and start counting while picturing the numbers in my head. And my font of choice is whatever Windows XP uses to identify monitors in a multi-monitor environment. You know the one, the big 1 or 2 (or if you're Hanselman, 3 or 4) that appears when you click Identify. That's what goes through my head at night against an undistinguishable background as I go to sleep.

 Test-driven development, indeed.

Friday, April 13, 2007

I'm going to pretend you don't already know this but the Calgary Code Camp is a mere two weeks away and it looks like it will surpass last year's in every way except one. Namely, I won't be presenting or attending. Which is just as well. My taste in music hasn't improved any. (MAN, Norah Jones' new CD rocks, metaphorically speaking.)

Normally, a nine-hour plane ride with a three-hour layover in TO wouldn't be enough to keep me from a Bil Simser/John Bristowe tag-team and the one titled Meet the Monkey almost sealed the deal but a $10k shopping trip to Miami to furnish our new condo (which previously contained furniture that looked like Edith Head puked and that puke designed it) put a big kibosh on that little cross-continental jaunt.

So, dear reader(s), it is up to you to be my eyes and ears. I need you to get up close and personal with the presenters. I'm talking INTIMATE. I want to be able to smell the soy-based food products on James Kovacs' breath when you report back to me. I want to know what JP's stimulant of choice is before he goes on. I want to know if Tom Opgenorth can make it through his presentation without giggling whenever he says Mono.

The one with the best use of clandestine tactics gets a free tour of Anna Nicole's house.

Wednesday, April 11, 2007

Plethora of postings today. Could combine them but I'm trying to stick to the Single Responsibility Principle, at least in one small aspect of my life. Doesn't seem to work while I'm parenting the young 'un.

Have recently started working with Subversion. Out of necessity because I want to share code with someone and it's harder to share when you're in the Bahamas. (That generally applies to everything in the Bahamas, especially in the government.)

First thing I did when installing Subversion was to add TortoiseSVN and AnkhSVN to my tool list. Hillbillies aren't generally what you would call command line coders.

Like most side aspects of software development, I don't have a very strong opinion on source control. The only thing I want is for it not to get in my way. In that respect, I liked SourceSafe while still recognizing that it was the one piece of software that Microsoft actually *needed* to update in the last ten years. Having said that, I haven't had any horror stories that many, many others have and checking in/checking out was pretty seamless from Visual Studio.

Now comes Subversion where I am painfully aware of the source control because it's throwing errors all over the place. Well, probably not Subversion but certainly Tortoise and definitely Ankh. Errors like "the directory already exists" and "this is not a working copy of the directory". When it wasn't failing, it was creating folder structures I didn't want or adding support files to source control. (Don't get me started on ignore lists. Sometimes I want to ignore the bin directory, sometimes I don't.)

Granted, part of this is a shift from my comfort zone. I've managed to get to a point where I can create a Subversion repository and folder structure I like and not have one overwrite the other. I'm also able to mangle Ankh enough to add another project to my solution without polluting it with ReSharper files. But even today, I'm not able to Update... my solution with Ankh because it says the lib object already exists. "lib" is a folder that contains my third-party tools. It's not even part of my solution.

Having said that, when it's on, it's really on. Fast and clean be Subversion. Especially over HTTP. But it's not exactly an "install and go" type application.

And it's better than SourceSafe. I say that mostly to keep my inbox free of hate mail because in reality, I don't care if it is "better" or not. It's just source control. I just want it to work.

Wednesday, April 11, 2007

The Coding Hillbilly loves typing as you can tell from the fact that he types out "The Coding Hillbilly" rather than using the short form, "I". But that's neither here nor there, whatever that means.

Part of my recent PD has been going more in-depth with various N-based tools than I have in the past. The one I'm going to discuss is NCover because that's the one that has caused a problem interesting enough to talk about.

The problem occurred when trying to run NCover from a NAnt script. It would reach the end of the unit tests, then hang for approximately 120.58 seconds before failing. The issue was documented in a forum somewhere and the recommended fix was to add registerProfiler="false" to the <ncover> task (which I prefer solely due to its aesthetics). I did that and lo!

Then I went on vacation, took a different computer, and did a download and build. Same problem. Eventually, I ended up switching to the <exec> task which worked. Until today. Now both versions are hanging, seemingly on the profiler.

The odd thing was that NCoverExplorer worked fine with the same profiler. So I used it to generate my <exec> task and lo!

The difference 'twixt the NCoverExplorer generated task and my task: The NCoverExplorer one referenced ncover.console.exe in C:\program files, mine referenced it in tools\ncover. The version in the former was 1.5.7.0, in the latter 1.5.4.0. Copy the newer version to tools\ncover and lo!

Know not why this is an issue and, as is my policy, I don't care much. This falls under the realm of infrastructure, which isn't my strong suit. All that matters is that the problem is solved and documented so that I may find the solution again in the future when it happens again and I inevitably forget the solution and have to find it on Google.

Wednesday, April 11, 2007

I do believe the light has come on, vis a vis Test Driven Development. Which isn't to say I've done it to a great extent. I've just finished refactoring a small WinForms app to Model-View-Presenter and the exercise was a bit of an epiphany for me.

So here are the things I've been told that I now "get":

  • Model-View-Presenter aids in testability

Whoa, nelly, is my view ever stupid. Like brother-cousin Zeke stupid. The form that implements it references System, System.Windows.Forms, and my presentation namespace and that's it. All methods/properties do one of three things: manipulate the value(s) of a form element, manipulate the value(s) of a local variable, or raise an event.

I'd like to say I made that rule early on and stuck to it but the fact is, it just ended up that way as a consequence of the refactoring.

That leaves a presenter with references to a bunch of non-UI assemblies (System.Collections, System.Xml, System.IO and the like) that does everything the original form did. All easily tested should I feel the need to write the tests (and take heart, I do feel the need; possum steps, readers, possum steps).

  • Refactoring and adding unit tests is not TDD

I was ever-so-slightly befuddled when I read this in JP's post. I knew you were supposed to write your tests firsts in TDD but I thought he was being overly semantic when he said adding unit tests to an existing project is not TDD. But I knew better than to throw down with a guy who has four kids so I kept my mouth shut. And thank David I did.

Had I done this application the TDD way from the beginning, I would have ended up (presumably) with the same core code I have now plus a bunch of supporting tests. And the tests would cover 100% of the code I had written because you don't write any code unless it is fulfilling a test.

But that doesn't necessarily mean that the application does everything it's supposed to; only everything that the tests cover. We make the assumption that the tests cover the functional specs (i.e. the user's expectations, which I think is a better term).

The point is, TDD is a design methodology, not a testing methodology. JP et al have lovingly tried to drill this into my skull since the beginning but until now, those were just words I knew the meaning of individually but didn't quite grasp as a whole.

The biggest thing for this exercise for me wasn't to become an advocate of Model-View-Presenter. Sure, I can probably defend it to some extent to a naysayer but I'm not one to hold fast to any given pattern/methodology/way of life. I don't have that kind of conviction in pretty much any aspect of my professional life.

No, the best thing about MVP for me is that it's a damn fun little package. There's something karmic about making a stupid view and a presenter that could be re-used (even if the chances of doing so are pretty remote). It keeps me on my toes trying to think about a problem non-procedurally, which will save me a ton of money in crossword puzzle books I usually buy when I'm working on a more mind-numbing contract. (For the record, I generally boycott Sudoku these days on the basis that I've been playing it for nigh on twenty years in puzzle books when it didn't have a sexy Japanese name.)

In short, MVP is fun. And it makes developing fun. The fact that it is useful is just semantics.

Final thought: In a comment to a previous post, alert reader, Tom Opgenorth, suggested a method for retrieving data from the view in a Parameter object. I did not do that in my refactoring and here's why: I already had a Preferences domain object that stored all the data I needed to pass back and forth. So originally, I refactored using that object as the DTO which (and correct me if I'm wrong) is kind of what Tom was suggesting.

But then, I refactored further and got rid of it altogether, choosing instead to expose getter properties on the view for each of the properties in the Preferences object. A couple of reasons for that. First, it felt awkward passing the entire DTO when I just wanted to work with a single property. Second, by removing the reference to the Preferences object, I remove the dependency the form had on my Domain layer altogether leaving it to deal only with primitive types.

Note that the Preferences object was small enough (half a dozen properties, give or take) that I could do this pretty easily. I can imagine more complicated scenarios where a DTO might be more appropriate.

Thursday, April 05, 2007

Sweet NJayzus, there be a lot of tools out there for a .NET developer. And the Coding NHillbilly has finally gotten around to doing an ninventory of them on his machine and collecting them into one place for quick and easy nmanipulation on his nlaptop.

And might I suggest to fledgeling tool developers that you forego the apparent nstandard when naming your gift to the nworld.

I...errr...mock but this is something I've given some thought to. Down in the Bahamas, acronymic company and product names are the norm. Which in some sense is good because the actual names are so generic, you need an acronym to tell one from the other. Some examples: Data Systems International (DSI), Computer Information Services Ltd (CIS), Micronet, International Private Banking Systems (IPBS), Custom Computers. These names may be somewhat descriptive but frankly, they're boring as hell. I tried for eight solid months to get the creators of IPBS to change their name to Flamingo but they weren't having none of that.

So put some thought into your company/product name. But don't get hung up on any hidden meaning of the actual word(s). It's not like people will even think about the company name past the end of your introduction. If you're good enough, the name will eventually come with its own connotations apart from the word's underlying meaning. To wit: Java, Sun, Amazon, Google, eBay, and almost any car name you can think of (what exactly does "civic" mean anyway?). I installed Rhino.Mocks over NMock based on its name alone.

Various members of my family have long owned companies named Suvius. It's a name I love. Yes, it has some relation to Mt. Vesuvius and if you want to draw connections to the power of volcanos, go blow it our ear. I like it because it rolls off the tongue easily, it's a (semi-) made up word, it has lots of round letters (which makes for nicer logos), it starts with the same letters that it ends with (bonus: they're reversed), and if you want to get REALLY touchy-feely, it ends with "us". Eventually, I'll get the name of the company in lights but until then, it's just a cool-sounding word to me.

Semi-related sidenote: My dad and brothers are now the owners and operators of a fast-growing land surveying company called Trilogy Surveys. The reasoning behind the name? We liked the sound of it. As luck would have it, they've bought out another company called Lennon Surveys so now they get to call themselves Lennon Trilogy. Here's hoping they don't get the wrath of Yoko descended upon western Manitoba...

Wednesday, April 04, 2007

OK, dear reader(s), I haven't had much luck engaging you in the past but let's see how I fare in 2007.

I'm implementing my very first Model-View-Presenter. She's a bonny WinForms application that, at its core, takes an Excel spreadsheet and converts it into another format. It uses a plug-in architecture so that you (as in I) can create other "converters" and drop them into the plug-in directory without having to recompile.

That has nothing to do with my question but I've typed it and I don't want to delete it.

I've seen many, many, many, many examples of Model-View-Presenter, most of them very clear and easy to follow but all suffering from a problem I am just now encountering: My form does more than display a list of employees.

So my question is, how do you implement a page that, for example, displays two lists, then allows the user to select one item from each and click a button that will do something with the two selections?

Sub-questions:

  • Do you encapsulate each list in a user control, each implementing their own view and presenter?
  • Do you create a view/presenter for each section and have the main form implement each view and create each presenter?
  • Do you treat the whole form as one view with one presenter?
  • Do you use multiple views (one for each "section") with one presenter to control them all?
  • Do you use one view but register it with multiple presenters? (I threw that in for completeness; it sounds kind of wacky to me.)

The first person that responds with "It depends" will be shot on sight.

Wednesday, April 04, 2007

Hooray! Another tie-in with Scott Hanselman's recent post. That's two in two weeks. At this rate, I won't have to come up with any original content, just feed off someone else's. I follow the same philosophy in my coding so it's nice to have some spillover to other parts of my life.

ANYway, Scott's post is on Mindful Coding. The idea is that programmers need to guard against spacing out while coding, something that also hits close to home because spacing out is probably my family's raison d'etre. My brother can do it so completely that the gum he's chewing will actually fall out of his mouth. So, ya, it's something I try to be...ummm...mindful of.

The tie-in is with my half-developed notion of Conscientious Coding. The idea that you should be coding with a mind that someone else will be looking at, debugging, and maintaining your code someday. Maybe not today or tomorrow but at some point, your code will be subject to critical review. And not by a code reviewer whose goal is to make sure standards are followed, but by someone who actually has to understand at a very intimate level what your code does. Including yourself a year from now after you've forgotten what it is the code originally did.

Until now, I've focussed mostly on the aesthetics of how code looks for Conscientious Coding. Judicious use of white space, adding comments for gestalt (and information, if you're into that sort of thing). I still think this is an overlooked aspect of software development but it's getting better thanks to Visual Studio's ability to export IDE settings.

The idea also extends to how you're coding as well, though. I've read my share of code whereby I would take great pains to avoid meeting the author for fear that my polite Canadian sensibilities would fail me.

This is more than your typical enterprise-level code written by a junior developer. That I can deal with. That's code by people who just don't know better. Many of them recognize that. What I'm referring to is DailyWTF (sorry, guys, the new name isn't as catchy) code by people who not only don't know better, they think they do. People who will look back at code they wrote six months out of college and say, "Now THAT is some fine logic." (Which leads to another personal motto: You can't save everybody.)

The underlying concept of Conscientious Coding (and I really need to stop capitalizing it because it makes it seem I've put some thought into the mantra) is to be nice to the person who has to read the code a year from now, especially because it might be you. Learn to recognize when something doesn't smell right even if you can't do anything about it right now (either from lack of time or lack of knowledge or both). Don't get complacent six months into the project and start taking shortcuts. Recognize problems that someone has probably already solved somewhere else. Read up on new techniques that might fit your problem.

And try not to space out too much.

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

Copyright © 2008 Kyle Baley. All rights reserved.
 
LATEST POSTS
 
POPULAR POSTS
 
LINKS
 
BLOG ROLL
 
CATEGORIES
 
ARCHIVE