View Poll Results: Functions first, or code first?

Voters
18. You may not vote on this poll
  • Functions first!

    15 83.33%
  • Code first!

    3 16.67%

Poll!

This is a discussion on Poll! within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Do you typically write your functions first, then code them, or write your major code first, then implement it into ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    249

    Talking Poll!

    Do you typically write your functions first, then code them, or write your major code first, then implement it into functions?

    I always find it easier to write all my code first, then place them in functions...
    Last edited by funkydude9; 07-18-2003 at 12:53 AM.
    Well, there are a few things wrong with your code:

    1) It does not work.
    2) It does not work.
    3) It does not work.

    Hope this helps.

  2. #2
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Always top down. Map out the classes I need, map out the public interfaces for each class, then implement.

    Working the other way (writing the interface as the code progresses) is a terrible habit to be in.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Moved to GD

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> always find it easier to write all my code first, then place them in functions...

    Wait until you start to write 500,000 line programs, I think maybe you'll have learnt by then!
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Classes & Interfaces first, code later. In larger programs, there is no way to write code first. Not if you want to succeed.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  6. #6
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    If you are developing a large program, it will be easier to write classes first!

    I never wrote a VERY large program, but whenever I have a large assignment I write classes first( or functions ) first.
    Last edited by ammar; 07-20-2003 at 03:58 AM.
    none...

  7. #7
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    I get a basic idea of the classes and functions I need and start coding them, and then if I find that I need something else, I add it. Ya know, sometimes there are things that you just don't think of in advance.
    Away.

  8. #8
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    I take care of all classes and functions and such before i write any code. It helps to write algorithms.

  9. #9
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    > I always find it easier to write all my code first, then place them in functions...

    Are you insane?

  10. #10
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    >> Wait until you start to write 500,000 line programs, I think maybe you'll have learnt by then!

    You put it too delicately Adrian.

    Anyone who would write "code first" for something that large should be dragged out into the street and shot (which is precisely what their compiler will do to them).
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  11. #11
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    you'd be surprised how many dinosaurs of the industry actually code that way. Zero structure, zero thought behind the architecture. It's like pulling teeth to get them to put thought into OO design. It's even worse to try to convince managers that it's to their benefit to take time to restructure spaghetti code.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  12. #12
    Registered User
    Join Date
    Mar 2002
    Posts
    249
    Hmm. It's hard (for me, at least) to write functions & classes if I don't know how I'm going to use them or write them. I make them as I go along, that way I have a better understanding of how I'm going to use them. Not sure why that would be a problem even when writing lot's of code.

  13. #13
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    >> Zero structure, zero thought behind the architecture.

    Code like that should seriously be deleted and started over.

    funkydude, the thing about OO design is that its extensible, and easy to maintain. No single piece (at least in theory) is too hard to digest, and has clearly defined dependencies. In a major piece of software, deisgn must be put in to determine exactly what abstractions are needed, how they will be used, and how they are expeced to behave. Granted, you'll run into unforseen requirements or conditions, but if you minimize those, your coding is a lot more efficient. Also, programmers brought in to maintain or extend the system can easily do so by only touching a small portion of code. They only need to know how things behave, not how they are implemented. Failure to design beforehand will lead to a much poorer overall structure.

    And that concluded my OOD rant for now.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  14. #14
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    I think that people who said that writting code first is easier were talking about small and simple programs, maybe because they haven't written large programs, or complicated ones, where it's impossible to write the whole program at once!
    none...

  15. #15
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    I just write empty functions first, just to make sure that my framework is valid. Then I begin filling them with code in the order that they will be executed.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do you create a Poll?
    By cpjust in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-30-2009, 11:35 PM
  2. Poll - Terrorism & Torture
    By Kybo_Ren in forum A Brief History of Cprogramming.com
    Replies: 38
    Last Post: 12-04-2006, 02:08 PM
  3. Hungarian Notation POLL
    By maxhavoc in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 06-21-2004, 11:52 AM
  4. Today on Cprogramming....When Polls go bad?
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 01-25-2002, 01:41 PM
  5. Poll this Poll that
    By ski6ski in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 09-28-2001, 05:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21