Please enjoy this self-check quiz to help you identify key concepts, points, and techniques discussed in this section.
What do we call the process of re-structuring code without altering functionality?
revisions
code review
refactoring
abstraction
Refactoring is the process of re-structuring code without altering functionality.
Which of the following are goals for refactoring?
improve code readability for developers
consolidate repetitive code blocks
improve performance
maintain a separation of concerns
All of these are goals for refactoring except improving performance (which would be considered an enhancement of the codebase).
What can we do to organize related data values in our software?
Name each variable with the same prefix (prefix_valueName
).
Combine variables into a single object.
Put values in a Node module.
Fetch values from an API.
JS Objects are well-suited for relating multiple data values.
Longer blocks of code are prone to more errors and make it more difficult for developers to understand what is happening in a program.
True
False
True: We prefer shorter blocks of code that can be more easily understood and debugged.
What are two structures that can be used to break apart lengthy code sequences into smaller components?
Array
Function
Method
Conditional
Break apart lengthy code sequences by breaking them into functions and/or methods that can be referenced instead.
What are some of the advantages of encapsulation?
Easier to swallow the code.
Information hiding allows us to present a more friendly interface to the developer
We gain the ability to enforce validation or optimization processes when getting or setting information
Other developers will think we are more professional
Encapsulation affords us the ability to hide information in order to present a more friendly interface for the developer, and it gives us points where we can more easily insert processes for validation and optimization of data.
What are additional methods of improving the structure of our code when refactoring?
Remove unused and temporary files in the project repository
Improving conditionals so they execute more quickly
Switching to a better library that offers more features for a given component
Improving names used to identify elements in the system
Removing any commented code or TODO notes
Remember that refactoring focuses on improving the organization and readability of the code, not improving performance or enhancing features.
When we "compose" components in Vue.js, what relationship do we create?
master/slave
parent/child
siblings
worker/agent
In Vue.js components are "composed" using parent/child relationships.
In Vue.js, a child component defines the data it needs from the parent component using the _______________ array.
data
params
props
args
Child components define the data they need through the props
("properties") object.
How can a child component signal to the parent component that some action has taken place?
Data syncing
Promises
Trigger a custom event
Reactivity
Child components can trigger a custom event, which can be picked up and handled by the parent component.
How can we consolidate common data or functionality used in multiple components in a Vue.js application?
Use code snippets in our IDE
Abstract data objects and functionality to common files and import those in components where they are needed
Define as a part of the core Vue.js instance
Use Angular
Common data objects and functionality can be abstracted into common files and imported into components where required.