Monthly Archives: August 2009

Is the business model of free a wise business model?

http://www.wired.com/wiredbizprogram/WIREDBusinessConferencePaper.pdf


http://www.wired.com/wiredbizprogram/videolibrary.html


Is the business model of free a wise business model?


I’m not sure this is a wise move…..


“Microsoft is another example of
smart use of the free model, says
Anderson. The company protested
quietly but took little legal action
while its Windows operating system
was widely pirated in China. Microsoft
executives were betting that each
pirated copy of the operating system
would help build a base of customers
who would pay for the convenience
of Windows support when they could
afford to. “Looking the other way,”
says Anderson, “Microsoft let pirates
be their best marketers, so that some
day that piracy would come back as
revenues.” Anderson says that the
Microsoft example perfectly illustrates
two major types of customers in
the world of free. One group is price
sensitive, and looks for the lowest
cost no matter what. The other is risk
sensitive, willing to pay—sometimes
a lot—for support, reliability, and
timeliness.”


I would really not like it if some VP somewhere made a conscious decision to look the other way and then use WGA to get back revenues.


What I see is that some of those legal Microsoft customers feel that the risk of WGA is not worth the benefit.  If the business model of WGA i is to catch some of those pirates and yet to hopefully not annoy too many legal customers, I’m not sure that’s a wise strategy.

Download IE8 and MSFT will donate $1.15 to Feeding America (charity)

It doesn’t matter what flavour you prefer when you browse the big interweb today, you can still contribute to helping out.


Microsoft is donating $1.15 for each download of IE8 from here – if you’re upgrading from IE6 they’ll double the donation.


The donation is given to Feeding America.


microsoft-logo logo-temp


 


So, contribute in your own way – and it costs you nothing – by clicking here to download IE8.

Eagerly anticipated Access 2007 hotfix

Description of the Access 2007 hotfix package (Access-x-none.msp, Ace-x-none.msp): August 25, 2009
http://support.microsoft.com/default.aspx?scid=kb;en-us;973405

Dunno what happened in the KB article title but this is a hotfix a lot of folks have been waiting for.

Tech.Ed AU 2009 – Sara Ford fan club

A good friend of mine, Mike, is even more of a social butterfly than i am. So, since he’s totally excited about going to Tech.Ed this year (who isn’t???) and because he’s a geek, he kicked off the Sara Ford Fan Club at Tech.Ed AU 2009.


After talking things over a few times it’s been organised to have a Geek Meet-Up on Tuesday evening, where Sara Ford will be attending too – check out the LinkedIn Tech.Ed Australia Group for details:


Tech.Ed Australia (Teched)


Lastly, we talked about getting some buttons made up – and Mike came through with them.


sffc


So, if you, like many many others are fans of Sara Ford seek us out at Tech.Ed and get your own :)

What is a Class?

Humans like to classify things, to find similarities in things, and to group
them accordingly. Things with similar attributes (properties) and behaviors
(methods) are grouped. In object-oriented terminology, the definition of
the properties and methods that describe a particular classification is called
a class. A class defines a particular object type. You can think of a class as a
blueprint, providing the details of how objects of that type are made.

[To begin with an overview of OO, start here.]

A cookie cutter is another analogy often used to illustrate the relationship
between objects and a class. The cookie cutter is the class and
provides the definition; it specifies the size and shape. The cookies are the
objects created from the cookie cutter class.

For example, an employee class can have name, address, and occupation
properties. Sam Smith and Jessica Jones are both objects from the
employee class. Likewise, a time sheet class can have employee, date, and hours properties and a calculate pay method. Each person’s weekly time
sheet is then an object from the time sheet class.

A specific object created from a class is called an instance of the
class. Each instance can have values for the defined set of properties and
can perform the defined methods. So Sam is an instance of the employee
class, and Jessica’s time sheet for last week is an instance of the time sheet
class.

The set of properties and methods described by a class are often called
class members. A class defines the members, including the actual code to
maintain the property values and perform the methods. Each object that
is an instance of that class can execute the methods and retain values for
each property.

A class itself normally does not maintain state, meaning that it normally
does not have any property values. Nor does it normally execute the class
methods. Instead, the class defines the properties and contains the implementation of the methods that are used by each object created from the
class. Each object has values for the properties and performs the methods.
You do not eat the cookie cutter or fill out a time sheet class. You eat each
cookie and fill out each individual time sheet.

The .NET Framework itself is composed of a set of classes. For
example, the button in the Visual Studio Toolbox represents a Button
class. Each time you add a button to a form, you create an instance of
that Button class. The Button class has specific defined methods, such
as Focus, and properties, such as Name and Text. The Button class
itself does not have a value for the Name or Text properties. Nor can it
have focus. Instead, it contains the implementation of the Name and Text
properties and the Focus method. The Button objects that you create as
instances of that Button class have values for the Name and Text properties
and perform the Focus method.

Code you write normally resides in a class. If you type some
code in a form, your code is in the form’s class. Even if you write code in a
Visual Basic module, the code compiles as a class!

If you have never created a class, the following example may help you
visualize the code for a TimeSheet class.

In C#:

public class TimeSheet
{
    public Employee CurrentEmployee { get; set; }
    public decimal TotalHours { get; set; }

    private DateTime _WeekEndingDate;
    public DateTime WeekEndingDate
    { get
        { return _WeekEndingDate; }
        set
        {
            if (value > DateTime.Now.Date)
                throw new Exception(
                    "Date must be on or before today’s date");
            _WeekEndingDate = value;
        }
    }

    public decimal CalculatePay()
    {
        return CurrentEmployee.HourlyRate * TotalHours;
    }
}

In VB:

Public Class TimeSheet
    Private _CurrentEmployee As Employee
    Public Property CurrentEmployee() As Employee
        Get
            Return _CurrentEmployee
        End Get
        Set(ByVal value As Employee)
            _CurrentEmployee = value
        End Set
    End Property

    Private _TotalHours As Decimal
    Public Property TotalHours() As Decimal
        Get
            Return _TotalHours
        End Get
        Set(ByVal value As Decimal)
            _TotalHours = value
        End Set
    End Property

    Private _WeekEndingDate As DateTime
    Public Property WeekEndingDate() As DateTime
        Get
            Return _WeekEndingDate
        End Get
        Set(ByVal value As DateTime)
            If value > Now.Date Then
                Throw New Exception( _
                "Date must be on or before today’s date")
            End If
            _WeekEndingDate = value
        End Set
    End Property

    Public Function CalculatePay() As Decimal
        Return CurrentEmployee.HourlyRate * TotalHours
    End Function
End Class


The first line defines the class’s scope and name. In this case, the class
is named TimeSheet and is public.

The next set of code defines the private data, called backing fields, and public accessors that provide access to that data. This follows the concept of encapsulation. For example, the private _WeekEndingDate backing field variable contains the value of the time period property. Since this variable is private, it is hidden and cannot be accessed except from within this class. The public WeekEndingDate Property statement implements the get time period and set time period functionality. Any code that needs to set or get the time period uses this public property.

NOTE: The C# code uses auto-implemented properties for the TotalHours and CurrentEmployee. Auto-implemented properties are a short-cut for defining a backing field with its associated accessor. The compiler defines the private backing field for you. You can use auto-implemented properties any time you don’t need extra code, such as validation, in your property statement. (VB is getting auto-implemented properties in VB 10 that is coming with VS 2010.)

By implementing properties using private backing fields and public
Property statements, you can associate code with the setting or retrieval
of the data value. In the WeekEndingDate example, the code that sets the
date validates the date before assigning it.

The code at the end of the class in the preceding example demonstrates
a method—in this case, a function that calculates the pay. In Visual
Basic, methods are implemented with functions or subroutines. In C# the syntax is the same for both functions and subroutines.

To access the properties and use the methods of a class, you normally
begin by creating an instance of the class and storing a reference to that
instance in an object variable. You then use that object variable to get or
set properties and execute methods on the resulting object.
The following code uses the new keyword to create a new object from
the TimeSheet class. It then sets the properties on the object and executes
the CalculatePay method on the object.

In C#:

TimeSheet ts = new TimeSheet();
decimal totalPay;
ts.CurrentEmployee = Jessica; //Jessica is an Employee object
ts.WeekEndingDate = new DateTime(2009, 8, 20);
ts.TotalHours = 51;
totalPay = ts.CalculatePay();

In VB:

Dim ts As New TimeSheet
Dim totalPay As Decimal
ts.CurrentEmployee = Jessica ‘Jessica is an Employee object
ts.WeekEndingDate = #8/20/2009#
ts.TotalHours = 51
totalPay = ts.CalculatePay

The new keyword creates a new instance of the TimeSheet class, and
a reference to that instance is stored in the defined object variable (ts).
Using the object variable and a period, the remainder of the code sets the
object’s properties and calls the method to calculate the pay.

As stated earlier in this section, objects normally maintain state (property
values) and execute methods. The class itself normally does not maintain
state or execute methods. However, .NET does support static
class data and static class methods.

Static class data (also called shared data) is data that the class
retains, independent of any object. Use static class data any time you want
to retain data that is shared between all objects, such as to keep a count of
the total objects created from a class.

A static class method (also called a shared method) is a method
that can be executed independent of any object. Static class methods are
good for utility functions when you don’t need to perform a process on
any particular object. The MessageBox and Debug classes in the .NET
Framework both have static class methods, so you don’t need to create an
instance of the class to use the methods.

NOTE: If you write code in a Visual Basic module instead of a class, all the properties and methods in the module are static. You cannot create an instance from a module.

Building code as individual classes logically separates the code, with
each class defining its own data and implementing its own methods.
Having code organized into logical classes makes finding code for maintenance and enhancements effortless and produces a system that is much easier to extend. It also simplifies testing and debugging, because you can test each class as an independent unit. By using OO, you can manage the complexity of your application.

(Based on an except from "Doing Objects in Visual Basic 2005".)

Enjoy!

What Are Objects?

Objects are things. People, companies, employees, time sheets, and ledger
entries are all types of objects. In object-oriented terms, the word object
is used to describe one specific thing, such as Sam Smith the carpenter at
3322 Main Street and the May 15th time sheet for Jessica Jones.

[To begin with an overview of OO, start here.]

Objects have data associated with them called properties. Sam Smith
has a name, occupation, and address. The time sheet has an employee
name, time period, and hours worked.

NOTE: In object-oriented literature, properties are sometimes called attributes, resources, or even just data.

Objects also do things. The time sheet is filled out, validated, and
submitted for payment. In real life, we fill out time sheets, validate them,
and submit them for payment. In a computer system, the time sheet can
perform these operations for itself. The things an object can do are defined
with methods.

NOTE: In object-oriented literature, methods are also called behaviors,
services, operations, or responsibilities.

Objects can be real-world things, such as an employee or time sheet.
Objects can be conceptual things, such as an engineering process or payroll.
Objects can also be implementation-specific things, such as forms,
controls, and DataSets. The same object-oriented concepts apply regardless
of whether the object is based on the real world, on a concept, or on
the implementation.

Since objects are fundamental to understanding object orientation,
it is important that you can recognize objects and define their appropriate
properties and methods. So take a moment to think about the things
around you. What objects do you see? How would you define their properties
and methods?

Your phone has properties such as color, volume, and mute. It has
methods such as increase volume, decrease volume, turn on mute, turn off
mute, dial, answer, and transfer. An employee has properties such as name,
address, and occupation. An electronic time sheet has properties such as
employee name, date, and hours. It has methods such as calculate pay.

An object’s property values should not be directly accessed by something outside the object. For example, the time period should not be adjusted except through a get time period method, and the employee name would not be retrieved except through a get employee name method. This concept of hiding the internal data is a part of what is called encapsulation and is a key premise of object-oriented programming.

Every object is of a specific type. For example, the object defined as
Sam Smith the carpenter at 3322 Main Street is an employee object type,
and the May 15th time sheet for Jessica Jones is a time sheet object type.
All the objects of a particular type have the same set of properties and
methods.

From a programming perspective, you can define your own object
types using classes. Or you can use the object types provided in the .NET Framework. In either case, you first create an object of the desired type, and then you can set or get the object’s properties and call its methods.

The following code creates an object using the .NET Framework
Timer object type. It then sets the object’s Interval property to define
how often the timer goes off and executes its Start method to start the
timer.

In C#:

Timer myTimer = new Timer();
myTimer.Interval = 1000;
myTimer.Start();

In VB:

Dim myTimer As New Timer
myTimer.Interval = 1000
myTimer.Start()

The new keyword in the first line of code creates a new Timer object
and assigns a reference to that new object to the myTimer object variable.
To access a property or method of the new Timer object, use the object
variable and a period (.) and then the name of the property or method.

NOTE: When you type the object variable name and a period in Visual Studio,
you see a list of the properties, methods, and events that are appropriate for that object. This demonstrates the List Members feature of Intellisense. Intellisense provides auto-completion and display of class documentation within Visual Studio as you are coding.

Everything in .NET can be accessed as an object: forms, strings,
even integers. Check out this code:

In C#:

int i = new int();
string s;
i = 5;
s = i.ToString();

In VB:

Dim i As New Integer
Dim s As String
i = 5
s = i.ToString

The first line creates a new Integer object and assigns it to i. The variable
i is then assigned a value of 5. The last line calls the ToString method of
the Integer object to convert the number to a string.

NOTE: Even though you can use the new keyword to create integers, it is not
necessary and is not commonly done in practice. It is shown in this example to illustrate that you can work with simple data types as objects.

In .NET, an integer and other primitive data types, such as Boolean
and decimal, are called value types. Value types store and pass their contents
by their actual value. Technically speaking, value types are allocated
either on the stack or inline in a structure. A standard set of value types
are built into the .NET Framework, such as integer and decimal. You can
also create your own value types. You do not need to use the new keyword
for any value type.

More complex data types in .NET, such as strings and arrays, are
reference types. Reference types store and pass their contents as a reference to the value’s memory location. Technically speaking, reference types
are allocated on the memory heap. The .NET Framework provides a set of
built-in reference types, such as string and array. Classes that you create are reference types.

.NET automatically creates a boxed value type for each value type when necessary. Boxed value types allow value types to be accessed like reference types (such as the preceding integer example). In addition, boxed value types
allow you to convert value types to reference types. For example, adding
to the preceding code example, you could assign the integer to an object.
This converts the integer value type to an object reference type.

In C#:

object o;
o = i;

In VB:

Dim o As Object
o = i

This conversion of value types to reference types and vice versa is
called boxing. Boxing has a performance hit, so you want to minimize the
amount of boxing in your application wherever possible.

Variables that are value types each have their own copy of the data.
Therefore, operations on one variable do not affect other variables.
Variables that are reference types, such as object variables, can refer to the
same object. Therefore, operations on one variable can affect the same
object referenced by another variable. Check this out:

In C#:

Timer myTimer = new Timer();
myTimer.Interval = 1000;

Timer myTimer2;
myTimer2 = myTimer;
myTimer2.Interval = 500;

Debug.WriteLine(myTimer.Interval); // Displays 500
Debug.WriteLine(myTimer2.Interval); // Displays 500

In VB:

Dim myTimer As New Timer
myTimer.Interval = 1000

Dim myTimer2 As Timer
myTimer2 = myTimer
myTimer2.Interval = 500

Debug.WriteLine(myTimer.Interval) ‘ Displays 500
Debug.WriteLine(myTimer2.Interval) ‘ Displays 500


This code creates a new Timer object, assigns it to the myTimer object
variable, and sets its Interval property to 1000. It then defines a second
myTimer2 object variable, assigns it to the same Timer object, and sets the
Interval property to 500.

Since myTimer and myTimer2 are object variables, they are reference
types. Assigning one object variable to another object variable sets
both variables to reference the same object. Changing the properties
using either object variable makes the changes to the underlying object.
Hence, the sample code results in 500 for both myTimer.Interval and
myTimer2.Interval.

The one exception to this behavior is strings. Even though strings are
a reference type, assigning one string to another string copies the data so
that both strings do not reference the same data. This provides a more
natural use of strings in your application. For example:

In C#:

string employeeName ;
employeeName = "Jessica Jones";

string employeeName2;
employeeName2 = employeeName;
employeeName2 = "Sam Smith";

Debug.WriteLine(employeeName); // Displays "Jessica Jones"
Debug.WriteLine(employeeName2); // Displays "Sam Smith"

In VB:

Dim employeeName As String
employeeName = "Jessica Jones"

Dim employeeName2 As String
employeeName2 = employeeName
employeeName2 = "Sam Smith"

Debug.WriteLine(employeeName) ‘ Displays "Jessica Jones"
Debug.WriteLine(employeeName2) ‘ Displays "Sam Smith"

Even though employeeName2 is assigned to employeeName and then
employeeName2 is changed, employeeName remains unchanged. The
sample code results in the display of Jessica Jones and then Sam
Smith.

Notice also that the New keyword is not required for strings. Strings
were designed as a special case to make it easier and more natural to work with string variables.

Understanding how to create an object and call its properties and
methods is crucial to any development with .NET.

(Based on an except from "Doing Objects in Visual Basic 2005".)

Enjoy!

PowerShell v2 help file

In PowerShell v2 we get a nice graphical help system that includes the cmdlets, the about files and and the User and Getting Started Guide. It doesn’t include the help for the optional modules though which is a pity.

The default locations on the Start Menu for PowerShell are Accessories – Windows PowerShell.  That is not very good placement considering Windows only really exists to give us somewhere to run Powershell :-)  

In these locations the help files are not visible. If you open up ISE then you can access the help file.

If you pin PowerShell to the start menu on Windows 7 then you get access to the help through the recent files menu.  The help file is located (on my system) at C:WindowsHelpmui409WindowsPowerShellHelp.chm

I keep a shortcut on my desktop and a shortcut to the version 1 graphical help file from the script center.  that way I can compare changes.

Technorati Tags: ,

What is OO?

Today’s world of software design and development is all about managing
complexity. Computer-savvy users want more and more features. Software
products, such as Microsoft Word and Excel, set high expectations. The
business environment requires software to react quickly to shifting corporate
needs. And tools and technologies are changing faster than ever. It is
easy to become overwhelmed by the complexity.

The key to successful software is managing this complexity—and managing
complexity is one of the goals of object orientation (OO).  Object-oriented
means looking at a software system in terms of the things, or
objects, that are relevant to that system and how those objects interact. As
you design and then build your application, you can focus on one object at
a time, temporarily ignoring the complexities of the rest of the system.

OO concepts are used in many professions. For example, when
designing an office, an architect thinks about working spaces, foundations,
frameworks, and plumbing systems. These are the real-world objects. The
architect does not concentrate on the process of pouring the foundation,
hammering nails, or connecting the plumbing, nor on the details of the
data, such as how much concrete or how many nails. These lower-level
processes and details are important but not applicable to the high-level
design of an office building. And without the high-level design, the processes
and data details are irrelevant.

Object orientation does not ignore the data or the process. It combines
the best of a procedure-oriented view (where the focus is on the
process) and a data-centric view (where the focus is on the data) and adds
productivity concepts such as reuse, testability, and, of course, managing
complexity.

Consider a time sheet. Using a data-centric view, the key data elements
are the employee name, date, and hours worked. But just looking at the
data does not provide the full picture of time sheet processing. Using a
procedure-oriented view, the focus is on the process of generating the time
sheet. But this does not consider the bigger picture of how the time sheet
fits into an overall system.

From an object-oriented perspective, the time sheet has data (called
properties) and processes (called methods). It also has relationships to
other objects in the system, such as an employee object, a logging object,
a data access object, and so on.

Thinking about an application in an object-oriented way makes it
easier to break the application into its parts (objects), focus on the most
important aspects of each part, and look at the relationships between those
parts. And since Visual Basic is now a fully object-oriented programming
language, using an object-oriented approach to thinking about your application makes it easier to map these thoughts into object-oriented code.

Excerpt from "Doing Objects in Visual Basic 2005".

For more information on using object-oriented techniques, see the following links:

Enjoy!

Bolding Text in Microsoft Word using .NET

One of the common requirements in working with Microsoft Word from .NET is to bold some text. This is often required to draw attention to specific words within the document.

This code example highlights any instances of the word "was". It can be changed to instead highlight any word you desire.

In C#:

// Add to the top of the code file
using Word = Microsoft.Office.Interop.Word;

// Add to a subroutine
Word.Application Wd;
Word.Document doc;
object missingValue = Missing.Value;

// Start Word and get Application object
Wd = new Word.Application();

// Add a new document
doc = Wd.Documents.Add(ref missingValue,ref missingValue, 
                       ref missingValue,ref missingValue );

// Write some text
Wd.Selection.TypeText("Once upon a time there was a document. " +
                      "The document was fair and fine." +
                      "The document was short.");

// Bold the specified word
foreach (Word.Range w in doc.Words)
{
    if (w.Text.Trim() == "was")
        w.Font.Bold = 1;
}

// Save
object fileName = @"test1.docx";
doc.SaveAs(ref fileName,
            ref missingValue, ref missingValue,
            ref missingValue, ref missingValue,
            ref missingValue, ref missingValue,
            ref missingValue, ref missingValue,
            ref missingValue, ref missingValue,
            ref missingValue, ref missingValue,
            ref missingValue, ref missingValue,
            ref missingValue);

// Close
doc.Close(ref missingValue, ref missingValue, ref missingValue);
doc = null;
Wd.Quit(ref missingValue, ref missingValue, ref missingValue);

// Clean up
// NOTE: When in release mode, this does the trick
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect() ;

In VB:

‘ Add to the top of the code file
Imports Word = Microsoft.Office.Interop.Word

‘ Add to a subroutine
Dim Wd As Word.Application
Dim doc As Word.Document

‘ Start Word and get Application object
Wd = New Word.Application

‘ Add a new document
doc = Wd.Documents.Add

‘ Write some text
Wd.Selection.TypeText("Once upon a time there was a document. " & _
                      "The document was fair and fine." & _
                      "The document was short.")

Bold the specified word
For Each w As Word.Range In doc.Words
    If (w.Text.Trim() = "was") Then
        w.Font.Bold = 1
    End If
Next

‘ Save
doc.SaveAs("test1.docx")

‘ Close
doc.Close()
doc = Nothing
Wd.Quit()

‘ Clean up
‘ NOTE: When in release mode, this does the trick
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()

In both of these examples, the code starts Word, creates a new Word document, and writes some text into the document. It then loops through the words in the document and bolds any that match "was". You can, of course, change this to any word.

The code then saves the document. Since no directory was found, it defaults to the My Document folder.

Notice the missingValue variable in the C# code that is not in the VB code. VB supports default parameters, but C# does not. So any time a parameter is defined for a Word method, C# must provide it. VB will use the default parameter values.

NOTE: A new feature in C# 4.0 (Visual Studio 2010) allows for default parameters in C# as well, dramatically simplifying the C# code that interacts with Word or Excel.

Enjoy!

Quinta Jardim da Serra weekend

I’ve just returned from a really nice weekend on this lovely hotel. Bar services could be a little better and it’s not the easiest place to find, but the hotel is just great! Highly recommended if you’re looking for a nice place to say and relax for a couple of days. Here are some pics I’ve taken during my stay there. And now, it’s time to go back to vacations mode.

Recent Comments

Archives