

Before you try to do something, make sure you can do nothing
source link: https://devblogs.microsoft.com/oldnewthing/20230725-00/?p=108482
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Before you try to do something, make sure you can do nothing

Raymond Chen
When building a new thing, a good first step is to build a thing that does nothing. That way, you at least know you are starting from a good place. If I’m building a component that performs an action, I’ll probably do it in these steps:
- Step zero is to write a standalone program to perform the action. This ensures that the action is even possible.
- Once I have working code to perform the action, I write a component that doesn’t perform an action. That at least makes sure I know how to build a component.
- Next, I register the component for the action, but have the
Invoke
method merely print the message “Yay!” to the debugger without doing anything else. This makes sure I know how to get the component to run at the proper time. - Next, I fill in the
Invoke
method with enough code to identify what action to perform and which object to perform it on, print that information to the debugger, and return without actually performing the action. This makes sure I can identify which action is supposed to be done. - Finally, I fill in the rest of the
Invoke
method to perform the action on the desired object. For this, I can copy/paste the already-debugged code from step zero.
Too often, I see relatively inexperienced developers dive in and start writing a big complex thing: Then they can’t even get it to compile because it’s so big and complex. They ask for help, saying, “I’m having trouble with this one line of code,” but as you study what they have written, you realize that this one line of code is hardly the problem. The program hasn’t even gotten to the point where it can comprehend the possibility of executing that line of code. I mutter to myself, “How did you let it get this bad?”
Start with something that does nothing. Make sure you can do nothing successfully. Only then should you start making changes so it starts doing something. That way, you know that any problems you have are related to your attempts to do something.
Recommend
-
6
Content_for, yield and making sure something gets displayed Posted: 2007-09-01 - Last updated: 2019-06-05 Tagged...
-
4
3 Things to Try When You Can't Make a Trait Object Feb 2nd, 2021 · Pattern ·
-
5
21 Mar 16 Before You Try To Get A Tech Job, Build Stuff It’s great to go through a coding school and learn the in’s and out’s...
-
16
Nov 15, 2021 — 11:55 CUT CleanMyMac X: Make Sure You Can Trust Your Mac [Sponsor]
-
6
Guides About the Author
-
3
Unique try-before-you-buy software for eCommerceMoast allows shoppers to see products in person through real customers before buying online. With Moast, brands have less pressure to open retail locatio...
-
10
JavaScript Weekly Issue 592 « Prev ...
-
5
Dbrand’s ‘Something’ skins make your phone look like a Nothing Phone 1Igor Bonifacic·Weekend Editor
-
5
Make Sure What You’re Erecting is Not a UX House of CardsYou are in Command of your UX Ship. Don’t Get Lost or Adrift in a Vast Ocean.It’s Easy to Spec...
-
4
Carl Pei wants to make something out of Nothing, but carefully
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK