|
|
Guidelines for developers
Portable coding
If you are a software developer who wants to create an application that is supposed to be portable, here are several details you should keep in mind, in order to make sure that your program will successfully handle all the issues portability raises. - Do not hard-code paths. Never assume that Windows resides in C:\Windows or in C:\WINNT. Use %Windir% instead, or find a way to dynamically determine Windows' directory.
- Do not use OS-version-specific functions or variables. Always assume that the program will be used on a version of Windows different from the one you have. If a function you need does not exist in each version of Windows, write your own instead.
- Try to avoid the situations in which your program will work only if certain software components are present (service packs, patches, extensions, etc.), because according to Murphy's laws, the component will certainly be missing :-)
- Do not use localized versions of the GUI, because other systems might not have the required fonts or system libraries which are required to render the text properly.
- Always prepare for the worst case scenario – i.e. the user who runs the program does not have administrative privileges, there are no access rights that permit read/write operations to certain system folders or registry keys you might need.
- Do not use 'magic numbers'. This is rather close to the first tip, only it relates to numbers rather than strings. A good example is the screen resolution – different people have different monitors and different video cards. So, instead of blindly believing that the system works in 800x600, find a way to dynamically determine the video mode and make the proper modifications to the GUI.
- Try not to link too many libraries to your program, in order to keep it small-sized. Not everyone has a 1 Gb flash disk, and certainly not everyone who has one is willing to dedicate the entire space to a single program.
- Minimize read/write operations. Flash disks have a limited life-time, too much stress on flash memory could significantly shorten your disk's operation time. That is why, it is a good practice to load data chunks into RAM and operate with them in the memory, rather than read them from files whenever they're needed. Another major advantage is that this will boost up the speed at which the program works – as flash disks are not the fastest memory storage devices out there.
- Try to make your program as less resource-demanding as possible. It is very likely that the computer on which it will be executed is not a part of NASA's latest server farm.
|
|