Gregory's profileStop Making SensePhotosBlogNetwork Tools Help

Blog


    July 01

    The Need to Refactor

    There are times when you look at code and you know it has to be retooled. Yesterday was one of those times.

    I want you to look at a bit of code. The following routine was written by a group of programmers from offshore. One theory amongst my peers is this code was purposefully written this way to get more billable hours. Another theory is the developers just don’t know any better. I am not here to worry about the reasons the code is the way it is, but rather to take you through an exercise in maintaining difficult code.

    First, here is the original code:

    private void WriteDiscoverFile()
    {
        try
        {
            IEnumerator enumerator = null;
            StreamWriter writer = MyProject.Computer.FileSystem.OpenTextFileWriter(
    this.FilePath + this.FileName, false, Encoding.ASCII);
            writer.WriteLine(this.GetFileHeaderRec().ToUpper());
            writer.WriteLine(this.Group.GetGroupHeaderRec().ToUpper());
            try
            {
                enumerator = this.Group.Batches.Values.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    IEnumerator enumerator2 = null;
                    cBatch current = (cBatch) enumerator.Current;
                    writer.WriteLine(current.GetBatchHeaderRec().ToUpper());
                    try
                    {
                        enumerator2 = current.Transactions.Values.GetEnumerator();
                        while (enumerator2.MoveNext())
                        {
                            cTransaction transaction = (cTransaction) enumerator2.Current;
                            writer.WriteLine(transaction.GetDetailTransactionRec().ToUpper());
                        }
                    }
                    finally
                    {
                        if (enumerator2 is IDisposable)
                        {
                            (enumerator2 as IDisposable).Dispose();
                        }
                    }
                    writer.WriteLine(current.GetBatchTrailerRec().ToUpper());
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            writer.WriteLine(this.Group.GetGroupTrailerRec().ToUpper());
            writer.WriteLine(this.GetFileTrailerRec().ToUpper());
            writer.Close();
            writer.Dispose();
        }
        catch (Exception exception1)
        {
            ProjectData.SetProjectError(exception1);
            Interaction.MsgBox("Error During File Write Process.  Error Description:" +
    exception1.ToString(), MsgBoxStyle.OkOnly, null);
            ProjectData.ClearProjectError();
        }
    }

    When you first see this code, you probably wonder what is going on? How can I maintain this? But a closer look at the code gives some hints to what is happening. Let’s break it down, in English. Here are the steps:

    1. Create a writer to write out lines
    2. Write the header lines
    3. Get the enumerator from the batches collection (it is actually a SortedList object)
    4. Loop through the batches collection using the enumerator
    5. For each batch, get the enumerator for the transactions collection
    6. Loop through each transaction
    7. Write out footers
    8. Close writers

    Let’s go step by step.

    First, the signature leaves us where we cannot easily unit test the code. There is too much magic being pulled from the object at hand, so we change this to get rid of the magic. The result is the following signature:

    private void WriteDiscoverFile(string fullFileName, bool append, Encoding encoding, Group group)
    {
    }

    Although I am only passing the information from within the class, this allows me to mock the Group object so I can test the code in a predictable manner rather than running the production file and then examining for mistakes. 

    The next few lines are nearly equivalent, although I have removed the My object, as it was a bit of overkill. In addition, the original code was magically pulling the value from the My object. This was not a huge problem, as the code was all contained in the UI project, but I am now separating out tiers, so pulling from My, which is essentially a .config wrapper in this case, broke encapsulation. That is bad, largely unmaintainable (or at least difficult to maintain) and fairly messy to work with. I won’t go further on this aside. Here are the next few lines:

    SortedList<string, Batch> batches = group.Batches;
    StreamWriter writer = new StreamWriter(fullFileName, append, encoding);
    writer.WriteLine(GetFileHeaderRecord());
    writer.WriteLine(group.GetGroupHeaderRecord());

    I did pull the SortedList for batches, which was magically pulled from the object earlier. There was nothing wrong with the initial implementation, except it required spinning up the object and exposing a Set method on batches (which should be read only, as they are pulled from the database and calculated). By inverting the code a bit and allowing the method that calls WriteDiscoverFile() to send in the group, I can isolate the WriteDiscoverFile() method and test it. The writer lines, as mentioned are pretty much the same as before.

    The enumerators are just a way to loop. Another fine loop (and cleaner in this case) is the for loop. Here is the bulk of the routine:

    foreach (Batch batch in batches.Values)
    {
       
    string batchHeader = batch.GetBatchHeaderRecord();
       
    SortedList<string, Transaction> transactions = batch.Transactions;
       
    writer.WriteLine(batch.GetBatchHeaderRecord());

        foreach (Transaction transaction in transactions.Values)
        {
           
    writer.WriteLine(transaction.ToString());
        }

        writer.WriteLine(batch.GetBatchTrailerRecord());
    }

    This is much cleaner and the intent is very clear, making this much easier to maintain. I then finish off writing out the trailers and get rid of the Writer, as follows:

    writer.WriteLine(group.GetGroupTrailerRecord());
    writer.WriteLine(GetFileTrailerRecord());
    writer.Close();

    Here is the entire routine:

    private void WriteDiscoverFile(string fullFileName, bool append, Encoding encoding, Group group)
    {
        SortedList<string, Batch> batches = group.Batches;
        StreamWriter writer = new StreamWriter(fullFileName, append, encoding);
        writer.WriteLine(GetFileHeaderRecord());
        writer.WriteLine(group.GetGroupHeaderRecord());
        foreach (Batch batch in batches.Values)
        {
            string batchHeader = batch.GetBatchHeaderRecord();
            SortedList<string, Transaction> transactions = batch.Transactions;
            writer.WriteLine(batch.GetBatchHeaderRecord());
            foreach (Transaction transaction in transactions.Values)
            {
                writer.WriteLine(transaction.ToString());
            }
            writer.WriteLine(batch.GetBatchTrailerRecord());
        }
        writer.WriteLine(group.GetGroupTrailerRecord());
        writer.WriteLine(GetFileTrailerRecord());
        writer.Close();
    }

    Which would you rather maintain?

    Summary

    What have we done here? Here is a list

    1. Removed dependencies on the My object
    2. Moved the conversion to Upper Case to the function that produces header and trailer lines (not mentioned until here)
    3. Inverted the signature a bit so we can test the code with a mock for the Group object (Testing is good)

    In the end, we have 14 lines of code (getting rid of the braces) versus 30 (many of which would never be hit or were always true).

    There is one question that might come to mind. Why did I remove the error handling bits? The main reason is I did not see them as necessary, as the process has run in the same location for ages. But, if I were to feel it was needed, rather than have a bunch of nested tries, I would simply surround the instantiation of the StreamWriter, as that is the only point I can see failure occurring. It would look like this:

    try
    {
        StreamWriter writer = new StreamWriter(fullFileName, append, encoding);
    }
    catch (Exception ex)
    {
        //Log exception
    }

    Note that we can also use a using statement if we do not wish to log, and allow the failure to create file error to bubble up to the UI. It really depends on whether or not we have a true user interface or not. My vote is not, as this should be an automated process, but that is a topic for another day.

    Peace and Grace,
    Greg

    Twitter: @gbworld

    June 26

    IT Adding Value to Business

    I have been working on a nightmare (yes, it is reporting – isn’t that always a nightmare? ;-0). One of the biggest issues, however, is the processes in place do not accurately reflect the business process. This got me thinking about how IT can add value to business by creating proper processes. That is the purpose of this blog entry. To make it more real world, I am going to show the concepts in the form of case studies.

    Case Studies

    Case Study #1: Programming GPS Units

    A GPS tracking company had a need to program units. Initially, this was done by using a terminal program and a script. One of the engineers (equipment engineer, not software engineer) created a program to more quickly push the script to multiple units. The IT department inherited this program and was asked to make it more flexible.

    The task at hand was to program the unit and track which script the unit was programmed with. In the process of programming, IT noticed two things:

    1. The unit scripts were essentially the same, with a few differences for each back end.
    2. The unit gave a lot of metadata back when it was programmed that was not being stored anywhere

    Lesson 1: Storing Data and Metadata

    When the system was envisioned, the unit scripts were “tokenized” and the metadata for each unit was stored in a database. While this was not seen as important at the time, it became an invaluable in troubleshooting units that were sent out. In some cases, the unit was programmed weeks before being shipped out and had an older script. In the interim between programming and shipping, a bug fix was introduced.

    Prior to instituting this system, units would have to be pulled from vehicles and shipped back to the company, creating an expense for the company. With the script being tracked, along with the metadata, engineering could send out an over the air command to update the “firmware” to the latest specs. Another benefit to storing this metadata was being able to proactively set up a fix on units shipped out in bulk that had bugs. Since the unit numbers could be easily identified, the system could be set up with a “when this unit first reports in, send out a fix” type of command.

    What IT was doing, in this case, was refactoring out duplication. The main difference between the normal refactoring out duplications, is the duplications here were not in the code. It is a fairly common practice, in good IT shops, to refactor out duplicates in code. For example, if you find two routines that contain data access code, you create a new routine that both of the original routines call. One quick example is when you edit data on a web form. The original bits will end up looking this this:

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
            //Work to bind here
    }

    protected void EditButton_Click(object sender, EventArgs e)
    {
        //Do processing of edit here
        //Do work to bind here

    }

    The fix is moving out the binding bits, more like this:

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)

            BindPage();
    }

    protected void EditButton_Click(object sender, EventArgs e)
    {
        //Do processing of edit here
        BindPage();
    }

    protected void BindPage()
    {
        //Do work to bind here
    }

    The scripts were a bit different in the fact they were just AT commands send to a unit, but the original might look like this:

    AT$Friend = 10.0.0.2
    AT$UDPAPI = 12873

    Refactored it would look like this:

    AT$Friend = {IP_Address}
    AT$UDPAPI = {UDP_Port}

    The process is the same as refactoring code, but the metadata is then stored as a set in a database and the unit number is tagged with that set.

    Summary of lesson: Refactoring is as important for business processes and data as it is for code.

    NOTE: I will have to cover IT that does not refactor code on another day. ;-)

    Lesson 2: Store Information Returned From Other Systems

    When a unit was programmed, it returned certain data, such as the manufacturer’s revision number, manufacturer’s firmware set, etc. Prior to IT working on the programmer, none of this data was stored. And, it was not considered important, for some reason. After the programmer application was coded to store the data, the manufacturer discovered a problem with their own firmware that had to be fixed. Units on the shelf could then be identified as needing the fix and upgraded selectively, rather than attempt to upgrade firmware on all units. It also allowed the company to selectively recall units based on firmware revision, rather than recall all units of that type purchased within a certain time period (the only other way of determining faulty units).

    Summary of lesson: One thing I have learned in my 15 years of IT is business often does not realize what it is getting from other systems. Data is often flagged as not important without fully ascertaining the business value of the data. I am not suggesting you go around business and store data they have demanded you not store, but rather that you do the following:

    • Document any data that comes back from a system and make a case for storing any data that might be important (now or in the future). When doing initial design, store the data. You can always drop it out if it is determined to be unimportant.
    • Keep a document trail on any data business flags as trash. This is a cover your butt maneuver, of course, but the blame game is very common when data is pitched and IT often gets the blame.

    Case Study #2: Financial Reporting

    A credit card processing company needed some financial data to help market their portfolio. The data came from end of month processes. In the process of reporting, the numbers were found to be off in many cases. Looking further, it was discovered that there was no firm way to track what had been reported, making it nearly impossible to get a completely accurate set of numbers.

    Lesson #1: Flag Data Used in Reporting

    Transactional data and reporting data are two different things. An individual transaction is stored to make sure every process related to the transaction can be repeated. But, when one reports from transactional data, there is a potential of not being able to repeat a report. In financial reporting, one potential issue is inherent in the process. NOTE: I probably have the names of the bits wrong here, but I am looking at this as a non-financial expert.

    • Merchant swipes card
    • Record sent from terminal to company responsible for processing the terminal (terminal processor)
    • Record is sent from terminal processor to authorization processor (may be same company)
    • Record is sent to processor for credit card company (example: MasterCard or Visa)
    • Credit limit is checked from card originator
    • Authorization number issued sent back to authorization processor
    • Authorization number is sent from authorization processor back to terminal processor
    • Authorization number sent back to terminal
    • At end of day, all records are settled from the terminal
    • Batch settlement sent to terminal processor
    • Receipt sent back to terminal
    • Batch settlement is sent to settlement processor (may be same as authorization processor)
    • At a later time, the settlement processor combines all settlement batches
    • Settlement batch sent to ACH processor
    • Money transferred from credit account to merchant account (and vice versa – in case of chargebacks, which is generally in the form of disputed transactions or returned merchandise)

    This is a bit of an oversimplification of the process.

    Now, at the end of the month, all of the processing companies send out bills. The terminal processor has to bill the merchant (which is done via ACH from the merchant account, but that is not really important). What is important is that the monthly bill be sent out to the merchant.

    What is normally done is records between X and Y dates are processed to make up the bills for the merchants. The problem with this approach is a merchant can forget to settle a batch at night. If the batch was created on 6/30 and he comes in on the morning of 7/1, the monthly process may have already been run for billing prior to the records entering the system. If you rerun the report, it will include these records, however.

    The solution to this problem is to add some type of flag to the system to indicate it has been run on a particular month’s month end process. This makes a for a repeatable process, as you report off records flag, not the date range. This means on the first reporting cycle, you have a pre-process that flags the records to be included. If business asks for a re-run to completely recalculate the numbers, you reflag the records to include any the merchant has processed late. But if they just want the numbers rerun for other reports, you respect the original flag. You now have a repeatable process.

    Summary of Lesson: It is up to IT to include flags in processes that have consolidated reports. This ensures the same transactions can be used to repeat the reporting process, as well as report other numbers back to business. Once again, if business states this is not important, make sure you document the statements, as this one will come back to bite you some day.

    Create reset scripts

    I have a particular case in mind for this, but I am not sure setting this one up as a case study makes sense. Here is the background:

    I am currently setting up some financial reports based on month end data (consolidated data, not the original transactions). There are some numbers that are run from other data points. In particular, I have to determine the expenses related to transactions. To make things easier, I have pulled the data from a variety of Access databases (don’t ask) into a single SQL Server table. I then added some columns to store the calculated data.

    Example: As numerous scripts are run to get the totals, I have set up the following script so I can start back at square one when the calculations are revised. The X, Y and Z are obfuscations of the actual column names, as is EndOfMonthTable (no need giving away any secret sauce ;-0):

    /*
    ALTER TABLE EndOfMonthTable
    DROP TrueXCount, TrueYCount, XAuthExpense, YAuthExpense
         , ZAuthExpense, TotalAuthExpense
    GO

    ALTER TABLE EndOfMonthTable
    ADD
        TrueXCount    int default 0 not null
        , TrueYCount    int default 0 not null
        , XAuthExpense    money    default 0 not null
        , YAuthExpense    money    default 0 not null
        , ZAuthExpense    money    default 0 not null
        , TotalAuthExpense    money    default 0 not null
    GO

    update EndOfMonthTable
    set     TrueXCount = 0
        , TrueYCount    = 0
        , XAuthExpense = 0
        , YAuthExpense = 0
        , ZAuthExpense = 0
        , TotalAuthExpense = 0
    GO
    */

    In this case, I have multiple ways of resetting. I can completely delete the columns, rebuild them. Or I can simply zero out the columns. The point here is I have multiple ways to go back in time, depending on my needs. The actual names are obfuscated here, but the process is what is important, not how my employer does business.

    This is very similar to the rule “you must use source control” and in the case of the actual code I have it stored in SourceSafe (not my choice, I might add, but it is better than no source control).

    Summary

    Here is a quick summary of the lessons learned from the case studies:

    1. Refactor business processes for commonalities. This is useful for programming, as you reduce errors. It is also useful for business, as one can determine the state the system was in when the data was stored. In the case of actual hardware, it allows you to troubleshoot problems and deploy fixes more efficiently.
    2. Store information returned from other systems. This is a very common issue in businesses I have consulted. The information is not considered important today, but becomes critical in times of crisis. Often times, getting this data at a later date is either very difficult (deployed hardware, as in the case study) or costly (company B charges to get the data back at a later date). In some cases, the other company may not store the data at all, so it may even be impossible to get the data after the initial process is complete.
    3. Flag data used in processes. This is basic auditing in action. The case in point was a month end report, but any time you consolidate information, you should flag the records used for the consolidation. While not mentioned in the case study, one possible need for the flag is if the process is determined to be flawed and needs to be rerun. If you have not flagged the data used, you will potentially make some assumptions that return different numbers.
    4. When a process changes data, you should set up a way to get back to square one. This is extremely critical as you develop the process, especially if you are testing on a large set of data.

    Hope this helps!

    Peace and Grace,
    Greg

    Twitter: @gbworld

    June 12

    Back to Basics: The ABCs of Development A = Algorithm

    I have been grousing lately about how ill prepared today’s developers are. In particular, I have been ranting about how developers today do not know the basics of development. Rather than simply bitch, I decided to put my foot into the water and start teaching people. This particular article stems from a book idea I have that I will likely be writing soon (really this time).

    The ABCs I am going to cover over the next few days are:

    A = Algorithms (this article)
    B = Boundaries
    C = Contracts

    From an logical architecture standpoint, C is the most important. From a physical architecture standpoint, B is the most important. But from a developer competency standpoint, it could be argued A is the most important, so here we go.

    Algorithm

    Merriam Websters defines algorithm as:

    Main Entry:
    al·go·rithm 
          Listen to the pronunciation of algorithm
    Pronunciation:
    \ˈal-gə-ˌri-thəm\
    Function:
    noun
    Etymology:
    alteration of Middle English algorisme, from Old French & Medieval Latin; Old French, from Medieval Latin algorismus, from Arabic al-khuwārizmi, from al-Khwārizmī fl a.d. 825 Islamic mathematician
    Date:
    1926

    : a procedure for solving a mathematical problem (as of finding the greatest common divisor) in a finite number of steps that frequently involves repetition of an operation ; broadly : a step-by-step procedure for solving a problem or accomplishing some end especially by a computer

    We will use the last part of that definition and see an algorithm as a step-by-step procedure for solving a problem or accomplishing some end. As computers only see 0s and 1s, the rest of the definition technically fits, but it leads to confusion as we deal on a higher level of abstraction in our daily work.

    A Sample Algorithm

    So, let’s suppose our “problem” is multiplying two numbers together, which we will call factorA and factorB. The signature for this method will end up something like the following:

    public int multiply(int factorA, int factorB)
    {
    }

    The guts of this method is the algorithm. I assume we all know that this can be resolved rather easily by returning factorA * factorB, but knowing multiplication is simply continuing to add the first factor until we do it factorB number of times. In other words 5*5 is simply 5+5+5+5+5 or five added five times. Following this logic, we might do something like this:

    public int multiply(int factorA, int factorB)
    {
        int returnVal = 0;
        int i = 0;

        do
        {
            returnVal += factorA;

            i++;
        } while (i < factorB);

        return returnVal;
    }

    What is wrong with this algorithm? For the consumer of the class? Nothing. They do not see the internals. We could place this code out into production and it would deliver the correct answer. The code is well encapsulated, which means it is completely contained and “hidden” from the consumer.

    ASIDE: Encapsulation is one of the fundamental concepts of Object Oriented Programming per Wikipedia, which defines it as “Encapsulation conceals the functional details of a class from objects that send messages to it.”

    There are two problems, from our standpoint.

    1. Performance – There are better algorithms for performance
    2. Clarity – This code does not make our intent clear

    We will now drift a bit from algorithms to refactoring.

    Refactoring the Algorithm

    Refactoring is altering the code base to improve it. In our code, the do loop is not the best performer. But it has an even larger problem. The intent of the code is not clear. A do loop is generally used to indicate the need to continue to perform a task (or tasks) until a certain condition is met. For example, we might have a do loop that checks to see if a file transfer is completed and when it is, it does work (yes, I know there are better ways of doing this in event driven programming, but roll with me until I think of a better reason for the do loop).

    If we want to make the intent clearer, we use a for loop, as in the following code snippet:

    public int multiply(int factorA, int factorB)
    {
        int returnVal = 0;

        for (int i = 0; i < factorB; i++)
        {
            returnVal += factorA;
        }

        return returnVal;
    }

    We now can see that the intent here is 5*5 = 5+5+5+5, as a for loop is terminated after a set number of loops (in this case, 5, as factor B is 5). This solves the clarity problem, but the first time I coded this, I found it actually ran slower. We will get back to this in a moment. Here is a simple test for looping.

    DateTime start = DateTime.Now;

    for (int i=0;i<numberIterations;i++)
    {
       
    MathLib target= new MathLib();
        target.multiply(a,b);
    }

    DateTime end = DateTime.Now;
    long diffTicks = end.Ticks - start.Ticks;

    We have solved the clarity problem, but we can still improve the algorithm even more. In fact, the end algorithm is likely the one most of us would have started with in the first place, as shown below:

    public int multiply(int factorA, int factorB)
    {

        return factorA * factorB;
    }

    Before moving into the next section, I need to write an aside.

    It should be noted that refactoring without tests is not a good idea. With small bits like this, we are probably safe. But most of the algorithms we write are a bit more complex and deal with less concrete problems. In addition, we often have routines calling other routines, creating very complex interactions. I have actually written a simple test surrounding this routine, which looks like this:

    [TestClass]
    public class when_multiplying_five_times_five
    {
        [Test]
        public void should_return_twenty_five()
        {
            int factorA = 5;
            int factorB = 5;
            int expected = 25;


            MathLib target= new MathLib();
            int actual = MathLib.Multiply(factorA, factorB);

            Assert.AreEqual(expected, actual, "Does not return 25");
        }
    }

    The test here uses a bastardized form of BDD (Behavior Driven Development), so don’t get caught up in the naming. I can cover TDD versus BDD (and my own bastardized attempt using a unit test framework for BDD, but that will be later). The takeaway with this test is I can verify that each of the algorithms works correctly.

    Just keep this in mind: refactoring without tests is a dangerous endeavor. And, since so few have tests surrounding their code, perhaps that is why so few people actually spend time refactoring? I am sure there are other dynamics, like management’s thinking that refactoring is paying twice for code, etc. , but that will have to wait for another day and another blog entry.

    Choosing an Algorithm

    When I look at Microsoft forums, I generally see people asking questions like this:

    Which works faster, a FileStream or BinaryStream?

    ASIDE: The answer, is “it depends”. In general, if you can use binary, it will be faster. But if you are converting to text, you may find binary streaming plus conversion is slower than just using a file stream.

    The entire conversation surrounds performance. But there are other considerations when choosing an algorithm. In our multiplication example, we refactored primarily for clarity, with the added benefit of greater performance. But, there are instances where you actually lose some performance for clarity.

    Many years ago, I was tasked with determining the best path to go with a company’s web development efforts. The idea was to focus on the web first and then possibly apply the standardize all types of development to the same standard. I looked at a variety of factors, including the following:

    • Ease of coding
    • Ease of maintenance
    • Resources in the market for particular skill sets

    There were other factors, as well, but you get the idea. In the end, I determined Visual Basic, using COM, was our best bet, with ASP as the UI technology. This sparked a debate with another programmer, who favored C++. His primary argument was C++ runs faster than VB. I could not argue against the performance characteristics, as C++ is noticeably faster than VB COM. I did, however, argue that VB, in our testing, was well below the bar in terms of maximum time to complete tasks. His insistence that performance was king led the company to spend around $50,000 to have a consulting firm reach the same conclusion.

    From a personal standpoint, I think you should try to learn what performs the best. Finding ways to get better performance makes you a better developer. You should also learn many different algorithms for the same problem and when to use each one. This brings us to the second point on algorithms:

    From a practical standpoint, however, maintenance costs business far more money than performance. Why? If the code base is not maintainable, you have to hire all rock stars, which come with a big price tag.  As rock stars are not fond of maintenance, you also have a bit of a revolving door problem, which cost the company even more. If the code is easy to maintain, you can hire rock stars for the hard parts and hire mid-level developers for the other work.

    There are exceptions to this rule, of course. If you are working for Google, high performing algorithms will win as long as they are scalable. But most of us do not work for Google, or a company that does anything near their level of scale.

    If you can create a highly maintainable system with high performance algorithms (very possible when using framework classes to perform work), then you have a win-win. But, when you must make a decision, maintainability should win the day more often than performance. This is not a hard, fast rule, of course, but I have found it is true in most places where I have worked or consulted.

    Summary

    In this blog entry, I covered algorithms, the A in our development ABCs. In the process, I touched on a couple of other topics:

    • Refactoring – changing algorithms
    • Testing (including basic TDD and BDD-style tests) – verifying algorithms
    • Performance versus Maintainability – choosing algorithms

    In the future, I will hit Boundaries and Contracts. I am not sure whether I will choose B or C first, as Contracts are extremely important in my world. Here are some future ideas for the Back to Basics blog entries:

    • B = Boundaries
    • C = Contracts
    • Throw in a little BS – Behavior and State
    • Aspects of Development – Performance, Maintainability, Availability, Extensibility, Scalability and Security
      NOTE: I covered this topic before with classic ASP on asptoday.com (now defunct site) in an article entitled Beyond Mere Performance
    • Page_Load is for Loading Pages – Problems in ASP.NET development

    if you search my blog, you will see I have already covered string concatenation versus a StringBuilder (better performing and more maintainable).

    Peace and Grace,
    Greg

    Twitter: @gbworld

    June 05

    The Case Against Homeschooling – A Response

    This is a response to a blog entry entitle The Case Against Homeschooling.

    For the record, so you can try to determine where my bias might lie, my wife and I decided two years ago to homeschool our children. We have a list of reasons, but our primary reasons were as follows:

    1. We were concerned that our child was no longer being taught once she reached grade proficiency. This would not have been a big issue if we saw an indication they were focusing on other children around April or May. But we saw the trend to have her read or play rather than learn starting around December. Having five months worth of learning essentially pissed away was a big issue for us. And, we were in what was considered one of the best schools in our county.
    2. We did not feel they were taking her peanut allergy seriously enough. For those not aware, peanuts are a very serious allergy. While anecdotal in nature, my mother was taken to the hospital on at least one occasion due to incidental inclusion of peanuts. One of the main complications from a peanut allergy is anaphylaxis, or a constriction of the throat, which compromises breathing.

    The article listed 10 items the author felt made a case against homeschooling. I have copied the blog entry, in toto, with my comments added. The original is in red and my comments are in green.

    Homeschooling: great for self-aggrandizing, society-phobic mother…… but not quite so good for the kid.

    I tend to discount any argument that begins with an ad hominem, as any argument based on a logical fallacy is a fallacious argument. Wink Giving benefit of the doubt that you are going to attempt to make a case against homeschooling, and by proxy homeschoolers, I will avoid “flipping the bozo bit” at this point in time.

    In forums, the ad hominem is generally a sign that the person presenting the argument has lost and is resorting to name-calling. Considering your stated education level, you might want to consider the use of logical fallacy in any follow up post.

    Here are my top ten reasons why homeschooling parents are doing the wrong thing:

    10. “You were totally home schooled” is an insult college kids use when mocking the geeky kid in the dorm (whether or not the offender was home schooled or not). And… say what you will… but it doesn’t feel nice to be considered an outsider, a natural outcropping of being homeschooled.

    This item makes a hasty generalization. There is an underlying assumption that homeschooled children, as a rule, are not socialized, making “geekhood” a “natural outcropping” of their schooling. As the author has shown disdain for homeschooling (item #5), I would question how many homeschooled children the author has queried to make this assumption. I would argue we are dealing with a biased sample, which is another logical fallacy.

    In my experience, this is not the case. While homeschooled students do not get day-to-day socialization with public school children, homeschooled children do participate in a wide variety of activities. As an example, my own children have the following activities throughout the year:

    • Girl scout troops
    • Dance and gymnastics
    • Church groups
    • Various camps – This year, we have church camp, cancer survivor/sibling camp amongst others

    Other homeschooled parents have children that participate in organized sports, either through city leagues or through umbrella school programs.

    But, destroying the underlying assumption that homeschooled children are not socialized (which you use in other items in your list) is not sufficient to completely destroy the point. There is also the underlying assumption that parents should shield their children from anything that might get them mocked. While I risk making a slippery slope argument here, it is impossible to shield your children from all mockery. And, I would state, that an attempt to do so would reduce the richness that makes life worth living.

    Imagine if we stopped our children from taking music, as they might be mocked as band geeks. Or if we stopped them from engaging in computers, as they might be called computer geeks. Or, going to the more base nature of man, imagine if we stopped our minority children from attending any activity in which some child might call out a racial slur.

    If increasing my child’s likelihood of excelling at life means they might be called names by crass people, then it is a risk worth taking. Schooling, even college, lasts for such a short time that it should not be a major factor in any decision about schooling, homeschooling or otherwise. it would be better to mitigate the risk by adding activities than to put a child in public school merely so they can avoid being called a “geek”.

    9. Call me old-fashioned, but a students’ classroom shouldn’t also be where they eat Fruit Loops and meat loaf (not at the same time I hope). It also shouldn’t be where the family gathers to watch American Idol or to play Wii. Students–from little ones to teens–deserve a learning-focused place to study. In modern society, we call them schools.

    If the case is being made that a student should not learn in a building where lunch is served or there are activities other than learning, then all schools, including traditional schools, are being argued against, as lunch, phys ed, computer labs and playgrounds exist in every school in the nation. If the case is that students should not eat or play in the same room they learn in, the author is once again using a biased sample.

    Most, if not all, of the credible homeschool sources suggest homeschooling in a separate space from the living or dining room. And while not every parent I know has the luxury of setting aside a separate room, a great majority of parents I know do have a separate space for homeschooling, even if it is a specific side of a room that is used for other activities. Even when this is not the case, the child has a separate time for learning that does not involve eating or playing Wii, even by siblings who have completed their daily learning activities.

    8. Homeschooling is selfish. According to this article in USA Today, students who get homeschooled are increasingly from wealthy and well-educated families. To take these (I’m assuming) high achieving students out of our schools is a disservice to our less fortunate public school kids. Poorer students with less literate parents are more reliant on peer support and motivation, and they  greatly benefit from the focus and commitment of their richer and higher achieving classmates.

    The underlying assumption here is highly educated students have a big impact on those less fortunate. According to studies, this is possible, but only when the school engages in peer learning activities. Conversely, there are many studies that show parental involvement is a much greater factor in success of the student, as it helps in the areas that make the biggest impact (according to the review Family, School, and Community Influences on Children’s Learning):

    1. Standards and Expectations
    2. Structure
    3. Opportunity to learn
    4. Support
    5. Climate/Relationships
    6. Modeling

    In my own experience, my children are currently above grade level in every subject. My oldest is reading 3 grade levels above her current grade and is a grade or two above her level in every other subject. Even if I were to take the argument at face value, I wonder if it would be wise to have her live up to less than her full potential for the “good of the many”. As the assumption is only fully valid in learning environments that include student collaboration (which is more common at college level than grade school level), I question whether removing my child is selfish at all.

    Furthermore, the decision to homeschool requires a huge sacrifice on the part of the parent. While the action might be selfish to others (not established), it is certainly not selfish when viewed in the light of economic and time sacrifices necessary to properly homeschool one’s own children.

    7. God hates homeschooling. The study, done by the National Center for Education Statistics, notes that the most common reason parents gave as the most important was a desire to provide religious or moral instruction. To the homeschooling Believers out there, didn’t God say “Go therefore and make disciples of all nations”? Didn’t he command, “Ye shall be witnesses unto me”? From my side, to take your faithful children out of schools is to miss an opportunity to spread the grace, power and beauty of the Lord to the common people. (Personally I’m agnostic, but I’m just saying…)

    According to the 2003 study (Homeschooling in the United States, 2003. table 4), the most common reason for homeschooling was “concern about environment of other schools”, with 85.4% of respondents stating this reason. Religious reasons was number 2, with 72.3%, followed closely by "dissatisfaction with academic instruction at other schools". The most important reason in this study was “concern about environment of other schools”, at 31.2%, with religious or moral instruction at 29.8%. While religious/moral reasons were a concern, they were not, as you have stated, “the most common reason”.

    According to the 1999 study (Homeschooling in the United States, 1999, table 4 - p11), the most common reason for homeschooling was  “can give a child better education at home), with 48.9% of respondents stating this reason. Religious reasons was not even close at 38.4%. Even including the standard error, religious/moral reasons cannot be stated as “the most common reason”.

    I am not sure why you stated religious/moral training was the most common reason, as it is not supported by the studies. I would assume a bit of ignorance on your part, as the other option is you willfully ignored the facts to make your point.

    6. Homeschooling parent/teachers are arrogant to the point of lunacy. For real! My qualifications to teach English include a double major in English and education, two master’s degrees (education and journalism), a student teaching semester and multiple internship terms, real world experience as a writer, and years in the classroom dealing with different learning styles. So, first of all, homeschooling parent, you think you can teach English as well as me? Well, maybe you can. I’ll give you that. But there’s no way that you can teach English as well as me, and biology as well as a trained professional, and history… and Spanish… and art… and counsel for college as well as a school’s guidance counselor… and… and…

    The fallacy here is known as argumentum ad verecundiam, or an appeal to authority. While credentials are useful in determining a person’s qualifications to perform an action, they do not mean that the person is particularly good at performing the action.

    There is also three unproven underlying assumptions:

    1. One must be an expert in every subject he teaches.
    2. Homeschool teachers do not have access to experts
    3. Public school has experts teaching in subjects.

    I will cover each of these assumptions in order.

    On assumption #1: In general, homeschooling is focused on curriculums that encourage students learning to teach themselves. While there is a lot of hands on learning in the early years, the student becomes more independent over time. The parent, like any other teacher, must prepare for lessons, to be able to properly grade the assignments. But, most homeschoolers use some form of formalized curriculum, especially in subjects where they are not an expert.

    On assumption #2: I have already covered this a bit in the last paragraph. The curriculums used by most homeschoolers are formalized and created by experts. Many of the curriculums used in homeschooling are also used in traditional schools, although the layout of the lessons is different due to difference in environment and teaching methods (homeschooling is one-on-one, while traditional school contains more lecture time).

    On assumption #3: While professors in colleges are required to be experts in the field they teach, the legal requirements for grade school are generally focused more on education coursework than expertise in their field. I can name many cases, locally, where the teacher has a strong interest in the subject rather than formalized teaching. As such, your argument runs against you on the grade level, at least in some cases..

    5. As a teacher, homeschooling kind of pisses me off. (That’s good enough for #5.)

    This sounds more like your problem than an argument, as it is an appeal to emotion, at best.

    4. Homeschooling could breed intolerance, and maybe even racism. Unless the student is being homeschooled at the  MTV Real World house, there’s probably only one race/sexuality/background in the room. How can a young person learn to appreciate other cultures if he or she doesn’t live among them?

    There are two assumptions here

    1. Homeschooled students do not participate in other activities – covered in my repsonse to the second point
    2. Traditionally schooled children are more well-rounded

    On point #2: While it is true public school children do come in contact with more races and sexual orientations, this does not mean they become more tolerant or less racist. Racism is still a huge problem in our traditional schools, as is intolerance. The one potential benefit to traditional schools, in this regard, is the students are more readily subject to public punishment for expressing racism or intolerance. The word “public” is very important in my last statement.

    My experience, however, has been that my children’s activities in her homeschooling career have the same racial mixture as they did in their public school career. This may not be true for all parts of the country, however.

    3. And don’t give me this “they still participate in activities with public school kids” garbage. Socialization in our grand multi-cultural experiment we call America is a process that takes more than an hour a day, a few times a week. Homeschooling, undoubtedly, leaves the child unprepared socially.

    I will agree with you that this is just a few hours a week for most homeschooled children, but you have provided no evidence that this leaves a child “unprepared socially”. In fact, there are numerous studies showing that homeschooled children, despite only a “few hours” of socialization, "gained the necessary skills, knowledge, and attitudes needed to function in society...at a rate similar to that of conventionally schooled children". In fact, one study of adults who had been homeschooled found their “socialization was often better than that of their [traditionally] schooled peers”.

    2. Homeschooling parents are arrogant, Part 2. According to Henry Cate, who runs the Why Homeschool blog, many highly educated, high-income parents are “probably people who are a little bit more comfortable in taking risks” in choosing a college or line of work. “The attributes that facilitate that might also facilitate them being more comfortable with home-schooling.”

    More comfortable taking risks with their child’s education? Gamble on, I don’t know, the Superbowl, not your child’s future.

    We all take risks in life. Not all of the risks involve gambling; the majority, in fact, are reasoned, calculated risks.

    When one examines homeschooling versus public education, the numbers show that homeschooled children do as well, if not better, in nearly every metric used to grade differences.

    1.  And finally… have you met someone homeschooled? Not to hate, but they do tend to be pretty geeky***.

    *** Please see the comments for thoughts on the word ‘geeky.’ But, in general, to be geeky connotes a certain inability to integrate and communicate in diverse social situations. Which, I would argue, is a likely result of being educated in an environment without peers. It’s hard to get by in such a diverse world as ours! And the more people you can hang out with the more likely you are to succeed, both in work life and real life.

    I have found there are homeschool geeks, as well as traditionally schooled geeks. Barring some study that shows a higher level of geekiness in homeschooled children, I will take this point for what it is worth: Nothing.

    One last note, to those homeschooling parents out there: it’s clear from the number and passion of your responses that TeacherRevised is missing an important voice in the teaching community. If any of you are interesting in writing for us, send me an email: jessescaccia@gmail.com. I would love to have you as part of our conversation.

    Based on your rant here, I am not sure you really want to hear a homeschool parents voice. If you would really like to hear one, I have given you my email so you can respond. Hopefully your response will be better researched and thought out than this long-winded ad hominem. If you want a conversation, I would entertain it. If you want to make me a butt of a joke, as you seem to have attempted here, I would rather bow out.

    Overall, homeschooling is working. So well that more and more states are opening public school facilities to homeschoolers to help in the education of these children. So well that more and more colleges are not only allowing homeschooled students to join their ranks, but are seeking them out. So well that more and more parents are turning to homeschooling as an option (estimated 850,000 in the 1999 study, 1.1 million in the 2003 study and 1.5 by 2007 – perhaps double by the time the numbers are calculated for 2009).

    While I respect the author’s zeal for traditional education, there is no evidence shown that any of the assertions made in the “case” are correct and the liberal use of logical fallacy makes me wonder whether this was truly an attempt to make a point or merely a chance to rant against something the author did not like.

    Peace and Grace,
    Greg

    Twitter: @gbworld

    June 01

    Immunotherapy working against cancer

    I just read this article and see that boosting the immune system is working against cancer. It appears we are finally making headway with the idea that boosting the immune system will kill cancer. And I think this is a great thing. But I am a bit pissed off about the way it is being handled. I am going to cover quite a few topics, and this one may ramble a bit, but I think it is very important to have these conversations.

    Background

    For those who are not aware, my daughter Miranda (now 5) was diagnosed with Ewing’s Sarcoma, a rare childhood cancer, in September of 2007. We opted for standard treatment. Ewing’s has about 250 victims each year, most boys between the age of 10 and 19. Miranda had an Askin’s tumor, which is a soft tissue form of Ewing’s, which normally appears in the bone. Her form of Ewing’s only hits about 25 people per year.

    During our treatment, we opted for a few complementary treatments. Examples:

    1. During her first chemo round, Miranda had horrible mucositis. As an example, she would vomit up ulcers that looked like giant spiders and had a sore that almost completely covered her tongue. We did some research and supplemented her with L-Glutamine and saw few mucositis symptoms for the rest of her treatment.
    2. Miranda had two bouts with C-Diff early on in her treatment. C-Diff (Clostridium Difficile) is an infection of the gut that appears in people whose immune systems have been compromised. When you poison your body with chemo, and pound it with antibiotics to stop infections, you get this infection. C. Diff is a weak bacteria, but it is also very opportunistic. Antibiotics that kill other gut flora do not kill C. Diff, so you end up with an infection that requires even stronger antibiotics. We supplemented her with probiotics. In general, we used Kefir, but also used pills when we were having a problem with Kefir causing vomiting. After we started supplementation, we had no further C. Diff infections.

    This is not science, however, as a case study of one is anecdotal. I will get back to this in the next section.

    The Daniel Hauser Case

    If you are not aware, Daniel Hauser is the child who is being forced to take chemo. Daniel was diagnosed with non-Hodgkins lymphoma and completed one round of chemo. Then he and his parents decided they wanted to try alternative methods. Child services stepped in and got a court to force chemo on Daniel, so he and his mother fled, with a desire to go to Mexico for alternative treatments.

    I am a bit torn on this one, as I would personally opt for conventional treatments, as Hodgkins is very survivable using them. But, I think they should have the option of choosing their medical care. What ticks me off is the media’s statements that Daniel has a 95% chance of survival with chemo and a 5% chance of survival with alternative treatments. I am not arguing the 95% number, as that stat is correct. I am arguing against the 5% number, however, as they have no freaking clue what the true percentage is. I will get back to this after the next section.

    The family was stuck between the proverbial rock and a hard place. Here is the matrix:

    Conventional Treatment (chemo)

    • Daniel lives – right decision was made. Science proven right.
    • Daniel dies – One of the unlucky ones. Delay in treatment made cancer uncurable.

    Alternative Treatment

    • Daniel lives – Fluke. Might have been his one chemo treatment that helped his body get control of the cancer.
    • Daniel dies – Parents are murderers

    Now, let’s look at alternative treatments.

    Science and Alternative Treatments

    For the most part alternative treatments are not scientifically tested. There are numerous reasons for this, some of which are iterated below:

    1. Food cannot be patented. Until you can artificially create the ingredients, you cannot patent the nutrient as a drug. This is why scientists are working hard to artificially create things like DAS, DADS and DATS (nutrients found in garlic) and Resveratrol (a polyphenol in red grape skins and other sources). The nutrients in both have shown promise in cancer (garlic against glioblastoma and Resveratrol against a wide variety of cancers).
    2. The drug companies dictate much of the research. In addition to research they conduct, the drug companies lobby for other funding.
    3. The medical establishment is convinced drugs cure, not food. This comes from a lack of nutritional education amongst other things.
    4. There is a overall feeling in the scientific community that alternative treatments are quackery.

    Let’s examine garlic for a moment. The glio link with cancer was found a few years ago. Doing research, I found research as early as the 1980s on the chemical pathways for garlic fighting cancer. I believe it was missed due to the prejudice against alternative treatments. In science, garlic is largely being tested only for heart disease, and this is primarily due to years of evidence that people eating more garlic have less incidence of heart disease.

    The glio link was published in 2007, but did not get much traction in the media until this year. It was an in vitro study (testtube) and there is no definitive proof it will work in vivo (in the body). I have found no evidence of studies in mice yet, but there may be some going on. There are no human trials with garlic yet. I would imagine it will be years, if not decades, before there are any. One problem with garlic against glio is the DAS, DADS, and especially DATS may not cross the blood-brain barrier. But, one of the newer treatments for operable glio is to introduce a chemo wafer after the tumor is removed. Why could we not make a garlic wafer and do the same thing? There is an issue with garlic causing bleeding, but I am sure that can be overcome if someone would do the research. My theory is they want to be able to patent artificially DAS, DADS and DATS before they attempt to trial garlic as a treatment for glio. If it is eventually used, and is successful, the lives of so many would have been lost looking for a profit motive.

    Please note that I am not taking potshots at the scientific community. There are many hurdles to research, including legal battles (both lawsuits and the FDA). I believe, however, that the patient, who has an almost certain death sentence, should be able to decide. As you cannot go to an alternative treatment center for brain surgery, the option is not available elsewhere.

    5% chance of survival

    Back to Daniel for a bit. Where did they get the 5% number? The best I can figure, if not just pulled out of thin air, they are using stats on people that survive in alternative treatment centers. The problem with this number is most people only try alternatives after the doctors tell them there is nothing more they can do. This is after years of chemo (aka poisoning) and/or radiation (also poisoning). That 5% survive after their bodies have been so abused is a promising number, if you ask me. What would the percentage be if people went alternative from the start?

    There might be a clue in people like Michael Gearin-Tosh and David Servan-Schreiber. Geran-Tosh was diagnosed with multiple myeloma in 1992, a cancer with a rather short median survival. Gearin-Tosh refused chemo and went to radical alternative treatments. he finally died in 2004, but not from cancer. Servan-Schreiber was diagnosed with a deadly brain cancer. He went conventional, but eventually radically altered his diet and environment and took efforts to control his stress. he is still alive today, despite a low median survival for his form of cancer.

    Both of these men are anecdotal evidence, however, as two do not make a scientifically significant case for the success of alternative treatment. You can read their stories in the books Living Proof (Gearin-Tosh) and Anticancer (Servan-Schreiber).

    What is Cancer? How is it Caused?

    The truth is we do not completely know the answers to these questions. We do know they are human cells that are out of control that have been genetically altered to avoid the normal cell death pattern. We also know that cancer has the ability to “create” its own blood supply, a process known as angiogenesis.

    The current “consensus” is cancer is caused by inflammatory processes out of control. We know that some cancers are caused by viruses or bacteria. For example, many GI cancers are known to start from viral or bacterial infections. They have also found that there is a virus association in glioblastoma cells – the HCMV (Human cytomegalovirus). They are not sure what the link is in glio, but the idea of parasites causing cancer is well established in the alternative treatment community, even if the scientific community accepts it for only some cancers. Then again, the science guys might be right on this one.

    There are a couple of things we know (or at least have shown to a high degree of certainty):

    • Carcinogens are instrumental in causing or advancing cancer. This is why you should reduce carcinogens as much as possible in your environment. Some of the easiest ways to do this are stopping tobacco use and reducing heavy grilling of food.
    • Sugar has a part in cancer. The question here is whether sugar is a cause or just a food source. Since the average western diet is high in sugar, avoiding boxed foods and prepared drinks is a good start. Moving to a diet primarily of fruits and veggies is a good step, as well. Reducing sugars will also help with heart disease and diabetes.
    • Acidity has something to do with cancer. The question here is whether or not cancer causes an acidic blood environment or is fed by it. Unfortunately, the alternative “eat alkaline foods” does not appear to have a proper chemical pathway to be a silver bullet in the fight against cancer, except perhaps some GI cancers, which are rare (except colo-rectal cancer) in the industrialized world. Fortunately, veggies are good sources for alkalinity, so following the advice might work, although not for the reason stated on these sites.
    • Inflammation is one key to cancer. We are not sure the exact reason, but we do see cancers appearing where there are injuries. My feelings on one potential reason we are seeing more cancers are we are consuming too many pro-inflammatory foods (meats very high in Omega 6s, sugars, etc.) and few anti-inflammatory foods. Reducing meat consumption and moving to free range meats can help. It is also helpful to find foods high in anti-inflammatory nutrients (like garlic, berries, grapes, etc.), which means moving to a diet higher in vegetables and perhaps some high omega 3 fish. I would go on about this, but this post is long enough.

    Given what we “know”, it only makes sense that a change in diet, which many alternative therapies focus on, is a good step in increasing survival during cancer treatment and perhaps preventing cancer.

    Immunotherapy

    The article that prompted this blog entry was about using therapies to help the immune system to fight cancer. Within the past month, a clinical trial on certain types of antibodies proved so effective in neuroblastoma that the therapy has been approved for use in neuroblastoma patients outside of the study. There were six children in the study that developed allergenic reactions that were very serious, but the survival increase potential outweigh the potential of life threatening allergies.

    What if boosting the immune system with proper nutrition works? The problem is we don’t know. And, this is why the media is reporting a 5% survival potential with alternative therapies for Daniel Hauser, despite the fact there is very little science to support that number.

    Summary

    I am not hacked off with the medical community, per se, but a system that so focuses on pharmaceuticals that it spends precious little money on alternative treatments like food. I do not expect the drug companies to become altruistic on this, as the are businesses. I would, however, like to see more government money spent on determining if alternative therapies hold any promise.

    This is a sticky situation, however, for a number of reasons.

    • You have to find patients willing to go the alternative route. With the current poisons showing high numbers, heading to alternatives first is a hard sell. This is not something the doctors can ethically force on patients, as a failure means death.
    • Medical researchers are not going to risk their careers for therapies outside of variations of current therapies or other “drugs”.
    • The government is set up to make it harder to fund alternative studies, due to the ethical considerations. Remember, however, that chemotherapy was once an ethical issue, as well.

    One potential way of getting real numbers is to take patients who are out of chemo and trying therapies like immunotherapy and comparing them to those going alternative. This would at least give us some real numbers. If the immunotherapy has a 1% survival after the doctors have “given up” on chemo/radiation due to body loads, then alternatives show promise, even at 5%, as they are four times more effective. This might solve some of the ethical dilemma.

    I am not sure how we will solve this. What if alternative therapies, despite some anecdotal evidence, do not work effectively enough to warrant them? Then again, what if they do? If we could use food as a pharmacy, it would change the medical world as we know it. And humans, in general, resist change.

    I know this has been a long one, and I thank you for sticking in. For my family, we have greatly altered our lifestyle after my daughter was diagnosed. We have had whole house filtering since long before her diagnosis. But we have gone more to fruits and veggies and eliminated most bagged and boxed foods. The few we do buy are largely organic and we strongly avoid foods with added sugars, especially foods from high omega-6 sources. We do not bring “juices” in the house with any form of added sugars and my children do not drink sodas or kool aid type mixes (including lemonade, gatorade, etc.) in the house, except on very rare occasions. We also have standing “orders” for people outside the home not to give them candy, etc. Is it enough? I don’t know.

    One thing I am certain of is people in areas of the world without processed foods see less incidence of the cancers plaguing the industrialized world. They do see more GI cancers, which are caused by infections.

    I will write another entry about Immunotherapy at some time, as the science there is fascinating. If you read the book anticancer, you will see some interesting info on how cancer works to make the immune system not see it as an invader, which is part of what they are working on.

    Peace and Grace.
    Greg

    Twitter: @gbworld


    May 28

    Sotomayor not fit to be a Supreme Court Justice?

    After receiving a few emails expressing outrage over the “liberal” nominee for the Supreme Court, I decided that I needed to read up a bit on the issues that were brought up by various talking heads, emails, etc. Here is my two cents on a couple of issues I have seen raised.

    The "Latina Women are better than White Men" comment

    Looking at the actual snippet, the comment is far less inflammatory than is being expressed.

    I would hope that a wise Latina woman, with the richness of her experiences, would more often than not reach a better conclusion than a white male who hasn't lived that life

    The above comment was part of a speech given at the University of California, Berkeley for  a conference entitled Raising the Bar: Latino and Latina Presence in the Judiciary and the Struggle for Representation. Given the context, I am not overly concerned with the comment, as it was specifically tailored for a particular group and was given in response to the comment “a wise old man and wise old woman will reach the same conclusion in deciding cases”.

    Do questions need to be asked about her feelings on racial issues? Certainly, as the answers the questions may, in fact, reveal that the above comment is part of her overall feelings on Latina women versus white men and may cloud her judgment on issues. But, it should be only to establish her thoughts on this issue and then taken as part of the entire line of questioning. Extended focus on this particular comment is ridiculous. I would certainly hope this does not become the major focus of the upcoming dog and pony show, as it distracts.

    The New Haven Fire Department Fiasco

    I agree with the sentiment being expressed over this one, but it is not Sotomayor’s fault. Title VII states that discrimination is illegal when it comes to hiring practices. It, unfortunately, does not iterate what discrimination is, leaving plenty of room open for interpretation. Specifically, it does not iterate what disparate discrimination is, or when there is unintentional discrimination.

    The sad part is the New Haven fire department heads knee jerked when they found 60% of white test takers passing and only 30% of black and hispanic takers passing the Lieutenant’s and Captain’s exams. The knee jerk was further justified by looking at the passing candidates and whether they would actually get one of the slots. No black individual would have been promoted, due to the number of slots. The first legal precedent is Griggs v. Duke Power Company, where the company stopped overt racist practices, but added a high school diploma and IQ test to the requirements for higher positions. The decision was further spelled out in Albemarle Paper Co. v. Moody, which concluded their tests unfairly excluded blacks from higher paying jobs, and Washington v. Davis, which concluded the Washington DC police force’s verbal tests were failed disproportionately by black applicants. The nail in the coffin was Connecticut v. Teal, which found that adverse impact at any stage in a promotion process constitutes discrimination.

    The crux of the law is it is illegal to have a process that has disparate impact on hiring and promotion unless one can prove the process is a "reasonable measure of job performance".

    The main argument I can see against Sotomayor’s decision is whether or not she correctly decided against the plaintiffs as precedence allows for adjusting scores of minority applications and not throwing out the results of an exam altogether. If this is the worst this woman has done, it seems like thin ice to me.

    Summary

    The best two arguments against Sotomayor, at this point, are rather trivial, unless one can show evidence that they shows a trend in favoritism against the majority. At present, this is not firmly evident.

    Peace and Grace,
    Greg

    Twitter: @gbworld

    May 22

    How to do simple recursion (XCopy in C# (and VB))

    Yesterday, I saw the following question in the C# NNTP group (microsoft.public.dotnet.languages.csharp):

    I need to get a listing of all folders and subfolders paths using C# .net 2.0.
    such as .\folderA\subfolderB\subfolderC
                 .\folderA\subfolderD
                 .\folderA\subfolderD\subfolderE
    Any ideas, examples?

    Simple recursion problem. The writer wrote back and stated he want to copy all files from a CD, using C#, into an equivalent directory structure on the drive. Now, I might choose to solve this by making a P/Invoke call to the API method that does xcopy or wrap XCopy in a Process object, but we can also solve this through simple recursion. Here is the follow up:

    Ok, so I've got a CD that has folders and files on that media.  I'm creating
    a small app that will basically copy from the Cd to the hard drive and
    maintain that same folder structure found on the CD.  I'm
    thinking the easiest way to such as task, is to create a string array with
    the folder paths on the CD, then create that folder structure on the hard
    drive, then I can copy from source to destination.

    Now, suppose we create a simple class library with a single class to do this move. I will leave the method as static, as it really does nothing more than read the directory, move files and then check for subdirectories. The entire class is represented below (this is a rough draft, of course):

    using System.IO;

    namespace GBWorld.RecursiveCopy.Business
    {
        public class DirectoryCopier
        {
            public static void CopyDirectory(string originalDirectory, string newDirectory)
            {
                MoveDirectory(originalDirectory, newDirectory);
            }

            private static void MoveDirectory(string originalDirectory, string newDirectory)
            {
                //Ensure new directory exists
                if (!Directory.Exists(newDirectory))
                    Directory.CreateDirectory(newDirectory);

                DirectoryInfo oldDir = new DirectoryInfo(originalDirectory);

                //Copy files
                foreach (FileInfo file in oldDir.GetFiles())
                {
                    string oldPath = file.FullName;
                    string newPath = newDirectory + "\\" + file.Name;
                    File.Copy(oldPath, newPath);
                }

                foreach(DirectoryInfo dir in oldDir.GetDirectories())
                {
                    string oldPath = dir.FullName;
                    string newPath = newDirectory + "\\" + dir.Name;
                    MoveDirectory(oldPath, newPath);
                }
            }
        }
    }

    The yellow highlighted part is where we are using recursion. The orange highlighted section helps this work, as it ensures the new directory is created. And the green highlighted section copies the files from the directory.

    To call this, you can do something as simple as this console application:

    using GBWorld.RecursiveCopy.Business;

    namespace GBWorld.RecursiveCopy.UI.Console
    {
        class Program
        {
            static void Main(string[] args)
            {
                string oldDir = "C:\\temp\\test1";
                string newDir = "C:\\temp\\test2";

                DirectoryCopier.CopyDirectory(oldDir, newDir);

                System.Console.WriteLine("Done");
                System.Console.Read();
            }
        }
    }


    Pretty Simple, eh? There is definitely more that can be done here for a production app. I should, for example, check if the original directory exists. I might also break down the new directory and make sure parent directories exists, as a call to create c:\temp\test2 will fail if c:\temp does not exist. And we could add some instrumentation and logging to help when things fail. But, this is just a simple example.

    BTW, this is a layered app. The UI is completely separate from the "business" code that holds the actual behavior. If you read this blog often, you will find I like to do this, as it makes it easy for me to change out user interfaces without rewriting application code. Here is how the projects look in the entire :application":



    For those of you who are into VB, there is an easier way to copy directories using the My object. But, here is the recursion exercise in VB, with the same highlights (I copied this from Reflector rather than rewrite it):

    Public Class DirectoryCopier

    Public Shared Sub CopyDirectory(ByVal originalDirectory As String, ByVal newDirectory As String)
    DirectoryCopier.MoveDirectory(originalDirectory, newDirectory)
    End Sub

    Private Shared Sub MoveDirectory(ByVal originalDirectory As String, ByVal newDirectory As String)

    Dim oldPath As String
    Dim newPath As String

    If Not Directory.Exists(newDirectory) Then
    Directory.CreateDirectory(newDirectory)
    End If

    Dim oldDir As New DirectoryInfo(originalDirectory)
    Dim file As FileInfo

    For Each file In oldDir.GetFiles
    oldPath = file.FullName
    newPath = (newDirectory & "\" & file.Name)
    File.Copy(oldPath, newPath)
    Next

    Dim dir As DirectoryInfo

    For Each dir In oldDir.GetDirectories
    oldPath = dir.FullName
    newPath = (newDirectory & "\" & dir.Name)
    DirectoryCopier.MoveDirectory(oldPath, newPath)
    Next

    End Sub

    End Class
    Reflector is not as concise, so feel free to edit as needed to make it cleaner. I was not interested in writing VB code right this second, so Reflector made things easier for me.Wink


    Peace and Grace,
    Greg

    Twitter: @gbworld

    May 21

    Visual Studio Beta 1 For Everyone

    Even if you do not have an MSDN subscription, you are in luck. Visual Studio 2010, beta 1, is now available on Microsoft download. Here is a list of public links I was sent just recently. The downloads are all on Microsoft download. You will also want to join Microsoft connect for feedback.

    VS 2010 Beta


    · VS2010 Download page

    · VS2010 Walkthroughs

    · MSDN Library: What’s New in Visual Studio 2010

    · VS2010 Connect

    · Forums: VS, VB, C#, F#

    · Samples: VS, VB, C#, F#

    · Language specs: VB, C#, F#

    · IronPython 2.6 CTP for .NET 4.0 Beta1

    SKU/download page

    Format

    Size

    Download page fwlinks

    Visual Studio 2010 Shell (Integrated) Beta 1 Redistributable Package

    exe

    521 MB

    http://go.microsoft.com/fwlink/?LinkId=147419

    Visual Studio 2010 Shell (Isolated) Beta 1 Redistributable Package

    exe

    593 MB

    http://go.microsoft.com/fwlink/?LinkId=147418

    Visual Studio 2010 Professional Beta 1 – Web Installer

    Bootstrapper

    5 MB

    http://go.microsoft.com/fwlink/?LinkId=147408

    Visual Studio 2010 Professional Beta 1 – ISO

    iso

    1.2 GB

    http://go.microsoft.com/fwlink/?LinkId=150591

    Visual Studio Team System 2010 Team Suite Beta 1 – Web Installer

    Bootstrapper

    5 MB

    http://go.microsoft.com/fwlink/?LinkId=147407

    Visual Studio Team System 2010 Team Suite Beta 1 - ISO

    iso

    1.3 GB

    http://go.microsoft.com/fwlink/?LinkId=150592

    Visual Studio Team System 2010 Test Load Agent Beta 1 - DTEA

    exe

    185 MB

    http://go.microsoft.com/fwlink/?LinkId=147420

    Visual Studio Team System 2010 Test Load Agent Beta 1 - DTEC

    exe

    599 MB

    same as above

    Visual Studio Team System 2010 Team Foundation Server Beta 1

    iso

    2.3 GB

    http://go.microsoft.com/fwlink/?LinkId=147412

    Microsoft Visual Studio Lab Management 2010 Beta 1

    no package

     

    http://go.microsoft.com/fwlink/?LinkId=147413

    Visual Studio Team System 2010 Lab Agent Beta 1

    exe

    427 MB

    http://go.microsoft.com/fwlink/?LinkId=147414

    Microsoft .NET Framework 4.0 Beta 1 – x86

    exe

    78 MB

    http://go.microsoft.com/fwlink/?LinkID=147415

    Microsoft .NET Framework 4.0 Beta 1 – IA64

    exe

    146 MB

    same as above

    Microsoft .NET Framework 4.0 Beta 1 – x64

    exe

    149 MB

    same as above

    Microsoft .NET Framework 4.0 Client Profile Beta 1 – x86

    exe

    35 MB

    http://go.microsoft.com/fwlink/?LinkID=147417

    Microsoft .NET Framework 4.0 Client Profile Beta 1 – x64

    exe

    73 MB

    same as above

    Visual Studio 2010 SDK Beta 1

    exe

    14 MB

    http://go.microsoft.com/fwlink/?LinkId=147422

    Microsoft Visual Studio 2010 Remote Debugger (Beta 1) – x86

    exe

    4 MB

    http://go.microsoft.com/fwlink/?LinkId=147421

    Microsoft Visual Studio 2010 Remote Debugger (Beta 1) – x64

    exe

    8 MB

    same as above

    · Channel 9 Video

    · Product Survey

    · Samples

    · VB 2010 Resources page

    · Visual C# 2010 Resources page

    · F# Dev Center

    This is great news for those of you who like to stay on the bleeding edge of technology. Thus far, I have enjoyed playing with the beta. It is still a bit slow, especially in a VPC environment, but far less so than the betas of Visual Studio 2008, so I am happy. I will be posting some tutorials soon, so you can learn how to use the new technology.

    Peace and Grace,
    Greg

    Twitter: @gbworld

    May 19

    More About Recruiters

    I posted yesterday 7 Things Recruiters do That Irritates me. I then got a call from Scott Gordon (one of my recruiter friends in Nashville) asking if he could use my blog post on his site, the Anti Pimp. I am sure I will see it some time today (he had some questions and we have not yet linked up).

    In terms of value, it goes like this:

    • Professional Recruiter: Does his homework to match candidates with positions. Generally gets a sale, as he has properly figured out client needs and vetted candidates. You might argue that his request of 20%+ of the first year’s salary is too high, but you cannot accuse him of adding no value.
    • Run of the Mill Recruiter: The primary thing this recruiter does is introduce people. He still holds some value, as he knows a lot of people and can introduce candidates to employers. It is very easy to argue this recruiter is overcharging.
    • Lazy, unprofessional recruiter: This guy is just in it for the money and gives everyone a bad name. His total claim to fame is he knows how to use the search page on Monster, Dice and Career Builder and he can use a telephone. He does not deserve to be paid for lining up candidates and I am hoping the United States Congress passes the hunting season bill for this waste of human flesh. ;-)

    The idea behind professional recruiting is this:

    1. Professional Recruiter goes to client and finds out the clients needs. This is a fact finding mission so he can add value to the proposition by only sending people that fit the qualifications. As many employers do not know what they need, the recruiter must know enough about technology and people to determine the proper match.
    2. Professional Recruiter goes to talent pool and finds the individual(s) that fit the position. This comes from having a relationship with the talent and understanding their skills, as well as their desires.
    3. Professional Recruiter matches talent and position and gets interviews set up.
    4. Professional Recruiter gets paid for setting up the right person for the job.

    The above is the professional recruiter, who earns his paycheck. But, like any field, someone comes along and tries to find ways to maximize profit, while minimizing work. This is what the lazy idiot did yesterday. Here is how this works:

    1. Lazy Recruiter does searches to find companies wanting to hire, or gets req in his inbox
    2. Lazy Recruiter calls company and gets approval to send candidates (if he subscribes to reqs, this step is optional)
    3. Lazy Recruiter circles buzz words in req
    4. Lazy Recruiter does buzz word search on circled buzz words
    5. Lazy Recruiter SPAMS every developer on Monster, Dice and Career Builder (and perhaps a few others)
    6. Lazy Recruiter makes phone calls to same developers

    The problem here is the lazy recruiter ends up calling numerous times and sends out numerous emails to each candidate. He offers no value to the company, as he is not really screening candidates. He is also wasting a lot of everyone’s time. And he gives all recruiters a bad name, as he paints the picture of recruiters being lazy, non-professional asses.

    The guy who called me numerous times in a row yesterday was a lazy recruiter, if we can call “pond scum” a recruiter. He then emailed me three times for the same position, as he is too lazy to even see if he is SPAMMING the same candidates on the three boards. But, he does not care.

    What makes it worse is when the lazy recruiter speaks marginal English at best, as this guy did. And, to make things even worse, many of these jerks are rude on the phone. I think they truly believe they are doing me a favor wasting my time on low paying positions. Just in case you have not bought a clue lately: You are NOT helping me out; you are just driving up my cell phone bill.

    For those of you who are professionals, keep doing what you are doing. For those of you who are human search engines spamming the world, I suggest spending some time and getting to know the business or get out. You are making the guys who treat recruiting as a career look bad and ticking so many of your potential customers off.

    Peace and Grace,
    Greg

    Twitter: @gbworld

    Visual Studio 2010 Beta 1 on MSDN

    Microsoft released Visual Studio 2010 Beta 1 on MSDN yesterday. If you have an MSDN account, you can find the following on your subscriber downloads:

    • .NET Framework 4 Beta 1
      • IA64 – 145.95 MB
      • x86 and x64 – 157.84 MB
    • .NET Framework 4 Client Profile Beta 1
      • x86 and x64 – 71.40 MB
      • x86 – 34.27 MB
    • Visual Studio 2010 Professional Beta 1
      • x86 – 1,164.30 MB
    • Visual Studio 2010 Remote Debugger Beta 1
      • x64 – 8.27 MB
      • x86 – 4.05 MB

    If you have a Team Subscription, you will also find team Foundation Server beta 1 (x86 – 2,272.80 MB), Team Suite beta 1 (x86 – 1,258.76 MB), Test Load Agent beta 1 (x86) – 181.59 MB and Test Load Controller beta 1 (x86 – 584.97 MB).

    Peace and Grace,
    Greg

    Twitter: @gbworld

    May 18

    7 Things Recruiters Do that Irritate Me

    Before getting into this post, I think I should state that there are recruiters I truly respect and like and recruiters that I do not respect and probably would not like even if I knew them. This post is about the later category, which I feel are the lazy recruiters who add no value to the candidate-employer relationship.

    I got a call today from a recruiter who I would have loved to strangle, if it was only possible to do so over the phone. So here is my list of the top things that irritate me, which I am sure also irritate others. The first three come from my caller this morning, who I will affectionally call Mr. Lazy so i do not post his name here.

    1. Ringing my phone over and over again until I answer – This was the issue number one when I talked to Mr. Lazy this morning. If you are going to call my line seven times in a row, my house had better be on fire. I realize this may seem like an emergency to you, but it is not my emergency.
    2. Being rude to me on the phone  – This was issue number 2 with Mr. Lazy today. I know saying “no, you have to listen now” might be polite talk in India or Pakistan or wherever you are from, but it is consider rude in the United States. It is consider ultra-rude in the south, where I current reside. I am sorry I hung up on you today, which was also rude, but when I tell you I don’t have time to talk, send me an email or give me a call back later. Do not assume your time is more important than mine and I have to listen to you this moment. The message it sends to me is you are smiling and dialing for dollars and not trying to add any value to the proposition.
    3. Being rude to my wife on the phone – Once again, I realize you might come from a country where you can beat your wife whenever you want, but it does not mean you can beat mine up. Of course, she is perfectly capable of giving you a tongue lashing and then hanging up on you, so feel free Mr. Lazy. And, yes, this HAS happened in the past.
    4. Emailing me numerous times for the same position  – This was issue number 3 with Mr. Lazy. I know it takes a little bit of time, but when you go from Monster to Dice to Career Builder, check and see if you already sent me an email. Otherwise, you are showing me how lazy you are and I would rather talk to a recruiter I know and trust about the position than you. NOTE: I can generally figure out who the company is by looking at your req; if not, I will call someone I trust and ask them if they can figure it out. I am NOT going to call YOU.
    5. Not reading my resume – When you call me or email me based solely on buzzwords, chances are you have something wrong. Yes, I know you have a lovely entry level .NET position you need to fill, but I am not going to work for $25 an hour 1099 or corp-to-corp. Don’t waste my time.
    6. Not reading my location preferences – yes, I realize that there are jobs that are too good to pass up, no matter where they are located. In general, these jobs have a greater than $250k/year salary ($500k/year for California ;->), moving allowance, and no cost health benefits. Yes, I am being a bit ridiculous, but I am not moving for $45 per hour 1099 or corp-to-corp. I can make that here without any headaches. Now, if you have that $1 million per annum, plus bonus, plus moving expenses, plus no-cost benefits, I might even be interested in going to Greenland for a few years.
    7. Having me do your job for you – I am far along in my career, I should not have to spend an hour answering email questions for you to send my resume to your client. You should be able to do the work to figure out if I am the right person to talk to.

    On point #7, the email today had the following questions and answers, most of which can be determined by READING my resume.

      1)       Full Name:

      2)       Present location:

      3)       Contact Details:

      4)       INS Status:

      5)       Availability:

      6)       Total IT Experience:

      7)       Total US Experience:

      8)       Ready to Relocate (Yes / NO):

      9)       Expected Compensation:

    10)     Comfort levels (on a scale of 1[Least] to 10[High])

            §  OO Design and Analysis

            §  .Net

            §  C#

            §  SharePoint

            §  Silverlight

            §  Web Services

            $  Messaging Framework

            §  PL/SQL (Oracle)

            §  UML

            §  Design Patterns

    11)     Interview Preferred Timings :

    12)    Do you bear the needed years experienced

            §  OO Design and Analysis               5

            §  .Net (C#, Sharepopint)               3

            §  Silverlight                          1+

            §  Web Services & Messaging Framework   2

            §  PL/SQL (Oracle)                      2

            §  UML                                  2

            §  XML                                  2

    BTW, this is not the worst one I have seen. I had one that actually read like a job application (in bad english, of course) and would have me copy almost my entire resume into the email. Do I look desperate?

    I was asked by a friend, who is a recruiter, why so many developers hate recruiters. I told him it was because recruiters were not earning their keep. This is not true of all of them, but there are some who are absolutely wasting my time, and the time of others, to try to make a quick buck. If you want to place me, and do not have a dream job, then you should at least take a few minutes to figure out if I am even qualified or would be remotely interested.

    For the recruiter friends I have in the Nashville area (and some outside the area), I am not talking about you here. Yes, there are some developers that view all every recruiter as scum, but you know I am not one of them. I do have a problem, however, with recruiters that are nothing more than human search engines, as they take way too much of my money for no added value.

    Peace and Grace,
    Greg

    Twitter: @gbworld



    May 11

    Announcements from TechEd

    As always, Microsoft likes to wait until conferences to make big announcements. This year, at Tech Ed, the news is:

    • Office 2010 is the next version of Office. Tech Ed attendees will be one of the first to see the new office product, with an invitation-only Technical Preview starting in July of this year.  The countdown has begun. Check it out at http://www.office2010themovie.com/. If you are not at TechEd, you can get “waitlisted” for the preview here.
    • A technical preview of SQL Server 2008 R2, formerly SQL Server 2010, aka Kilimanjaro (or tallest mountain in Africa), will be released later this summer. You can register for notification here, if they actually have it working now.

    I am more interested in SQL Server at this point in time, although the spec sheet does not show a huge amount that I am likely to get overly excited about right now. Here are the new features;

    • Support for more that 64 logical processors – I am sure some DBAs are salivating, but I’ll pass for now
    • Server Management additions – Great for DBAs
    • Integration with Visual Studio – Okay, this one has my attention, as I hate having to switch tools
    • Master Data Services – Like the idea, more DBA than I am now
    • Self-Service Analysis – Whether you use Excel or SharePoint, end users can now do their own reports against the Enterprise data store. Great idea, but if DBAs cannot control this, it has the potential to be a nightmare.
    • Self-Service Reporting – All users to create their own “grab and go” reports in Reporting Services. I am a bit skeptical, as I have yet to see self-service work; on the other hand, I get paid to fix things people muck up, so maybe this is a good idea. :-)
    Peace and Grace,
    Greg

    Twitter: @gbworld
    May 07

    Star Trek Review

    I just got back from watching Star Trek, aka Star Trek 2009, aka Star Trek Reboot. In many ways, I think Reboot is the most proper name of the three. Perhaps that is why so many sites are using that word.

    The movie starts out in a manner very similar to Lethal Weapon 3. Very few credits and right into the action. In the first few minutes, an interesting plot device allows Abrams to both respect and reinvent the Star Trek universe. I am certain this will be the first film in a set of films and I would be happy to see them continue the story line. I firmly believe this film has finally broken the curse of the odd numbered Star Trek films.

    The film starts out with the childhoods of both Kirk and Spock. As you have most likely seen the trailers for the film, these moments will contain very few surprises. Kirk, a troubled youth, is the genius repeat offender of small town Iowa. Spock, the child of human a Vulcan parents, is an outcast. A sense of duty and a bar fight send them off to Starfleet Academy and starts the ball rolling. Thus ends act 1.

    One by one, familiar characters are introduced, from the paranoid Doctor Leonard “Bones” McCoy to the “pull it out at the last second’ engineer Montgomery Scott, we have characters that are familiar and yet new. And each, in his own way, stays true to the character, at least enough old style Trekkies will enjoy the movie, and adds their own take on the characters. Each character has a pivotal moment in the film where their unique skills provide much needed aid.

    For fans of the old show, there are plenty of one liners in the film. I found myself laughing out loud at some of the lines, much to the chagrin of the twenty-some-odds sitting near me. Perhaps they have not purchased the DVD set?

    One tragedy of the film is it never allows Nero, the Romulan character played by Eric Bana, to fully explore the character. While it might have made the film a bit longer, I think the film could have been better allowing a bit more depth to his character. It would have also been nice to give a bit more depth to the character of Scotty, played by Simon Pegg, who delivers some of the best one liners of the movie.

    The film is a nice blend of action and character development. I think it will play well with audiences that are fans of the original series, as well as those who have never experienced it. I give credit to the screenwriters for pulling this off.

    Grade? I would give the movie a solid B, perhaps even a B+. With a bit more development of the bad guy, and a bit more time spent on the conflict facing Scotty in his first scene, I would have given it an A. When it is finally released on DVD, I will definitely purchase a copy. Here’s to the hope that removing the curse of the odd Star Trek films does not come back with the next even film.

    Peace and Grace,
    Greg

    Twitter: @gbworld

    Windows 7 RC for Everybody

    Microsoft is banking on an RC now. As I mentioned last week, the RC was made available for TechNet and MSDN subscribers. On Tuesday, Windows 7 RC was made available for download for everybody. Click here for the info.

    The RC will expire on June 1, 2010, so you have time to play before it expires. You can download from now until some time in July of this year, so there is no need to rush.

    If you are unsure of whether Windows 7 is for you, I have a taste here.

    Peace and Grace,
    Greg

    Twitter: @gbworld
    May 05

    The C# using statement

    I had a talk with a colleague today about the using statement. It had come up in a job interview and he was thinking about the using statement at the top of the file. If I were asked about using, I would probably answer “you mean try … finally with a Dispose”.

    The following code is nearly identical, when taken from an IL standpoint:

    Code sample 1:

    private static void GetData(string connectionString)
    {
        SqlConnection connection = new SqlConnection(connectionString);
        try
        {
            connection.Open();
        }
        finally
        {
            connection.Dispose();
        }
    }

    Code sample 2:

    private static void GetData(string connectionString)
    {
        using(SqlConnection connection = new SqlConnection(connectionString))
        {
            connection.Open();
        }
    }

    Need proof?

    When reverse engineering file 1 to C#, you end up with the following:

    private static void GetData(string connectionString)
    {
    using (SqlConnection connection = new SqlConnection(connectionString))
    {
    connection.Open();
    }
    }

    Looks just like example 2.
    And here is the IL produced when you run this through Reflector (black lines are the same in both files, blue lines are from file 1 and red lines are from file 2):

    .method private hidebysig static void GetData(string connectionString) cil managed
    {
        .maxstack 2
        .locals init (
            [0] class [System.Data]System.Data.SqlClient.SqlConnection connection)

        .locals init (
            [0] class [System.Data]System.Data.SqlClient.SqlConnection connection,
            [1] bool CS$4$0000)

        L_0000: nop
        L_0001: ldarg.0
        L_0002: newobj instance void [System.Data]System.Data.SqlClient.SqlConnection::.ctor(string)
        L_0007: stloc.0
        L_0008: nop
        L_0009: ldloc.0
        L_000a: callvirt instance void [System.Data]System.Data.Common.DbConnection::Open()
        L_000f: nop
        L_0010: nop
        L_0011: leave.s L_001d
        L_0011: leave.s L_0023
        L_0013: nop

    EXTRA LINES:
       
    L_0014: ldnull
        L_0015: ceq
        L_0017: stloc.1
        L_0018: ldloc.1
        L_0019: brtrue.s L_0022

        L_0014: ldloc.0
        L_0015: callvirt instance void [System]System.ComponentModel.Component::Dispose()
        L_001a: nop
        L_001b: nop – MISSING FROM FILE WITH USING STATEMENT
        L_001c: endfinally
        L_001d: nop
        L_001e: ret
        .try L_0008 to L_0013 finally handler L_0013 to L_001d
        .try L_0008 to L_0013 finally handler L_0013 to L_0023
    }

    When do you use using and when do you use a try?

    • If there is ever a chance of having a catch added, use a try instead of using
    • If not, the choice is yours, but the using statement requires less typing.

    Peace and Grace,
    Greg

    Twitter: @gbworld
    May 01

    OMG, It’s Swine Flu

    In the realm of non-news, I am getting a real kick out of the recent brouhaha over the swine flu. So far, there are 331 confirmed cases of Swine Flu in the world, a “pandemic” that started about 3 weeks ago in Mexico. Thus far there are 28 confirmed deaths in Mexico, 1 in the United States (although I have heard of another death from a person coming back sick from Mexico, so it may be 2 in the US – unfortunately, the man was not tested before he was buried).

    Someone has a Google map of cases: http://snurl.com/h5whe

    This “pandemic” has a lot of people freaking out, but let’s take a reasonable look at the “pandemic”.

    • Flu stats from the CDC show about 18,000 cases of influenza A & B in the US with 55 pediatric deaths
      http://www.cdc.gov/flu/weekly/
    • Flufacts.com shows there are about 25-50 million flu cases each year, with 300,000 – 500,000 deaths annually (1-1.2% of people dying that contract flu)
    • Currently about 8/.4% of the people contracting swine flu have died, but almost all of the deaths are in Mexico. The likely explanation here is not getting proper care before the virus has fully incubated (10 days). In comparison, there have been 168 deaths in Mexico of flu like symptoms that have not been swine flu.

    Don’t get me wrong. This version of the swine flu (H1N1) appears to cause respiratory distress and can be serious if contracted. But we are going crazy.

    On a positive note, the focus on swine flu has the media far less obsessed with their new 100 day old king and the economy. Still it reminds me of the panic over shark attacks a few years ago. I guess we need something to obsess about.

    Peace and Grace,
    Greg

    April 30

    Windows 7 RC

    PC Installed on: Windows Media Center PC n1270m (HP): Pentium 4 3.0 GHz with 2 GB RAM.

    main

    I downloaded the Windows 7 RC from MSDN today and I am in the process of installing it to my home computer. So far I am much more impressed with the install than I was with the betas. They have obviously added some compatibility for the machinery I have to the mix, as I had to install XP and then upgrade with previous builds. With this build, I put in the disk, toasted the hard drive, and it is installed without issue. It took about 20 minutes, which is a great improvement over both the Vista install and previous builds of Windows 7.

    Immediately on install, it found my TV tuner card, which is quite impressive. In previous builds, I had to go searching for the driver, which was a royal pain in the rear. Put in a key and I am up and running in less than 1/2 hour. That is nice. The rest of this entry are random thoughts, as I go through the install.

    Media Center

    The Media Center set up took about 4 minutes to set up. The setup of the local directory took a few more minutes, but I am overall impressed compared to the betas. And it realized I cannot get above channel 99 with this tuner, so I chopped off the channels I can’t get. Much smarter than earlier versions of Media Center, including the beta versions of Windows 7 Ultimate.

    Then, I hit my first snag. The sound is not working in Windows Media Center. Going out into Windows proper, I had no problems whatsoever with tests, but then I noticed the speakers were not a “default” device. Turning that on, the sound came through fine. This sounds much better than both Vista and the betas. Another positive step. It also reacts much faster when expanding or contracting.

    I had a lot of video skipping during the beta, but it is running smooth in the RC. The only skip I have seen thus far was when the background changed (one of the new options on with some of the themes. I am not sure whether I like the changing background or not. Yeah, it is cool, but is it really practical to have a bunch of pictures in queue that change every hour. As I generally have the background covered up with other programs, I am not sure it is worth the cycles.

    Windows Experience

    I, unfortunately, do not have a rating here yet, as the computer BSODed while I tried to have it tested. I am going to try again when I have nothing open and see if there was a conflict between programs i was playing with or it is going to be an ongoing problem. I will post my findings here with an update.

    General Feelings

    With Internet Explorer and Media Center opened, Windows 7 is consuming about 1 GB of memory, so this is not a windows for low end computers. Then again, it runs on my Pentium 4 just fine, so I guess as long as you have memory, you will be fine.

    Windows 7 runs a lot faster than Windows Vista. It also has a cleaner look and is much easier to navigate around. It still feels a lot like Vista. I do like the fact you can move the Sidebar items anywhere on the screen, but this is only marginally better than the Vista implementation, as you generally cover the Sidebar gadgets with real programs anyway.

    Speaking of the sidebar, it is rather funny how it has been used for largely useless widgets. The demos Microsoft showed a few years ago gave some neat ideas of what it might become when it grows up, but with many companies still using XP, it never took off. Perhaps with Windows 7, but I am not holding my breath.

    Startup and shut down are faster now. With the beta, it felt more like a ME experience, where Microsoft merely moved some of the visual elements earlier in the boot cycle. This meant it looked like you could use your computer faster than you actually could. Of course, ME was considered Windows Bob by many people, so I am glad they did not follow the same path when coding Windows 7.

    Games

    Windows installed games are not usually a strong point, and I see the standard stuff here. Chess titans, FreeCell, Hearts, Internet Backgammon, Internet Checkers, Internet Spades, Majong Titans, Minesweeper, Purble Place (children’s game), Solataire and Spider Solitaire. Not sure why they have not included Tinker (a Vista Ultimate strategy game), as it was the best of the lot.

    Features

    I like the fact I can use the Windows keys to open programs I used most often. Drag them on the toolbar and you can Windows key shortcut to them by pressing Windows Key + the number of the item. On the snippet below, that means:

    1. Internet Explorer
    2. Windows Explorer
    3. Media Player
    4. MSPaint
    5. Snippet Tool

    Toolbar

    This makes it much nicer. In addition, you can right click on the items on the toolbar and get a shortcut menu. With Internet Explorer, you get the option of opening a new window, opening a new tab or even going back through history. There is also an option called In Private, which allows you to use Internet Explorer without leaving a bunch of traces (I can see both good and bad uses for this option).

    I can click any item on the toolbar and get previews (note the hover causes a full screen preview, as well) …

    Full Screen Preview

    or right click and get a menu.

    Right Click Menu

    I also think this magnifier might come in handy for demos.

    Magnifier

    Overall, I believe this is what Vista should have been.

    Peace and Grace,
    Greg

    Windows 7 RC Released

    If you have an MSDN or TechNet subscription, you can now download the RC for Windows 7. The sites are experiencing heavy loads right now and I have seen some issues. Best of luck.

    Peace and Grace,
    Greg

    April 29

    Getting rid of some nasty malware (xnev.exe and lsass.exe)

    NOTE: Using CNET links so you feel safe downloading the software I have chosen. Many link back to the manufacturer page anyway, but you will see that CNET, a trusted source, is the starting point. This does not guarantee safety, but it sure increases your chances.

    NOTE: This post deals with Vundo (aka, Virtumonde) and the xneve.exe/lsass.exe virus (not sure the actual name, nor do I care at this time (will research logs later and see if I have a name). The steps here are not guaranteed to get rid of all viruses and malware.

    Yesterday, I got a nasty version of Vundo, aka Virtumonde, on my computer at work. I am not sure where it came from, as we are pretty heavily filtered, but I can state that our Trend Micro at work did not catch it. (Please note this should not be taken as a reason not to buy Trend Micro, as virii and other malcontents are being developed all the time and NO product catches everything all the time).

    Rather than take the chance of not having a computer for a few days, I figured I would take a crack at the malware first and see if I could irradicate it. My first shot was with Spybot – Search and Destroy, which you can find on CNET’s download.com. The main reason for downloading this program was finding a deleted folder with the name, indicating the company had installed it at one time. Spybot – S&D has a neat tool that installs with it called TeaTimer, which allows you to stop the malware from making Registry changes. This is the theory, but the varient of Vundo I had was making changes so fast I could not guarantee I killed all refs prior to reboot.

    I then shredded any files with what is now yesterday’s date in my system32 directory and at the root of my drive, etc. Not every file, but every file with a strange name. Looking back, killing every file might have worked. For this, I used Search and Destroy’s file shredder.

    I did do some damage,  and when I started shredding the files that were not started (using the file shredder in Spybot – Search and Destroy), the malware went into overdrive and started installing other malcontents. This is when xnev.exe and lsass.exe showed up at the root.

    Here is how I killed xnev and lsass (or at least how I feel I killed them. The first thing was getting the computer off the network completely. Any network means the malware can call home for reinforcements. 

    I started with Search and Destroy, which missed them on reboot, although it killed other baddies on the machine. My nextshot was with Malwarebyte’s Anti-Malware. It caught the malware and destroyed it, but it did not destroy the browser objects it installs, so the malware came back. I am sure with some seeking for the root files that caused the problems. I then used Spyware Doctor (CNET download.com launch page). I did have to connect to the network to download the latest patches for the product, so I did it at the same time as Malwarebyte’s Anti-Malware (next step), so I only connnected once.

    If you go this route, you have two options:

    1. Pay for the product
    2. Manually delete the items it shows you

    I chose the later. This got rid of the browser plug in that was making it hard to kill all this garbage. I then ran Malwarebyte’s Anti-Malware, which removed the xnev.exe and lsass.exe that were running from C:. After reboot, I got into the registry and deleted the key for xnev.exe in HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run.

    The machine was now running normally again, but I was not satisfied all the baddies were dead. Running Anti-Malware again, I see 2 Objects infected using a full scan. It is a system restore point, so it is turn off system restore and kill off the remaining baddies. I will edit this once I have fully clean scans.

    Here are the steps I would recommend, from my experience:

    1. Download Spybot – Search and Destroy, Malwarebyte’s Anti-Malware, and Spyware Doctor and possibly some others. Having your tools ready before you get off the Internet is key.
    2. Install the programs and download the latest patches
    3. Disconnect from the Internet completely (including wireless)
    4. Run all three programs
    5. For Spyware Doctor, you will either have to purchase or manually remove the entries, as much as possible
    6. For the others, let them do their thing
    7. Delete all temp files
    8. Delete all internet temp files
    9. Turn off system restore
    10. Delete files created the day you are infected (this may not be easy), or files that have very strange names in your system32 directory. Take care here if you are a newbie at this and use products instead.

    You should do this as soon as you find malware on your computer, which is normally noticed by slow downs of the machine and possibly popups. If you start getting popups to strange places (porn sites, sites advertising anti-virus/malware products), you are probably infected. The quicker you find it, the better, as you can see the files the malware installed.

    Peace and Grace,
    Greg

    April 17

    Review: Artisteer - CSS templates made easy

    Every once is a blue moon, I find an offer to try a product that I am really interested in. The other day, I was examining offers for Microsoft MVPs and I came across Artisteer, a product that creates website templates, for lack of a better short description.

    I contacted Artisteer and got a license key within the hour. I then got a chance last night to sit down and play with the product. I am going to go through the good and bad of the product.

    When you first stoke up Artisteer, you are greeted with a menu that gives you choices for what kinds of templates you would like to work with. These choices are not binding, as you have complete flexibility over your final design, but choose wisely, as you can paint yourself into a bit of a corner. The opening screen looks like this:

    I tried a couple of the templates, and there are a few restrictions on building for things like WordPress, but that is simply because you to fit within the WordPress model.

    Templates:

    There is a bit of good and bad with templates. I like the fact that I can keep mashing the Suggest button to roll through the templates, but it would be nice to see some of these starting designs in a chooser, like the other elements. I realize things might be created "on the fly", but I eventually get tired of mashing suggest to change the look and feel. On the other hand, I like a great deal of the design decisions. Below is a template I created:

    Customization

    While I am not completely sold on the starting point mechanism, you have complete control over the templates you design. For example, the following screenshot is the template above after only 3 mouse clicks on different menus, starting with the Suggest Design button. If I liked the original fonts and colors, I could have hit it with 1 click.

     What can you customize?

    • Layout
    • Color Scheme, including color brightness
    • Header (graphics, fonts, font placement, graphic effects)
    • Background (graphics, color, etc.)
    • Button shape, actions
    • Menu style, including menu item gradients, shape
    • Bounding boxes for sections (block style)
    • Placement of different elements
    • Footer style

    There are some other customizations, as well.

    Saving Your Work

    When you are done, you can export your project. One of the options is a .NET project. The resulting project contains the following tree structure.

     

    Notice that everything is very modular, which is nice. I am not sure I like the placement of the CSS files, personally, but this can be adjusted. I do like the use of a master page. One update I would like to see is an ASP.NET MVC output, but it is not too difficult to output to HTML and create my own MVC site from the template.

    Rendering in Browsers

    I have not tested every browser yet, but the first site I created seems to work fine in IE (v 7), safari, opera and firefox. I have not tested IE 8 yet, which may be interesting.

    One nice thing is the entire site is rendered using CSS. I like this standards based approach to creating sites. There is a separate style sheet for IE6 (which I did not test), so they have thought about the disparity of IE pre 7 days (when standards meant "Microsoft standards"?).

    Thoughts

    Overall the product is rather intuitive and easy to play with. You will find that is mostly what you are doing is playing. There is an undo button, so you can go back if a change munges up something you like. And, it produces a nice site. I will get time for more full featured investigation as I create an actual site with the product.

    I only have two "negative" comments, neither of which is extremely negative.

    1. I am not fond of the lack of an easy way to get to different template styles. Once I have a basic design, it is fully customizable, but getting there is a bit of a pain if the first "suggested" site does not match what I would like. From the downloadable help file, suggest design is the proper way to do this.
    2. There is no help file included in the product (menu). This is minor, overall, as you can easily navigate, but documentation would be nice without having to download a PDF.

    Suggestions for future enhancements:

    • ASP.NET MVC style template output
    • Ability to get to a few design ideas other than suggest
    • Help file included in the product
    • Ability to choose from fixed width and liquid layout

    There is one other thing that nags at me a bit and it is my questioning whether or not the sites, as varied as they are, are a bit too similar to every other site created by this tool. The lack of a liquid layout option (mentioned in my list) may also limit its usefulness for some readers. I will play around for awhile and see if I change my mind on this.

    Side note: Every software product paints you into some type of box, especially products designed to do boilerplate work for you. One question you have to ask is whether or not the box is too tight for your needs.

    Should You Buy This?

    This is the big question for many people when they see a review. Here is my feelings on this.

    The price is not bad for what the product does. The standard version is only $129, so it is not a budget breaker. if you are only designing a single site, it is probably overkill and not worth the price, but if you design for clients, it is a good starting point and I would say worth the price. It sure beats running out the one of the free CSS sites and searching, as my time is worth something (at least in my opinion Wink).

    You can download a trial if you wish to play with the product before buying. It will stamp all the graphics with trial, so it is literally a trial only version. It will allow you to determine if the product is right for you, however. If you are a student or home user, you can buy a $49 version, but I see enough limitations in the student/home version to plunk down the extra money for the full version. Your mileage may vary.

    Peace and Grace,
    Greg

    Twitter: @gbworld