Join Kevin Skoglund for an in-depth discussion in this video Refactor length conversions, part of Easy PHP Projects: Measurement Conversion.
- Over the next two movies,…we'll do some refactoring of the conversion code…we've written for length and area.…Refactoring is a fancy word that means…improving the structure of the code…without changing any of the output.…To begin with, let's work with our length code.…So I'm going to close out area.php…and open up length.php instead.…Let's jump up here to the top.…And I've got convert_to_meters,…convert_from_meters, and convert_length.…The first thing that I think we can do to improve this…is to move these functions over to a separate file.…A file that we can include as a functions file…whenever we need it.…
It's a good best practice, to keep…all your functions in one place.…So, before I go about deleting those.…I'm first going to switch back over to my desktop.…And inside convert, I'm going to add a new folder.…I'm going to put it right up here, inside there.…And I'm going to call it includes.…And then inside that directory,…go back to my project.…I can create a new TextMate page.…And let's just save that inside sites,…
Along the way, series designer Kevin Skoglund introduces coding strategies, refactoring techniques, and useful skills including dynamically generating form select-option values and formatting decimal numbers and scientific notation.
- Converting length and area measurements
- Using functions to avoid repetition
- Refactoring to produce simpler code
- Converting volume and mass
- Generating form select-option values dynamically
- Formatting scientific notation
- Converting speed and temperature
Skill Level Beginner
Accessing Databases with Object-Oriented PHPwith David Powers3h 47m Intermediate
1. Length and Distance
3. Volume and Capacity
4. Mass and Weight
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.