TypeCasted

My .Net Adventure

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

with 2 comments

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”

 

Written by brettedotnet

November 10, 2011 at 4:25 am

Posted in Toastmasters

Frameworks and Austrian Economics

leave a comment »

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

Written by brettedotnet

October 18, 2011 at 9:20 am

Team Dynamics

with one comment

Team dynamics play a large part in the success or failure of a project. Often times they play a bigger role in an application making it successfully to production then the collective skill set of a team. I have had the opportunity to work on teams that have had both good and bad dynamics. The difference is night and day. A team that works well together and collaborates  is far more motivated, excited, and concerned with over all quality of the end product. Sadly the experiences I have had on teams with lousy dynamics are just the opposite. Team members will isolate themselves, quality will drop exponentially and team members stop caring because they are frustrated. This reduces the chances of creating a usable finished product to almost zero.

Something that I have found to be true in my tenure in the software development business is that personalities to a very large degree make or break a team dynamic.  In fact more important than the enumerated skill sets of a team are the personalities of the team members. Personality say a lot about a developers ability to work within the confines of a team and a methodology. Below I describe some of the personality types that I have seen on the various teams I have been on over time.

The Cherry Picker

The cherry picker hunts and pecks away at the requirement backlog, only working on requirements he/she finds interesting or easiest. What is worse, is that often times a Cherry Picker will break down a given requirement into several parts, again only working on the aspects he/she finds simple or interesting. Cherry Pickers never finish a requirement. They are done when they get board or confused caring very little about the state of the work  when they quit. This leads to the endless cycle of a requirement going from dev to test and back to dev. Cherry Pickers are bad.

The BA Developer

The BA Developer is one of the most frustrating personality types to work with. A BA Developer will find things he/she believes are shortcomings or missing requirement in a current system, decide without consulting other team members that it is important and do the work right now (99% of the time there is no defect or requirement to track the work against.) Because the BA Developer knows that the actions he/she is taking will be looked down upon by other team members no design discussion happens leading to fragile implementations of ‘features’ that may or may not be needed. Once the BA Developer completes his/her ‘enhancement’ the BA Developer will contact the team member he/she feels will be least appalled by the actions taken by the BA Developer. The BA Developer will then show the perceived weak team member the changes that were made. A BA Developer if confronted will claim things like ‘I have not checked anything in, I just wanted to see how it would look’ caring very little to the untracked wasted time that brings down the overall velocity of a sprint. The BA Developer is in my opinion one of the most toxic personality types to have on a team. Trumped only by the absolute worse The Sneaker.

The Sneaker

The Sneaker does not care about process, teamwork, standards, patterns, requirements or quality. You may be totally unaware that a Sneaker is among you until  you see first hand their handy work. The Sneaker is much like BA Developer with one critical infuriating difference. The Sneaker skips the showing, checks in the code and says nothing of it. When source control fingers The Sneaker, and you choose to confront the offender The Sneaker will say things like ‘well I mentioned it’, or ‘I talked to this person or that person’. You should fear above all other personality types The Sneaker.

The No Google-er

The No Google-er seems harmless at first, though somewhat annoying. When faced with a problem, their first instinct is to ask whoever is near by. Overtime if other developers allow this to continue, The No Google-er actually forgets about the vast resources available to us by simply asking a question to the handy text box on www.google.com. Often times they are in denial that a thing called the ‘internet’ exists. The No Google-er not only wastes other team members time he/she is responsible for a disproportionate percentage of defects reported, a problem that is greatly compounded around vacation season when their human search engines are out of town.

The Watcher

The Watcher is a strange personality type who’s motivation is as illusive as it is unpredictable. The single trait that all Watchers have in common however, is that they will hold others up to standard they themselves refuse to follow. A Watcher is the first to comment about other developers non-standard development practices while ignoring broken build notifications. Those who can do, those who can’t watch.

The Waiter

The Waiter is harmless enough, however they can be frustrating. Waiters are very common and come full of wonderful catch phrases like, ‘we are kind of low on work, do I did some online reading’, ‘I am waiting on ______’. Or the classic ‘I am ready to take on something new’. The Waiter is good in that they do not do to much work thus limiting the damage they can do. However they often times pass on work to more advanced team member out of sheer laziness stating that the work is above their skill level.

So there it is! The most common personality types I have run into in my career so far. I am sure you all have your own list, feel free to add them.


Written by brettedotnet

June 17, 2010 at 3:00 pm

Do You DoEvents?

leave a comment »

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!

Written by brettedotnet

November 11, 2009 at 5:26 pm

A Better Sandwich!

leave a comment »

When considering topics for blog posts more often then not I filter out ideas based on their technical merit. I try my best to offer solutions to problems that I face everyday as a software developer in an attempt to repay the many others who’s blog postings have helped me. This post however does not fall into that category. So feel free to ignore it.

In a recent dinner with my wife and her parents. I retold a story that my wife has heard many times before. This particular time however, I managed to make some correlations to software development that had not previously occurred to me. So before I go any further let me retell the story…. Again…

In the beginning…. Wait wrong story.

When I was in high school I was dating a girl who in all accounts was much smarter then I was. However since I was a rocking guitar player and all around rebel she found my charms irresistible.

*The statement above is a complete embellishment except for the fact that she was indeed much smarter then I am*

One night while the two of us sat in my parents kitchen, I decided to take full advantage of the refrigerator filled with all of the parental subsidized food you could imagine, and make us some sandwiches. I grabbed some lunch meat, lettuce, tomatoes, mustard and all the other standard sandwich fixings available. I reached for the bread box to grab the bread, and the sandwich making commenced.

First up my sandwich (because I am selfish). I slapped down two slices of bread and started to add the fixings. On one slice went the meat, and on the other slice all of the fixings, salad, mustard, onions etc. Once all of the fixings were in place I grabbed each fully loaded slice and tried my best to marry the two without dumping the fixings all over. I managed to get the sandwich together like I had with all sandwiches before. After all I was not at all new to the art of sandwich making with free ingredients. I took a look over at my girlfriend expecting a look of awe as she basked in my artistry. Instead I got a look of utter confusion mixed in with a little disgust. She said, “Really? That is how you make a sandwich?” This was the beginning of the end for use as a couple. She then continued to tell my how much easier it would have been if I put all of the fixings on one slice of bread, and simply placed the second slice on top.

Her words flipped my world upside down. I could not believe what she was saying! It was a perfect solution. A perfect solution to a problem I never thought existed! I then proceeded to make her the most efficiently crafted sandwich I had ever made. It was a work of art that would bring the likes of Picasso to tears.

And that is the story. My story of a better sandwich! So why blog about it?

Well at that moment when my girlfriend pointed out the problems in my process I realized that had she not done so, I would have continued making sandwiches that way. Who knows how long or how many sandwiches would have fallen victim to my intellectual laziness. The reason this horrible process would have continued is because despite its short comings it did in fact work. At the end of this process I could always partake in some tasty sandwich goodness.

The point here is simple. You can go years and years doing what you do the way you always have. The results after all in this case were just fine. The same is true in software development. We can follow all of the patterns we have always followed. We use all of the best practices we have spent so long learning and mastering over and over again. And as long as we do that and nothing major changes we can turn our brains off and churn out application after application, object after object, and pattern after pattern. And all along never even considering that there may be a much better way to make a sandwich. And if we are not looking for ways to make our sandwiches better, what the hell is the point!

Enjoy!

Written by brettedotnet

August 2, 2009 at 11:32 am

Follow

Get every new post delivered to your Inbox.

Join 34 other followers