Tuesday, August 21, 2012

Are our words really wasted?


Scott Hanselman told us that our words are wasted, and then went on to ask how his post was controversial?  Well...

  • He said that my words are wasted?
  • He told me that I'm not blogging enough?
  • He implied that Google and Facebook will SURELY fail?
So, perhaps there is a bit of controversy there :)

It's not like I don't agree with Scott on a number of points.  I've hosted my own blog in the past and even written my own blogging platform.  In terms of portability, I created BlogML to help allow people to move from service to service.  And regardless, controversy is not such a bad thing.  I just don't think that the article was his best piece of writing (I hold him to a much higher standard than I hold myself :)  One point I have trouble with in the post is the list of things that we apparently find ourselves asking over and over again:

AttributeG+FacebookLiveOther?
Is a free or cheap social network for the people?????
Let's me control my content?????
Allows export of everything ?????
Allows me to own what I type?????
Has an open API for my content?????
Allows search posts over a month old?????
Limits available usernames?????
Allows me to be 'verified'?????

Is that the full list of 'product attributes' or is it constantly changing.  And how do you find a single product which meets those needs while also staying current with constantly changing expanding list of product features that users need.  And what is the cost of meeting those needs with any single boxed product?

The current state of software services is such a moving target and I'm continually rethinking how I use my journal to link it with and help my daily activities.  That includes things such as being able to link activities by location, having content delivered to whatever device I'm on, sharing stuff easily through a variety of ways, embedding rich content such as maps and documents through to having a variety of different privacy and sharing options.

I feel like I'm trying stuff out to help improve my life's process flow.

So I tend to focus on the benefits of that I get from "renting" an existing service and not so much on the fact that some greedy NASDAQ listed company is making money from my effort.  Those benefits include:

  • I get a fancier "apartment" :)
  • There are often added perks over the choices I have otherwise
  • I get to share costs/overheads with multiple tenants
  • It is generally cheaper and easier to relocate
  • Boring maintenance work is often removed
  • For me, I believe that there are reduced risks

So, as with most things in life, there are choices and trade-offs.

Tuesday, August 14, 2012

Constructors in Dart

Recently I've started using the Dart language and tools to maintain my interest in programming.  Coming from a .NET and JavaScript background, many of the features of the language are familiar to me but there are also some syntactical aspects that I like and which are particular to Dart.

One of the areas within the language that I'm enjoying is the constructor syntax.

Simple and default constructors
Every class will have a default constructor which is provided in case you don't specify your own.  To specify your own constructor, simply create a method with the same name as the class.

class WordContainer
{
  List _wordList;
  
  WordContainer(List words)
  {
    _wordList = words;
  }
  
  void Print()
  {
    _wordList.forEach((word) => print(word));
  }
}

In the above example, as you might expect, we have a simple constructor which allows us to construct new instances the class by passing in a list of words:



Assignment of constructor arguments to member variables
A handy shortcut exists in the Dart language for assigning constructor arguments to member variables which can save keystrokes and time.

class Point
{
  num x, y;
  
  Point(this.x, this.y);
}

Named constructors and default parameters
Another nice feature of Dart is the named constructor syntax which is designed to make it easier to identify the purpose for different constructor overloads.  In the following example I have created a separate, named constructor which takes a single word and provides an optional parameter to specify the number of times to add the single word to the word list.  To differentiate the purpose of this constructor method, I will give it a unique name.

class WordContainer
{
  List _wordList;
  
  WordContainer.fromSingleWord(String word, [num times = 10])
  {
    _wordList = [];
    
    for(var i = 0; i < times; i++)
    {
      _wordList.add(word);
    }
  }
}

When calling the overloaded constructor method, it now becomes more readily apparent as to what is happening from where the code is called: