You are here:About>Computing & Technology>C / C++ / C#
About.comC / C++ / C#
From David Bolton,
Your Guide to C / C++ / C#.
FREE Newsletter. Sign Up Now!

Hungarian Notation or What?

In case you didn't know it, Hungarian names are apparently given in the order family names first then personal name. This was the reason given for Hungarian Notation where variable names had identifiers like lpFred (Fred is a long pointer). C and C++ developers on Windows will be familar with this. It was created by was invented by Charles Simonyi, a programmer at Xerox Parc who later became Chief Architect at Microsoft. The idea was that variable names were somewhat self-documenting. This was before IDEs had nifty lookups.

I've never been a great fan of this; I'd rather have longer more meaningful names such as CurrentUserCount, where you'd expect that the variable would be an int as it's a counter. It doesn't matter which language you use, so long as you are consistent. For work I try and minimize the effort needed by future developers of my code to understand it. But I'm interested in knowing- are there any other naming conventions ( not Pascal Case or camelCase which use capitalization) that you use to simplify this sort of thing?

Tuesday May 13, 2008 | permalink | comments (0)

XNA Version 3.0 Technology preview Now Available

This is not the full version but an early beta and if you want to start programming games (including multiplayer) for the Zune media player you'll want to try this out. If you're still on Visual C# 2005 (Full or Express versions) you'll need to move to the 2008 editions but it works with the Express editions so it won't cost you a cent. It also works alongside the 2005 editions with the XNA Game Studio 2.0 so no uninstalling is needed.

You can download it from the Microsoft download page. At a modest 42MB it won't take too long.

Monday May 12, 2008 | permalink | comments (0)

My Progress With ASP.NET

It's not that it is intrinsically difficult, I think I was just trying to run before I could walk. I've just spent three days last week taking an existing partly built website in PHP and rewriting it to use ASP.NET/C#. The PHP website used a very nice free template called Multiflex-3. This was written in html and css and I'd used all the PHP tricks I knew so that most of each web page was done with just a few lines of code and a few include files. That's the php way. But I'd been somewhat dissatisfied with PHP over the years and so was determined to make the break and jump to ASP.NET. I even rented cheap ASP.NET 3.5 hosting and registered a domain for it. I started on Tuesday this week and by Thursday I had a lookalike website running (though with most things unimplemented).

With ASP.NET, there are a couple of ways of doing things to simplify life; Master Pages and Themes. You create a Master Page with site logo, menus etc and then each page on the site uses the Master page and you add code to customize it. It's a bit like a master slide in Power Point. Themes let you style all the controls as well as the sites look and feel. Melding them was fun but a bit time consuming but I've now done it with both 2 column and 3 column pages. The frontpage now looks identical to the PHP one including drop down menus. That's to be expected as both these technologies ASP.NET and PHP are both server side and serve up html and css etc but it was still nice to see it! Now of course comes the rest of the hard work; databases, logins, cookies etc. My main reason for switching is that for a sophisticated web application I think C# outguns php.

Sunday May 11, 2008 | permalink | comments (1)

Back to the C Tutorial

With the publication of the C# strings tutorial last week, I'm now back onto C again and this tutorial will be about files; both text files and random access files. Much of my earlier programming was using random access files, particularly in the postal games area. This was in the first few years of PCs, in the late 80s when databases were just starting to appear but were very expensive so everyone rolled their own file system. I didn't actually write any database applications until late 1997 and that was using Microsoft Access mdb files..

Nowadays of course even tiny applications can use small databases like SQLite, which links all its code into the application so there is much less need for random access files. And yet I believe it's a useful programming technique to know.

  • Link to What is a Relational Database?
  • Link to C Tutorials
  • Saturday May 10, 2008 | permalink | comments (1)

    Answer to C# Programming Puzzle and Another!

    If you're used to C or C++ and not C#, you'd expect the compiler to whinge about the casual mixing of incompatible types but C# is more like some scripting languages (eg PHP) in this regard. C# is actually strictly typed but is happy to compile and run this (and outputs a= David 45.60) because all objects, including number literals and types include a ToString() method. So concat works fine!

    Continuing the C# oddities as I've just finished the next C# Tutorial on strings. Is there any difference between the two string variables s1 and s2 in the code below? Is the comparison true or false?

    using System;
    using System.Text;

    namespace ex1
    {
        class Program
        {
            static void Main(string[] args)
            {
            string s1 = "".PadRight(60) + '*';
            string s2 = String.Empty.PadRight(60) + '*';
            if (s1 == s2)
              Console.WriteLine("They're the same!") ;
            else
              Console.WriteLine("They're not the same!") ;
            Console.ReadKey() ;
            }
        }
    }

    Thursday May 8, 2008 | permalink | comments (1)

    C# Programming Puzzle

    Answer tomorrow. Without trying it, will this compile and if so what does it output?

    using System;
    using System.Text;

    namespace ex1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string a="David ";
                int b = 0;
                a= string.Concat(a,4,5.6,b) ;
                Console.WriteLine("a= {0}",a) ;
                Console.ReadKey() ;
            }
        }
    }

    Wednesday May 7, 2008 | permalink | comments (5)

    Inkscape - Open Source Vector Drawing Program

    Inkscape - Vector Drawing ApplicationAlthough not at version 1.0 yet, Inkscape is a quality vector drawing program not unlike Illustrator. I'm pretty dire in the artistic stakes, more technical drawing ability than artistic flair but I used to get by with DPaint back in the early 90s.

    Inkscape is a vector drawing package which means that an entire image is created by millions of vectors; each something like a direction, a distance and a color. This is not the same type as the STL vector (a single array). The big advantage of vector over raster formats (bitmaps etc) is that vector can be stretched without requiring fancy pixel color interpolation schemes. As this is coded in C++ it is cross-platform (Windows, Linux, Mac and more) and you can download the source code from Sourceforge.net and see how it works. I'm very impressed just from playing with it for a short time and it's certainly earned a place in the C++ code library.

    Tuesday May 6, 2008 | permalink | comments (0)

    Programming Challenge 11 Results Posted

    If there is a problem with a programming challenge entry I try and fix it. Not to make it run faster but just to make it compile and run. Usually this is only a problem for C and C++ programmers as most C# compilers are compatible. I gave up compiling entries with Microsoft Visual C++ 6.0 a few months back because it had a few incompatibilities with the likes of GCC, though over the years I've used VC++ 6, it has been extremely popular. I suspect that there must be a C compiler that accepts variable declarations after code judging by one of the entries this month!

    Incompatibilities between different compiler writers is a reflection on the detail of the language specification. Both C and C++ have the odd dusty little area where the order of things isn't defined.

    Anyway, thank you to everyone who entered and congrats to Chris Runyan with his scorchingly fast C++ entry. I'm ready for Challenge 12 entries!

    Monday May 5, 2008 | permalink | comments (0)

    Downloaded the New MFC 2008 Feature Pack Yet?

    Back in January I commented about the available Betas and the full version of the MFC Feature Pack is now out as a free download for Visual C++ 2008 (The full version, not the Express). This is a big update that lets you write software with the modern UI that Microsoft uses for its own software.

    Though IT isn't exactly the fashion industry, there's no doubt that some software tends to look dated, particularly on Windows. That's often not the programmer's fault as the UI visual aspects is determined by the operating system and the support for it. If you've seen the Ribbon bar in Office 2007 (known as the Fluent UI) then you'll know what to expect.. There's also detachable and auto hide tabs, auto use of Aero in Vista, Outlook style alerts, URL link buttons etc. There's lots more and the download link plus walkthroughs, reference material and Samples on this page. Also included are portions of TR1, the new forthcoming standard for C++ and this includes

    • Smart pointers
    • Regular expression parsing
    • New containers (tuple, array, unordered set, etc)
    • Sophisticated random number generators
    • Polymorphic function wrappers
    • Type traits
    And more!
    Saturday May 3, 2008 | permalink | comments (0)

    Programming Challenge 12 now Live.

    This challenge is about writing a program to find the shortest path between ten points in a data file designated by the characters A- J. This is what a very small part of the data file looks like. If you look closely you'll see the first two points A and B. The numbers are the cost to enter each location except for the * locations which are impassable and must be bypassed. So your program must work out the shortest route between each pair of points and add them up. Lowest wins!

    *17594631*577393*244*454466252352121327**47*93955*3
    3524412734*1565*2*3191197531816245*8**1759613859778
    53*253416576251392268418395265918596444*58233992532
    9951*294785*4A*5656*87718896*662295*91*185628846844
    211*65754*47*63767*748687*51221536*4972*9*66*849289
    991496*1667737798285213688473543324267384993194*79*
    97513776433*3*3327925434*57825947255444679131265458
    73564347183668524*5298*4168974178825474967672297712
    7679979*46*8113182489189685282531*76655*85185*93*86
    2981474*85*534186891737369*281*336*59*12253*4366*49
    159*45156384216436639*9*177792581412681934149945627
    987747*3444669656**65*B1*43581546884934614967*3965*
    9673646777641149816313472955**731*4*61*229912468768
    969625978*2689961825**74*649*64837636692349956351*2
    6*798353987653618**42*9*87295688*48219*957682893158

    I'll get Programming Challenge 11 marked over the weekend. There were five entrants.

    Thursday May 1, 2008 | permalink | comments (0)

    Email to a Friend

    Display Latest Headlines | | | Read Archives

    powered by WordPress

    Newsletters & RSSEmail to a friendSubmit to Digg
     All Topics | Email Article | | |
    Advertising Info | News & Events | Work at About | SiteMap | Reprints | HelpOur Story | Be a Guide
    User Agreement | Ethics Policy | Patent Info. | Privacy Policy©2008 About, Inc., A part of The New York Times Company. All rights reserved.