What I usually do for a melon farm (and for pumpkins farm, also) is the following:
FFFFFFFF
DDDDDDDD
DDDDWDDD
FFFF?FFF
FFFFFFFF
DDDDDDDD
DDDDDDDD
FFFFFFFF
D = Dirt
F = Fertile soil (with stem)
W = Water
? = Anything (I usually put up some fences and blocks, like a lamp post)
Then, I just add sticky pistons below the dirt, wired to a button. And, above the stems, I put up glass, so not to step in it and turn the fertile soil back to dirt. This ensures you only have to push a button and walk through the dirt to get all the melon slices. Nice and easy.
Of course, you can replicate this structure as many times as you want. I personally find that 2 or 3 of those gives all the melons you'd want.