Google Analytics

Monday, May 21, 2012

Mountains

Every so often I need to break out this quote. Today seems like a good day to do that.

"Mountains should be climbed with as little effort as possible and without desire. The reality of your own nature should determine the speed. If you become restless, speed up. If you become winded, slow down. You climb the mountain in an equilibrium between restlessness and exhaustion. Then when you’re no longer thinking ahead, each footstep isn’t just a means to an end but a unique event in itself. This leaf has jagged edges. This rock looks loose. From this place the snow is less visible, even though closer. These are things you should notice anyway. To live only for some future goal is shallow. It’s the sides of the mountain which sustain life, not the top. Here’s where things grow."

Robert M. Pirsig
Zen and the Art of Motorcycle Maintenance

Monday, May 14, 2012

Marriage and Civil Unions in Colorado

A couple points about this special session of Colorado State Legislature that Governor Hickenlooper has called. First of all the Republicans are saying that it is an expensive and unnecessary session being used to divert public attention from the real issues, particularly the economy. The fact is, the Governor wouldn't have had the opportunity to call the special session if legislators on both sides of the aisle had done their jobs in the first place and gotten the bill to a vote before adjourning. This isn't just the Republicans' fault as the Democrats stalled the issue in the first place knowing they probably didn't have the votes, at the time, to even get this through committee. They waited until they could throw the spotlight on it and force the Republicans to stall until the end of the session in order to not have to vote "No" on it. Furthermore, given the nationl attention the issue has gotten, both with the vote in NC and with VPOTUS and POTUS commenting on it, it seems this very much is an issue that the voters are concerned with now.

Secondly, government should no longer be determining what does or does not constitute a legal marriage. Many of these laws regarding marriage and sexual norms in general stem from the early notions that government should encourage a strong population by encouraging procreation in monogamous relationships between a man and woman. A strong population was a LARGE population. This is an outdated notion. The government's involvement in who should and should not procreate, in my opinion, should have been nullified at some point in history before the Nazi's started saying that blond-haired, blue-eyed citizens made the best babies.

That said, there are certain legal ramifications accorded to married individuals that the government should have some say in to maintain a relatively orderly society. What constitutes a family in regards to shared health care? Who should have hospital visitation rights? Who should get implicit guardianship of children following the death of a parent? How does should legal inheritance of possessions be dealt with? The contract of marriage has been relied up on to deal with many of these issues. However, why shouldn't any two people be able to draw up a similar contract? Why should they need to be married?

For legal purposes, I can see why the contract would necessarily be between two-and-only-two human beings. Of course both would have to be of a legal age to understand and consent to a legal contract. I would propose that the government would stop registering marriages altogether. I think that marriage is inherently religious or spiritual or at the very least a moral issue that the government should not be concerned with. Instead, they register these "civil unions" between any two people who are at least 18 years of age. The government would also need to administer to the dissolution of these contracts as they do divorce currently. A person could not enter into such a contract with more than one person. I frankly don't understand what is so difficult about this.

Friday, April 13, 2012

In the wake of North Korea's "failed" rocket test, I was reminded at how striking it was to learn of all of Robert Goddard's similarly "failed" tests as he was experimenting with his liquid fueled rockets. His first test flight barely made it 40 feet into the air! For every test in which he achieved a new altitude record there seemed to be at least a dozen which came nowhere close to a record, some of which burned up before they left the ground and I'm sure hundreds of designs that never made it out of the laboratory.

Of course Goddard, like Edison, never considered a test a "failure" because he was always learning from those experiments. He'd probably just say that he discovered one more way how NOT to make a rocket! He was obviously a genius, and I'm sort of disappointed that I had not previously learned more about him. As a society it seems that we do not celebrate genius like we once did.

Finally, I really sort of question as to whether we should be condemning North Korea for trying to advance their technology. Of course, I wouldn't want an unstable society gaining nuclear weapons, but I think even us "civilized" countries would be better off without anyone having nukes. But to me, stifling a country's push to gain technological competence is akin to the slave master making sure that his slaves can't read.

My personal belief is that increased knowledge is central to human morality. Ignorance is akin to evil. Knowledge leads to the truth, and the truth is that Communism is not a economic model that is sustainable in a just human society. It seems to me counterintuitive to keep a nation down and ignorant rather than demonstrating to them the power of democracy and the open market.

I'm only suggesting maybe rethinking our policy when it comes to foreign rivals in this respect. North Korea is probably the most extreme case, and our approach maybe shouldn't shift too radically. But you have a country like Iran, that we sanction and Cuba that we have effectively kept mired in the 1950's. I'm sure it's an anathema to suggest we work with the three biggest "foreign rivals" that the U.S. has. Honestly, what I really believe I mean to suggest is taking a different tack to work AGAINST them... lead them to the truth that will show them that communism and religious extremism and non-democratic government does not work. Let them celebrate their inventors, their geniuses. One of those geniuses will break free and lead those nations to the truth.

Thursday, February 23, 2012

Prism Module Loading "Incorrect Format"

We ran across this this morning where a colleague was trying to load a module she had built from a DirectoryModuleCatalog into the shell of our Prism application. She was getting an error that the module could not be loaded, an error which included "An attempt was made to load a program with an incorrect format." We stripped the module down to the bare bones, but still were getting the error. In fact, when we tried debugging, the debugger never even got into the constructor of the module. 


A little research suggested that maybe the Unity dlls being referenced were different, which wouldn't surprise me since VisualStudio seems to go out and add whatever dll might be registered that it thinks fits the bill when you load up a project that another developer had started. After checking and re-checking the references for both the shell and module projects, we determined that probably wasn't it.


Then I found a bit about the build configuration. Her plugin was being built with an X86 target platform and the shell was being built for 'Any CPU' on her x64 machine. Voila. She went into Properties > Build for the Module project and changed the target to x64 (interestingly Any CPU was not available, which is maybe another issue), and the module loads into the shell as expected.

Friday, February 10, 2012

A Letter to Colorado Rep. Laura Bradford


Jan. 31, 2012

Ms. Bradford,


I made the mistake of getting into my car and driving back home to Brighton after enjoying a Rockies game and some beers downtown back in June. It was very irresponsible of me and I am very ashamed for having done it. I was pulled over by Brighton Police less than two miles from home and subsequently was arrested and convicted of a DUI.

I have done everything I have been ordered and advised to do and have finished most of those things early. I have completed 48 hours community service, paid thousands of dollars in fines and fees,attended a MADD victim's panel, done random breathalyzers 3 times per week, completed 24 hours of mandatory alcohol education and another 40 hours of alcohol therapy with another 12 hours left to complete. I went without being able to drive for 30 days mandated by the DMV, about another 30 days because they couldn't find the correct paperwork from my insurance company, and must go the next 2 years with an ignition Interlock system in my vehicle. Not only do I get to face scorn of those around me every time I start my car, but I also cannot travel for work since I cannot rent a car, putting my job in some jeopardy.

It was my first offense.

I impart this to you because you will not have the opportunity to gain the full extent of the implications of driving while intoxicated that my family and I have had the privilege of learning. Luckily I did not have to learn of the more sever consequences that some good people I have had the privilege of meeting have endured - causing damage and going to jail, or even worse hurting or killing another person. So far I have spent at least $3370 on DUI expenses, not including loss of work and vacation time to make scheduled hearings and probation appointments and other unrecorded expenses I paid with cash. The Interlock system is about $70/month and I will have 3 more months of alcohol therapy plus breathalyzers which will add at least another $1500 to that total. It just cash terms the DUI will easily cost me $5000. For that money I could have taken a helicopter home that unfortunate night.

With your position you do not have to deal with that. I am sure the bad press you are getting now is awful. Frankly, I'm sure that most of it is hypocritical coming from many people who have taken drinks and then driven home. As so many of my friends have told me, "That could have been me." But in a few months your bad press will be gone, and me and those without legislative privilege will still be blowing in straws to start our cars. However, with that position you have, you also have a lot of power to take Senator White's full advice and make positive change. Perhaps you will consider donating a portion of that $5000 or so you would have incurred to MADD. I know when I attended the impact panel they could have used more than the $5 I was able to donate. Perhaps you will consider attending an impact panel in your area? I wouldn't expect you to attend the education or therapy sessions that your legislative peers have mandated for anyone who gets caught with alcohol in their systems and isn't in the state legislature, but perhaps you will pick up the materials that every attendee is required to buy?

A few other things that I learned from this experience: Alcohol stays in your system much longer than they say. Your body doesn't process a drink an hour: It's more like a drink every two hours. Carrying a breathalyzer in your car will probably keep you out of more trouble than carrying a gun in your car will get you into. You can purchase breathalyzers on Amazon for around $150. Finally, it's not worth it to EVER get behind the wheel after drinking, even after one drink.

I hope you do not resign from your office, but instead use it to make some positive change in regards to drinking and driving. One thing that personally really bothers me is that a bar patron in Denver cannot hail a cab from the curb, but instead has to make a call or find a designated cab stand. I think more people drink and drive because of this. I've found that the other people I am in classes with generally are all good people who have made a very stupid mistake. There are very harsh consequences of getting caught with that in Colorado. You are really pretty fortunate that you don't have to deal with most of them.

Sincerely,

Benjamin Rice
Brighton, CO

Thursday, December 15, 2011

I am adding the module now to the shell. I'm looking at the UI Composition QuickStart in the guidance to get an idea of how to start. I want to have a main region and within that a tab region that I can add a tab to. Started by adding TabControl and TabItem template to the shell. Had to work out the fact that I didn't need the Silverlight adapter and other related markup. Added the module project as a simple class library and added the Views directory to it. Added the UserManagementModule class as a normal class. It implements IModule and its constructor takes a UnityContainer and RegionManager interfaces. In the Initialize() method we Register the UserManagement view with the tabRegion on the shell. So... we need to add the UserManagement View. We add that to the Views directory as a UserControl. I also just added a textBlock in the view to indicate that it is loaded. I had to explicitly override ConfigureModuleCatalog in the Bootstrapper and add the UserManagementModule to the catalog for now. Like I said before, I want to use the directory discovery method to get the modules, but we are taking baby steps here. So when I run this now an odd thing happens: I get a shell with two tabs. The first has no content. I think that it has to do with the fact that I am doing view injection rather than the view discovery of the QuickStart for the main region and I am getting the two methods crossed. The second tab has my content. It doesn't have the name on the tab, which is supposed to be bound to the View's ViewName property. Took me a few minutes to realize that I need to put that in the ViewModel object for the view. (Duh! Isn't that how all this is supposed to work in the first place?) So Next I will be adding the ViewModel for the UserManagement view, adding the ViewName property of that, and seeing if it gets displayed in my tab. The UserManagementModel gets added as a plain class that implements INotifyPropertyChanged, so it has a PropertyChanged event. The model is injected in the constructor of the view. Then we set the dataContext of the view to the model. This is a change from the MVP architecture we have used in the past where an interface to the view was injected into the constructor of a presenter and the view basically had no knowledge of its presenter. With MVVM the view will actively subscribe to events from the model and bind to its collections and commands. I'm wondering at this point if I should create an interface for the ViewModel, but I don't see why at the moment so leaving as is. WPF TabControl done differently than the Silverlight example in QuickStart, and that is what was giving me the two tabs and not correctly showing the view name on the tab as I wanted. I had to bind to Content.DataContext.ViewName rather than just ViewName as described in the QuickStart or DataContext.ViewName as some examples on the internets showed. Now I need to activate the tab. Hook up some dataService and bind users to a listControl. Add a second tab and probably localize region names.

Wednesday, December 14, 2011

Prism, WPF and My First Module

To start off with, I would like to create my shell, bootstrapper and first module. I'm choosing the User Management interface of our current project as that initial module, though to begin with all I plan on doing is loading a tab control into the main region. My current plan is to create a shell with a main menu and a main content region. One of the menu items will be Administration and one of the sub-menus under that will be User Management. When the user selects User Management the tab control with the title User Management should load in the main content region.

At first the menu content will just be static, but it would be nice if I could dynamically add the menu item at runtime. I'm not sure that I can specify that the User Management module should load OnDemand rather than OnStartup and still be able to populate the menu. That is one of the things to figure out. I am going to try using populating the module catalog with directory discovery. Another option I think we COULD possibly use is a ConfigurationModuleCatalog. In either case we just need to make sure we are doing thigns securely so that no one can drop in a rogue assembly that could be discovered and loaded. Also I would like to be able to "unload" the tab control and not just hide it so that the control is not using overhead memory. That is another thing to experiment with.

Then the user management view is probably going to be composed of two related views: a Roles control and a Users control. Each of those controls will have a list of their respective model data as well as a Detail view for selected items. So my next task will be to wire up the model to correctly display the system's roles and users as well as the command(s) for selecting an oject from the list and showing its properties in the details view.

In the Users control there will be commands for adding, editing and disabling users. (There is no deleting of created users.) This will give me a chance to do error handling and business rules regarding the users (like password strength and that the default Admin user cannot be disabled).

For each of the controls there are a couple view-related features like the refresh and filter commands. They may be interesting to experiment with in the MVVM framework, but aren't terribly important.

Finally, there is the relatively simple task of adding and removing users from roles, which will give me the opportunity to see how my two controls will communicate with each other.

So on to creating my application and creating the shell and bootstrapper.

Following the walk-throughs for Prism Guidance:

In Visual Studio 2010: New Project > Windows > WPF Application. I'm naming it AdjudicationPoC.

Change MainWindow.xaml to Shell.xaml. VS changes the code-behind name to Shell.xaml.cs, but need to change the actual class name and constructor and also go into App.xaml and remove the startupURI attribute. The Bootstrapper will handle what starts, and in fact we can just go in now to the App.xaml.cs code-behind and override the OnStartup method to create and run our Bootstrapper. Of course, now VS is going to bitch that we don't have a Bootstrapper class so let's add that to the project now too.

Now I'm going to make the executive decision to use Unity as our IoC container, so our Bootstrapper is going to inherit from UnityBootstrapper, and to do this we need to include the Microsoft Prism Libraries. Again following the walk-through in the Guidance I created a Libraries folder in my solution folder. I copied in the Prism libraries (I'm just leaving out the MEF libraries, since, at least for now, I won't be using them), and added the references to my project. Our development team usually keeps our 3rd party libraries outside the solution, so that will probably change, but good for now.

After adding those references I just need to override the CreateShell and InitializeShell methodsof the UnityBootstrapper to create an instance of the Shell, set it as the MainWindow of our App and show it. I'm sort of not crazy about the reference to the App here, since it would be nice to be able to unit test the bootstrapper (and, more importantly, automate that test) without it. It isn't doing much at the moment, plus I may see what MSTest can do for me in order to really test it. That's for tomorrow.
plus I may see what MSTest can do for me in order to really test it. That's for tomorrow.