It's all about the data.
This series shows you how to work with line-oriented data (by line, by index, by filter), field-oriented data (fixed width, ragged right, variable width), string data (hash tables, property lists, ini files, json), excel data, and XML data (with either XPath or object accessors).
Part 1: File-Based Data, December 2, 2013
Part 2: XML, January 3, 2014
Modules allow you to use standard libraries that extend PowerShell's functionality. They are easier to use than to create, but if you get the hang of creating them, your code will be more easily-maintained and re-usable.
For an experienced programmer to learn a new language can be a journey quite like Alice's in wonderland. Paradoxes, unexpected twists, blind tangents, bafflements and nice surprises. This examination of practices and pitfalls of functions yields some fascinating results.
When you are first learning PowerShell, it often seems to be an 'Alice through the looking-glass' world. Just the simple process of comparing and selecting strings can seem strangely obtuse. This handy wallchart illuminates everything you need to know.
The Manual That Time Forgot
A primer on Red Gate's new foray into the MySql space, mirroring their outstanding products from SQL Server and Oracle:
I literally wrote the book on SqlDiffFramework--plus the application itself! This 150+ page user guide for SqlDiffFramework reveals everything you need to know to get the most out of comparing dissimilar data sources including SQL Server, Oracle, MySql, and any ODBC data source (e.g. Access, Excel, CSV, etc.).
By adding XML-based documentation capability to your SQL code, you can automatically extract tagged comments and format them into truly useful documentation.
Unlike other SQL documentation generators that document the schema and structure of a database,
this article discusses a tool to generate a true API for the procedures and functions in your database.
LINQ has the capabilities of providing a great productivity boost. LINQ Chaining is particularly powerful magic, giving your code greater clarity and brevity. Using it, and debugging it, can be tricky without the right tools and techniques. In this article I talk about the standalone LINQPad utility, with its amazing Dump method, plus several techniques to use within Visual Studio, including a similar Dump method, and even using LINQPad's data visualization capability inside of Visual Studio.
The traditional means for making a generic component that is customizable is the callback method. With LINQ one can do the same thing with just a bit more panache. I like to present my ideas grounded in specific, practical applications: in this case, I chose a file masking user control, allowing a user to filter a list of files from a directory by specifying one--or more--file masks and displaying a dynamic list of matching files.
I then add on top of that a thorough discussion--with sample projects!--for injecting additional, arbitrary constraints in the form of LINQ lambda expressions.
This article takes a fairly simple technique involving both LINQ-to-Objects and extension methods (both new concepts in C# 3.0) and uses it as the heart of two moderate complexity components that could themselves be immediately incorporated as building blocks in a production application. What is interesting is that the two components are quite different on the surface: one involves managing an application's external (file) resources; the other involves initializing choices in a context menu upon a right-click to open the menu. I present a thorough discussion of the LINQ and extension methods that comprise the key portions of the code.
One of the earliest-but still important-tenets of software engineering is the concept of reuse with "software building blocks". In the .NET framework, user controls are the quintessential building blocks, giving you a simple yet powerful way to encapsulate a set of visual components into a more complex one. This holds true both in the WinForms realm and the WPF realm.
What is not well known, nor particularly obvious, is that you can build hybrids, embedding WPF controls in a WinForms application or WinForms controls in a WPF application, using simple adapters. And you can do this either with your custom user controls, or with the set of the full set of .NET controls if the "other" technology has a control you need.
Typical prototypes take too long, cost too much, or achieve too little (or some combination of those). Think back to when you were designing and writing code before Visual Studio. And then, one day, you discovered the capabilities that Visual Studio provides. You could create WinForm applications by dragging and dropping controls from a toolbox and editing their properties! You could create and connect data sources; develop class diagrams; etc. Visual Studio was an earthshaking paradigm shift in design and development.
With the advent of SketchFlow the landscape for creating prototypes has changed. SketchFlow is new, not very well known, not even a standalone product. But it is earthshaking in a similar way.
WPF is simultaneously enticing and intimidating. It offers potential for amazing flexibility in UI design but there is a mountain of learning to climb. In this article I present a collection of little known but useful utility applications that can assist you as you learn and develop WPF code.
This article presents a wallchart (in two versions) that is a cookbook;
It includes an extensive recipe list for--and cross-reference between--XPath, CSS, and DOM, with attention for any Selenium considerations (since Selenium uses all three technologies). It is a useful reference for any of the separate technologies on its own merits, though!
Selenium is a powerful, flexible, yet easy-to-use web testing platform. This article illustrates how to stretch Selenium's boundaries with my open-source extension Selenium Sushi, providing both a support library and a .NET project framework, to make Selenium more useful and make you more productive. It lets you, among other things: retarget different browsers and different application servers without recompiling, handle file URLs automatically and, most importantly, convert a standard code file emitted by the IDE into a substantially smaller piece of source code.
Using a code review tool like the one within TFS is valuable but most people do not use it to their best advantage. This article explains a simple process to get more and better feedback from a TFS code review.
Taming Sandcastle: A .NET Programmer's Guide to Documenting Your Code
The most effective way to document .NET code so that others can understand and use it is with XML Documentation and SandCastle. But the documentation for creating documentation is--quite ironically--hard to come by! This article and wallchart is a guide to the process and the pitfalls.
Taming Sandcastle article, September 13, 2010
Wallchart on Sandcastle Help File Builder, October 11, 2010
Taking XML Validation to the Next Level: Content Assembly Mechanism (CAM)
Use this XmlTransform application to generate sets of HTML pages, SQL documentation, or apply it to your own particular needs.
XmlTransform is a general-purpose XML transformer and validator that operates on an arbitrarily deep directory tree containing files you want to transform, optionally generating multi-level indices and adding navigational linkages.
How one visualizes a concept can greatly impact how well one understands it or, perhaps more importantly, how well one may communicate the concept to others.
In this case study I focus on Ant build files and show how different perspectives on the same code allow you to absorb more information faster, reduce errors, and provide intuitive methods to help you comprehend, modify, and test build targets.
Part 1 (of 3) of my series on the QueryPicker control: No matter how good your SQL skills are, walking into a new situation with unfamiliar databases is only going to make that task trickier; and most large companies - and many small ones, too - will have a heterogeneous database environment, unless you are very fortunate. Mixtures of SQL Server and Oracle are fairly common, and every database type will have different structures and different syntax to remember. This article describes a .NET control called a QueryPicker, a cross-platform query template solution to make life easier.
Part 2 (of 3) of my series on the QueryPicker control: This article presents the technical details on how to integrate the QueryPicker into applications both simple and complex. With screenshots and code samples, this has everything you need to build your own powerful SQL editor or query template explorer.
Part 3 (of 3) of my series on the QueryPicker control: For LINQ lovers, this provides a treatment of how the QueryPicker populates its TreeView from XML using LINQ to Objects, LINQ to XML, and LINQ to XSD.
.NET Building Blocks: Custom User Controls
Part 1 delves into the nitty gritty details required to create, test, use, inherit, install, and distribute .NET User Controls of all types.
Part 2 explores the differences between the various types of custom controls, and shows how to integrate your controls into Visual Studio and make them easy to use.
Part 1: Custom User Control Fundamentals, May 15, 2008
Part 2: Custom User Controls In Practice, July 9, 2008
This handy control provides a complete solution for interactive handling of database credentials, giving you everything you need to control how users input usernames and passwords, select servers, and choose connection types.
After I created a few different proprietary applications where I had to create a custom login form for each, I decided it was time to make one generic enough to be flexible and configurable with just a few lines to set properties.
By using a SyntaxHilightTextBox control, you can build an editor for the language of your choice that highlights keywords, quoted strings, and comments. The article further shows just one example (a VBScript interpreter) of how easy it is to build an IDE leveraging this control.
This article is different: you can read it backwards or forwards. If you have seen those old books-with two books literally pasted together back to back so that if you flip it over you have a different book to read-this article is like that.
It discusses tray applications in WinForms or WPF or both, with consideration of three techniques for mutual exclusion, and presents a tray application framework that you can put to immediate use.
It also presents--as a real-world example of the framework--a utility to switch your host file servers from development to staging to production with one click, called HostSwitcher.
So you can download either source or an installer for HostSwitcher.
If you've ever been frustrated trying to figure out how to intercept or assign specific keystrokes to specific controls, you'll be glad you found this article.
It reveals not only the fundamentals about how keystroke handling is exposed in the .NET framework, but also provides a handy Keystroke Sandbox to actually observe how keystrokes flow through an application, and concludes with a "cook book" detailing how to instrument your code for all the common key handling hooks.
Diagnostics, or program tracing, is a crucial-and often overlooked and underappreciated-component of application development.
It is useful not only during program development but even more so once your application is deployed. Ongoing maintenance costs are one of the largest segments of software's true cost, and well-instrumented diagnostics can reduce maintenance costs significantly.
The MSDN documentation includes a lot of material on persisting application settings in a Windows application. But like much documentation, it's primarily a reference rather than a practical implementation guide, giving the complex and intricate usage details of settings without giving a clear and concise discussion of typical simple uses--exactly what a large number of users will be interested in. This article attempts to provide some tips on implementation.
Input validation is something that every program needs, and every programmer dreads. Most developers craft hard-coded program logic to verify that a phone number consists of 7 or 10 digits; that an IP address consists of 4 octets; that a country name matches 1 of 193 choices, etc. While .NET 2.0 provides some support for streamlining input validation, it barely scratches the surface of automating and simplifying the input validation process.