Monday, December 13, 2010

Today in Excel 2007

Past Special>Formats is useful when you spend time setting up a sheet with customized formatting and then you need to make the sheet expand over/down.

Data>Remove Duplicates is useful when you have rows containing line items and you want, say, all the “names” in one of the columns.  It’s quicker than making a pivot table, which is the other way I know how to do it.

Home>Wrap Text can be thought of as a button with the same functional semantics as Bold or Underline, that is, it’s either on or off for any given position in the document.  It does what it says – if you enter more data than can fit in a column horizontally, and wrap text is in the ON state, then the text will wrap, taking up additional vertical space.

Sunday, December 12, 2010

SQL Server 2008 R2 Feature List (in prog)

todo: make a list of the most interesting features with respect to my projects.

(in prog)

Bus Thought: intern from Rutgers?

The company I work for recently put an ad out for a database developer. It might make sense to inquire with the CS dept. at Rutgers, where they have a notably theory heavy curriculum, if there are any super star academics who would benefit from an intense stint in the real world.  Someone like me when I was there.  Motivated, smart, but inexperienced.  I would be happy to act as a mentor, and the “apprentice like” environment would be a great way to help make a connection to the “why” of all that theory.

Maybe more on this later…

EOF for now.

Notes: My first look at Azure

ME: Today I am working on Sunday because I want to get ahead of the game.

NOW: listening to a pre-recorded web cast on about Azure, the MS cloud database. notes as I listen.Talking about challenges.

AZURE: How to make applications that are useful and scalable? need disks, memory, hardware - managing a data center is hard. How to get app to the market quickly? Helps to have a simplified deployment path (?). Optimize.  Sample: NFL website - very active during games but not all the time. --> data center optimization --> benefits from pay-as-you-go service platform. Azure enables developers to deploy apps. If it can be hosted in IIS, it can be put into Azure. Blob storage:file system. SQL Azure: database. App fabric: queuing/messaging.  Codename Dallas: analysis and BI. 

AZURE: familiar SQL Server relational model. Uses existing APIs and tools. Friction free provisioning and reduced management (?). Built for cloud with availability and scale.

ME: marketing is annoying.

AZURE: true relational database as a service.

ME: This contrasts to, say, SalesForce (maybe more about this later).

AZURE: Data always available and (automatically?) replicated. self heal because (todo. learn more). Scale. 1GB to 50GB.  Control over load balancing.  business ready SLAs.  data centers are all around the world.

AZURE: Relational. Developers use existing knowledge with building SQL server based relational apps. Azure looks just like SQL server to the app. Requests go through the load balancer.


Architecture.  Provision with ActiveDirectory (?).  App topologies. – Azure compute/Code Near – use the azure deployed web site – LOW latency.  Code Far – traditional app model (!!!) – Hybrid. Synch up.

ME: OK!  This is a good thing that I was listening.  “Code Far” is the model I am using with my project right now.  It would be a disaster to try and deploy this knowing the latency would be an issue and the product is not really aimed at this (my interpretation).

HOWEVER! We also need a solution for maintaining highly available PHP based sites, so it’s worth learning a little more.  That said I really need to know if the pricing is something I can sell to management.

Interesting the next topic in the web cast addresses this concern.  Maybe they do focus groups or something and people out there like me reacted just like me.

Provisioning.  Account>Server>Database.


EOF for now.

Wednesday, December 1, 2010

Language Feature Idea - Inner Method

// does thing number one only called here

Tuesday, November 30, 2010

Idea for OO Language Feature

This is a very simple idea. I should think someone has already thought of it but I haven't heard so here goes:

It occurs to me that there's no value in the convention of using the name of class to specify the constructor.

Why not devote a keyword? Like, say, 'ctor'?


Saturday, October 23, 2010

Quick Tip: Windows key combination to launch a program from the start menu with adminitrator rights.

You need to start a program from the start menu with adminitrator rights. You already know how to do it the long way, by right-clicking and drilling into the properties for the shortcut, but you wish there was a faster way.

Open the start menu and type the name of the program just as if you were starting it normally.

Hold down control+shift when you hit enter.

Yay, now the program launches with adminitrator rights!

Friday, October 22, 2010

Foo for Thought: 'Faking' a private readonly property in C#.

We find ourselves wanting to implement a public readonly property.

We are annoyed by the fact that the internal name is different than the external.

public class C
   public C()
      myProp = "V";
   private readonly string myProp;
   public string MyProp { get { return myProp; } }

If you have an interface in place like this:

public interface IC
   string MyProp { get; }
public class C
   public C()
      MyProp = "V";
   // ---------------------------------------------------
   // Then as far as the rest of your code is concerned,
   // this is basically the same as if C# supported 
   // public readonly properties.
   // ---------------------------------------------------
   private readonly string MyProp;
   string IC.MyProp { get { return this.MyProp; } }

Hack-A-Riffic Batch Script Pays Off

I'm writing code that uses a REST API and as project input I have a set of URLs to XSD schema files. I use svcutil.exe to download them from the command line and xsd.exe to generate XML serialization code to make it a breeze retrieving and posting valid requests.

I ran into a snag when the long filenames generated by svcutil combined with xsd's behavior that concatenates its input files to form the name of its (one) output file.

So, I took the opportunity to break out the .BAT file. It's been years, but I've done it before, I can do it again, right? (right)

Long story medium sized, I learned the same few things that I had forgotten a few years ago when it had been a few years since I'd done up a .BAT (See the Notables near EOF).

I wasn't terribly proud of my concoction at first, but the next day when I had to add another XSD schema to my code, and it took me all of 13 seconds, I decided I was, in fact, quite proud.

Here it is, code that first bravely deltes all the XSD and CS files in the current directory, then works from a list of names that get plugged into a URL as part of the svcutil command which downlaods each XSD schema one by one. At this point, the files have really long names based on the URL they came from. If xsd.exe got all of them together, it could (would, will, did) exceed the maximum length allowed by the tool (or the O/S I don't know which, take your pick) --> thus! --> my seasoned hacking brain sprung forth the idea to get the names of the recently downloaded files using the special form of the for loop that acts on directory listings (now you really see the roots of bravery) and renamtes them to 1, 2, 3, etc.

Problem solved :)

I *know* there's a fine chance this entire exercise was unnecessary due to there being a more sensible way of achieving the same goal. Yet, I read the help for xsd and svcutil twice, and nothing came to mind. I'll be very happy to have someone tell me my prized script is pointless in exchange for schooling me proper.

echo OFF 
del *.xsd *.cs 
for %%X in (resourceList campaign campaignGroup affiliate affiliateGroup stats payout) do (  
 svcutil.exe /nologo /t:metadata 
set C=/classes /n:DAgents.DirectTrack.Rest 
set N=1 
for %%X in (*.xsd) do (  
 copy %%X !N!.xsd  
 del %%X  
 set /a N=!N!+1 
for %%X in (*.xsd) do (  
 set C=!C! %%X 
xsd %C% 
echo ON 
  • Use echo OFF/ON to supress extra garbage on the screen while script is running.
  • W.S.T. loop variables, use a single % if entering from DOS prompt and %% if coding a .BAT
  • To code logic that builds up a string via successive concatenation in the body of a loop, use 'SETLOCAL ENABLEDELAYEDEXPANSION' in combination with yet another form of variable referencing as in !N!
  • The for loop has handy features like the ability to loop over the results of a directory list.
  • To do math, use 'set /a'.


Wednesday, October 20, 2010

Subtlety: When the location of using makes a difference for importing namespaces in C#.

You've noticed C# code that imports namespaces with the 'using' keyword in two slightly different syntactic contexts.

  1. At the top of the source code file.
  2. In the body of another namespace.

Understand by Example
namespace My {
  public class C { }

namespace My.Foo {
  public class C { }

// C from My
namespace My.Bar {
  public class Bar { private C instance; } 

// C from My <-- this might be counter intuitive
using My.Foo;
namespace My.Bar {
  public class Bar { private C instance; }

// C from My.Foo
namespace My.Baz {
  using Foo;
  public class Baz { private C instance; }

Tuesday, October 19, 2010

Quick Tip: Using Visual Studio Command Prompt Programs from Windows PowerShell


You use the Visual Studio Command Prompt to invoke programs like cs.exe and xsd.exe and you want to invoke those programs from within PowerShell.


You can use the right-click to paste short cut that is not available in a regular DOS shell.


This procedure explcitly invokes the DOS interpreter causing you to leave the PowerShell immidiate mode environment.


It is possible to create a powershell script that causes the same environment changes programatically, but it's more complicated.  See here.


Right click on the shortcut (usually found in the start menu) that you would use to launch the Visual Studio Command Prompt.

In the properties window that appears, in the Shortcut tab, locate the value of Target.  It should be something like:

%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" amd64
You may replace amd64 above with one of:

   x86 | ia64 | amd64 | x86_amd64 | x86_ia64

Launch PowerShell.

Use copy and paste (in powershell right-click is a short cut to paste text from the clipboard)  to construct a command similar to:

cmd /k 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat' amd64


(IN PROGRESS) An instructional walk-thru.

Learning the MVP pattern is easier by example.

As such, the following table is only to plant a tiny seed in your mind.  Clarity will come by working through examples and then experimenting on your own.

Part Purpose
IModel Data
IView UI
Presenter Intermediary between View and Model.

You have been asked to write a program that lets its user pick two currency types and convert an amount from one to the other.

You define an enumeration type to represent the supported kinds of currency.

public enum CurrencyKind
   USD, // U.S. Dollar
   EUR, // Euro
   AUD // Australian Dollar
   // Additional currencies may be added here.

You define an interface that specifies the functionality required to convert one currency to another.

public interface IModel 
   double ConvertCurrency(
    CurrencyKind from,
    CurrencyKind to,
    double amount);

You define an interface that specifies the movement of information to and from the UI.  Note the use of properties and events to model the direction of data flow. If you're wondering what exactly it is that the data will flow between, dont worry, that's the right question. Stay tuned. (Hint: if you guessed "View and Presenter" you were right)
public interface IView
   CurrencyKind FromCurrencyKind { get; }
   CurrencyKind ToCurrencyKind { get; }
   double ConvertedAmount { set; }
   event EventHandler ConvertCurrency;

You do not want to worry about the details of currency conversion right now so you make a temporary implementation of the model that will suffice.

public class TemporaryModel : IModel 
   double ConvertCurrency(
     CurrencyKind from, CurrencyKind to, double amount)
       // Hard-coded conversion.
       // For now the result is always twice the amount.
       return amount * 2;

TODO: stub the presenter

TODO: Implement first version of concrete View.

Main Program
TODO: Create a driver program to create the objects and get things going.

Test from windows live....