Last night, I was going to go home and write a short script that would combine nmap's output with that of netstat as to give a better understand of what programs had open ports, as to the best of my knowledge, you can't determine this directly from either app. (If there is a way, I'd appriciate it). So I get home, exercise, get dinner going, check email, and the other usual routines, then sit down and flex my fingers, ready to start typing -- and then my mind wandered.

Part of it was that a new episode of Samuri Jack was on :-), but another reason was that while I knew what I wanted, there seems to be a lot of extra steps in between starting with nothing, figuring out the right nmap and netstat calls, parsing them, combining them, and returning the data in some usable format. For some reason, at least for a Monday night, I couldn't see myself sitting through that process to develop it. Mind you, the idea is still there, and I will try to get to it later in the week, but I've found that lately I've been having problems getting started on any of these projects that I've got in my mind due to causal distractions.

I think part of this comes down to the idea of instant gratification, and the more I think about this, I realize that I typically am one of those that looks for this; certainly, this isn't uncommon. I look at how I regard my experiments that I do at work; some I can assertain the results immediately, and I get more excited about those, while others that require a bit more time or work to get meaningful numbers from, I'm a bit hesitent to work on. With regards to programming, instant gratification comes if I can write a quick 10 line perl script to get something done, but if it's going to involve a lot of background research or the like, I must be in the right mindset to get going on it; once the project's at a point that changes or additions have some visible result with running the code, then it's much easier to continue. This is probably more of a problem for programming done on personal time as opposed to work-related programs, since you HAVE to get those done to earn your paycheck.

So, last night instead of programming, I flipped on the DC and played some games (the ultimate form of instant gratification), browsed the web, and otherwise 'wasted' the night.

So I'm wondering if anyone has any advice, both programmatically or environmentally, that would help in avoid the instant gratification syndrome. I can already think of a few ideas. For complex projects, tasks such as unit testing on small segments of code can help , as you can 'contain' each development piece to a short programming challenge with a way to generate results. Setting a goal for a larger project ("I will write this function and this function today") also seems to help; particularly if those goals are met in the time, then moving on to additional goals is usually an easy extention in the same period. I also figure that programming every day on the same project is good, and a hour or two playing games is certainly enough to allow for the need for instant gratification to be served.

It could also just be an issue of willpower; forcing myself to do the programming despite the lack of instant rewards.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: Programming and Instant Gratification
by VSarkiss (Monsignor) on Oct 16, 2001 at 18:53 UTC

    Hmm.... You're not writing long articles on PM just to avoid work, are you? ;-)

    I think your issue is shared by many. In my own case, what helps is knowing what my "avoidance behaviors" are. For example, I make short to-do lists (8-10 items) to organize my work. A sure sign of procrastination is that the bottom few lines -- which tend to be less important but easy to do -- get crossed out first. When I see that, I realize I have to muster the energy to go after the top lines. It doesn't always work, but it usually helps.

    So I'd say the first step is to become aware of what you do to get an "instant gratification" charge. The second step is to figure out how to change those behaviors. Again in my own case, I think it's fine to sometimes indulge, so I set aside one morning a week (more or less ;-) for fun, small items. It's a lot easier to gather the energy to go after the dreary stuff when I know I'm going to have some fun later1.The trick is to strike a balance that works for you.

    Yeah, all of these require some level of determination and will power (or "won't" power). But you already knew that. ;-)

    1Hmm... Delayed instant gratification? Is this an oxymoron?

Re: Programming and Instant Gratification
by perrin (Chancellor) on Oct 16, 2001 at 19:21 UTC
    The XP folks have an answer for this. It's called a spike solution.

    Personally, I just try to take it one step at a time. Fill in the package name and "use strict;". Run it. It works, yay! Feel the instant gratification of writing a sccussful program, even if it doesn't do much. Add a couple of lines that call netstat but don't do anything really useful. Run it. It works, yay! Keep going this way for a while and you'll find you wrote your program.

Re: Programming and Instant Gratification
by jepri (Parson) on Oct 16, 2001 at 19:54 UTC
    I have learned to just give up in those situations. Sometimes following your instincts instead of controlling them is a good idea. If your body or mind decides it would really prefer to be doing something else, let it.

    Grab a can of your favourite beverage and get really into your time wasting activity. I've noticed that a lot of people who have done as much study as you must have often have trouble with the idea of 'wasting' an evening. In reality, you aren't wasting it at all. You'll feel better for it, and the next day you'll feel more like 'working' because you'll still have happy memories from your last recreation break (well, it works for me).

    As for the goals and gratification, I agree that breaking them down into sub components helps a lot. I can't even stand writing a function without seeing it work, let alone a whole module. I wouldn't worry too much about the instant gratification thing. You have to get your (psychological) 'payoff' somehow, otherwise why would you be doing it at all?

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

Re: Programming and Instant Gratification
by lachoy (Parson) on Oct 16, 2001 at 22:23 UTC

    Secondary to the point: if you're on Unix, the program lsof will do this for you. Despite its name, it also lists open ports and what processes are holding them open (lsof -i). It's not perl, but it should definitely be in your toolbox. I've found it indispensible.

    Chris
    M-x auto-bs-mode

Re: Programming and Instant Gratification
by stefan k (Curate) on Oct 16, 2001 at 19:28 UTC
    Howdy Coding Colleague,
    your speaking directly from the heart.

    I can't offer solutions just a few little things to help improve.

    • Scribble some quick brainstorming thoughts on paper. This always gives the feeling of organizing things (though it need not really do that). Somewhen a line you wrote will strike you as something that can quickly be implemented - then you found your start.
    • Have your editor setup to automatically insert some code fragments for you. This has the effect that you'll never have to start from scratch again. Yes, this is kind of self-betrayal, but it works (for me)
    • Try to find small sub-problems of the framework that can be tested immediately and give some results. This is a technique that I use successfully at the moment in a project that will take a few months at least to get a working version running (coded in Ruby - fun!)
    And I hope that others will have other solutions, tips and ideas, indeed.

    Regards... Stefan
    you begin bashing the string with a +42 regexp of confusion

Re: Programming and Instant Gratification
by Anonymous Monk on Oct 17, 2001 at 07:30 UTC
    ...what programs had open ports, as to the best of my knowledge, you can't determine this directly from either app. (If there is a way, I'd appriciate it).

    The -p switch works for my version (1.42) of netstat.
    List tcp ports and program info: netstat -tp
    Still, lsof is a much more complete solution.