Connecting to Standalone/RAC I would like to know if SERVICE_NAME is always configured for a Oracle standalone and RAC setup or it's optional to set up.

In my code I would like to connect to Database using SERVICE_NAME. But if SERVICE_NAME is not always present then I will have to have option to connect using SID. Please advice.
If you're using a current releases, then it will always have default services.  Check dba_services.  Unless there's an application constraint, you should connect with SERVICE_NAME.