DTE Term 2 - Coding Flashcards
(29 cards)
What is debugging?
- It requires persistence and resilience
- Debugging is figuring out why an error in a code is incorrect, and fixing it
- Codes rarely work the first time
- Debugging is part of the problem-solving process of programming
- It’s very common to go through several cycles of run-test-debug to get a code right
- Debugging is the nature of business
- Making a habit of running your code, checking your code, and making changes as needed are important
- It is a continuous cycle of writing, testing, and improving code
- It is a skill and an art
- With practice you learn how to write relatively bug-free code and more importantly you learn about yourself and the kind of errors you typically make
What are Syntax Errors?
- They are things you misspelled or wrote in such a way the computer doesn’t understand what you’re trying to say
- App Lab provides an error message of some kind that is a clue about what it can’t understand
- Carefully read the error message to determine what has gone wrong
- They are usually the easiest to find
Debug Console informs coders of any typos
What are Logic Errors?
- The program runs but doesn’t do what you think it should
- They can be tricky to fix because there might not be an error message
- You can fix these by retracing your steps, being humble, and trying to understand why the computer is interpreting what you wrote the way it is
- The program runs but doesn’t do what you think it should
- It may run without any error notification
- You may initially think all is good, however, closer inspection shows it didn’t do what was expected
- Debug console doesn’t provide any help (because it is not a syntax issue)
- Investigate the code and make a prediction - what should happen?
- Observe the program as it runs to see what’s going on
- Reflect upon what is going on
- Fix it - make it work as intended
Repeat as necessary, until the program is correct
What are the screen dimensions in App Lab?
- The screen is 320 pixels wide
- It is 450 pixels long
What are the screen coordinates in App Lab?
- X is the horizontal axis
- Y is the vertical axis
- (0, 0) is the top left corner
- (320, 0) is the top right corner
- (0, 450) is the bottom left corner
- (320, 450) is the bottom right corner
- The setPosition () command lets you move to any position on the screen and optionally set the size at the same time
- The little arrows of the setPosition() command mean that some of the parameters are optional
- You can click the arrows or expand the available parameters
You can hover over the screen to see the (x, y) coordinates of any point
What are random numbers in App Lab?
- App Lab has a block in the Math toolbox called randomNumber (0, 0)
- The block will create a random number in the range provided
- E.g. randomNumber (1, 215) this block would generate a random number between 1 (minimum) and 215 (maximum)
- You can put in a negative number e.g. randomNumber (-10, 10)
- It will also work if you reverse the max numbers
- E.g. randomNumber (10, -10)
What are different mouse events?
- We know what happens when we use the mouse or keypad to click on a button
- Lesson 2 introduced different mouse vents
- When the mouse is rolled over the button, when the mouse moves within the boundary of a button or when the mouse button is pressed or released
- Click = Event is triggered when the button is clicked
- Mouseup = Event is triggered when the cursor button is released
- Mousedown = Event is triggered when the cursor button is pressed and held
- Mouseover = Event is triggered when the cursor is moved inside the button
- Mousemove = Event is triggered when the cursor is moved onto the button
What are the three different ways to add images in App Lab?
- From the Web
* Note that you cannot use the URL of an Google image search
* You have to right+click to the image (not the thumbnail) and select “Copy Image Address”
* Note that only .png image transparent background- From your OneDrive
- You have to save images found on the web into your OneDrive≻2025≻DTE folder
- App Lab can only use .jpg, .png, or .gif files
- From the icon library
- Search the icon library or a wide range of icons
You can change the dimensions the colour of icons
- Search the icon library or a wide range of icons
- From your OneDrive
What is some useful terminology from Lesson 2 in App Lab?
- Error - when the program does not perform as expected
- Syntax Error - an error that prevents the program running, usually associated with spelling issue or order of elements
- Logic Error - an error discovered when a program runs but does not produce the desired result
- Debugging - the process of Predict≻Observe≻Reflect as a process to remove issues that prevent the app from running as expected
- Random number - a number that is between a minimum and mum range (that you specify)
- Transparency - we are able to ‘see through’ images with a transparent background to see what is ‘behind it’
What are some abbreviations that are used for naming widgets?
- Lbl = label
- Btn = button
- Scr = screen
- Snd = sound
- Rb = radio button
- Img = image
- CKbx = checkbox
What is App Lab?
- App Lab is a programming tool to design and develop simple mobile applications
- Has Design
Has Code components
- Has Design
What is interactivity?
- It is about creating widgets such as buttons that have the vents listeners and event handlers
- Event Listeners are waiting for ‘events to happen’
Event Handlers is the code that runs when an event occurs
- Event Listeners are waiting for ‘events to happen’
What are some design principles?
- Contrast
- Alignment
- Repetition
- Proximity
- Colour theory
- Type theory
What is some key information about widget names?
- They must be named meaningful way
- ID property is used to set the name a widget
- A widget name should describe the widget in some way
- App Lab does not force certain naming conventions, in your own project developments you are to ensure you prefix your get names with the widget type
What are the 3 naming conventions for widgets?
- camelCase
* btnMoveBee
* imgCloudySky
* lblUserName- kebab-case
- btn-move-bee
- img-cloudy-sky
- lbl-user-name
- snake_case
- btn_move_bee
- img_cloudy_sky
lbl_user_name
- kebab-case
What is some key vocabulary from Lesson 3?
- User Interface/UI - The visual elements of a program through which a user controls or communicates with the application
- UI Elements/Widgets - on-screen widgets, like buttons, images, text boxes, pull down menus, screens, etc
- Event-driven program - a program designed to run blocks of code or functions in response to specified events e.g. a mouse clicker
- Event - an action that causes something to happen e.g. clicking a button
- Event listener - a command that can be set up to trigger a function when a particular type of event occurs on a particular UI element
Event handling/Event handler - a term used for coding tasks involved in making a program respond to events by triggering functions
How do you use the control log in App Lab?
- The console area is where we receive error message
- The console area can also be used to determine:
- The order in which things are happening
- Show the value of a variable or state of something at various points in the program during execution
Whether an event is firing (working) or not, and when
- E.g. a btnCalculate button needs to initiate one event when clicked and another when the mouse is over the button
Before determining the required Callback Function, you might want to create a console log message that displays the correct message depending upon the action
What is the order in which things appear in the control log?
- Something for you to remember, is that slightly unexpected events occur when widgets that overlap on the screen are clicked:
- When you click on a location where two objects are overlapping, which event(s) fire(s)?
- The event-handler for object that is on top gets triggered
- The object that is underneath is blocked from being clicked in the overlapping portion
- When you click on a non-overlapping part of some object what gets triggered?
- The event-handler for the object gets triggered as you might expect
- When does a “click” on the “screen” get triggered?
- Always
- Events that occur on the screen cannot be blocked by other objects
- If you set up an event listener for the screen it will capture EVERY event of that type, no matter what other UI elements are on the screen
This behavior of the screen is done on purpose and is useful for certain kinds of things
How do you code multiple screens?
- You know that a screen is just another UI element
- In design mode, you can only see one screen at a time
- In code mode you can program all screens
However, only one code space is available
What are some screen properties in App Lab?
Look in OneNote for diagram.
What are learning properties in App Lab.
Look in OneNote for diagram.
What is the definition of a variable?
- A variable is a named placeholder in memory that stores and can be changed
- The information that can be stored in a variable consists of:
- A number (1, 345, 3.14, etc)
- A single character (a, b, A, B, etc)
- A symbol (@, #, $, etc)
- A word or string of characters (Hello, My name is Sally, The sun shone brightly, etc)
- fullName (Sally Smith, Tom Jones, etc)
- Email (someone@someplace.com.au etc)
- Password
What are some things learned in Lesson 5 of App Lab?
- Var - use the keyword var only when you create a variable
- E.g. var age;
- var year = 2020;
- Variable re-assignment - we can change the value of a variable based on its current contents
- E.g. age = age + 1;
- var year = year + 1;
- setText is used to set the text property of a widget to a different value
- E.g. setText (“Title”, “Welcome”)
- What was learnt in Lesson 5?
- Coding onEvents in text
- Setting the text in a label to be something else when an event occurs
- Consolidation of creating variables and variable re-assignment
- Debugging issues with setting text and variable re-assignment
What does setText do?
- It sets the text for the specified element
- Any element (widget) that had a text property can be altered with the setText command e.g. labels, buttons, text area, text input boxes, etc