In WW2, UBoat tactics did include night surface attacks. Mostly torpedo although deck guns were used in the early Atlantic war. Their doctrine set a minimum range of 300 yards for a night surface attack. Further, their early war doctrine emphasized repeat attacks on the surface. For a UBoat, surface maneuvering preserved the subs mobility as top submerged speed was less than half surfaced and battery life short at top speed.