Code for page access
I think you are looking for a node access module. There are many of them, for example http://drupal.org/project/content_access (configure access with roles directly) or http://drupal.org/project/tac_lite (control access by adding special taxonomy terms) and many more.

For your second question, you should always define some permissions (with hook_perm in D6, hook_permission() in D7) and then check that. That allows to configure through the UI, which roles have that permission and the code is not tied to your specific configuration.