Saturday, April 28, 2007

Keyboarding [Part 1] - The Very Basics

Hi, my name is Dave, I'm certifiably … a mouser. As a matter of a fact, I've intentionally ignored keyboard short-cuts since I upgraded from DOS to [it’s only a passing fad] Windows 3.0 and I just can’t justify having made that decision - at all. Yea, I know, what a horribly inefficient way to get anything done -but- I’m on the road to recovery and plan on dragging you with me, if you’re interested. Sadly, the inspiration didn’t actually come from any self realization of inefficiency or a burning need to become more productive. I read an article Going Commando - Put Down The Mouse on Coding Horror by Jeff Attwood which included digging down into and reading the links found in the article, and it came to me … gosh, you’re unbelievably inefficient with that mouse in your hand. The real kicker was … I was on the laptop which has one built right into the machine, conveniently located right under my thumbs and I’m using one that’s plugged into a USB port. Truth be told, I’m so addicted to it, I’ve been known to pick up the mouse to select a word that is currently right next to the cursor, right clicking on the selection and scrolling to cut/copy or delete on the selection menu! Have I mentioned how dumb I feel about all this? If you’re anything like me, this problem is so ingrained that finally getting around to dropping the mouse, specifically when you’re already working at the keyboard [in the code window], is going to take some effort. Having said that, once you get started down the right path, it seems to get easier and easier. Part of the solution is to make using the mouse -more- of an effort than using the keyboard. Unplug it or hang it over the back of the desk. Digging down into the Going Commando - Put Down The Mouse article I found another written by Jeff called (Very) Basic Textbox Keyboard Shortcuts. This article, which if you’re a newbie like me at this, is a great place to start. You will quickly find that some of the key combinations take a bit of a different path in the code editor than what you get from them in other text editors. We’re going to look at the Delphi key mapping. On to the learning portion of our program … (Very) Basic Textbox Keyboard Shortcuts for the Delphi IDE Code Window. Basic Navigation We all know the basic navigation keys … the Left, Right, Up and Down arrow keys along with Home, End, Page Up and Page Down.
  • Left and Right will move the cursor one character in the chosen direction.
  • Up and Down will move the cursor one line in the chosen direction.
  • Home and End move the cursor to either the beginning or end of the current line.
  • PgUp and PgDn will move to the previous or next text block that will fit in the viewable text area and it will try to keep the cursor in the same [row-column] position.
All these keys work exactly as advertised in the IDE. There is one trick that you really need to know about … Home-Home. The first time you push it, it will do exactly as advertised jumping to the very beginning of the line – the next time you press it, it will jump your code indent and end up just before the first character in whatever code you have on that line. Cool. Accelerated Navigation Want to move that cursor along a wee bit faster? Meet the Ctrl key.
  • Ctrl and either Left or Right will move the cursor to the beginning of the previous or next word.
  • Ctrl and either Up or Down will scroll the code window contents up or down leaving the cursor in it’s current position … unless you try and scroll the cursor off the code window.
  • Ctrl and either Home or End will move the cursor to the beginning or end of the current module.
  • Ctrl and either PgUp or PgDn will move the cursor to the beginning or end of the visible code.
Selecting Text Need to select some text? Meet the Shift key. In a nut shell, adding Shift to any of the Basic or Accelerated key combinations that we’ve already discussed, will select everything between the current position of the cursor, and it’s destination. Yes, there is an “exception” … well, sort of, it isn’t an exception if you really think about it. Ctrl-Shift with Up/Dn won’t select any text primarily because Ctrl Up/Dn doesn’t move the relative cursor position. As the Ctrl-Shift Up/Dn shortcuts aren’t useful in selecting text, this combination has been assigned to move the cursor in a very different, but extremely useful manner. This is a key combination that just has to be in your “use it all the time” collection, read what I’ve already had to say about Ctrl-Shift-Up and Ctrl-Shift-Down. Coming up next ... Keyboarding [Part 2] – Power of the Alt Key Thanks for stopping by, -- Dave

Sunday, April 22, 2007

Ctrl-Shift-Up and Ctrl-Shift-Down

... there may just be a little more to them, than what initially meets the eye. Now it might be common knowledge to you guys -but- I was doing a little research on an article [learning actually] on using the keyboard and forgetting about the mouse when I came across one of those “Wow, that is seriously cool!” features that I just love to find. Ctrl-Shift-Up is a powerful [and pretty clever] little bugger –but- then so is its partner Ctrl-Shift-Down … maybe even more than you would initially think. Now, it may just be because I'm new to even looking at keyboard short-cuts [yea, I know ... I know] but this just makes things so much faster to get to. Using either of these keyboard short-cuts on a run of the mill method is a handy bit of knowledge to have when you need to toggle the cursor between the method and it’s declaration. Have you tried it on a Property declaration or method? From a Property declaration it will toggle the cursor to the first “etter” declaration it finds, from then on you can toggle between the “etter” declarations by continuing to key in Ctrl-Shift-Up. I suppose it’s waiting for you to decide on which of them you want to Ctrl-Shift-Down to. If it only finds one “etter” then it will go there and keying in Ctrl-Shift-Up again toggles back to the Property declaration … probably in case you want to add the missing sibling. If you’ve toggled down [Ctrl-Shift-Down] to either of the “etter” methods Ctrl-Shift-Down again ... you end up in the other “etter” method. How cool is that, eh? Thanks for stopping by, -- Dave

Friday, April 20, 2007

Heat-N-Serve Tutorials ...

... trolling the newsgroups and blogs is a great way to come up with your own ready to serve tutorials. Yes, I am stretching any known definition of the term tutorial to the extremes here but close enough will just have to be good enough. In my seemingly endless sojourn to become apt [oh, alright ... adequate] at using Delphi for Object Pascal, I learn a terrific amount from reading newsgroups and Delphi blogs. There is a wealth of information out there just waiting to be tapped into and transferred, quickly and permanently, up into your noggin. I don't know how many of the "pros" would bother with this simplistic and time consuming method of learning, but it has worked really, really well for me. When these things come up ... I make room for them in my schedule. Getting on with whatever I had planned on doing, just has to wait. It's really quite simple ... find a question on a NG that really interests you. One you just have to know the answer to. I find that the ones that you need to know the answer to but just don't quite "get", are the best. The problem with simply reading the question and then the answers that others provide is that, it doesn't really stick with you and, if you are anything at all like me - when you do finally need the information involved, you'll never find the question again. Read the question carefully. It's really easy to miss subtle nuances in questions and getting it right, is important. If you really have no clue as to where to start, you may be biting off too big a chunk - wait for something you can manage to come along. STOP ... if there are existing responses to the post, it is also very important that you don't read them! Not now, that will come later. Do everything you can to learn as much as you possibly can to be able to respond to the question. I like to limit my resources to the help files, manuals and whatever books I have at hand but I'm not afraid [and can quite often be found] to venture out into the net looking for tutorials and other forms of help. The target is, to be able to provide a response that is as complete as you can possibly come up with. If in the process you sniff out alternative methods to solve the problem - look into them. Become a master at solving the problem ... just stay focused. Relax, there is no time limit ... the clock isn't ticking. Stick with it until until you know [more than] enough to provide a full and accurate response including the possibility of "lively" discussions on the alternatives and the merits and short comings of using them. Now, if code is involved in the answer to the question, write a "Hello World" application that uses everything you've just learned. If it was a cool feature or bit of code you found on a blog ... just do this part. Write the application as if it were production code, you were being paid an outrageously embarrassing sum for it and it had to be submitted for review by the nastiest most ignorant and self righteous developer you could possibly imagine. If you follow the guidelines in Code Complete by Steve McConnell [you do have a copy don't you] and always do it that way, it will soon become second nature - kinda the point. When you're done, go take a break. Think about something else for a while. When you're feeling relaxed and refreshed, come back and review everything you've learned and check over your project [if there is one] for errors or omissions. This whole process can take and hour or it may take days. The longest HNS Tutorial I concocted for myself took me more than two weeks at a couple of hours per day. I avoided the growing number of responses to the question for the entire period ... it was worth it :) Now ... go read the answers. Thanks for stopping by, -- Dave

Friday, April 13, 2007

Now that's a lesson learned ...

Don't use comedic titles on your posts while you're waiting to come up with something relevant. My last blog article was comment about the size of the .Net installation required for Delphi 2007. I put "Why you great fat cow ..." in as a temporary title. While I was thinking, editing and rewriting parts of it I sort of lost track of that fact and hit publish. Coming home after picking up the kids at school, I decided to see how it looked. Shocked that I hadn't changed the title, I jumped into edit mode and started rereading to see if I could come up with something better. Figuring "That's a big chunk of hard drive ... " would be the best I could come up with, it would have to do. Too late; the document itself is called why-you-great-fat-cow.html and DelphiFeeds had already picked it up. Hopefully the DelphiFeeds title may refresh to the one I intended. If you don't find the first title or even my embarrassment in all this the least bit humorous ... sorry.

That's a big chunk of hard drive ...

If you haven't installed it yet and yours is a .Net Free machine, the size of the support structure for Delphi 2007 may come as, well .... a bit of a surprise. Are you "one of them" ... as I once was, who swears "all that .Not crap will never find its way onto my hard drive"? Have you conscientiously managed to kept your machine a .Net free zone? Were you always planning to keep it that way, for as long as you owned your machine? Did the Delphi 2007 bug get you too and now, in a moment of apparent weakness, you have decided to give in to the .Net demon, primarily because you really, really want to install and use Delphi 2007 ... well then, be prepared for a wee bit of disk space usage shock. All that work you've done, keeping the drive lean, tidy and uncluttered by continuously ferreting out and getting rid of all the old unused files and utilities ... is about to pay dividends. The bloated and unwieldy behemoth known as .Net 2.x is lumbering your way and it plans on thunderously and unceremoniously squatting on a very, very large portion of your hard drive. What's more ... it's bringing a bunch of it's equally distended [and to my specific needs, outside of D2007 IDE support - equally useless] friends. Oh yea ... fun times! If there was a web site for "Hard Drive Space ... Pig of the Year" I would have to say that, considering the support files needed to install it on a .Net free system, Delphi for Object Pascal 2007 would most certainly become the new poster child. In fairness though, any .Net dependant piece of software going onto a .Net free machine would do the same. It was indeed a bit of a shock when, having taken a break from happily playing with all the new features and getting the IDE set up - just the way I like it, I had a look at both my hard-drive disk usage and the new items found under the Programs folder. The shock was so intense, I seem to have lost my CodeGear pom-poms :) Ah ... there they are, never mind. I have to admit, thinking I could get away with it forever, was pretty unrealistic. You can actually ... but you would have to forgo anything beyond Delphi 7. Had I kept up with all the .Net installs as well as the additional support files that get installed in the process, I expect I would have to consider Delphi 2007 itself to actually, be pretty lean. The problem is, there's been so much gype installed with it ... I just can't tell. In truth, it's not like I didn't see it coming; Of course, I didn't really expect to find;
  • Microsoft Visual Studio 8 and
  • Microsoft Visual Studio .NET 2003 in addition to
  • Microsoft.NET
hiding away in the Programs Files folder ... but I did. Somehow, an apparently un-deletable [currently], "microsoft frontpage" folder has also sprouted in my Program Files folder, but I don't know if I can blame the recent .Net infestation for that? Woohoo :( Yea, it's all a bit of a shock and although some are finding it somewhat more annoying than others. You have to consider ... this is a professional development tool. Typically installed on a machine with little or no other software. Would it be nice, to have a quick, clean Win32 install of a Win32 IDE for Win32 developers? One that doesn't need any of the .Net support files? Sure it would. Is it going to happen? No, I don't believe for a second that it will. CodeGear needs a single IDE for all the products it produces and several of them need the .Net support files. Read the links above ... the IDE needs the .Net support files. Would I give up Delphi 2007 for a leaner hard drive and no .Net? Not bloody likely. Would I recommend that you install it? In a heartbeat! Have I looked at most of the installed support files and wondered how much of it can I rip out of there and not break things ... oh, yea. Am I going to bother? I seriously doubt it. Unfortunately, it's simply so much easier to just think of it all from a slightly different perspective; now my machine is ready for all of that cool .Not crap I've been secretly hoping to have a peek at :) Shrug it off big guy, let's move on ... time to get back in the game. Thanks for stopping by, -- Dave

Thursday, April 5, 2007

Chat with Jim Douglas, new CEO at CodeGear

Yes, CodeGear has a new CEO [you can find all the details, in a post by DavidI, here: Announcing: Jim Douglas, new CEO of CodeGear] and we all had a chance to meet him this morning during a live chat [CDN Log-In required]. If you missed it, relax, there will be another one this evening at 17:00 PDT. Don't miss that one though! In a nut shell ... I was impressed. The man speaks very, very well and seems down to earth while doing so. Significance of the content aside, we could have all been at the local pub. Although I was expecting fifty-five minutes of this is where I'm taking the show and five minutes of pick a question "that fits where I want this to go" and see if we can slide it in, the chat was quite the reverse. Once DavidI got things going with a couple of not so standard lead ins they moved right into questions from the crowd. Jim was right in there, swinging away at the questions like they had all been scripted. From where I was sitting, he pretty much knocked every one of them out of the park. There wasn't a huge turn out for the chat, around forty in the venue I was using - there were two being used. Considering the chicken-little impersonators and cheer-leaders that have already positioned themselves for the inevitable "told you so" if the change in leadership results in either world domination or death to the product line, I'd say they've pretty much wasted their time. Although I'm leaning toward the world domination corner, I just think he's going to do a really, really good job at what needs to be done next ... and boy, does he have his hands full there. I'm not getting into it here, suffice to say if there's any hiding under desks being done ... it's not at CodeGear HQ - they've done a fantastic job to date and really need to be extremely satisfied with themselves and what they've accomplished in getting some excellent products to market. Jim, welcome to CodeGear and [perhaps more importantly] the CodeGear community! Thanks for stopping by, -- Dave

Monday, April 2, 2007

FizzBuzz ... anyone ... ?

OK, hands up all of you that read the Why Can't Programmers.. Program? article on Coding Horror and wrote a FizzBuzz program? I have to admit that did ...
******************************************************** program FizzBuzz; {Write a program that prints the numbers from 1 to 100 and test for multiples of 3, 5 and both 3 and 5 use Fizz, Buzz and FizzBuzz respectivly to indicate these finds.} {$APPTYPE CONSOLE} uses SysUtils; resourcestring rsFizzBuzz = ' ... FizzBuzz'; rsBuzz = ' ... Buzz'; rsFizz = ' ... Fizz'; const cZero = 0; cThree = 3; cFive = 5; cForDoStart = 1; cForDoEnd = 100; var i: Integer; function FizzBuzzTest(IntIn: Integer): string; {For numbers which are multiples of both 3 and 5 return "FizzBuzz", for multiples of 3 return "Fizz" and multiples of 5 return "Buzz"} var bolMultp3, bolMultp5: Boolean; begin bolMultp3 := (IntIn mod cThree = cZero); bolMultp5 := (IntIn mod cFive = cZero); if bolMultp3 and bolMultp5 then Result := rsFizzBuzz else if bolMultp5 then Result := rsBuzz else if bolMultp3 then Result := rsFizz else Result := ''; end; begin for i := cForDoStart to cForDoEnd do begin writeln(IntToStr(i) + FizzBuzzTest(i)); end; readln; end. ********************************************************
Hey, I just want to see ... Well, I admit, I did go a little over-board with it. I did however write this before the FizzBuzz: the Programmer's Stairway to Heaven came out ... honest.