There’s Nothing Wrong with Hungarian Notation!

I was just scanning StackOverflow looking for interesting Questions and Answers, and happened up this one: Converting JSON to C# Class Object. Serialization is always an interesting subject, and I had previously thought about the idea of serializing (or deserializing) to and from JSON, so I had a look. The questioner was having a problem getting JSON serialization to work, and asked if anyone could see what he was doing wrong. Well, I certainly couldn’t see anything (since I’ve never dealt much with JSON — that’s “JavaScript Object Notation” for those of you wondering about it — it was Greek to me).

But what caught my eye the most was a comment to the question. See, the questioner’s displayed code contained data names like this one: “strMapPolicyID”. Note the “str” prefix. This is one way to indicate that the object in question contains a string. Or “intZoomLevel”, where “int” indicates that it contains an integer. This kind of notation is what is called “Hungarian Notation”, and in some (most?) programmer’s minds it is a thing to be avoided like the plague. The comment in this case was:

Don’t use Hungarian notation. It’s bad practice generally, and totally unexpected when working with JSON. – Panagiotis Kanavos

This annoyed me. There’s nothing wrong with Hungarian notation, per se, any more than there’s anything wrong with Hungarian. In it’s proper place (amongst Hungarians), the Hungarian language is perfectly appropriate. And Hungarian notation has its place, as well. I don’t use the style of Hungarian Notation expressed in the StackOverflow question (I used to, long time ago), but the inventor of the notation, at-that-time Microsofty Charles Simonyi (who is, by the way, Hungarian), didn’t encourage this version of the notation that most programmers are familiar with anyway. This idea of prefacing each variable name with a short indicator of the object’s underlying data type (such as “str” or “int”) is a tautology, and was not what Simonyi had in mind.

One should read Simonyi’s original article on the subect, on Microsoft’s Developer Network site: http://msdn.microsoft.com/en-us/library/aa260976(v=vs.60).aspx

The kind of prefix that Simonyi argued for was the functional prefix, not the data type. For example, if an integer was intended to represent a color, specifically the color red, the variable might be named coRed. Or, if it was supposed to represent the color of a house, coHouse. I don’t have time to provide a precis of Simonyi’s article — just read it.

The simple fact about Hungarian notation is this: what most programmers think is Hungarian notion isn’t. They’re abusing a straw man.

I still use Hungarian notation for names of controls in web pages and windows forms. For example, I might name a textbox txtFirstName, or txtAddress1. What this does is enable me make sure I am addressing all related objects. On the other hand, if I had a lot of textboxes, I might group them in nominal groups, such as a set of textboxes intended to collect or display address information. For example: addrStreet1, addrStreet2, addrCity, addrState, and addrZip. The fact that addrState might be a dropdown containing all 50 states is not important, but it IS important that it enables me to more easily code to them all because auto-completion (Intellisense in Visual Studio) would help me make sure I got them all during coding to access them. And that is the proper role of Hungarian notation — not to mention the proper definition of Hungarian notation.

By the way, there are a couple of blog posts from famous programmers on the subject that bear linking to:

And, as always, have fun coding!

Posted in Coding | Leave a comment

I’ve Just Published a Book (or Two)!

This blog generally deals with technical topics only, but I am going to make an exception in this case. I guess I have that privilege — I make the rules here, after all!

I’ve been working on a side project for the last six or seven years, something completely unconnected with information technology. And after a lot of time, research and just plain work, it has finally come to fruition. I’ve been working on two books, getting them ready for publication.

My wife’s family is German. My mother- and father-in-law were from Memel, Germany, which is now Klaipeda, Lithuania. At the end of the war in Europe they had been living in Osterode in East Prussia (now Ostroda, Poland). As the Red Army invaded East Prussia in January 1945, the family (consisting of Dad, Mom, and four little girls aged 4 through 11) fled via rail toward Elbing, near the Baltic Coast. They got about halfway before a train wreck blocked further progress, and then there were on foot, walking near the rail line in the dead of a cold, cold winter, until they reached the town of Prussian Holland, which is where the Red Army caught up with them. They took shelter in an abandoned house.

They were able to stay in Prussian Holland while the Red Army flowed through on the way towards Berlin, until the military occupation authorities declared that all German adults must register. Mom and Dad left the kids in the house (a different one, because they had been forced to move), and duly went to report. They never returned, leaving the four little girls to fend for themselves in the burned out town. Both the father and mother were taken separately into the Soviet Union, where the Soviets took advantage of the Yalta Agreement provision permitting them to use “German labor” in rebuilding.

The two books track what happened to the little girls and their mother over the next four years, To this day, nobody knows what happened to the Dad. He never returned, which was the fate of nearly half of Germans taken into the Soviet Union to do forced labor. And over 500,000 were so taken. This is not including any prisoners of war taken during or after battle. And these half-million were all civilians, mostly women and old men.

The books themselves are the first person accounts of one of my sisters-in-law, and my mother-in-law. My SiL wrote her own book, titled Yesterday’s Sandhills, and I have edited it extensively over the past seven years (I’ve actually rewritten it five times, but decided in the end to go back and stick closer to her own version). My MiL’s account was actually originally a transcript (in German) of a tape recording of her telling her entire tale from the moment they left Osterode on the train, until she finally returned to East Berlin. My SiL provided my wife and I with the typed transcript, and we translated it into rough English. I have spent the last two years working to turn it into a viable story that could be made into a book.  We’ve given this book the title The Bones of My People.

I am so relieved to finally be able to say: I’M DONE!!!! During the past week we have finally gotten both books into print, using Amazon’s CreateSpace, and both books are now available in both print and Kindle editions. Actually, the second one isn’t quite available on Amazon (in a few days it will be), but I can offer it on my CreateSpace eMarket already. It’s in the pipeline, though.

While I am happy to say I’M DONE, I’m not really done, of course. Since this is self-published (and we formed an actual publishing company with an EIN and all that), we still have to market the books or nobody will ever see them.

I am going to go to bed tonight and I will not set the alarm clock. I am sleeping in tomorrow, Saturday. I’ve been staying up into the wee hours for the last 2 weeks getting all this finalized and I declare that it is now vacation time. I am going to take a Saturday off. For the first time in months.

BothCovers

Available from Prospect Avenue Books!

Posted in Books | Leave a comment

Yesterday’s Sandhills and Bones of My People

The Books are DONE!

As of tonight, both Yesterday’s Sandhills and The Bones of My People are published! The former made it into CreateSpace just tonight, so it isn’t available immediately on Amazon, but it will be there in just a few days. Both books are in print and Kindle editions. Here are their front covers:

BothCovers

We formed a publishing company just to make this a really official effort, and the name of the company is Prospect Avenue Books LLC. The company has a website:

http://www.prospectavenuebooks.com

Don’t judge the appearance too harshly — I’ve been very busy with the books over the past week, and so the site was a rush job.

More later!

Posted in Publishing | Leave a comment

R.I.P. Mikhail Kalashnikov

I was startled to find out this morning that Mikhail Kalashnikov, one of the world’s premier small arms designers, has passed away at the age of 94. I was startled because I hadn’t imagined that he was still alive this late in world history! Also surprising to me, since I had never bothered to look him up before, was that besides a small arms designer he was also a tank commander in the Soviet Army in World War II, and had eventually reached the rank of Lieutenant General.

Along with John Moses Browning and Eugene Stoner, Kalashnikov’s name is legendary in the field of firearms design. His most famous arm, the AK-47 and its variations, continues to be produced and used worldwide by both military forces and civilians. And as ubiquitous as it is, there is naturally some degree of infamy associated with it, as so many terrorist acts have been committed using this very successful firearm. Hoplophobes worldwide have given the weapon great cachet as a tool of destruction, but as Kalashnikov himself has said, it is a weapon just as useful in defense as it has been in offense.

A relevant quote: “I created a weapon to defend the borders of my motherland. It’s not my fault that it’s being used where it shouldn’t be. The politicians are more to blame for this.”

A useful biography of Kalashnikov can be found on Wikipedia, and rather than attempt a precis of it, here is a link: Mikhail Kalashnikov.

Posted in News | Leave a comment

Alaa Wardi is at it Again!

Alaa Wardi is an Iranian muscian based in Saudi Arabia.  He makes some of the best a capella works around.  Many in Engllish and Arabic, but here’s a new offering in French (with a bit of an Arabic flavor in parts).

Way Cool!

Posted in Miscellaneous | Leave a comment

Not Getting Rich On My WP Apps, But…

I got started building apps for Windows Phone with the idea that maybe I’d be able to make some money at it. Keep dreaming, as they say…

In any case, I wasn’t building games, but more-or-less practical apps, and that, combined with the slow startup of Windows Phone, meant that I wasn’t getting much traction in the Marketplace. My practical apps were somewhat marginally practical — who really needs a Fraction Calculator, anyway? Or a Ham Radio License Test Practice app? Very nice, err.. niche.

But last year I got a surprise from Microsoft: $207! It took well over a year, but I finally saw some cash. And to my surprise (having let my developer account lapse due to the less-than-stellar income), I’m getting another approx. $200 this month! Wow! Won’t let me retire early, but apparently “interest” in my apps is steady, if slow. Maybe I should develop another few apps? Perhaps I will. After I get a couple of books published, maybe.

Thanks Microsoft for remembering me!

Posted in My Apps | Leave a comment

Finding a Publisher: CreateSpace

As I said in my earlier post, I tried to get some standard publisher to take on my sister-in-law’s book, but nobody was interested.  I let the matter lie until just recently when I became aware that self-publishing had matured greatly since the time I had tried to get a standard publisher interested.  This where I became aware of CreateSpace.

Since Amazon.com is the best outlet, for sheer worldwide coverage, and CreateSpace is the house self-publisher, I decided to give them a shot.

But first, I decided to make a trial.

I have an autobiography, which isn’t finished (because I am not done, either).  But the section devoted to my life up to the end of the 6th grade is pretty much done, I decided to use CreateSpace to publish it — just so I could see what kind of work they do.  Here’s a link to the first part of my autobiography:

http://www.createspace.com/4317285

After uploading the book, I ordered a “proof” copy and found it to be a quality paperback!  That was great, but would CreateSpace trade honestly with me?  I put this to an experiment.

The experiment involved ordering several copies of the book through both Amazon and CreateSpace itself, and seeing what happened.  I had my brother and sister assist with this, and the results were: CreateSpace reported on all sales.  So my one suspicion, that they would perhaps under-report sales, cheating me out of royalties, seemed to be allayed.

So we got a publisher!  This means that the books will be appearing before the end of the year.

I thought it would be instructive to post an image of my CreateSpace dashboard with the report of sales:

CSUserDashboard_details

I can identify these as:

  • First five orders are a bulk order of five that I put in myself through Amazon.
  • Next one is an order I put in through JnJStore, which appears to be an Amazon surrogate, since it is attributed to Amazon, and its price was 10 cents less than the Amazon discounted price.  This seems to be a sly way to give the buyer alternative price points — and note that my royalty is the same in this case.
  • Next one, the 26th, is the order my sister put in
  • The last one is the order my brother put in.  Note that it is “eStore”, meaning direct through CreateSpace’s own market.  And note further that the royalty is one whole dollar more than through Amazon directly.

This confirms nicely (to me, anyway) that CreateSpace quickly attributes orders to authors, and attributes them correctly.  I’m satisfied.

Posted in Miscellaneous | 5 Comments

Two New Books on the Way!

A long time ago, in 1980, I got lucky and married a very fine woman who made my subsequent life more fulfilled than I ever imagined it could be. Not long after I became acquainted with her, I found out that one of her older sisters, Rita, had written a book about their family’s experiences at the end of World War II in Germany. She had submitted her book to a few publishers by this time, but there had been no interest. I did have a cursory look at the book, and I could see why publishers might not be interested, and that was that the book desparately needed the services of an editor; it was a great story, but not well written, and to a certain extent it needed to be completely re-written. But who would do it? I had no time for it, and back in those days I wouldn’t have described myself as a writer. And we had no money to pay anyone to do it, and neither did my sister-in-law. And so it lay.

Fast forward 25 years to 2005, and with all our children now raised, it suddenly occurred to me that I now had time that I could devote to the project of editing the book into some kind of shape. After all that time I had also added “writing” to my skillset, and though I wouldn’t compare myself with the likes of Tom Clancy, it seemed to me that I could give it a try. So off I went.

To make a long story short, over the next seven years I rewrote the book six times. When I finished the sixth version last year, it was 20% longer than the original, and in my humble opinion I thought I had turned it into a decent piece of work. My wife, however, did not like it. In her opinion, she thought I had turned it into a travelogue-cum-history-lesson, with her sister’s raw emotion wrung all out of it (I had other opinions that strongly suggested she was wrong, but…). I had been ignoring her complaints all along, and I didn’t agree with her, but she finally convinced me that I ought to go back and rewrite the book, as her sister had written it, without going off into flights of geography and history that I, at least, had thought made it even more interesting.

Well, I thought, after six run-throughs, why not do it one more time?

But there was a complication! About five years ago, my sister-in-law sent us a copy of a trascript she had typed up from a tape-recorded monologue that her mother had given her in 1978, in German, This transcript contained some of the story that my sister-in-law recounted, but because her mother had been taken by the Soviets for forced labor in the Ural Mountains for 3 1/2 years, it contained a whole huge pile of other stuff that clearly belonged in this book as well. But how do I put it in? The seventh version of the original book was 246 pages, and were I to add this new material, this would bring the work to close to 400 pages! After some discussion, we decided to publish them as two separate books.

My search for a publisher was the next step, but I will not describe that here. Suffice it to say that I sent submission packages to about 30 publishers for Rita’s book, but there were no takers. If you can’t publish ONE book, how do you expect to publish TWO?

Good question!

Here’s the provisional covers for these two books:

Image

Posted in Miscellaneous | Leave a comment

Remember Versioning Before Putting Fist Through Monitor

I am currently working on a project with a deadline in my day job, and I am having fun with it. Well, mostly. There was this little problem I was having that was beginning to make me quite frustrated. And you know that frustration occasionally results in a computer programmer putting his or her fist through the monitor display, right? Well, I guess that’s a favorite meme; nobody really does this, right? Gosh, I hope not. It wouldn’t be so dangerous these days, what with LED monitors and all, but in earlier ages when we had glass monitor screens we risked serious cuts and bruises.

I was trying to enforce some encapsulation by working with two different VS2012 solutions at the same time. Since I was planning to use a particular set of class libraries in multiple related projects, I wanted to make them into common components. No sense reinventing wheels. So here I was with the common component libraries in one solution and the application using those libraries in the other. The user application had references to the DLLs of the class library, and to the point, the references pointed to the Release folders of the class libraries. Since I was developing both pretty much at the some time (though the class libraries started life and got their major form prior to the user application), I would occasionally find I needed to go back to the class libraries to make tweaks and corrections. Then I would test the user application to see how well the changes worked. The user application was being neatly used as a test bed for the common libraries — meaning the next time I use them, which will be in a follow-on project this week, they will have been largely debugged. Two birds with one stone.

This worked out mostly OK, but I started noticing that sometimes my class library changes weren’t taking effect. I’d make changes, rebuild the libraries, and the changes wouldn’t take effect! But then again, sometimes they would! I was nearing the peak frustration level, with my dual monitors beginning to cringe in anticipation of the inevitable shattering blow from my Fist of Steel®, when suddenly it popped in there as to what was going on.

Aaarrrgggghhhh!

Here I was, rebuilding my libraries with the new changes, and failing to rebuild my user application! Of course the changes weren’t taking effect! The user application was never referring to the DLLs in the Release folders of the class libraries, it was referring to the copies of the DLLs it had placed in its own bin folder! And since I had not rebuilt the user application to pull the class libarary changes into the user application’s bin folver, OF COURSE it continued to use the old versions of the libaries.

In a certain sense I was creating my very own Hell. A versioning Hell. Complete with red-tinged, tailed demons wielding pitchforks. Jabbing me into a towering frustration! But realization is power, and so the demons are now banished to the nether regions. And all is now blue-sky with chirping birds again.

Gosh, I hope I remember this next time.

Posted in Miscellaneous | Leave a comment

So Glad the Royal Baby is Born

First of all, I am an Anglophile.  Which, for those of you who have mislaid your dictionaries, means that I like British stuff. I even lived there for almost three years once!  Love the place, and would like to visit it again one of these days.

Second, I am glad that the new Prince is born.  Long live Prince whatever-his-name-will-be!

Finally, I am also glad that finally we can put the front-page and TV coverage of this whole thing to rest.  I hope, anyway.  It grows tiresome.

Yes, he’s third in line to the throne.  But is he likely to inherit?  That’s an intriguing question.  There have been many royal princes who have been in direct line to the throne who have never actually inherited.  I believe that Prince X will live to be King X, however, because the history of his recent family seems to support it.

Queen Elizabeth is presently 87.  She is well past the median lifespan of women of her age cohort, but her health is apparently quite good, and her mother lived to see her 101st birthday.  It’s hard to factor in her father’s longevity, since he died at age 56 due to environmental effects — he was a heavy smoker and the strain of reigning during World War II took its toll on his health.  Elizabeth has no intention of abdicating, like a few of her fellow European monarchs have done, but this might change if her health deteriorates.  But I don’t know how to bet on that one. Anyone want to start up a pool on how soon Prince Charles, her heir apparent, might inherit?  It is entirely possible that she could outlive Charles, who is now 64.   If she lived to her mother’s age, Charles would be 79.  This would be 2027. At that time, William would be 45 and Prince X would be 14.

One thing of interest here is that the birth of Prince X marks the first time since the reign of Queen Victoria that the reigning monarch and three generations of heirs have been alive at the same time.

79 would be an amazing age to become King.  Let’s assume that Elizabeth leaves the throne (by death or abdication) at her calculated age expectation of 93.  This would be 2019.  Charles would be King at 71.  His calculated age expectancy is 82, making William inherit in 2032.  William would therefore succeed to the throne at age 48, giving him a fair amount of time to reign, and lots of time for Prince X to be prepared to reign.  If William lived until 88 (calculated life expectancy) this means that he would reign for 40 years, and Prince X would succeed him in his turn at age 57 in 2070.

Unfortunately, my calculated life expectancy is 81, meaning that I will likely die during the reign of King William V.  Assuming he chooses William as his regnal name, instead of one of his other Christian names, which are Arthur, Philip, and Louis.

That is a rather interesting set of names he could choose from (although I do believe he need not be limited to them — he’d be the King after all, and could pick something else entirely, or so I suppose).   Arthur Pendragon (of Round Table fame) is a legendary figure, and did not rule all of England, but only a small portion of it, assuming he existed at all.  So William could be Arthur for real, with no need for a numeral after his name.  Or would he prefer to give a nod to Pendragon by being Arthur II?  Interesting question.

As to Louis, Louis VIII of France briefly ruled about half of England from 1216 to 1217, but he was never crowned, and in signing the Treaty of Lambeth in 1217, Louis conceded that he had never been the legitimate king of England.  So, William could be King Louis.

And then there is Philip.  Under the terms of the marriage treaty between Philip I of Naples (Philip II of Spain from 15 January 1556) and Queen Mary I, Philip was to enjoy Mary’s titles and honours for as long as their marriage should last.  And the Pope recognized both Philip and Mary as legitimate King and Queen of England.  So if William chose Philip as his regnal name, he would be Philip II.

And so there we have it.  Much ado about nothing, although I did have fun investigating all the possibilities.

Posted in Miscellaneous | Leave a comment