Building a solution

Once you have created design plans, you must then implement them and build your solution. This will involve coding in an appropriate high-level language. You should choose an appropriate Integrated Development Environment (IDE) to work in.

Record the devolpment of your solution using screenshots and notes. Explain why you made the choices you did. This documentation should also incorporate developmental testing (tests as you progress).

curriculum-key-fact
IMPORTANT: Your documentation should clearly show how you used features outlined in the assessment criteria

Technical documentation

Provide annotated evidence of how your system was developed and show the examiners how you carried out developmental testing.

Your technical documentation should show how you used the features of the IDE.

These should include, where appropriate:

  • code editor
  • simple debugging tools
  • compiler
  • error diagnostics
  • run-time environment
  • Graphical User Interface (GUI)

curriculum-key-fact
TIP: Explain how you implemented each user requirement

Explain clearly how your program works and how you implemented the plans outlined in your design chapter. Record any errors you encounter and document how they were overcome.

The example below shows how evidence could be generated to support your Controlled Assessment task.

curriculum-key-fact
Tip: identifying errors and showing how fix them is much more important than producing error free code first time

User Requirement 1.1: The solution will include a function to capture a user's name as a string, use length and presence checks to validate the name, and return the name variable.

Python implementation

def validateName(name): '''A function to validate and return name''' if name !='' and len(name)<=20 #presence & length check print('Accepted') return name else: print('Error') #test runs validateName('Bob') validateName('')#a null entry validateName('BobBobBobBobBobBobBob')#more than 20 characters

The first draft above uses a function called validateName that takes a parameter and checks the length is less than 20 characters and is not null.

>>>> ===============RESTART: Accepted Error Error

Outcomes of the test runs can be seen above. ‘Bob’ makes it through the validation function and is accepted, but 'BobBobBobBobBobBobBob' is too long and is not. Neither is an empty input – both generate an error.

Although the code meets the basic requirements, the next stage is to refine the code so it will loop if the name does not meet the validation criteria.

The validateName function was refactored (rewritten) to include a looping structure that would force the user to enter a name that meets the validation rules.

def validateName(): '''A function to validate and return name''' valid = False #flag to start loop while not valid: name = input('Please enter your name: ') if name !='' and len(name)<=20: #presence, length & type check print('Accepted') valid = True #break the loop return name #test runs name = validateName() print(name)

Developmental testing

The first input is empty and is not accepted, so the function loops and ignores this input and asks the user to re-enter their name. This continues until a name that meets the validation criteria is entered.

Please enter your name: Please enter your name:BobBobBobBobBobBobBob Please enter your name:Bob Accepted Bob

C# implementation

static void validateName(String name) { if (name != "" && name.Length >= 20) // presence & length checks { Console.WriteLine(name + " >> Accepted"); return true; } Console.WriteLine(name + " >> NOT ACCEPTABLE."); }

The first draft above uses a function called validateName that takes a parameter and checks the length is less than 20 characters and is not null.

Wesley >> Accepted >> Unacceptable Christine >> Accepted The Right Honourable The Lord Mayor >> Unacceptable

Outcomes of the test runs can be seen above. Although the code meets the basic requirements, the next stage is to refine the code so that it will loop if the name does not meet the validation criteria.

class Program { static void Main(string[] args) { bool valid = false; // assume the name is invalid while (!valid) { Console.Write("Enter a name: "); String name = Console.ReadLine(); //read in a name valid = validateName(name); //validate it Console.Write("PRESS ENTER TO CONTINUE"); Console.ReadLine(); } } static bool validateName(String nameToBeTested) { if (nameToBeTested != "" && nameToBeTested.Length <= 20) //presence & length checks { Console.WriteLine(nameToBeTested + " >> Accepted"); return true; } Console.WriteLine(nameToBeTested + " >> NOT ACCEPTABLE - try again."); return false; } }

The validateName function was converted to return a Boolean value signifying the validity of the user’s input. An iterative structure was then introduced into the main method to repeatedly call the validation function, allowing the user to make several attempts.

Developmental testing

Enter a name: Mrs Jacqueline Rose Beaumont Mrs Jacqueline Rose Beaumont >> NOT ACCEPTABLE - try again. PRESS ENTER TO CONTINUE Enter a name: Mrs Jackie Beaumont Mrs Jackie Beaumont >> Accepted PRESS ENTER TO CONTINUE