The procedure does work for a cube, if you apply it in the right way. In the case of a sphere, you measure the volume and surface area in terms of the radius, which is the distance from a point on the sphere to the centre. You need to do the same thing for the cube. More precisely, if you have a cube with side s, then the distance x from the centre of the cube to a midpoint of a face of the cube is given by , or The volume of the cube is Differentiate that with respect to x and you get which correctly tells you the surface area.
The same thing works for area and perimeter in two dimensions. If you use the half-side, rather than the side, as the variable, you find that the derivative of the area of a square gives you the perimeter.