Know What You're Working With

When teaching programming, every teacher has his or her own custom style.  The difficulty is that, when learning about programming, you need to understand the teacher's style, and that's the bit their less likely to explain, sometimes because they can't and other times just to avoid arguments about how they should change.

So I'm going to go over a stylistic trick that a lot of teachers use.  When learning to program, some teachers tend to live in the IDE.  They don't discuss the background stuff that's going on, which can leave you in the dark when you try to understand how everything attaches to the computer as it exists.  So the teacher will be discussing programs inside the IDE but may never even show you the output directory.

I'm using Visual Studio in this walkthrough, but the purpose here is to show you that you should look at the output directories of your own programs, even your toy apps.  Here's the output directory of a tiny hello world app.
Notice first the directory itself is set deep inside the project folder structure in a binaries folder called "bin" and in a folder titled with the build type, in this case "Debug".

My application isn't complicated, it's 16 lines, including unnecessary usings and whitespace, but Visual Studio output 4 files here.  All of the files are named after my solution, so the only way to tell them apart is by the text after the first dot, so let's stick to that text.

First, the "exe" file.

This is the actual application.  I'm sure your professor told you once that your application is producing an exe file, but it's important to note that all of your code was compiled and put inside that exe file.  That's the compiled code.  Different project types may produce different output, but in this case, all of our code is put into one exe file.

Second, the "pdb" file.

This file is used for debugging.  It's purpose is so that visual studio knows what line of your originally written code corresponds to what line of compiled code inside the "exe" file.  It's only purpose is in debugging and it has nothing to do with your actual application when it runs.

Finally, the "vshost.exe" and "vshost.exe.manifest" file.

VSHOST is a feature enhancement to Visual studio to make the Debugger faster.  It creates a hosting environment so that your file can be debugged easily.  This is also only used in debugging and has nothing to do with when your application runs.

It's important to understand what your IDE is doing, because you will some day end up working with other people's code.  If you see that someone else's application has some code you would like to call from your code, you only have a few ways to do it.

If you use the app that the other person wrote, then you have to call an Execute method, wait for the Operating System to spin up the application, and then wait for the application to process your data.  However, if there's a way to call the application through an API, then you have the flexibility to call it directly from your code which can be loads faster.

The reason I mentioned this is because I have seen teachers use the API pattern when working with outside code, but never note it to the students.  Not only are the students missing out on the valuable reason the teacher is doing things in that way, but some might even have missed the very brief sentence in the lecture where the external code was written.  It can be extremely confusing trying to write code that comes from an external API being unaware that you're supposed to have downloaded an external API.


Popular Posts