A PDF file can serve as a container for other files. The embedded (attached) files can be of any type: various source files (e.g. spreadsheet), configuration files or PDFs (e.g. a purchase order or a feedback form). A PDF file can serve as a secure delivery medium, where some components optionally require a password before they can be opened. Links/bookmarks in the container PDF can open embedded PDFs at the specified destination or page number, in a new window or in the same window.
In online PDFs of software documentation, it may be beneficial for end users to be able to copy the text out of the PDF and paste it in their software applications. But the different text selection tools in Acrobat/Reader produce different variations with respect to white space characters, line breaks or special characters. However you do this (even if you create a Tagged PDF), there is no guarantee that the text extracted from Acrobat/Reader will be identical to the text that you see in the PDF (or originally placed in FrameMaker). Acrobat has its own interpretation as to what the text is, even if there are no problems related to font encoding/deformation. If the text is split between pages, running header/footer text will be copied as well.
Therefore, adding the code fragments to the document is not enough, as the text copied and pasted is not necessarily identical to the original. But if you embed the code fragments as files in the PDF, users with Acrobat/Reader 6 or higher will be able to open such embedded files or save them to the disk.
When using FrameMaker, file embedding can be automated with TimeSavers + custom ~CommentEmbed and ~DocEmbed shortcuts; the FrameMaker file includes hypertext markers directing Distiller to embed the files and specify properties such as the icon type and color (i.e. "define once in the FM file, distill many", without post-distilling operations).