it's called gerrymandering, after a early-1800s massachusetts governor named elbridge gerry, who had a genius for the practice.
District boundaries should be fairly drawn so as to include geographically contiguous communities and similar constituencies.