Sunday, July 28, 2019

Delphi Tip of the Day - TODO or not TODO

I tend to be a scatter-brain when it comes to Delphi.

Really? Tend to be? "No Gunny. You are a scatter-brain when it comes to Delphi." I can hear all of you who know me saying this. That's fine.. I fully embrace it. I am a scatter-brain, especially when it comes to everything Delphi. There is so much I want to learn and do.

I have been trying to update my very old, flagship product Zilch Standard for 8 years. I've made zero progress. Why? Two reasons:
  1. I am a scatter-brain.
  2. I was of the mindset I needed to start from scratch and completely redesign everything.

When I was a teenager,
I would go to the ...


When I was a teenager, I would go to the library with a specific idea of what I wanted to read about. I'd head straight to those bookshelves and start eyeballing titles. "Nope." "Nope." "Uh Uh." 'Nah." 'Oh, that looks interesting." "Hey that reminds me of  X."  "Where is the 'X' section." Off I'd go to the "X" section,  and repeat this process until I found something all consuming.

This happens to me all the time with Delphi. My thirst for learning overtakes me and I lose focus on actually making progress inside the IDE. 

How about the other issue, having the mindset of completely redesigning everything from scratch? Well that was squelched when my hard drive crashed and I lost over three-and-a-half years of code. Gone! Poof! It actually turned out to be a blessing. It has forced me to look at things with a whole different perspective. 

That brings me to today's Delphi Tip of the Day.

As I was going through and porting over my old Delphi 5 code, I started doing that "scatter-brain" thing again. I first noticed it when I was updating the Main Menu functionality. "Hey, you know what would be cool, an MRU (Most Recently Used) file list." "Yeah lets add that". And off I went on a quest to learn how to build an MRU list.

Two hours later when I went to make another Nespresso (yeah I'm a coffee snob), it hit me. "Hey Gunny, an MRU list is not the objective. Put it on the back burner."

My back burner items tend to get lost and disappear.


My back burner items tend to get lost and disappear. Then I get frustrated because I can't remember all those "To Do" items I have on the back burner. "Hey wait a minute. Doesn't Delphi have a 'To Do' list function built in? 

Yes, Delphi does indeed have TODO functionality and I started using it the other day. However, in traditional Gunny Fashion it's not your normal TODO.
"If we are going to get wet up to our knees, we might as well get wet up to our waist and get the job done right."
I often use that phrase at my day job. Especially when there are two or three of us gathered around working on an immediate issue. It's different when it's an urgent need that must get done before you go home. 

So when I get ankle deep on a "new" feature I'd like to add, that is not a priority, I add it to my TODO list in Delphi. However, I also include the links to the website articles that will be useful when the time comes to implement them later. For example here is my current TODO list:


If you drill down into the highlighted "TODO" item it brings up the source code:

var
  HWnd: THandle;
  MR_Result : Word;

begin
  {---------------------------------------------------------------}
  { Use this code for retail version                              }
  {---------------------------------------------------------------}
  Hwnd := FindWindow('TMainForm','Zilch Standard - Main Screen');
  {---------------------------------------------------------------}
  { Use this code for trial version                               }
  {---------------------------------------------------------------}
  //Hwnd := FindWindow('TMainForm','Zilch Standard (Evaluation Copy) - Main Screen');

  {---------------------------------------------------------------}
  { TODO 3 -oMJR -cPhase 2 : Set Focus to running application     }
  {---------------------------------------------------------------}
  // Refer to these links when for implementing this TODO item
  // https://codeoncode.blogspot.com/2016/12/get-processid-by-programname-include.html
  // https://stackoverflow.com/questions/47598473/how-can-i-call-getwindowthreadprocessid-in-delphi-10-2
  {---------------------------------------------------------------}
   If Hwnd <> 0 then SetForeGroundWindow(GetForeGroundWindow())
  else
  begin
    Application.Title := 'Zilch';
    Application.CreateForm(TMainForm, MainForm);
    Application.CreateForm(TNoPrintDlg, NoPrintDlg);
    Application.CreateForm(TCreditorInfo, CreditorInfo);
    Application.CreateForm(TDisclaim_Save, Disclaim_Save);
    {---------------------------------------------------------------}
    { Use this code for US Marine Corps distribution                }
    {---------------------------------------------------------------}
    {
    MR_Result := USMC_End_User_License.ShowModal;
    If MR_Result = idYes then
    begin
      Application.ProcessMessages;
      Application.Run;
    end;
    }
    {---------------------------------------------------------------}
    { Use this code for genral public distribution                  }
    {---------------------------------------------------------------}
    Application.ProcessMessages;
    Application.Run;
  end;
end.

This way I can do a little "ankle deep" research and keep it preserved on the back burner for latter use without the risk of loosing it. It allows me to scratch the itch at the time it itches and lets me go knee deep later on when the time comes to dive in.

Going forward I will make extensive use of the TODO feature in Delphi. I hope this has helped you better understand TODO's and how they can help you scratch the itch when it itches.

It's time to publish this and get back to work!

Enjoy,
Gunny Mike
https://zilchworks.com

No comments:

Post a Comment