ch12 - 12 Clarity and Maintainability CERTIFICATION...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
12 Clarity and Maintainability CERTIFICATION OBJECTIVE Writing Clear and Maintainable Code
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CERTIFICATION OBJECTIVE Write Clear and Maintainable Code Now that you’ve made your code readable , does your easy-to-read code actually make sense? Can it be easily maintained? These are huge issues for the exam, worth a very significant chunk of your assessment score. We’ll look at everything from class design to error handling. Remember that you’re a Team Player. Some key areas of code clarity are covered in more detail in the Documentation chapter, so we won’t discuss them here. Those areas include the importance of meaningful comments and self-documenting identifiers. The issues raised in this chapter are General programming style considerations Following OO design principles Reinventing the wheel Error-handling General Programming Considerations The coding conventions covered in the previous chapter are a great starting point. But the exam is also looking for consistency and appropriateness in your programming style . The following section lists some key points you should keep in mind when writing your perfectly-formatted code. Some of these will be explained in subsequent sections; several of these points are related to OO design, for example, and we cover them in more detail in that section. Once again, this is no time to debate the actual merits of these principles. Again, imagine you’ve come into a project team and need to prove yourself as a, what? Yes! Team Player . The first thing the team is looking for is whether you can follow the conventions and standards so that everyone can work together without wanting to throw one another out the seventh floor window and onto the cement fountain below. (Unless you’re a dot-com company and your office now looks over an abandoned gas station.) These points are in no particular order, so don’t infer that the first ones are more important than the last. You can infer, however, that your exam assessor will probably be asking if you’ve done these things appropriately. 2 Chapter 12: Clarity and Maintainability
Background image of page 2
Keep Variable Scope as Small as Possible Don’t use an instance variable when a local variable will work! Not only does this impact memory use, but it reduces the risk that an object “slips out” to some place it shouldn’t be used, either accidentally or on purpose. Wait to declare a variable until just before it’s used. And you should always initialize a local variable at the time it is declared (which is just before use), with the exception of try/catch blocks. In that case, if the variable is declared and assigned in the try/catch block, the compiler won’t let you use it beyond that block, so if you need the variable after a try or catch block, then you’ll have to declare it first outside the try/catch . Another way to reduce scope is to use a
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

ch12 - 12 Clarity and Maintainability CERTIFICATION...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online