Michigan Loco Ubuntu Global Bug Jam 11.09 for 11.10 is Over

I just got back from the Michigan Loco Ubuntu Global Bug Jam at SRT Solutions in Ann Arbor. I can safely report that Ubuntu 11.10 Oneiric Ocelot is a very nice Ubuntu Linux release which smoothly upgrades from Natty Narwhal. Admittedly, my Natty install didn’t have much customization to it since I had upgraded it from Lucid back in April.

After the upgrade, I worked with John S. Gruber on confirmed a Lernid package that he had put together with some new features. I ran into a nasty desktop couch bug that it seems has been tracked back to Erlang, but luckily, it just meant that my settings weren’t persisted. I was still able to test out all of the Lernid features that John wanted to test. I’ve always been interested in Lernid and I really appreciated the opportunity to help out. I also liked seeing how the –config option worked. Also, the new slideshow command that uses a url to push a slideshow down to clients from the host/instructor is pretty cool. Its an interesting feature and shows where the program might be going in the future.

Once I’d learned enough Lernid, I decided to focus on some things that I wanted to make sure worked. I did an apt-get install mod_mono and monodevelop. I’m extremely excited about this ubuntu release. For the first time in years, Ubuntu is shipping a reasonably modern version of Mono. I was able to get an ASP.NET MVC application running in MonoDevelop in minutes. Note that this includes the download and install of the mono runtime and IDE. To do the same with Visual Studio would take hours. MANY hours if you include installation of VS2010SP1 on top of VS2010. After that, I tried hosting the asp.net mvc app in Apache. I didn’t realize that someone had written an apache config front end. http://go-mono.com/config-mod-mono/ This let me type in a few things and have my application hosted in no time.

I guess that was about it. After we cleared out of the SRT office, I handed off the Amiga 1000 that has been with me for 24 years to our Michigan Loco leader, Craig Maloney. I’m a little sorry to see the Amiga 1000 go, but I am not the type of person who will resurrect it. I think it has found a nice new home with Craig.

Writing Software is not Comparable to Using a Hammer

I’m going to rant.

Take a look at the first two paragraphs and bullet list here: http://www.peteonsoftware.com/index.php/2011/08/23/programming-language-skills/

Which part of programming is as simple as using a hammer, a manual saw, a table saw, a router, a clamp?

I’d argue that these are fundamentals. If you want to compare, compare them to programmer fundamentals.

  • using the if statement – 20 years experience
  • using the for statement – 20 years experience
  • using recursion – 20 years experience
  • writing functions – 20 years experience
  • using variable assignment – 20 years experience
  • using math operators – 20 years experience
  • doing string manipulation – 20 years experience

Just as the Programming Language “Skiills” post says, you never really need to put this on your resume.

You can have many years of carpentry experience and just as in programming, maybe you have repeated the same one year many times, or maybe you have done something new every year.

A quick search for Cabinet Maker at monster.com shows a job posting: http://jobview.monster.com/Cabinet-Maker-Job-Rome-GA-101712507.aspx

Notice how the requirements are nothing like “we want 20 years experience using a hammer’” ?

Its because metaphor does not work.

Can we as programmers please stop using this metaphor?

Are Access Modifiers Antiquated?

I just wrote a rather lengthy reply to a Programmers StackExchange question which I’d summarize as “why are the types and or methods I want to extend often sealed in common Java and .NET frameworks and libraries?” Its actually titled “Why shouldn’t classes be designed to be ‘open’?’”

My reply is here:

Because they don’t know any better.

The original authors are probably clinging to a misunderstanding of SOLID principles which originated in a confused and complicated C++ world.

I hope you will notice that the ruby, python, and perl worlds don’t have the problems that the answers here claim to be the reason for sealing. Note that its orthogonal to dynamic typing. Access modifiers are easy to work in most (all?) languages. C++ fields can be mucked with by casting to some other type (C++ is more weak). Java and C# can use reflection. Access modifiers make things just difficult enough to prevent you from doing it unless you REALLY want to.

Sealing classes and marking any members private explicitly violates the principle that simple things should be simple and hard things should be possible. Suddenly things that should be simple, aren’t.

I’d encourage you to try to understand the viewpoint of the original authors. Much of it is from an academic idea of encapsulation that has never demonstrated absolute success in the real world. I’ve never seen a framework or library where some developer somewhere didn’t wish it worked slightly differently and didn’t have good reason to change it. There are two possibilities that may have plagued the original software developers which sealed and made members private.

1. Arrogance – they really did believe they were open for extension and closed for modification
2. Complacence – they knew there might be other use cases but decided not to write for those use cases

I think in the corporate framework world, #2 is probably the case. Those C++, Java and .NET frameworks have to be "done" and they have to follow certain guidelines. Those guidelines usually mean sealed types unless the type was explicitly designed as part of a type hierarchy and private members for many things which might be useful for others use.. but since they don’t directly relate to that class, they aren’t exposed. Extracting a new type would be too expensive to support, document, etc…

The entire idea behind access modifiers is that programmers should be protected from themselves. "C programming is bad because it lets you shoot yourself in the foot." It is not a philosophy that I agree with as a programmer.

I much prefer python’s name mangling approach. You can easily (much easier than reflection) replace privates if you need. A great write up on it is available here: http://bytebaker.com/2009/03/31/python-properties-vs-java-access-modifiers/

Ruby’s private modifier is actually more like protected in C# and doesn’t have a private as C# modifier. Protected is a little different. There is great explanation here: http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/

Remember, your static language doesn’t have to conform to the antiquated styles of the code written in that language past.

Nuget could be more usable outside of visual studio

This is a reply to http://blog.davidebbo.com/2011/05/thoughts-on-installing-and-updating.html

 

I think you are wrong.

Everything in this post points out that you were wrong to base nuget on DTE.

The points here do explain "why this isn’t supported today" but it sounds like they are defending the lack of features as a good thing. It is not a good thing.

I sympathize with the lack of a strong foundation upon which to build. (limits of DTE) However, the idea of updating the csproj outside of visual studio point 1-3 and 7 in your post, is a sound idea.

The fact that #7 allows arbitrary code execution is something you will never overcome. As a packager might also automate something which is prevented by a GPO in a corporate environment, or utilize a COM object that doesn’t exist. You cannot solve all problems.

Inheriting WPF DataGrid might cause defaulting to OneTime databinding

I just ran into an annoying issue. I am extending WPF DataGrid copy and paste functionality similar to what is suggested by Vincent Sibal here.

public BetterDataGrid : DataGrid {…}

But when I did, data binding only worked against my initial view model. In my case a file load operation replaced the original view model and binding did not happen against the new view model.

I had to explicitly include Mode=TwoWay on the Binding, when using <this:BetterDataGrid … but this was not necessary when using <toolkit:Datagrid.

Just a warning, if you are going to extend DataGrid, be sure to explicitly set your binding mode.

XAML Comments in Attributes.

Sometimes I wish that XML supported comments in attributes instead of just <!—style.

Almost always this is a XAML file that I wish had this.

Today I realized just how silly I was being.

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  mc:Ignorable="d"

And now I can just d:Anything=”any comment”.

Sure, I can’t nest my quotes there, but this is good enough for a lot of things.

<Grid d:Purpose=”this is the grid that contains the other grid that contains the things”>…

CodeRush test runner for NUnit25 without NUnit installed.

What path is the Unit Testing\Test Runner options page expecting?
I have NUnit 2.5.9 downloaded from zip file, not installed from MSI and I try these paths and none of them work.
C:\Users\jrwren\Downloads\NUnit-2.5.9.10348
C:\Users\jrwren\Downloads\NUnit-2.5.9.10348\bin
C:\Users\jrwren\Downloads\NUnit-2.5.9.10348\bin\net-2.0
C:\Users\jrwren\Downloads\NUnit-2.5.9.10348\bin\net-2.0\framework

 

I get an error that says
—————————
Error
—————————
Test Provider ‘NUnit25’ can’t find required assemblies in this path
—————————
OK  
—————————
I finally tried C:\Users\jrwren\Downloads\NUnit-2.5.9.10348\bin\net-2.0\lib and it worked.

I didn’t see this documented anywhere. It is now. (here)

Collection Encapsulation is Bunk

I heard someone ask a question about encapsulated collections today and pointed to this blog post http://www.lostechies.com/blogs/jimmy_bogard/archive/2010/03/10/strengthening-your-domain-encapsulated-collections.aspx

I don’t want to comment on the blog post exactly, but I do want to comment on encapsulating collections in general. I’ve struggled with it. For some reason the OO purist in me wants to strong type everything and when it comes down to collections a Collection<T> or List<T> just isn’t good enough. I want to go full FDGL and make MyTypeCollection that extends Collection<T> or implements IList<T> or something of the sort and have all sorts of nice checking and expose only what is needed on MyOtherTypeThatHasACollectionOfMyType.

But what value does this add?

None.

Zero.

Zilch.

Nada.

My years of PHP and Perl before finding the joys of strong and static types taught me that you just use what is at your disposal and you don’t worry about bugs that don’t exist yet. No one (that I ever saw) ever wrote collection types in these languages. We always just used the built in lists and arrays. If an API didn’t support you adding to a list at the wrong time, then things didn’t work and you would read the docs and/or source and find out just what was supported and what was not. I’m guessing things are this way in the Ruby and Python world too.

The idea that encapsulation is good came about because programmers were creating the same bugs over and over again and running into the same problems again and again. These were the bugs and problems that encapsulation could solve. Do you really think a django or rails programmer is going to go make sure that a controller or other consumer of a model cannot accidentally clear a collection of values on that model? Or add to it when the model thinks that it should not be added to? No. Its a waste of time to do these things before it becomes an issue. Its premature optimization to fix a bug that doesn’t exist yet. If you try, you are just writing code for no reason.

Its probably not important to spend hours or days writing it when you can just as easily document it and say "don’t do that." If you have team members who don’t read documentation, you have bigger problems. Better yet, make everyone on the team aware of the code. Work in a shared ownership environment. Solve problems of unintended use by working with people rather than creating extra work to prevent unintended use.

I’m tempted to make some "the state of this collection can never be invalid" types too. Lets promise each other that we won’t spend time on this. Lets solve better problems.

WCF Async Without Changing The Contract

Someone asked a group of people recently about how to prevent overloading a WCF service that gets blocked. It sounded like the WCF service was getting called a lot and this was causing many threads to get created to service all of the requests, but nearly all of those threads were blocked handling some IO requests.

I vaguely recalled something about WCF async and I suggested this person look into that. I even looked up the AsyncPattern=true property and value for the OperationContract attribute, but the person didn’t want to break the contract. I was pretty sure that this change was only a server side change and that it wouldn’t break any contract, but I wasn’t 100% sure.

Today I confirmed that I was right. The generated WSDL does not change when you change your contract from something like this:

[ServiceContract]

public interface IOrderService

{

[OperationContract]

Order[] GetOrders(int numOrders);

}

To something like this:

[ServiceContract]

public interface IOrderService

{

[OperationContract(AsyncPattern=true)]

IAsyncResult BeginGetOrders(int numOrders, AsyncCallback callback, object state);

Order[] EndGetOrders(IAsyncResult result);

}

If you want to convert existing WCF services to server-side async style, you can do so without your clients ever knowing. (There may be a caveat when using a ChannelFactory, see the docs.)

The MSDN docs are pretty good. An overview here http://msdn.microsoft.com/en-us/library/ms730059.aspx some better details here http://msdn.microsoft.com/en-us/library/ms731177.aspx

Dan Rigsby had some blog posts from when these features were rolled out, but beware his examples, he keeps a sync version and an async version, which is not strictly required. http://www.danrigsby.com/blog/index.php/2008/03/26/async-operations-in-wcf-iasyncresult-model-server-side/

Finally, Wenlong Dong’s blog gives great reasons why you would want this and even goes as far as suggesting using the async version of the datareader for async database access. http://blogs.msdn.com/b/wenlong/archive/2009/02/09/scale-wcf-application-better-with-asynchronous-programming.aspx

50 Simple Steps To Debugging IE7 Javascript

I had the need to debug javascript in IE7. After the Spoon studio distribution didn’t work for me in 64bit Windows 7, I decided to try the VM approach. Here are 50 simple steps to debugging Javascript in IE7 in a Virtual PC Virtual Machine.

* Download Virtual PC without XP Mode.
* Download IE7 VHD.
* Create a new VPC pointed to the VHD.
* upgrade the vpc integration components.
* defer the reboot.
* Install web developer toolbar.
* install Visual Studio WEb Dev Express 2010 which requires…
* WebPI which requires…
* .NET 2.0
* which fails because of the pending integration components installation.
* reboot.
* watch the upgrade fail when it prompts you for a XP CD ROM.
* Be happy that now you have no intergration components…
* Your mouse it now captured in the VPC window…
* be in awe of how much slower IE7 browsing is without the integration components.
* ITs so slow its going to be unusable for actual work so try installing the integration components again.
* Watch the installer simply fail with no explaination.
* Try WebPI again, even though it will be slow.
* be amazed at how long it takes to ngen System.Design.
* reboot after .net2.0 install.
* reboot after microsoft installer installation.
* be in awe of how long it takes SQL Express 2008 to install.
* reboot after web developer express partly installs.
* be in awe of how long you still have to wait for WebDevExpress to install.
* now that it is all done, try once more for the integration tools.
* get prompted for the CD again for usbhub.sys.
* search your system for this file. c:\> dir /s usbhub.sys
* curse when it is missing.
* google it (you don’t bing it at this point because of MSFT anger).
* after much clicking find this awesome post http://superuser.com/questions/244659/where-can-i-find-windows-xp-sp3-as-a-zip-file.
* nearly get a virus trying to get usbd.sys from memers.driverguide.com.
* find usbd.sys at sysfiles-download.com.
* complete integration components installation.
* wonder what this RemoteApp redirect is… sounds like Unity Mode on a mac for XP in Win7.
* reboot (to complete integration components installation).
* start Visual Web Developer and be in awe of how slow that first time launch is in a VM.
* Create an empty ASP.net web app and click run.
* see the 404 in IE7 and be happy because your browser is now attached to the VWD debugger.
* browse your site with the JS that kills IE7.
* click debug when IE7 prompts you.
* go back to VWD and see the JS open with cursor on the line with the error and no error message and no exception or other information about what is wrong with the JS.
* find a corner.
* sit down.
* curl into fetal position.
* rock yourself gently.
* sing yourself a slow and calm song.
* remember that you go home at 5pm and don’t think about software again until 9am tomorrow.
* be glad you aren’t one of those "passionate" devs that never stops thinking about software.
* think of your children.
* ask a coworker who knows js better than you and let them point to where you don’t have valid js.