Chapter 6. Structured Code

If you work in software development, you probably will recognize the following situation: your manager comes in and drops a bombshell. Your coworker, the lead developer of the FindACab app, is ill. The app needs to go live today, but there’s a huge bug in it. The app doesn’t display any results. “Can you help fix this?” your boss asks (read: demands).

Together with the project manager, you review the application in Google Chrome. When you click on the Network tab, you see that the AJAX request returns no results. Digging deeper, you learn that this is because the parameters in the URL are incorrect. “Piece of cake,” you say, “there’s something wrong with the request URL. Just give me an hour.” But, once you open your coworker’s project file, you see that the entire project exists as one single JavaScript file. There is no structure in it at all. What should have taken one hour suddenly turns into five. Wouldn’t it be better if there were a bit more structure in the code?

Design Patterns

Another expression for building structure in code is creating a design pattern. When you are working with a large code base, you’re probably also working with a team. When working with teams, you’ll have to create standards because you don’t want to deal with a different coding style for every team member.

As of the release of Sencha Touch version 2.0, Sencha solves this challenge with the Model-View-Controller (MVC) pattern. The benefits of using ...

Get Hands-On Sencha Touch 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.