Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


Harris Geospatial / Docs Center / Using IDL / Best Practices in Organizing Your Code

IDL

Best Practices in Organizing Your Code

Best Practices in Organizing Your Code

IDL offers a variety of ways to organize your code. This topic covers some of the methods we have seen that work well and consistently. You could choose to organize your code in other ways, though, so select a method that makes sense and is easy to use.

  • Our strongest recommendation to organize your code is to use projects.
  • Make sure your projects are tied to unique folders or directories that exist outside of IDL's program files area. If you link projects to folders or directories inside the program files area, you may lose them during an IDL upgrade.
  • Do not store anything in the "Default" project that you want to keep.
    • Use "Default" as a scratch space or a sandbox.
    • Files stored in the "Default" project can be lost during an IDL upgrade.

This topic includes the following content areas:

Creating and Using Projects


In the IDL Workbench, projects are simply a way of organizing your files. Logical groupings of related files make it easier to keep them organized, or compile code and build larger programs.

We recommend creating directories on your computer or network to hold related IDL source code for tasks like a programming project or a scientific paper. You can then link these directories to the IDL Workbench with a project. Think of a project as being equivalent to these directories - logical groupings of related files.

Advantages of Projects


The advantages of using individual projects rather than storing all of your files under one project are:

  • Stay organized: keep related code and supporting files together.
  • Cleaner, more efficient builds: build an entire project at once rather than compiling .PRO files individually.
  • Set the compile order for the Project, as well as other preferences used during the build process.
  • Make it easier to export/share related files.
  • You can use projects to manage IDL's path. An "open" Project is in the path and a "closed" project is not. This also gives you a visual indication of what is in the current IDL path.

Guidelines for Using Projects


There are a few guidelines to keep in mind when using projects in the Workbench:

  •  

    When you write programs, create projects that point to directories outside of the workspace provided by IDL. The default location of this workspace is:
    • Windows: C:\Users\<username>\IDLWorkspace8x
    • Mac: /Users/<username>/IDLWorkspace8x
    • UNIX: /home/<username>/IDLWorkspace8x
  • We recommend this so that when you upgrade IDL, you will avoid the need to move your existing .PRO files to the new IDL workspace or new "Default" project.
  • Place routines that you consistently reuse in a separate directory and link them to a project. Keep this "library" project open so you can always access these routines.
  • Keep your projects separated.
    • Keep all code for a single paper for publication in one project (for example, each .PRO file creates a new figure for the finished paper).
    • Keep all program files for a single programming deliverable together in one project. This makes performing a full build on the program easier.

Creating Projects: Demonstration


In this demonstration, we will walk you through creating a project to hold .PRO files for a paper we will publish on Tritium Contamination.

First, use the local computer's native file browser to set up a folder or directory to house the related .PRO files for our paper. In the screenshot below, we have created a folder called "TritiumContaminationPaper" in the "My Documents" area of our local computer (a Windows machine). Note that we have previously created three .PRO files for our paper and have moved them into this directory (see below):

 

Next, create the project from the IDL workbench and connect it to the folder we just created on the local computer. Click the "New Project" icon in the Workbench's toolbar.

The New Project dialog will appear. Type the name of the new project, "TritiumContaminationPaper", in the "Name" field:

 

Next, click the radio button for "Create the new project from an existing directory," then click the Browse button. A second dialog will appear allowing you to connect the new project to an existing folder or directory:

 

Navigate to the folder you want to use to store your files, in this case it is the folder we created in the first step, above, called "TritiumContaminationPaper." Select the folder and click "OK." (Optionally, from this dialog you can create a new folder or directory to use for your project files if you have not already done this.)

Once you click "OK," the Workbench displays the new project in the Project Explorer. Expand the contents of the project by double-clicking its name to see the .PRO files already stored there:

 

Compare the Workbench view of the project with the file browser's view of the folder:

Note that both windows display the .PRO files we created previously. Additionally, the file browser displays a file created by the IDL Workbench called ".project". This file contains IDL-specific information about the project.

Projects and Path Management


IDL gives you many ways to manage your path. The use of projects is one way that we have found works well and gives you a real-time, visual indication of your current path in the IDL Workbench.

By default, if a project's folder is "open" in your IDL Workbench's Project Explorer, then its underlying directory on your computer is automatically included in your IDL path. Conversely, if a project's folder is "closed," then its directory is not included in your IDL path. Note that you can override this behavior when creating a project.

See Also


Creating and Using Projects, The Project Explorer, Projects and Path Management



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us