Hard coding: Difference between revisions

Content deleted Content added
merge from Softcoding
Tag: Reverted
Line 37:
This last example shows why hard coding may turn out to be impractical even when it seems at the time that it would work completely. In the 1980s and 1990s, the great majority of PCs were fitted with at least one floppy drive, but floppy drives later fell out of use. A program hard-coded in that manner 15 years ago could face problems if not updated.
 
==Special folders==
Some Windows operating systems have so called ''[[Special Folders]]'' which organize files logically on the hard disk. There are problems that can arise involving hard coding:
 
===Profile path===
Some Windows programs hard code the profile path to developer-defined locations such as <code>C:\Documents and Settings\''Username''</code>. This is the path for the vast majority of [[Windows 2000]] or above, but this would cause an error if the profile is stored on a network or otherwise relocated. The proper way to get it is to call the <code>GetUserProfileDirectory</code> function or to resolve the <code>%userprofile%</code> environment variable. Another assumption that developers often make is assuming that the profile is located on a local hard disk.
 
===My Documents folder path===
Some Windows programs hardcode the path to <code>[[My Documents]]</code> as <code>''ProfilePath''\My Documents</code>. These programs would work on machines running the English version, but on [[internationalization and localization|localized]] versions of Windows this folder normally has a different name. For example, in Italian versions the <code>My Documents</code> folder is named ''Documenti''. <code>My Documents</code> may also have been relocated using Folder Redirection in Group Policy in Windows 2000 or above. The proper way to get it is to call the <code>SHGetFolderPath</code> function.