Preconditions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • truezplaya
    New Member
    • Jul 2007
    • 115

    Preconditions

    When you are asked in a question to specify a precondition as a valid boolean expression for a certain procedure. Is this just a comment within the procedure or do you have to write an if statement where the outcome is true? This is on a PDL question.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    A pre-condition occurs before the procedure.
    A post-condition occurs after the procedure.

    [code=c]

    PreCondition();

    // the procedure

    PostCondition() ;
    [/code]

    All the boolean would mean is if the procondition were true then execute the procedure:

    [code=c]

    if (PreCondition() )
    {

    // the procedure
    }
    PostCondition() ;
    [/code]

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Also note that if the precondition fails, it's the caller's fault. If the postcondition
      fails it's the callee's fault.

      kind regards,

      Jos

      Comment

      • truezplaya
        New Member
        • Jul 2007
        • 115

        #4
        thank you very much for that help. Thats put it clear for me now :P

        Comment

        Working...