Finding and Employing Data Science Tools

Python for Data Science for Dummies introduces you to a number of common libraries used for data science experimentation and discovery. Most of these libraries also figure prominently as part of a data scientist’s toolbox because they provide common functionality needed for every application. It is a great idea for those who are interested in expanding their knowledge in data science and how it can be applied to the field of Artificial Intelligence (AI). You can learn more about some of the basic principles such as applying, developing, leveraging and creating data science projects. However, these libraries are only the tip of the data science toolbox. Because data science is such a new technology, you can find all sorts of tools to perform a wide range of tasks, but there is little standardization and some of these tools are hard to categorize so that you know where they fit within your toolbox. That’s why I was excited to see, The data science ecosystem, the first of a three part series of articles that describe some of the tools available for use in data science projects. If you are interested in finding out more about data science, you might want to check out this data science bootcamp for more information. You can also find the other two parts of the article at:

The problem for people who want to explore data science and machine learning today might not be the lack of tools, but the lack of creativity in using them. In order to explore data science, it’s important to understand that the tools only work when your prepare the data properly, employ the correct algorithm, and define reasonable goals. So for those that are looking for suitable tools and aid when looking to start experimenting with data science or machine learning processes they might look to collaborate with other data scientists using this open-source dvc data science platform or one similar that can integrate many other data science tools. No matter how hard you try, data science and machine learning can’t provide you with the correct numeric sequences for the next five lottery wins. However, data science can help you locate potential sources of fraud in an organization. The article, Machine learning and the strategic snake oil reserve, sums up what may be the biggest problem with data science today-people expect miracles without putting in the required work. Fortunately, there are new tools on the horizon to make languages, such as Python, and products, such as Hadoop, easier for even the less creative mind to use (see Python and Hadoop project puts data scientists first).

Even with a great imagination, the tools available today may not do the job you want as well as they should because the underlying hardware isn’t capable of performing the required tasks. The process is further hampered by a misuse of the skills that data scientists provide (see You’re hiring the wrong data scientists for details). As a result, you need a large number of specialized tools in order to perform tasks that shouldn’t require them. However, that’s the reason why you need to know about the availability of these tools so that you can produce useful results on today’s hardware with a minimum of fuss. Asking the question, “How would Alan Turing fix A.I.?” helps you understand the complexities of the data science and machine learning environments.

Data science, machine learning, data scientists with even greater skills, and better hardware will keep the momentum going well into the future. As the Internet of Things (IoT) continues to move forward and the problem of what to do with all that data becomes even larger, data science will take on a larger role in everyone’s daily life. Count on reading more articles like, Google a step closer to developing machines with human-like intelligence, that describe the proliferation of new hardware and new tools to make the full potential of data science and machine learning a reality. In the meantime, getting the tools you need and exploring the ways in which you can creatively use data science to solve problems is the best way to go for now. Let me know your thoughts on the future of data science at [email protected].

Are You Lying? Can I Tell?

I just read an interesting article, “What happens when your friend’s smartphone can tell that you’re lying?” The reason this article is so interesting is that it involves a kind of application development that I would never have thought possible at one time. That’s what is underneath the technology described in the article. The hardware provides sensors that provide input to application. The application uses the resulting data to determine whether the person in question is lying.

It’s an odd sort of thing to think of, but our society relies on lies to make things work. When someone asks how you feel, do you really think you can be brutally honest? Because lying has such negative connotations, most people would likely say that they’re honest all the time, but in fact, they aren’t. We habitually lie because it’s not only socially acceptable, but socially necessary to do so. Even if we feel terrible, most of us respond that we feel fine when asked how we feel. We know that the other person is simply trying to be nice and probably isn’t interested in how we feel. Asking how someone is doing or how they feel is an ice breaker—a means to start polite communication. The idea that smartphones can possibly detect these little lies will make people feel uncomfortable.

Our society is currently undergoing a massive change and most people aren’t even aware of just how significant the change really is. After all, the change lacks the protests, marching, and other indicators that previous changes have incurred. However, of all the changes I’ve read about, this change is possibly the most significant. We’re now monitoring every aspect of human behavior in ways that our ancestors couldn’t even conceive. Soon, we’ll have the capability of monitoring emotion. The idea that we can literally look into another person’s head and accurately see what they’re thinking and feeling is terrifying in the extreme. At some point we’ll have no privacy of any sort if things continue as they are now. We’ll become Borg-like creatures of the sort described in Star Trek: The Next Generation.

I’ve discussed privacy issues before. In An Unreasonable Expectation of Privacy, I pointed out that humans have never had complete privacy unless they became hermits (and even then, someone probably knew our whereabouts). I’ve also tried to help you counter some of today’s intrusions with posts such as Exercising Personal Privacy. Taking yourself off the grid, ensuring you maintain good privacy techniques online, and so on do help, but this latest article tells me that it may eventually become an issue of not being able to be private, even if you really want privacy. If someone can flash their smartphone at you and determine things like what you’re thinking and how you feel, the act of being private becomes impossible.

We’re on the cusp of a major change that we won’t be able to counteract. Humankind is plunging headlong into a new world where communication takes place more or less instantly and conveys more than just words. It’s going to be interesting to see what sorts of new social rules that we put into place to help with the loss of privacy. For now, users and developers alike need to consider how best to maintain privacy and allow for those times when privacy is no longer possible.

Where do you feel privacy is going? How do you think you’ll react as more and more applications are able to not only accept your input, but also sense your feelings and detect whether you’re engaging in behaviors such as lying? Do developers need to put safeguards in place to keep security issues under control? Let me know your thoughts about the future privacy implications of applications at [email protected].

 

Death of Windows XP? (Part 3)

Questions continue to come in from readers who are still using Windows XP despite the fact that Microsoft is only marginally supporting it. Yes, it’s the operating system that refuses to die and readers really are confused as to why Microsoft has decided to kill what is obviously a popular operating system. They’re in good company. In fact, some authors, such as John Dvorak, have gone a lot further in their negative comments regarding the demise of Windows XP. The point is that Microsoft is quite determined to force anyone they can into using Windows 8.1, whether it works for them or not. It doesn’t seem to matter that people still have perfectly usable systems that are happily running Windows XP without problem.

My first two posts on this topic, Death of Windows XP? and Death of Windows XP? (Part 2) should have addressed any questions that people reading my books might have. Essentially, I recommend updating to Windows 7 (for business users) or Windows 8.1 (for consumers) when your hardware begins to die of old age or your needs change.

 


I no longer have access to a Windows XP system, so I’m not able to provide support for my old Windows XP books at this point in time. If you have one of my old Windows XP books, you’ll need to use it as is. I haven’t purposely gone out of my way to orphan the books, but the technology is old and I simply don’t have the resources to provide support for these books any longer. In addition, none of my current programming books are designed for Windows XP developers.

In the meantime, you need to ensure that you get security updates. Microsoft has extended a limited level of security support until 14 July 2015 that includes malware signatures and the associated engine. You won’t receive any sort of bug fixes. In order to enhance the security of your environment, you may want to consider these changes to your system:


  • Use a browser that receives regular security upgrades, such as Chrome or Firefox (IE is a bad choice because Microsoft won’t update it).

  • Remove any software that is prone to security problems, such as Java.

  • Rely on an account with limited privileges, rather than use the Administrator account.
  • Update any application software as often as is possible.
  • Keep the number of installed applications as small as is possible.
  • Examine your system (especially your hard drive) for signs of intruders (such as unexplained processes) on a regular basis.

  • Stay offline whenever possible.

These strategies can help you out for a while, but they’re short term solutions. Eventually, you need to go offline permanently (such as when using the system to run older games) or upgrade to something newer. Please let me know whether you have any additional questions about Windows XP and how it affects support for my books at [email protected].

Death of Windows XP? (Part 2)

The fact that Windows XP, despite some pretty aggressive attack by Microsoft on its own product, is still alive isn’t in doubt. Of course, there is the matter of support to consider. Microsoft has decided not to provide any more support for Windows XP unless you’re a big company or government organization with immensely deep pockets and have a lot of cash to spend. Stories abound about the Dutch and British governments forking over huge bucks to keep their copies of Windows XP patched. Of course, the IRS is in on it too. (Microsoft begrudgingly decided to provide security updates for Windows XP until 14 July 2015 after a lot of complaining.)

My previous post on this topic, Death of Windows XP?, discussed some of the pros and cons of keeping the aging operating system around. In general, it’s a good idea to update to Windows 7 if you have equipment that can run it. Windows 8 has received a lot of negative press, especially for business needs. After working with it for a while myself, I see it as a good consumer operating system, but not necessarily something a business would want to use. Even with the updates, Windows 8 simply forces the user to work too hard to get things done in a manner that businesses would normally do them.

What surprised me this past week (and it shouldn’t have) is that some larger organizations are taking matters into their own hands. For example, if you’re a Windows XP user in China, you can get updates for your Windows XP installation from Qihoo 360. The point is that it appears that Windows XP will continue to receive patches and security updates even if Microsoft isn’t involved. This process almost reminds me of what happened to IBM when it started to drop the ball on the PC. At one time, everything revolved around IBM, but then the company made some really bad decisions and third parties had an opportunity to take control of the market (which they promptly did).

Whether you believe Windows XP is worth saving or not isn’t the issue. What the whole Windows XP scenario points out is that Microsoft is losing it’s grip on the market, even the desktop market where it once reigned supreme. What are your thoughts about Microsoft’s future? Let me know at [email protected].

 

Death of Windows XP?

There have been a lot of stories in the trade press about Windows XP as of late. A number of readers have written to ask about the aging operating system because they’re confused by stories from one side that say everyone is sticking with Windows XP and stories from the other that say people are abandoning it. Windows XP is certainly one of the longest lasting and favored operating systems that Microsoft has produced, so it’s not surprising there is so much confusion about it.

Microsoft is certainly putting a lot of effort into getting rid of the aging operating system and for good reason—the code has become hard to maintain. Development decisions that seemed appropriate at the time Windows XP was created have proven not to work out in the long run. Of course, there are monetary reasons for getting rid of Windows XP as well. A company can’t continue to operate if no one buys new product. It must receive a constant influx of funds to stay in business, even a company as large as Microsoft. In short, if you’re Microsoft and you want to stay in business, rather than service what has become an unreliable operating system, you do anything it takes to move people in some other direction.

On the other side of the fence are people are are simply happy with the operating system they have today. The equipment they own is paid for and there isn’t a strong business reason to move to some other platform until said equipment breaks. The reliability of computer equipment is such today that it can last quite a long time without replacement. Theoretically, based on reliability alone, it’s possible that people will continue to use Windows XP for many more years. I have such as system setup to hold my movie database and to play older games I enjoy, but I don’t network it with any other equipment and it definitely doesn’t have access to the Internet.

From many perspectives, reports of the death of Windows XP are likely premature. The latest statistics still place the Windows XP market share above 27 percent. Even when Microsoft’s support goes away on April 8th, many third party vendors will continue to support Windows XP. What Microsoft’s end of support means is that you won’t get any new drivers for new hardware or upgrades to core operating system features. However, you can still get updates to your virus protection and Windows XP will continue to operate with your existing hardware.

For most people, the question of whether to keep Windows XP around hinges around the simple question of whether the operating system still fulfills every need. If this is the case, there really isn’t any reason to succumb to the fear mongering that is taking place and move to something else. However, once your equipment does start to break down or you find that Windows XP doesn’t quite fit the bill any longer, try moving along to something newer.

As to the essential question about the level of Windows XP support I’m willing to provide for my books, it depends on the book. My system no longer has development software on it because developers have moved on to other platforms. So, if you ask me programming questions about Windows XP, I’m not going to be able to help you. To some extent, I can offer a little help with user-level support questions for a few of my older books. However, I won’t be able to cover issues that my support system doesn’t address any longer, such as connecting to a network or the Internet. In sum, even though I can offer you some level of support in many cases, I can’t continue to provide the full support I once did. Let me know about your Windows XP book support questions at [email protected].

 

Review of Visual Basic 2012 Programmer’s Reference

As you might expect, Visual Basic 2012 Programmer’s Reference is a heavy tome at 798 pages. Of course, those pages could be filled with fluff, but that isn’t the case with this book. Rod Stephens does a great job of covering a wide variety of topics that anyone who wants to know how to write Visual Basic applications will need to know. The book starts with the assumption that you have never worked with Visual Studio before. Actually, it’s a good start for some developers who have been coding a while because they are self-taught and really haven’t explored everything Visual Studio has to offer.

The first part of the book discusses using the tools of the trade—a topic that most books seem to miss for whatever reason. I’m not talking a quick overview either. Rod provides six full chapters, 77 pages, worth of material on how to use the Visual Studio IDE for various kinds of application development including both Windows Forms and Windows Presentation Foundation (WPF). This may not seem very important at first, but quite a few readers of my books have problems with the IDE they’re using and even more have no idea that the IDE supports certain functionality. In short, many developers don’t have a firm grasp of the tool that they’re using to write code, so they can’t perform their best work. However, if you’re already completely familiar with the IDE, it’s probably a good idea to skip this part of the book because it is quite detailed. Missing from this part of the book is material on working with Metro applications. In fact, that material doesn’t appear until Chapter 21, so this really isn’t a strong Windows 8 offering from a building Metro applications perspective.

The second part of the book is entitled, “Getting Started,” which I view as a misnomer. Yes, you’re getting started writing code, but anyone who skips the first part really hasn’t gotten a good start. This part of the book introduces the reader to controls, forms, and other objects used to create applications. There are six chapters of this sort of material. Again, you can’t expect to create great applications if you don’t know what objects are already available to you. Developers who don’t really know what objects are available will tend to reinvent the wheel or assume that the language isn’t capable of performing a specific task. Rod does an outstanding job of making the reader aware of what is available and how to use it effectively. There are 100 pages worth of extremely useful material of this sort.

Chapter 13 should have begun a new part. Rod leaves controls, forms, and other objects in this chapter to begin working with applications. It’s one of the few organizational errors in the book, but one that is easily forgiven. The next six chapters, 160 pages worth, discuss basic programming topics such as variable data types and the use of programming structures. Chapter 18 provides an excellent discourse on error handling and will be one of the chapters that even experienced developers will want to read.

Chapters 19 and 20 provide extremely basic, but thorough coverage of database topics. This is not a book about database development. Rather, it exposes you to the topic of database development and you’ll need to obtain another book on the topic to finish your education. This said, what this book is really doing is helping you understand database development at an extremely basic level so that the second book you get, the one specifically about database development, will make sense.

Chapter 21 (which is only 12 pages), likewise, is an extremely basic view of Metro development. Again, this isn’t a Windows 8 book and it doesn’t appear that the author ever intended it to fulfill that role. What Chapter 21 does is introduce you to Metro in a basic way so that you can go on to work with a Windows 8-specific book and make sense of the material it contains. That said, I did notice that Chapter 21 does miss out on a few fundamentals, such as obtaining a license for developing apps. Rod doesn’t appear to mention that the target application will only work when running Windows 8 either (at least, I wasn’t able to get it to run on Windows 7).

Starting with Part III, you learn about Object-Oriented Programming (OOP) techniques in detail. Chapter 22 is a must read chapter because it provides the theory that many books on the market lack. It describes what OOP is all about. It’s tough to understand coding examples when you don’t understand the basis for those examples and Rod fills all of the gaps for you. In the chapters that follow, Rod leads the reader through basic class development, structures, and namespaces. The book then continues with some specifies on collection classes and generics. Again, all of this material is designed around a person who really doesn’t know anything about Visual Basic, so Rod takes time to explain the details not found in other books.

Part IV of the book fills out some basic information needed to create standard desktop applications, such as printing in Chapter 27 and the use of configuration information in Chapter 28. The use of streams and filesystem objects come next in Chapters 29 and 30 respectively. The book closes out with an enormous array of appendices (22 of them) that contain all sorts of useful reference information. After you’ve gone through the book, the example applications and this reference material continue to provide you with long term value.

Overall, this is the book that you want when learning Visual Basic. It provides the details needed to write robust applications quickly. However, getting this information is like getting any other sort of education—it takes time and you must work through the examples. This isn’t a quick reference book, nor is it going to provide you with details about specific technologies such as database development or writing Metro apps. Where the book does touch on specifics, it covers those specifics at a basic level with an emphasis on helping people understand the underlying technology. If you’re looking for a book that provides quick answers, a cookbook approach to solving problems, or detailed information about specific technologies, you really do need to look elsewhere. On the other hand, if you’re tired of being confused by online examples and tutorials that don’t really teach you anything, then this is the book you want.

 

Talking Technical with Non-technical Audiences

Communication has always been key to any sort of technical activity, but the need to communicate efficiently is greater today than ever before. The fact that early developers were successful despite having limited communication skills is more due to the fact that early users were also technical (so they shared the same frame of reference), rather than the superiority of the application environment at the time. In fact, applications are a form of communication specific to computers, but until recently, most developers didn’t view them in that light.

The days of the solo developer working in a darkened room and subsisting on a diet of pizza and soda are gone. Applications today have to appeal to a broad range of people-most of whom have no technical skills and have no desire whatsoever to develop such skills. The complex application environment means that developers must possess the means to articulate abstract coding issues in a concrete and understandable manner to people who view their computers as appliances. In addition, developers now commonly work as part of a team that includes non-developer members such as graphics designers. In short, if you don’t know how to tell others about your ideas and the means you plan to use to implement them, your ideas are likely going to end up on the junk heap. That’s why I wrote, “10 Reasons Development Teams Don’t Communicate” for SmartBear Blog.

The problems that developers experience today have more to do with limited communication skills, than technical ability. It’s quite possible to write amazing applications without developing the skills to communicate the concepts and techniques demonstrated in the applications to others. In fact, the stereotype of the geek is funny, in part, because it has a basis in fact. Schools don’t spend much time teaching those with technical skills how to communicate effectively and the graduates often struggle to understand the basis for miscommunication, even amongst peers. Schools will eventually catch up and begin teaching developers (and other technical disciplines) strong communication skills, but in the meantime, developers and other members of the technical professions will need to rely on articles such as mine to obtain the information needed to communicate clearly.

A successful developer now needs to listen to others actively-to be able to repeat the goals others have for an application in terms that the listener understands. In addition, the developer needs to know how to communicate well in both written and oral forms. The transition between the abstract world of code and the concrete world of the typical user is something that a developer needs to practice because there are no books that adequately address the topic today. To keep costs to a minimum, developers must accomplish communication tasks within a limited time frame and without error. In short, there is a significant burden on the developer today to create an environment in which users, administrators, management, DevOps, and other interested parties can communicate both needs (required application features) and wants (nice-to-have application features) in a way that the developer can interpret and turn into a functioning application. Luckily, there are ways to make this a bit easier on the developer. For example, when it comes to DevOps: Agosto offers expertise to help you rapidly deliver what’s needed.

What sorts of communication issues have you faced as a developer or other technical specialist? Do you often find that people look at you quizzically and then proceed as if they understand (but you can tell they don’t)? Let me know your thoughts about communication issues at [email protected].

 

SendKeys for Office 2010 Revisited

Some time ago, I wrote a post entitled, “SendKeys in VBA.” In that post, I described a problem where the SendKeys example in Listing 5-8 of VBA for Dummies isn’t working as expected. It turns out that a lot of people are having this problem and not just with Excel—the problem seems to happen with other Office products as well. I’ve played with the macro in Listing 5-8 quite a lot and while it does work in Office 2007 SP2, it doesn’t work in Office 2010 as written.

Apparently, this problem isn’t unique to Office 2010 either. I’ve found threads online that indicate that the problem also existed in early versions of Office 2007, but was fixed in SP2 after a lot of people complained. Wandering around the Internet has proven interesting because I’ve found other blog posts that try to fix the problem, but didn’t work on my system for whatever reason. The bottom line is that SendKeys is broken and quite a few people know it.

Since my original post, I’ve tried several experiments, none of which resolve the problem, but some of which serve to highlight the true essence of the problem. For example, I tried to break the code in Listing 5-8 apart into room selection and row processing pieces. Here is the room selection piece:

Sub SelectRooms()
    ' Select the first data cell in the worksheet.
    Range("A5").Select
     
    ' Use SendKeys to select all of the cells in the column.
    VBA.SendKeys "+^{DOWN}", True
End Sub

and here’s the row processing piece:

Sub ProcessRows()
    Dim ActiveRows As Integer   ' Number of active rows.
    Dim Counter As Integer      ' Current row in process.
     
    ' Get the number of rows to process.
    ActiveRows = ActiveWindow.RangeSelection.Rows.Count
     
    ' Reset the cell pointer.
    Range("C5").Select
     
    ' Keep processing the cells until complete.
    For Counter = 5 To ActiveRows + 5
     
        ' Call the Sub created to change a single cell.
        MakeChoice3
         
        ' Move to the next cell.
        Range("C" + CStr(Counter)).Select
    Next
End Sub

If you run these pieces one at a time, the example will work just as it did with earlier versions of Office. However, that means running two separate macros instead of one, which does cut down on the usability of the technique. The SendKeys function appears to perform its task at the end of the macro, whenever the end of the macro occurs. Initially, I thought that calling these two macros in succession might do the trick, so I created this piece of code:

Sub ChangeAllRooms2()
    ' Select the rooms.
    SelectRooms
     
    ' Process the selections.
    ProcessRows
End Sub

Unfortunately, the result is the same as before. The SendKeys function really does appear not to output anything until the macro is finished. However, because I’m a glutton for punishment, I tried a few other things. For example, I thought perhaps that the wait part of the SendKeys call was to blame, so I created a manual wait like this:

Sub WaitForSendKeys(Timeout As Integer)
    ' Create a variable to hold the wait interval.
    Dim WaitTime
     
    ' Set the interval.
    WaitTime = TimeSerial(Hour(Now()), _
                          Minute(Now()), _
                          Second(Now()) + Timeout)
     
    ' Wait for the event to happen.
    Application.Wait WaitTime
End Sub

I then modified the original macro to look like this:

Public Sub ChangeAllRooms3()
    Dim ActiveRows As Integer   ' Number of active rows.
    Dim Counter As Integer      ' Current row in process.
     
    ' Select the first data cell in the worksheet.
    Range("A5").Select
     
    ' Use SendKeys to select all of the cells in the column.
    SendKeys "+^{DOWN}"
     
    ' Add a wait interval.
    WaitForSendKeys 5
     
    ' Get the number of rows to process.
    ActiveRows = ActiveWindow.RangeSelection.Rows.Count
     
    ' Reset the cell pointer.
    Range("C5").Select
     
    ' Keep processing the cells until complete.
    For Counter = 5 To ActiveRows + 5
     
        ' Call the Sub created to change a single cell.
        MakeChoice3
         
        ' Move to the next cell.
        Range("C" + CStr(Counter)).Select
    Next
End Sub

The results are that the macro runs a lot slower, but still doesn’t do the job. The only way that SendKeys works is to have it at the end of the macro. In short, you need to execute the code in Listing 5-8 in two parts in order to make it work as originally described in the book. As an alternative, you can still use the code in my previous post. The fix that seems to work best is not to use SendKeys at all.

Microsoft has been quiet about this whole issue. Nowhere have I found any word from Microsoft on the problem with SendKeys and I doubt there is a fix in the offing. If someone has a suggestion for fixing this problem, I’m all ears. Please contact me at [email protected] with full details of your fix. Make sure you’ve tested your code using Office 2010 on a Vista or Windows 7 system. I’ll be sure to give full credit to anyone who does come up with a fix for this problem.

 

Profession Versus Job

I often find inspiration for posts in places that you wouldn’t think to look. Today’s post comes courtesy of Bill Bridges from his Green Market Press blog. The post in question is the Taipei Journal entry for today—there are many of these journal entries, all entertaining and educational about the human condition. Bill is a professional journalist and a good friend who has often inspired me to excel with his seemingly simple posts. The reason that today’s post struck a chord with me is that it answers part of the question of how to become a programmer. My initial post discussed the mechanics, the precursors that someone might pursue to become a programmer, but that post didn’t answer the question of how to make programming a profession.

Today’s journal entry answers the question of profession versus job rather succinctly. Susan writes an article that constantly mentions “the French system of government” without ever explaining what the term means. Bill asks her about it and her response is, “I did sort of wonder about that.” Susan has a job, Bill has a profession. Education, no matter how complete, is only a precursor to a profession. In order to turn a job into a profession, one must also become involved, learn to think for oneself, and have a desire to excel. An aspiring programmer must have integrity as well and be willing to devote long hours toward the goal of delivering the best possible code. Mind you, the code a particular individual delivers is unlikely to be perfect and it’s always possibly that someone else will write better codeI’m talking here about excellence within the individual’s ability to deliver it.

Anyone can perform a job. Only a few people have a profession. However, I’m not talking about a particular sort of profession. When Rebecca and I lived in San Diego, we’d go to a particular restaurant (the name escapes me at the moment, but the restaurant is no longer there anyway). There was a man named Kevin there who waited tablesit was his profession. You could see it in the way he performed the tasks of his tradewith enthusiasm, vigor, and more than a little subtle humor. You felt honored to be served by him and the lines were often long with people who specifically asked for him. Application development is a trade that requires no small amount of education, but I’ve seen more than a few people obtain the required skills by simply reading a book. The difference between a job and a profession remains the samethe professional takes responsibility for successful completion of the task and delights in seeing the task well-done.

While my previous post described a job, this one describes a profession. Many people have questioned why America has been losing it’s place in many different technology areas. First of all, I submit that statistics lie and often tell the story that they’re designed to tell. Don’t believe the lies that you readthink for yourself. Americans still have what it takes to create some of the most amazing technologies ever and I’ve discussed more than a few of these technologies in previous posts. If America has truly lost its edge, then where do these technologies come from? Second, far too many Americans are focused on getting a job, rather than a profession. When you view America of the past, you discover that we have had an array of professionals that delivered new technology is all sorts of waysmany never thought about before.

The bottom line is that you need to consider what sort of programmer you’re going to be as part of your journey. Education isn’t enough. If you really want to become a good programmer, then you must be willing to do what it takes to become a professional. As a professional, you’ll have a higher quality of life, discover the benefits of job satisfaction, and contribute to society in ways that you can scarcely imagine. So what do you havea job or a profession? Let me know your thoughts at [email protected].

 

Understanding the Connection Between Application Output and ErrorLevel

Many readers have a disconnect between application output and the ErrorLevel variable found in batch files. I’ve received more than a few e-mails where readers don’t quite understand the whole concept behind the ErrorLevel variable. They think it actually signifies some sort of mystical operating system derived error, when it isn’t anything of the sort.

A large part of the problem is that those readers who commonly work with batch files aren’t developers and many developers don’t work with batch files. In fact, even though many administrators are moving back to command line utilities because working with the GUI is time consuming and inefficient, many developers have decided to eschew the console application in favor of GUIs with fancier user interfaces.

Another problem is that ErrorLevel is inappropriately named. It should really be named ApplicationOutput. I’m sure that at one time the intention truly was to convey some sort of error information, but even Microsoft uses ErrorLevel for other purposes.

Let’s take a practical look at the whole concept of ErrorLevel beginning with a simple C# application to generate the codes. When working with C#, you’ll find that the output is now called an ExitCode as shown here.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace GenerateOutput
{
    class ExitCode
    {
        static void Main(string[] args)
        {
            // Create a variable to hold the exit
            // value.
            Int32 Value;
 
            // Make sure there is a variable provided as input.
            if (args.Count() > 0)
            {
 
                // Determine whether the input is actually a number.
                if (Int32.TryParse(args[0], out Value))
 
                    // If it is, then exit using that number.
                    Environment.Exit(Value);
                else
 
                    // Otherwise, exit with an error value of -2.
                    Environment.Exit(-2);
            }
            else
 
                // Exit with an error value of -1
                Environment.Exit(-1);
        }
    }
}

The only purpose of this application is to generate exit codes given certain circumstances. The first check determines whether the user has supplied any sort of input at all. If not, if the user simply types GenerateOutput without any arguments at all, then the application exits with a value of -1 to indicate an error. Likewise, if the user types something other than a number, such as GenerateOutput Hello, the application exits with a value of -2 to indicate a different sort of error. Only when the user supplies a number does the application exit with a numeric value.

The batch file used to test this application is equally simple. All it does is call GenerateOutput with the value (if any) that the user provides to the batch file, TestOutput.bat. Here’s the batch file code.

@Echo Off
 
REM Run the application.
GenerateOutput %1
 
REM Most application output are status indicators.
If ERRORLEVEL 2 GOTO HighOutput
 
REM You can perform specific actions for a specific status.
If ERRORLEVEL 1 GOTO ValueOne
 
REM Applications can also provide a success indicator.
If ERRORLEVEL 0 GOTO Success
 
REM Errors are normally negative numbers, but can be anything.
If ERRORLEVEL -1 GOTO Error1
If ERRORLEVEL -2 GOTO Error2
 
:HighOutput
ECHO The value you provided is higher than 1.
GOTO End
 
:ValueOne
ECHO You provided an input of precisely 1.
GOTO End
 
:Success
ECHO An output value of 0 indicates success!
GOTO End
 
REM Here is the beginning of the various messages.
:Error1
ECHO You must supply a number as an argument!
GOTO End
 
:Error2
ECHO You must supply a number and not text or special characters!
GOTO End
 
REM Here is the ending point.
:End

As you can see, the tests check for errors, success messages, and non-error application output. Any combination of console application and batch file can do the same thing provided the developer and administrator get together to work out the details or the developer at least documents the exit codes.

The process is the same each time. Test for an ErrorLevel value, then go to the label specified, execute the directions, and then go to the end of the batch file. The ErrorLevel values must appear in order from greatest to least in order to work correctly. Here is some test output from this test application and batch file pair.

ErrorLevel01

The point of this exercise is to ensure that developer and administrator alike realize the importance of the exit code (ErrorLevel). The application should use it to provide some sort of status information that the administrator can then use to track how well the application works in an automated setting. Let me know if you have any questions at [email protected].