Riding on the sidewalk is usually not advised and for the most part, a cyclists is much safer on the street. There are a few exceptions I use though. When a street or road is particularly unsafe with zero shoulder and high traffic, I would choose the sidewalk for short sections. Although, the best technique is not to put yourself in that position and choose a better route, but sometimes it's unavoidable. When riding with younger kids, unless the road is very low traffic and wide, I might also choose the sidewalk over the road. Also, if I was riding with someone that rode at a slow velocity, and the sidewalk didn't have a high pedestrian volume, I might choose the sidewalk.