Author Archives: brettedotnet

MDC 2012

Had a great time at MDC 2012 for those who had problems getting my presentation files you can get them here.

I have included the .bak for the pitty love database as well.

Enjoy,
Brette

Advertisements
Tagged

TechMasters After Dark Oh My!

Last year around October I decided to finally attend my first TechMasters meeting. It had been something I had thought about for a few years but I just never pulled the trigger. But one Tuesday morning last October I got myself up a bit earlier and headed out to the Benchmark Learning Building where we host our weekly meetings. Knowing absolutely nothing about Toastmasters and even less about TechMasters I had no idea what to expect. But what I did know is that I had several things I wanted to improve upon personally. As a software developer for 10+ years I had become fairly comfortable with my technical skills. My communication skills however, like many of us technical types had a lot of room for improvement.

At my first meeting I was given a warm greeting from the regular members, so much so that I came back the next week and signed up. After just 6 months of attending regular meetings I can honestly say that my presentation skills have very much improved. I have spoken at my first user group, and am hoping to be speaking at the upcoming Microsoft Developer Conference. While these skills are always a work in progress and I am a long way from where I hope to be in the future, I feel like I now at least have tools at my disposal to help me communicate more effectively than before I started. These tools do not just apply to presentations, but also when communicating with people one on one or in small groups. TechMasters gives you weekly practice at impromptu speaking, listening, public speaking, and even delivering jokes to a group in a fun and friendly environment. And these skill are useful in every aspect of your life.

So why the blog post? Well it’s simple, I think its a great thing and would like to see more of the local technical folks show up. I know mornings are hard, but guess what? Now you have a chance to check it out after work. This month on April 24th we are launching the TechMasters After Dark Series. A free event where you can see some of our speakers in action. This month one of our most veteran members Paul Scivetti will be delivering a presentation on how to give presentations! Paul is a very dynamic speaker who regularly speaks at the local user groups and the like. Not only is Paul a great speaker, I was lucky enough to have him as my mentor when I joined (we have a mentoring program). And as such I can tell you from personal experience he has a lot of great information to share on the topic of presenting.

So if you are like I was, and have always been curious but just never made it to a morning meeting here is your chance!

Hope to see you there!

Brette

Don’t Play With the Monkeys (Ice-Breaker)

The year was 2010 and the location was Botswana Africa inside a wild game reserve just south of the Zimbabwe border. I was walking back to our camp site from the showers wearing only the towel around my waist when I inadvertently crossed paths with a monkey that was tending to her young. Unhappy with my presence she lunged at me chasing me back into the shower area. As I stared at the hissing monkey now blocking my exit I began frantically calculating my options.

  1. Run into the shower stall, but that would offer little protection
  2. Try and run past the monkey, but wearing only a towel and flip flops this was great option
  3. I could wait, risking a confrontation with the monkey.

It was at this point I asked myself how on earth did I get end up here?

To answer that question I have to go back to 8th grade when my parents reluctantly purchased me my first guitar. I say reluctantly because my general pattern was to lose interest in everything I started very quickly. This was not the case with guitar however. I became obsessed with it; at school I joined the Jazz band, outside of school I played in rock bands, I started taking lessons two times a week, and even started to learn how to build them.

It was my obsession with guitar that led me to college. Mostly interested in Classical guitar by this time, I enrolled at the University of River Falls, while a school mostly known for agriculture they also have one of the best classical guitar instructors in the Midwest. Music became my life, six hour days in the practice rooms, music theory parties, composition contests it was a great time in my life.

About two years into my study, my guitar teacher expressed interest in developing a web site for his group the Minneapolis Guitar Quartet. Knowing absolutely nothing about computing at that time and even less about web development I volunteered to do it. Using my roommate’s computer and a HTML book from the computer science department’s library I built my first website. It was at this point that I found yet another obsession. Programming! Shortly after that I added an additional major in computer science. This was the happiest day of dad’s life, since he had hopes that I could actually get a job after college.

Fast forward 4 years, with my music degree and computer science degree in hand, I found myself in Winona, MN working as a web developer for a company called Fastenal. It was here where I met a woman from India name Pragya who after several months of begging finally agreed to go out on a date with me. While it’s true I begged for the first date, I want to make sure to state that it was her who asked me to marry her! In 2005 Pragya and I were married in New Delhi India, in a traditional Hindu wedding.

By now you must be thinking, what does this all have to do with the Monkey? I promise I am getting there!

When my wife came to Iowa for college her parents left India to start a manufacturing company in Africa. With half of her family in India and her parents in Africa we travel to both places quite a bit. In 2010 we went to Africa, and traveled to the Chobe game reserve for a safari, and this is where I found myself face to face with the angry monkey.

So how did I get here? My parents got me a guitar, guitar led me to college, college let me to computing, computing led me to Pragya, and Pragya let me to Africa and Africa to this very angry monkey.

So what happened? Well just as the monkey was about to lunge at me, out of nowhere a man with a big broom smacked the monkey out of the door way. The man started at me and said, “Don’t play with the monkeys”

 

Frameworks and Austrian Economics

Inception

An interesting thing happened to me a few years back while sitting in a Sprint Retrospective. A nameless developer on our team voiced some frustration with our UI Framework. Person X stated that that the UI Framework was too constraining. Since I was largely responsible for this aspect of the system I was interested in hearing the developers concerns. When pressed to describe the areas Person X felt were too limiting, it became clear that the developer was trying to work out of band and out of pattern. The developer was trying to introduce a new UI pattern not yet discussed or agreed upon by our team and users.  It was in this moment it occurred to me that while frameworks need to support the needs of the system, they should also prevent developers from introducing things that are not well understood at a whim.  This particular conversation was the seedling for my particular view of how frameworks should support applications. I call it Framework Organics.

What is the Role of a Framework

This question will likely elicit 10 different answers if you ask 10 different people. And though you did not ask here is my answer.

A framework should box developers into the understood and agreed upon patterns while allowing for the necessary changes agreed upon over time.

In greater detail a framework should provide support for concepts that are relevant to the system being developed. In stark contrast a framework absolutely should not support any random concept a developer can dream up. It should limit the ability of developers to travel to far off into the weeds. Protecting your users from cowboy coders who are spinner happy!

Along with limiting developers from introducing new concepts, a well-designed framework should be able to adapt to change over time. It should be resilient and extendable to meet any reasonable need that may arise throughout the development lifecycle. This does not mean that you need to build an over engineered goliath of a framework that supports every possible permutation possible. Because you can’t and no one I have ever met can.

Organics and Austrians

One of my favorite economists F.A. Hayek wrote an entire book called ‘The Fatal Conceit’. In this book he makes the case against socialism. Political affiliation aside his premise is worth mentioning here. Hayek believed as many Austrian Economists did/do, that it was impossible for central planners to understand that millions of interactions of the millions of people they govern. He also argued that any attempt to plan around these interactions was a form of conceit that was doomed to fail. Austrians believe that the framework of society was grown overtime in a free market sort of way. If problems came up they were addressed and solved, it was this sort organic evolution that Austrians feel allow us to strive as we do today.

Again this is not meant to be a political rant. But parallels can be drawn between concepts in software design and economics.  The Agile Method and the various approaches of iterative development it has spawned clearly harness the power of organic growth over time. Short cycles of problem/solution/repeat are much more in line with Hayek’s ideas than they are with say the Keynesian approach to planned government. In contrast the Waterfall methodology is more in line with Socialism. Waterfall is far more plan centric it’s ridged, and less adaptable to change over time. Waterfall does what it can to make sure change is as painful and costly as possible. It’s no wonder at all why that methodology is for the most part dead.

Bringing Back In

Ok so I am not an economist and I really do not want to be tagged a right wing radical because of this post. But the point here is simple, frameworks should evolve organically overtime. Yes this means constant refactoring of your core code throughout the life of a project. When new patterns are introduced, your framework will change and code sweeps will need to happen. As your product grows so will the level of support your framework provides but on an as needed basis. Keeping in mind the framework should also limit developers to the current set of patterns that are supported by the current revision of your framework.

The benefit of framework limitation should not be underestimated. By limiting concepts allowed in your systems users start to learn and understand stereotypes. As a result new screens seem familiar to them, less support questions arise, and your application is usable unlike ITunes for the PC. The benefits are not only seen by users. Developers now have a common language when designing new screens. “This fits our Master Detail pattern”; “This fits our search pattern”. And if a scenario does not seem to fit existing patterns perhaps the introduction of something new is needed. And the cycle continues in a nice organic sort of way!

 

Enjoy

Do You DoEvents?

Often times during the development of enterprise software requirements arise stating that specific operations need to be handled both synchronously and asynchronously. A perfect example of this is printing. Perhaps a user wishes to print a document and wait for confirmation of a successful print operation before moving on to the next step of their business process. Or perhaps the user wants to request a print operation for multiple documents in a fire and forget fashion. In one case we should provide some sort of user interface cue as to the status of the print operation and in the other we just fire and forget, while hoping everything works out.

Thinking Synchronously

So we have a WPF window with a Print Button we also have a label to indicate the status of the running print job.

Some XAML

<Window x:Class="WpfApplication2.Print"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 Title="Print" Height="300" Width="300">
 <Grid>
 <StackPanel>
 <Button Command="{Binding Path=PrintCommand}">Print</Button>
 <Label Content="{Binding Path=PrintStatus}"/>
 </StackPanel>
 </Grid>
</Window>

Code Behind

using System.ComponentModel;
using System.Threading;
using System.Windows;

namespace WpfApplication2
{
    /// <summary>
    /// Interaction logic for Print.xaml
    /// </summary>
    public partial class Print : Window, INotifyPropertyChanged
    {
        #region Private Data Members

        private string mPrintStatus;

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="Print"/> class.
        /// </summary>
        public Print()
        {
            InitializeComponent();
            DataContext = this;
            PrintCommand = new RelayCommand(PrintExecuted);
            PrintStatus = "Ready";
        }

        #endregion

        #region Private Methods

        /// <summary>
        /// Prints the specified parameter.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        private void PrintExecuted(object parameter)
        {
            PrintStatus = "Print Executed";
            //Long Running Print Operatoin
            Thread.Sleep(1000);
            PrintStatus = "Print Completed";
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the print status.
        /// </summary>
        /// <value>The print status.</value>
        public string PrintStatus
        {
            get
            {
                return mPrintStatus;
            }
            private set
            {
                mPrintStatus = value;

                var handler = PropertyChanged;
                if (handler != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("PrintStatus"));
                }
            }
        }

        /// <summary>
        /// Gets or sets the print command.
        /// </summary>
        /// <value>The print command.</value>
        public RelayCommand PrintCommand
        {
            get;
            private set;
        }

        #endregion

        #region INotifyPropertyChanged Members

        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}

Looking at the code here you can see that the intended behavior is as follows.

  1. User Clicks Print Button
  2. PrintCommand is executed
  3. A label used to show the print status is updated from ‘Ready’ to ‘Print Executed’
  4. The long running Thread.Sleep is called simulating a synchronous print operation
  5. Once complete the status is again changed to ‘Print Completed’

This sequence of events does actually happen, the problem however is that it all happens within the execution scope of the  PrintExecuted method. Since this method is blocking until completed the user never sees the nice status updates we provide.

Before Click

Before Click

When the window is loaded the status is set to ‘Ready’ as seen in the image on the left. Once the print button is clicked we want to change the status to ‘Print Executed’ and finally when the PrintCommand is complete to ‘Print Complete’. However since the updates to the status all happen while the UI thread is blocking, the status of ‘Print Executed’ never makes it to the user. Instead the status will transition from ‘Ready’ directly to ‘Print Completed’  upon command completion. This presents a pretty serious issue if you need to give the user meaningful feedback about what is going on. On interesting way to get around this is to use DoEvents.

Do a What?

If you came to the wonderful world of WPF DoEvents was something new to you. In fact when I first presented this problem to a colleague with a strong Win Forms background he was quick to mention this. So what is it?

Take a look

To make a long story short DoEvents allows you to interrupt current event processing in order to process waiting events in the message pumps message queue. The good/bad news depending on your view of such things, is that if you need to replicated DoEvents in WPF you can. Because  WPF and WinForms both leverage the User32 message pump. the solution ends up to be very simple Lets take a look and what our PrintExecuted method might look like.

#region Private Methods

        /// <summary>
        /// Prints the specified parameter.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        private void PrintExecuted(object parameter)
        {
            PrintStatus = "Print Executed";
            Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { }));
            Thread.Sleep(1000);
            PrintStatus = "Print Completed";
        }

        #endregion

This approach give us the desired behavior of all of the status updates being presented to the user. Why this may not be a great illustration of proper use of an admitted hack. It is always good to have another tool in your toolbox.

Enjoy!

Advertisements