Welcome to DevAuthority.Com Sign in | Join | Help

I've finally got my blog set back up at joeyDotNet.com.  So I'll be using that as my main blog from now on.  Please change your subscription link in your aggregators to my new blog.

Thanks,

Joey

Jean-Paul Boodhoo has just announced he'll be doing a deep dive boot camp class in .NET.  Based on the topics he has listed and the quality of his postings and sample code in the past, this is going to be an awesome class for the .NET community.  

I think .NET developers have needed this kind of class for a long time instead of the typical drag-n-drop, wizard-based development that most of the .NET classes include.  Looks like he'll really be diving into some much needed patterns and concepts that are essential for developing high-quality software.

And hey, you get an awesome book (one of my favorites) and the best producitivity tool for Visual Studio (IMHO) with the class.  Only 12 spots, so sign up quickly.

(If anyone in the Virginia area is reading this and you'd like to have this class down here, let him know...)  :)

As noted in a previous post about WLW, I was wishing WLW would allow you to save your posts and drafts in another location other than the default C:\Documents and Settings\blah blah.  Well thanks to a former co-worker who GTalk'd me today, I was reminded of a great little feature of NTFS called reparse points.  For some reason I had forgotten how useful these little guys can be.

So Sysinternals, recently acquired by Microsoft, has this nifty little utility called junction allowing you to create these reparse points, aka symbolic links.  I'd highly recommend downloading the entire Sysinternals suite while you're there.

With a simple command like the one below, I was able to "fake out" my file system into allowing my d:\joey\documents\blog posts folder and c:\documents and settings\blah blah folder to essentially be the same.  At least as far as windows is concerned.

junction "d:\joey\documents\blog posts" "C:\Documents and Settings\jeb\My Documents\My Weblog Posts"

You can read up more about using reparse points in this PCGuide article and Scott Hanselman has an article relating to how Vista uses and extends this technique for manipulating how files and folders are represented on the file system.

(Chalk this one up to lessons learned...)

I recently made the comment to a co-worker that the more applications I develop, the more layers and complexity I seem to be removing and the more I'm striving for simplicity.  At first glance, this may look like a step backwards to those caught up in BDUF and designing a complex layering scheme for what you think the application is going to need. 

But even if you're trying to emerge the design as you develop, you can still be tempted to prematurely inject layers of complexity that aren't warranted.  As you can probably tell if you read one of my previous posts, we are using DTOs, perhaps when they aren't needed. 

Like on one of my current projects, I started out with a pretty typical architecture (non-distributed):

  • web ui
  • presentation layer
    • using one of my favorite patterns, Model-View-Presenter (right now I lean towards the Passive View flavor of MVP for its increased testability, but I can see how using Supervising Controller might be a good choice for windows forms apps if you actually like databinding...  :)
  • services
  • domain
  • data access layer
    • you know, that layer we all hate writing over and over again (can't wait to actually use NHibernate on a real project)

So the basic gist of it is my presentation layer uses different services to perform operations using my domain objects and my services take care of shoving stuff in and out of my data access layer.

Well for some strange reason I got on a DTO kick and prematurely injected a set of LocalDTOs to hide my domain objects from my presentation layer.  I thought it would be nice to separate how the data is represented in my presentation layer from my actual domain model.  Turns out this flexibility comes at quite a hefty price.  I suppose I should've known this going into it when I found this quote in PoEAA...

"Don't underestimate the cost of [using DTOs].... It's significant, and it's painful - perhaps second only to the cost and pain of object-relational mapping"

Perhaps if I would have read this post by Jon Tirsen and Fowler's response, it would have persuaded me away from my attempt at improperly applying the DTO pattern to my application.  The mapping logic that needs to be written and maintained in order to support this pattern can be tedious and downright frustrating.  However, if you're in a situation where you have to use DTOs, you should check out the BLToolkit which has a nice mapping engine which will definitely ease your pain.

Bottom line is that I decided to remove this layer of complexity from my application by refactoring away from this pattern and boy am I glad I did.  Now I can use my nice rich domain objects in my presentation layer which will really speed up future development and lower maintenance costs for this system.

So, remember, whenever you feel compelled to introduce another layer of abstraction or apply some new cool pattern you just learned about, make sure you're not over-architecting and you're KISS.  :)  (Refactoring is your friend...)

Well looks like I only got to the DTOs portion of my title, so I'll tackle Data Contracts and Accidental Complexity vs. Essential Complexity in subsequent parts.

Happy TDD'ing!

So like a lot of other bloggers, I'm really liking Windows Live Writer (WLW) for posting to my blog.  For some reason I was always too cheap to fork out the $$$ for BlogJet which most say is the leader is this particular area.  So WLW is a pretty nice free blog editor with some very useful plugins

One of the things that does bug me about it though is the fact that, by default, I can't save my drafts in a location other than My Documents\My Weblog Posts\Drafts.  Since I don't use the My Documents folder structure for anything, this does me no good.  I know, I know, just redirect the location of My Documents to the location of my choosing.  Just something about prefixing everything with "My" gives me the VB heeby jeebies.  :)

(Besides, I've set up a portable, synchronized work environment allowing me to use my same portable apps and same documents across different PCs using FolderShare.)

So after much googling without an answer I fired up my handy dandy Reflector to confirm my suspicion that the path is indeed hard-coded based off the Environment.SpecialFolder.Personal folder as shown below...

WLW.PostEditorFile

So my workaround is to simply create a blank .wpost file in my own "drafts" folder, (for me it's at d:\joey\documents\blog posts\drafts) and just create copies of that to use for new blog posts.

DraftsFolder

Notice I've marked the file named "New Post.wpost" with the read-only attribute to keep me from accidentally altering it.  And I've made a copy of it and opened it up in WLW.  The nice thing about this is that when you open a .wpost file directly from Windows Explorer into WLW, when you save, it will save it in that location instead of trying to save it in the default Drafts folder.  Another nice thing is that it will automatically rename the .wpost file to match the title you give the post in WLW

The downside to this approach is WLW won't show your drafts in its sidebar, since that only looks at the default My Weblog Posts\Drafts folder.

So hopefully Microsoft will make the save locations configurable (like every other Office app) as WLW comes out of beta so this kind of nonsense is not necessary.

http://joeydotnet.com/blog/MVPRefactoringExtractViewMapper.aspx
0 Comments
Filed Under: , ,

One of the bloggers I've really been following lately is Jean-Paul Boodhoo, formerly a Senior Developer with ThoughtWorks.  I've learned quite a bit from his posts which often include very good sample code.  I first saw him present a couple screencasts on DNR TV using TDD with the Model-View-Presenter pattern

<ReSharper Plug>

(JP also gave a very good commercial for using ReSharper for C# development, something I now find hard to live without.  Look to Jeffrey Palermo's post on ReSharper for a good overview and to Paul Laudeman's post on how ReSharper can help with TDD.)

</ReSharper Plug>

Anywho, I decided to make this mainly a link posting as a reference for myself and thought others might find it useful.  Here are some of my favorite series and postings by JP...

First, here's his latest MSDN Article

 DNR TV Episodes

NAnt Starter Series

Test-Driven Development

Domain-Driven Design / Architecture / Patterns

Misc.

Well guess that's it for now.  There are a few more older links, but I haven't read those yet.  If you're not already subscribed to his blog, I'd highly recommend it!

0 Comments
Filed Under: ,
So I'm currently on the hunt for a good free desktop blogging tool.  Of course I'd love to have BlogJet, but can't fork over the $$$ right now.  Beside if I get anything right now, it's going to be Resharper 2.0.  So I've tried a few of them like Qumana and of course w.bloggar, both of which I really like.  Just one problem... they're not portable.  If you recall in my last post about my portable work environment, I'm on a portable app craze and loving it. 

So since I already use Portable Firefox, I figured I'd give the Performancing FF extension a shot to solve my stand-along desktop blogging needs.

This is just my first post with it kinda as a test, but looks good so far.
0 Comments
Filed Under: ,

No, I'm not talking about an extension to the new My namespace in VB 2005. I'm talking about my recent addiction to portable apps and the idea of having a roaming work environment which includes most of the common apps I use as well as their application settings.



Suprisingly most of the apps I use are either already portable, or have portable variations available. If only a portable version of Visual Studio 2005 existed... :-) I do however like to store my VS 2005 .vssettings and other application settings files in a common location so I can import them on all the machines I use if needed.



Here's a screenshot of the root directory of what I wanted to have available whereever I'm located:




And here's a screenshot of the portable apps I'm currently using:




My initial goal was to keep my "portable work environment" on my 1GB i-Stick. But after a few headaches with file corruption and the fact that I always needed to have my i-Stick on hand (which I found wasn't always the case), I needed a better solution.


So I decided to experiment with using FolderShare to synchronize this folder of common apps and settings between multiple machines. And it works surpisingly well. I currently have 2 desktops and 1 laptop as devices and I have a folder named "Joey" which contains all the items shown above and it is automagically 2-way synchronized among all the computers that I use. I do still keep a backup of this folder on my i-Stick for the cases where I'm maybe working on someone else's computer, but still want to use my favorite tools, portable-style. :)


However, I still had a couple problems to solve. I pretty much use SlickRun exclusively for doing *everything* in windows. If you haven't used this nifty little app, go download it now! Anything I can do to keep my hands on the keyboard makes me happy. Anyways, since SlickRun apparently requires it to be installed using their installer, I was worried that I wouldn't be able to portablize it (that's right, I made that up :) ). Well my fears were relieved when I found out how to run SlickRun from a flash keychain. And it works perfectly. Also, I changed all of my SlickRun shortcuts that point to my portable apps to use a relative path, so that it doesn't matter where I specify the folder to be synchronized on my different machines, the shortcuts always work!


The last problem was that of startup. I generally like to remove everything I possibly can from running when windows starts (recommend AutoRuns), but I do have a few things I like to have automatically start. And it just so happens that all of them are now portable apps in my roaming work environment. So I created a startup.bat file in my root directory which contains the following:




So, on my own machines I frequently use, I can just add a shortcut to the location of this startup.bat file into my Startup group in my start menu. Notice in the screenshot that I'm firing up SlickRun so that I can immediately start launching anything else I want to run using my favorite launcher.


Well that's pretty much it. So far this set up is working very well for me. I now have an entire portable work environment that stays synchronized between all machines and I keep a backup on my i-Stick in case of emergencies.


I'd love to hear from folks about the portable apps they use. What are your favorite portable apps?

2 Comments
Filed Under:
I've been following pretty closely the series Jean-Paul Boodhoo is doing on build automation with NAnt.  I'm a huge fan of automating everything that doesn't require human intervention.  After all, isn't that why we have these things called computers in the first place.  Anyways, recently he posted an answer to a question that someone had about running all the sql scripts in a directory using NAnt.  I had a need to do the same thing because I like to keep stored procedure scripts in their own file to make them easier to maintain and store in source control. 

I've used NAnt a lot and really like it, but where I currently work, we're using MSBuild for the moment.  And MSBuild doesn't have that nice looping task that you can use in NAnt to perform a task on multiple files.  So my solution?  Create a custom MSBuild task to run any number of sql scripts in a directory.  See below...

Here's an example of how it can be used in an MSBuild script:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="BuildDB" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="tools\joeyDotNet\joeyDotNet.MSBuild.Tasks.dll" TaskName="RunSqlScripts" />

<PropertyGroup>
    <SqlToolsFolder>C:\program files\microsoft sql server\90\Tools\Binn</SqlToolsFolder>
    <Osql>$(SqlToolsFolder)\osql.exe</Osql>
    <OsqlConnString>-E</OsqlConnString>
    <InitialCatalog>joeyDotNetDB</InitialCatalog>
</PropertyGroup>

<ItemGroup>
    <TargetDBScriptFileInclude="sql\Database.sql" />
    <TargetTableScriptFileInclude="sql\Tables.sql" />
    <TargetSProcs Include="sql\sprocs\**\*.sql" />
</ItemGroup>

<Target Name="BuildDB">  
    <RunSqlScripts OsqlPath="$(Osql)" SqlScripts="@(TargetDBScriptFile)" WaitForExit="true" />
    <RunSqlScripts OsqlPath="$(Osql)" SqlScripts="@(TargetTableScriptFile)" />
    <RunSqlScripts OsqlPath="$(Osql)" SqlScripts="@(TargetSProcs)" DatabaseName="$(InitialCatalog)" />
</Target>
</Project>

Here's a list of properties that can be set for this task:
  • OsqlPath - The absolute path to osql.exe   <-- Required
  • OsqlConnectionString - The security connection information for osql (i.e. -E for integrated security)
  • ServerName - The database server name
  • DatabaseName - The name of the database to run the sql scripts against
  • SqlScripts: Collection of task items (constructed by using <ItemGroup> elements in MSBuild) representing the sql scripts to be run
  • WaitForExit - Boolean to indicate whether the osql process halt further processes from running until it's done (I found I needed to set this to true for the example above to make sure the database itself was created before running the table and stored procedure scripts)
That's it!  I would still like to create a custom MSBuild task to mimic the foreach task in NAnt.  I'll save that one for another day.

See attachment link below to download the source.
6 Comments
Filed Under:
Attachment(s): joeyDotNet.MSBuild.zip
No, I'm not trying to start another language war (at least not intentionally).  This is mostly about how the VS 2005 IDE performs when using VB.NET.  First off, I am a C# kinda guy.  Been using C# for almost 3 years now, but I did cut my teeth in .NET 1.0 using VB.NET (boy am I glad I made the switch).  Anywho, I recently started a client project in which I'm forced to write it in VB.NET, and the first week I could just feel my productivity declining.
  • Since I use TDD exclusively in my development and try to practice feature-driven development, I started work on a few features they wanted right out the gate.  So as I'm adding test projects and their associated class library projects (all in VB), I notice immediately how ridiculously slow the IDE becomes.  Then I remembered that VB.NET has this background compiling "feature", which by the way you can't turn off!  At least I haven't found any information to state otherwise, but if you know how to, PLEASE let me know. 
productivity--;
  • And who would've thought that one day Intellisense would be better in C# than in VB.NET.  Well, that's certainly the case now.  Just look....
  1. Because the data type is the first thing typed in C# for declaring a variable, you get instant Intellisense... not so with VB.NET.... you have to wait until after the "As"...
  2. And even then VB.NET isn't smart enough to highlight the default data type to instansiate like C# does...
  3. And has anyone noticed how poor of a job VB.NET does with Intellisense if *anything* on the current line has compilation errors.  This is big for me, because since I do everything in TDD, most of the time I'm writing a test that includes references to interfaces or classes that don't exist yet.  So if I'm writing a line of code in my test that references say an interface which *does* exist, but also say a class that *doesn't* exist, I lose Intellisense on the interface which *does* exist.  Not so in C#... must be do to that darn background compiliation "feature"....  :|
productivity--;
  • Compilation in general seems slower in VB.NET than in C# as well.  And if you follow the red-green-refactor rhythm, you know how often you are compiling.
productivity--;
  • And it probably doesn't help that ReSharper doesn't yet support VB.NET, but I've had confirmations that it will be the end of the year.  If you doing C# and you haven't tried ReSharper, stop reading this post right now and go download it!  I'm trying to get some use out of Refactor! Pro from Dev Express since it supports VB.NET, but it's just nowhere near the same.
productivity--;

So I guess this wasn't much of a productive post, but it was just something I needed to get off my chest.  Boy am I looking forward to some future projects that will hopefully be in C#!
0 Comments
Filed Under: , ,
So I've been messing around with the latest build of ReSharper which is quite cool.  I have a feeling I'm just starting to uncover all the goodies it offers.  The code formatting and discovery tools are killer and I love that it shows all signatures for overloaded methods without having to hit the down arrow (like what you have to do with the plain vanilla VS 2005). 

But, what I didn't know is that it actually includes support for MSBuild and NAnt scripts.  I just happened to open up one of my build script to make some changes and noticed that the ReSharper "smart tags" kicked in for one my undeclared properties and ReSharper was able to automatically create the property for me in the correct location.  How cool is that! 

Anyways, not sure if I'm the last person to realize this, but it's pretty cool stuff.
0 Comments
Filed Under:
One of the CB'ers mentioned how much he likes log4net, and I just had to 2nd that notion.  Thanks to Paul, I've started using log4net for all my logging needs, and it's amazingly lightweight and very configurable.  I've had to use the new EntLib for data access and configuration for a couple things, and to be honest, it just felt like bloat-ware.  Config files, config files, everywhere.  log4net is very simple to use and set up.  I like to think of logging as "inline comments on steriods".  I do also like what Ron Grabowski said (check out the comment thread here) about abstracting out your own logging interface for your project, allowing you to plug in and swap out logging engines (log4net, EntLib, etc.).  I'll probably try and do that on my next project.

BTW, log4net has a ton of documentation that I've used quite a bit, so go check it out!

Apparently the ExpectedException attribute doesn't work quite as well as it should in VS 2005 unit tests.  As far as I know this should make a test fail:

<code>

[TestMethod]

[ExpectedException(typeof(ArgumentNullException), "expected message"))]

public void MethodThrowsArgumentNullExceptionWithValidMessage()

{

SomeClass context = new SomeClass();

context.SomeMethodThatThrowsArgumentNullException();  // throws ArgumentNullException with a message of "bad message"

}

</code>

Now, shouldn't that fail because the exception messages don't match?  Well, it doesn't.  So here's what I do as an alternative, albeit not exactly a satisfactory one.

<code>

[ExpectedException(typeof(ArgumentNullException)))]

public void MethodThrowsArgumentNullExceptionWithValidMessage()

{

      string expected = "expected message";      

      try

      {

      SomeClass context = new SomeClass();

      context.SomeMethodThatThrowsArgumentNullException();  // throws ArgumentNullException with a message of "bad message"

      }

      catch (ArgumentNullException ex)

      {

            string actual = ex.Message;

            StringAssert.StartsWith(actual, expected);

            throw;

      }

}

</code>

This test will fail because the actual exception message doesn't start with your expected exception message. 

This way you check both the exception type and exception message.

Just stumbled upon a great new extension for Firefox, named IE Tab.  It performs the same function as one of my other favorite extensions, IE View, BUT it actually adds the IE window as a tab right inside Firefox!  It also allows you to add sites that will always open up in an IE Tab (for instance, I included msdn2.microsoft.com, which has had its share of problems if you're using anything other than IE, but to their credit, it does seem to be getting better :)...).

Very nice!  Now I *really* won't ever have to open up an IE window, even when developing intranet-based/IE-only web applications.  Sweet!

0 Comments
Filed Under:
More Posts Next page »