views:

95

answers:

3

Very often, I just create a new folder and test things out in there. I use remote upload and then edit and refresh the page to see if it works. Now, one time when I was asked to work on a friend's website, he told me to change the IP for his domain in my HOSTS windows file. He had a clone of his website on another server, so I could edit everything and still visually see my work. Is it ideal to work like this? What's a good strategy for programming when developing websites? e.g. Back up before you begin working, working on the files in a separate directory, etc...

I know everyone has their own style and I understand there's no right way. I'm simply just interested in everyone's common practices and I hope to pick up a few tips here and there and incorporate it to my own style.

+2  A: 

Fiddling with the /etc/hosts file is a quick and simple way to simulate a Web address for testing purposes - nothing wrong with that at first blush.

However, if decently done then working on the site shouldn't need that kind of trickery, because all links inside the site should be relative. i.e. if the original site had an address like http://true.app.com and you were testing on a server with address mock.app.com, then you should be able to point your browser at http://mock.app.com and once you're there all the links should work. If the links are absolute (i.e. the page is full of references to true.app.com) then there might be a problem with the design/architecture/structure.

If your friend doesn't have a domain name for his testing server, then the same applies to the numeric address; the links should still work if you start off browsing to http://1.2.3.4.

A valid reason for "faking" the address might be if your site does a lot of back-and-forth with another, and the other site's links send your browser back to your site.

To answer the question: A good strategy is to work with relative links as much as possible; that way, when your friend's business and software get sold to another company, or he goes out of business and has to re-surface under another name you'll have much less work adapting the links - ideally, none.

Carl Smotricz
This is something I should learn and incorporate in to my developing practice.
Doug
I mess around with my hosts a lot, so I use the ShowIP firefox extension to always display what IP I'm pointed to for a particular address. See it here: https://addons.mozilla.org/en-US/firefox/addon/590/
sdolan
+4  A: 

If you're not already doing it, start using a version control system like git or subversion for keeping track of changes. That way, you'll always be able to revert to an older version if new changes breaks something.

I develop and test changes on my workstation or a development server with a configuration that resembles the web server's config as closely as possible, so that I can be confident that things won't break when I deploy the new version on the web server. I commit my changes as I go, and when I'm satisfied with the new version I deploy it to the web server by checking out the new version on the server.

Pär Wieslander
Ha, subversion was mentioned in my other question. Interesting...
Doug
Using version control is excellent advice. No professional developer should be working without. The Pragmatic Programmers advocate this very strongly. Git is rather painless to set up and work with.
Carl Smotricz
+1  A: 

Pull the site down (if you're going to edit an existing) to your local development web and database server/workstation. Make it run and develop locally. Have the source (code, images, stylesheets, db scripts and so fourth) go into your own version control system.

Oskar Duveborn
I'm guess you're suggesting something like XAMP or WAMP?
Doug
I was thinking of suggesting this, but there is a chance this solution is painful to set up. There may be a significant bit of work involved in setting up the complete environment of a site; and his working relationship with said friend is obviously not a full-blown employment gig. If the friend can set it up, less work and more power to him!
Carl Smotricz
Yeah I know, but that's kinda my idea here ^^ Setting it up will give you important knowledge of how the site works AND make you able to actually set it up from scratch if ever needed. I'd always dive into a project making sure it's actually (re)deployable first.
Oskar Duveborn
With regard to the XAMP or WAMP, that's entirely up to you and of course dependant on what platform the site in question uses to begin with.
Oskar Duveborn