A recent Sci-Fi adventure movie called Valerian and the city of 1000 planets, featured a giant ball of ships which accumulated over centuries forming a type of space station. However, even that didn't have enough mass to hold things together by gravity, all the ships were just latched onto each other.
There are a lot more efficient structures that can be built in space to achieve a low materials to surface area ratio. And with spin you can give it a fake gravity. The "Ringworld" type designs come to mind as some of the most efficient.
For a more low-cost and robust type of solution to space habitation, I favor hollowing out asteroids. You get a relatively protected environment and you can use the asteroid for raw materials, so you don't need to ship them in. You can also do it just as a byproduct of the mining process itself. It's a "two (or three) birds with one stone" type of situation.