Generators and representability of functors in commutative and noncommutative geometry