Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming Python

Ask Slashdot: Taming a Wild, One-Man Codebase? 151

New submitter tavi.g writes "Working for an ISP, along with my main job (networking) I get to create some useful code (Bash and Python) that's running on various internal machines. Among them: glue scripts, Cisco interaction / automatization tools, backup tools, alerting tools, IP-to-Serial OOB stuff, even a couple of web applications (LAMPython and CherryPy). Code has piled up — maybe over 20,000 lines — and I need a way to reliably work on it and deploy it. So far I used headers at the beginning of the scripts, but now I'm migrating the code over to Bazaar with TracBzr, because it seems best for my situation. My question for the Slashdot community is: in the case of single developer (for now), multiple machines, and a small-ish user base, what would be your suggestions for code versioning and deployment, considering that there are no real test environments and most code just goes into production ? This is relevant because lacking a test environment, I got used to immediate feedback from the scripts, since they were in production, and now a versioning system would mean going through proper deployment/rollback in order to get real feedback."
This discussion has been archived. No new comments can be posted.

Ask Slashdot: Taming a Wild, One-Man Codebase?

Comments Filter:
  • by MetalliQaZ ( 539913 ) on Thursday September 20, 2012 @02:32PM (#41402683)

    I don't understand how code versioning has to be coupled with deployment? You have no test environment, as you said... so just make releases and deploy them manually. Since you are going straight to production, you had better be there in person to roll it back if you screwed up. Right? So, SVN should be all you need...

  • Simple answer (Score:5, Insightful)

    by girlintraining ( 1395911 ) on Thursday September 20, 2012 @02:35PM (#41402725)

    My question for the Slashdot community is: in the case of single developer (for now), multiple machines, and a small-ish user base, what would be your suggestions for code versioning and deployment, considering that there are no real test environments and most code just goes into production ?

    The simple answer is, "Whatever works best for you." You're the only developer for these projects. Unless your manager is giving you direction on a specific process or requirements, it's your ball game. You know how you work best -- pick your tools accordingly.

  • by turbidostato ( 878842 ) on Thursday September 20, 2012 @02:37PM (#41402777)

    You say that "now a versioning system would mean going through proper deployment/rollback in order to get real feedback."

    But then, no, it wouldn't.

    Storing your code on a versioning system doesn't mean but that: that you store your code in a versioning system, nothing more, nothing else.

    I'm starting to be an old fart so you can believe me when I tell I've already been in your position.

    Back then I used CVS and it didn't change my deployment procedures in the slightest -only that I had all those scripts in a single convenient place and I could look in past history when I found a regression or I wanted to look for the way I did something in the past.

    The most naive approach is you just got working just the way you are doing now, only that when you are confident on a script/set of scripts you check them in for posterity. You mainly develop in your own desktop and you push your scripts to the servers with an rsync-based script. A bit over this, you use a CM tool (say, puppet) so instead of pushing to the servers you push to the puppetmaster and then run a `puppet agent --test` on the servers: that way configuration becomes code and therefore, repeatibility.

    It allows for almost a novel but the basic idea is just the same: SCM is SCM is SCM; nothing more, nothing less.

  • Re:A few things (Score:5, Insightful)

    by jellomizer ( 103300 ) on Thursday September 20, 2012 @02:40PM (#41402811)

    If you can't get the hardware. Try to Virtualize a Test Envionment with like VM Ware or Virtual Box.
    At least you have something to play in before it you put it out on the open.

  • by MrSenile ( 759314 ) on Thursday September 20, 2012 @02:51PM (#41402953)
    Before it gets out of hand, I'd look to set up four things.

    1. Set up a proper split environment. Even if you don't have the hardware for it, set it up in such a way that when the hardware becomes available, you can move it appropriately. That being, a standard dev -> qa -> stress -> prod infrastructure.
    2. Set up a good revision control. I've started to really enjoy using GIT for this, as there's other software like gitolite that can give you fine-grained access control to your repositories. However, feel free to use subversion or any other well contained revision control platform.
    3. Set up a good method for deployment. My suggestion? Try puppet. It's free, and it's powerful, and if you get it configured, adding new systems to it is exceedingly easy to do.
    4. Packaging for your deployment. If you are installing a bunch of software (scripts, job control, etc) package it and give it a revision, then it's easy to upgrade systems with the 'new package', or revert it to the 'previous package' instead of having to manually copy around files or (re)editing them.

    Hope that helps.
  • Re:git (Score:5, Insightful)

    by ThorGod ( 456163 ) on Thursday September 20, 2012 @02:59PM (#41403065) Journal

    git

    Yes!!! Create git repos of all those various parts on some central git server. Create backups of those repos periodically, like a sane person...

    Git really doesn't require a ton of understanding to "just start using git" competently. It's not going to trash whatever you have in place; it's mathematically proven to *not* lose data.

    Also, freaking set up a dev server already! (That's like 2 machines, or a private, 3rd party git repo (bitbucket is what I use) and a dedicated test/dev machine).

  • by SQLGuru ( 980662 ) on Thursday September 20, 2012 @03:14PM (#41403267) Homepage Journal

    Another benefit of a versioning system is that you don't have to keep large chunks of commented out code. If it needs to go, delete it. It's in the history if you need to go back to it. This alone will clean up most of the spaghetti that a one-coder shop faces.

  • by dgatwood ( 11270 ) on Thursday September 20, 2012 @03:26PM (#41403397) Homepage Journal

    Git is a cleaner model in a lot of ways. In particular, the fact that you have a local copy of the entire repository makes it easier to roll back mistakes you make while editing the code. This isn't always important, but if you decide you're going to do a significant rewrite of some piece of code (and in particular, if you are ever remote while you're doing so), it helps a lot.

  • by slim ( 1652 ) <john@ h a r t nup.net> on Thursday September 20, 2012 @03:31PM (#41403477) Homepage

    Forget that you're a lone programmer. Set up a proper environment anyway.

    This is going to seem like hard work, but once you've done the upfront effort, it will pay dividends.

    Do *everything* that you'd do if you were a team. There are plenty of books / web sites on the subject.

    Pick a version control system -- since you're starting from scratch, Git or Mercurial. Get your code into it.
    Pick a continuous build system -- Jenkins is popular and free.
    Write one unit test, and make Jenkins run it as part of the build process.
    Decide on some sort of repository for your build artefacts.
    Establish an integration testing box, and have your CI system deploy to that every build. Ideally use something like Puppet for this, and also use Puppet on your production machines.
    Write one integration test, and make Jenkins run it after deployment.

    You can dedicate a server to all of this, several servers, run it all on your laptop or in VMs; it really doesn't matter. But think ahead so that you can move it to dedicated machines later if you need to.

    Lots of work, but now you have a nice, confidence inspiring build / code management system.

    Once that's going, you can decide how to fix your lack of tests. One approach is to take a few weeks just writing tests. Another is to write tests as the need arises -- for new code as you write it; to demonstrate bugs before you fix them. Or somewhere in between.

    Python isn't my area, but there is probably an ecosystem of pythonesque tools for a lot of this stuff. pyUnit, code coverage tools, etc.

    You will have problems unit testing, since you won't have designed the code for testability. The choice is, live with fewer tests than might otherwise be possible, or refactor your design into something more unit testable. (IOC is unit testing's best friend)

  • Re:first thought: (Score:5, Insightful)

    by Stiletto ( 12066 ) on Thursday September 20, 2012 @03:36PM (#41403547)

    It's not a silver bullet, but lack of a test environment is sure to eventually cause disaster. It's by far the biggest problem mentioned above, even more of a problem than lack of version control.

  • Re:A few things (Score:4, Insightful)

    by KingMotley ( 944240 ) on Thursday September 20, 2012 @03:58PM (#41403821) Journal

    Not sure why you think you need a separate server just to host the repo. Just host it on the same machine.

    Sure at the office we have a server that hosts the repo, but at my house, I have the repo running on the same machine I develop on. Of course the repo is on a RAID-6, and my local copy I develop on is on a RAID-0, but I didn't need to buy another machine just to host the repo.

  • Well ... (Score:5, Insightful)

    by gstoddart ( 321705 ) on Thursday September 20, 2012 @04:21PM (#41404073) Homepage

    My question for the Slashdot community is: in the case of single developer (for now), multiple machines, and a small-ish user base, what would be your suggestions for code versioning and deployment, considering that there are no real test environments and most code just goes into production ?

    If I'm the people who run the company, I start firing people. If I'm the developer, I run like hell before anybody realizes what a complete mess I've made.

    No versioning, no test environment, live changes in production ... these are warning signs of something which has been cobbled together, and which continues working by sheer dumb luck.

    I had a developer once who edited a live production environment without telling anybody and broke it even worse -- he very quickly found himself with no access to the machines and being told that we no longer trusted him with a production environment.

    Having worked in highly regulated industries where the stakes are really high, I've had it drilled into me that you simply have no room whatsoever to be doing this kind of thing that ad hoc.

    Glad you're starting to use something. But the risk to your employer of all of your stuff tanking and becoming something you can't recover is just too great. From the sounds of it, if you get abducted by aliens or hit by a bus, your company would come to a screeching halt.

  • Re:first thought: (Score:5, Insightful)

    by luis_a_espinal ( 1810296 ) on Thursday September 20, 2012 @05:28PM (#41404869)

    The scripts are irrelevant if not ran on the real environment,

    Well, that's an oxymoron. Any program, large or small, is irrelevant if it never runs on the intended target platform. That's no excuse for having a test server, however feeble compared to production it might be.

    the test environment would have to be a clone of the production environments.

    A clone does not have to be equivalent in terms of hardware or data. A good example is a test db box for testing your SQL scripts. Such a box can have the exact same software, OS and patches, and with equivalent database configuration and schemas, but on lower-cost hardware and with a fraction of the data. As long as a test bench can provide a reasonable, objective measure of comfort of your code, that is all you need. You do not need an absolute guarantee (as there is never one anyways.)

    Good luck with that with the described environment!

    Yeah, because the task is so hard, he might as well give up, right, right, right? Let's do the paralysis-by-analysis chicken dance, shall we?

    He could test each piece of the scripts in testing - which he probably does - but that only gets you so far

    Which is better than nothing, and it is always better to carry tests, however little they might be on a test/sacrificial box than on production. It's not rocket science man.

    and tells you that there's no typos.

    No. It can also tell you that it will not do something bad, like deleting all records in a table, or initiating a shutdown, or filling up the /tmp partition. Better to detect such things on a mickey mouse test box than on the real thing. It might not catch bugs that are triggered by the actual characteristics present in a production environment, but it will most likely catch up bugs (annoying or fatal) that are not dependent on such characteristics.

    Ideal? No. Better than nothing? Hell yeah.

  • Re:Well ... (Score:4, Insightful)

    by turbidostato ( 878842 ) on Thursday September 20, 2012 @07:57PM (#41406287)

    "If I'm the people who run the company, I start firing people."

    Unless, of course and as it is usually the case, it is the one running that small company the one that set the policy to start with.

    "If I'm the developer, I run like hell before anybody realizes what a complete mess I've made."

    Unless, of course and as it is usually the case, the guy is a professional, understands the trade-offs and such does (more or less) the boss that thinks the resulting mess is the most cost-effective way to run his business (and, up to a point, it usually is).

The solution of this problem is trivial and is left as an exercise for the reader.

Working...