Thread: Doing programs and algorithms

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    5

    Doing programs and algorithms

    I'm having a though time when trying to do programming. I don't know why but I block and keep thinking someway to do something which is supposely to be simple, like doing a calculator for a beginner in programming, perhaps because I have a problem in getting totally focused in something and there's other things around like tv.

    Was it the same with some of you or what? I'm not in university yet but I hope I will be attending it. While trying to do programs like that it's tough because if I keep thinking too much about doing it I get a bit stressed because it's so simple and I've to think a lot in order to do it. Chosing which variables to set before writing the program or which way to code is a bit stressful for me because I don't know which vairables to be used in the whole program.

    It's so frustrating that and I get very upset.

    What do you think? What would you do?

  2. #2
    Registered User
    Join Date
    Jan 2007
    Location
    Euless, TX
    Posts
    144
    I'd find a new career, because if your mind wanders when trying to program at this level, you won't make when the heavier programming comes along.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    It's a matter of acquiring a discipline.

    When I'm starting a new program (which I'm doing now) I tend to wander around doing my daily routine, but spending my spare time visualizing it and thinking about what it has to do. Once I have a decent mental image of the *result* I can start backtracking into the larger blocks needed to make it work... major sections like "display", "network ops" or "math processing"... now these I write down, each on the top line of it's own page and I'll carry these pages around with me for a few days, adding notes and ideas as I go. (My friends are known to say: "See that clipboard...he's programming again!")

    Then as the process continues, I write down the smaller elements needed to make each major section work... for example the "network ops" might include "check password", "send error", "make new packet" etc.

    Now when all this is done and I think I understand the *problem* well enough, I will sit down a the keyboard and start roughing out a *solution* which basically consists of writing a set of comments --"//Get new user", "// examine password" etc. that will eventually delineate the code I write. (think of it as a book author's outline)

    From there it's coding time and I usually start by getting the output functions working (a GUI in most cases). Then it's internal business, such as functions to open files, read the keyboard etc. leaving the background work... networking, internet, etc. for last.

    Now... be aware... when I do this, the final product usually bears little or no actual resemblence to all my notes and comment lists. It is changing constantly as I solve a hundered little problems along the way... But in the end I usually do end up with a successful program.

    The notion that programmers hear a list of requirements then immediately start hammering the keyboard is totall bogus... Nobody with a lick of sense *starts* by writing code...

    For me, and most of the others I know, the best way is to just keep thinking about it until you figure it out... The keyboard will still be there when I'm ready.

    You can see one result of this process on my website... RemoteMedia

    Quote Originally Posted by kcpilot View Post
    I'd find a new career, because if your mind wanders when trying to program at this level, you won't make when the heavier programming comes along.
    Well, that might be true... but I think it's a tad premature.

    Many people approach programming like it's a "sit down and write code" thing... not realizing that's only a small part of the process. The real work is done in the planning stages.

    Perhaps our friend just needs to approach it with the right mindset.
    Last edited by CommonTater; 03-30-2011 at 07:12 PM.

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    @guilhermeptrr: CommonTater method sounds good.

    I would add that I try to write prototypes of the functions I think I will be using in the project before I write code for any functions; after I list all the prototypes I start coding. I even sometimes use the prototypes without changing/adding to them.

    Tim S.

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    5
    Quote Originally Posted by kcpilot View Post
    I'd find a new career, because if your mind wanders when trying to program at this level, you won't make when the heavier programming comes along.
    I've been thinking about that but I really do want to do programming.

    Quote Originally Posted by CommonTater View Post
    It's a matter of acquiring a dicipline.

    When I'm starting a new program (which I'm doing now) I tend to wander around doing my daily routine, but spending my spare time visualizing it and thinking about what it has to do. Once I have a decent mental image of the *result* I can start backtracking into the larger blocks needed to make it work... major sections like "display", "network ops" or "math processing"... now these I write down, each on the top line of it's own page and I'll carry these pages around with me for a few days, adding notes and ideas as I go. (My friends are known to say: "See that clipboard...he's programming again!")

    Then as the process continues, I write down the smaller elements needed to make each major section work... for example the "network ops" might include "check password", "send error", "make new packet" etc.

    Now when all this is done and I think I understand the *problem* well enough, I will sit down a the keyboard and start roughing out a *solution* which basically consists of writing a set of comments --"//Get new user", "// examine password" etc. that will eventually delineate the code I write. (think of it as a book author's outline)

    From there it's coding time and I usually start by getting the output functions working (a GUI in most cases). Then it's internal business, such as functions to open files, read the keyboard etc. leaving the background work... networking, internet, etc. for last.

    Now... be aware... when I do this, the final product usually bears little or no actual resemblence to all my notes and comment lists. It is changing constantly as I solve a hundered little problems along the way... But in the end I usually do end up with a successful program.

    The notion that programmers hear a list of requirements then immediately start hammering the keyboard is totall bogus... Nobody with a lick of sense *starts* by writing code...

    For me, and most of the others I know, the best way is to just keep thinking about it until you figure it out... The keyboard will still be there when I'm ready.

    You can see one result of this process on my website... RemoteMedia



    Well, that might be true... but I think it's a tad premature.

    Many people approach programming like it's a "sit down and write code" thing... not realizing that's only a small part of the process. The real work is done in the planning stages.

    Perhaps our friend just needs to approach it with the right mindset.
    Thank you for your post. It's nice. Yes, I'm one of the people who think programming as it's "sit down and write code", it's not because I always thought programming is like that, but the coders that I know by name are really good code writers and I think they're very thankful for that, but now that I'm having difficulties trying to code and together with your post I'm thinking that it's really about thinking first before writing the code, I've always thought that way regading programming partly because of the kind of code I want to write and then I think I need to be very fast thinker and code writer.

    Quote Originally Posted by stahta01 View Post
    @guilhermeptrr: CommonTater method sounds good.

    I would add that I try to write prototypes of the functions I think I will be using in the project before I write code for any functions; after I list all the prototypes I start coding. I even sometimes use the prototypes without changing/adding to them.

    Tim S.
    I prefer to write down things to a paper first when I'm studying, even though when it's just a draft or random things related to the subject I'm trying to read.
    Last edited by guilhermeptrr; 03-30-2011 at 05:03 PM.

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by guilhermeptrr View Post
    I've been thinking about that but I really do want to do programming.
    If you want to do it... then you do what it takes...

    Thank you for your post. It's nice. Yes, I'm one of the people who think programming as it's "sit down and write code", it's not because I always thought programming is like that, but the coders that I know by name are really good code writers and I think they're very thankful for that,
    Think about it... here's this guy walking around quietly working on solving a problem. He's not talking about it or making a fuss over it... just thinking about it. What are the odds of you realizing what he's doing? Many of the prelminary steps are invisible to others... Believe me, no matter how it looks, there is a period of "mulling it over" before they start keyboarding.

    but now that I'm having difficulties trying to code and together with your post I'm thinking that it's really about thinking first before writing the code, I've always thought that way regading programming partly because of the kind of code I want to write and then I think I need to be very fast thinker and code writer.
    In the early stages you can take pride in getting it to work at all ... ease, speed and efficiency will come with practice and only from practice. My first dozen or so programs (other than textbook exercies) never got past my own hard disk... but with time and practice comes ability and eventually I was able to produce worthwhile code. Nobody's first program rocks the world... take my word for that.

    I prefer to write down things to a paper first when I'm studying, even though when it's just a draft or random things related to the subject I'm trying to read.
    Sooooo.... does ths suggest a process to you?

    As several others here have said, and I agree... You can't solve a problem you don't understand.

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Doing a project like a calculator is actually fairly advanced. You need to understand how users input data, how the program will interpret numbers, symbols, perhaps parenthesis, order of operations,... So what you may think is a simple thing actually incorporates many problems and solutions.

    It all starts with simple test programs. Get yourself familiar with entering a number. The program might just print it, and its square root for example. Already you'll figure out how to define double (floating point), how to include certain necessary header files, how to link math libraries if necessary.

    The programmers you see just sitting down to code right away do so because the fundamental things are done by rote now... Just spilling out routine stuff. But give them something they've never attempted before, say, “write an X’s and O’s program, or chess”, and they’ll go to lunch and fill a bunch of napkins with arrows, boxes, circles... all part of “coding”, but at a higher conceptual level.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 09:09 AM
  2. scan memory algorithms?
    By chunlee in forum C Programming
    Replies: 4
    Last Post: 01-07-2005, 07:00 AM
  3. File transfer algorithms
    By LuckY in forum Networking/Device Communication
    Replies: 1
    Last Post: 10-07-2003, 12:34 PM
  4. Books on C and C++
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-28-2002, 04:18 PM
  5. My best C++ Programs
    By Paro in forum C++ Programming
    Replies: 113
    Last Post: 03-24-2002, 11:52 AM