Please select random order or first card below to begin studying 🤓
Congratulations! You have finished studying this set of cards
According to Code Craft, good programming stems from what?
Your attitude
According to Code Craft, what will happen if you do not write clear, defensive, easily testable, and easily maintainable software?
Many tedious code-related problems
What does Code Craft call an informal set of guidelines that is a practical way to prevent many coding problems?
Defensive programming
What is the definition of legacy code given by Code Craft?
Archaic programs written by code monkeys that are now long gone
What summarizes the Code Craft stance on making assumptions in programming?
Assume nothing (in bold)!
When is the easiest time to use defensive programming techniques?
The first write of the code
When should defensive programming techniques be deployed?
All the time
What is the first rule of defensive programming according to Code Craft?
Do not make assumptions
What are two reasons you shouldn't make assumptions according to Code Craft?
You will forget them and they will not hold true
How does Code Craft recommend you smash unwritten assumptions?
Explicitly check for them in the code
What do good programmers also do when they make assumptions according to Code Craft?
Document them
What are three things that some people mistakenly believe are defensive programming techniques?
Error handling, testing, and debugging
How is defensive programming different from debugging?
Defensive programming prevents problems
What happens when you do not do the right thing right away according to Code Craft?
You become more likely to not do the right thing next time
How should all inputs be treated according to Code Craft?
With suspicion
What do good programmers do with garbage input according to Code Craft?
Ensure well-defined behavior
What scope should variables be held in according to Code Craft?
The tightest scope possible
Where should variables be declared according to Code Craft?
As late as possible
When should variables be initialized according to Code Craft?
At their points of declaration
What does Code Craft claim causes the most common security vulnerability?
Buffer overrun
What does Code Craft say to do when you see warnings being generated?
Fix them immediately
Why does Code Craft recommend using parentheses judiciously?
They increase clarity and reduce faults
Defensive programming is a practice where time invested in the beginning saves time later, and it can even do what?
Save the entire project
What does Code Craft give as a common mistake that happens when you do not think carefully about the code you are typing as you are typing it?
Typing = instead of ==
What happens when programmers are careless, do not apply much thought to the code they write, and do not document assumptions?
Unreliable/unpredictable software
What question does Code Craft state regarding casting a 64-bit integer into an 8-bit type?
What happens to 56 of the bits?
Code Craft describes what kind of programming as ensuring well-defined behavior for garbage input, making sure any assumptions are codified or explicitly captured, and writing code that protects itself against the worst that could happen?
Defensive programming
According to Code Craft, what is the most obvious, and contentious, issue of code presentation?
Brace positioning
What is a common name for the curly bracket?
Brace
Is the format of code not important since the compiler completely ignores it?
No
Good format can make code easier to read and maintain, and bad format can do the opposite and hide bugs
What are the three audiences for source code?
Ourselves, the compiler, and other people
Who is the most important audience for the source code, according to Code Craft?
Other people
What is the Code Craft recommendation for what indentation strategy to use?
One that is conventional and can be described concisely
What is the name for the style of brace positioning that was established in The C Programming Language and may be the dominant style for Java code?
K&R
What is a reasonable thing to assume about sloppily laid out code?
It was not carefully designed
Is it true that names will never hurt you?
No
Without uncertainty, what is Miller's number?
7
What are two groups of six words that should be avoided in naming, three of them specifically because they are redundant?
data, object, type
be, do, perform
What are two groups of six words that should be avoided in naming, three of them specifically because they add noise and do not add value?
be, do, perform
data, object, type
What is the most important naming principle according to Code Craft?
Consistency
What does Code Craft say about splitting the code into files?
It should be split into the maximum number of files that it can
What kind of word should the name of a function be?
A verb
What kind of word should the name of a variable be?
A noun
What was one of the things that made Hungarian notation popular?
Microsoft's Win32 APIs
What might you need to do if you cannot come up with a good name for something in code?
Reconsider the design
What does Code Craft call i18n?
A "sexy little abbreviation" and a way of naming should be avoided
What is a common cause of bad names, as pointed out by Code Craft?
Not understanding what you are naming
When should you name things well in programming?
All the time
What is the only document that describes a program completely and correctly?
The program (code) itself
What does Code Craft say is the main quality of code that can make it self-documenting?
It is easy to read
When does Code Craft recommend adding comments to code?
When you cannot improve the clarity in any other way
What was the self-documenting code technique conceived by Donald Knuth that involves writing a document that compiles into the program?
Literate programming
What is the tool that popularized generating documentation from source code (and now there are many similar tools that sit about halfway between literate programming and external specifications)?
Javadoc
What is the Code Craft stance on documentation extracted from specifically formatted comments in the source code?
It is an excellent approach to API documentation
What idea which was not popular (but has some good points to consider) essentially took self-documenting code to the extreme?
Literate programming
What is the main reason to make code as self-documenting as possible according to Code Craft?
It is the only documentation you will always have
What are icing on the cake when you have truly good code?
Comments
What can be good to document unusual, unexpected, or surprising bits of code?
Comments
Should you ever use comments to express something that could be enforced by the language itself?
No
What type of programmers cannot tell the difference between good and bad comments, write comments explaining how stuff works, bolster code with many bad comments, and fill their source files with redundant code information?
Bad programmers
What type of programmers write a few good comments explaining why and helpful comments that make sense (and concentrate writing good code rather than a bunch of comments)?
Good programmers
What to do with inane comments you find?
Leave them as a warning
Where should a comment be written?
Above the code that it describes
What principle is violated when comments are written that simply describe the code (describing how, not why)?
DRY
Which is worse: bad comments or no comments?
Bad comments are WORSE
What should comments describe according to Code Craft?
Why something is written the way it is
Does well written code always need comments?
No
What does too much commenting do?
It hides important information
What is a comment?
A block of source that the compiler will ignore
What are the three categories of errors according to Code Craft?
user error, programmer error, and exceptional circumstance
What will a good program do in response to a user error?
Help the user rectify it
What programming technique helps stop the cycle of unhandled errors causing further error conditions?
Defensive programming
What kind of errors should ideally never occur?
Programmer errors
When something goes wrong in a subordinate component, what should it do?
Communicate the error upward to be dealt with by the caller
What should a caller do if it cannot handle an error propagated upward by a subordinate component?
Propagate it upward to be handled by a different caller
What does it mean for an error to be local in time?
It is discovered soon after it is created
What does it mean for an error to be local in space?
It is identified close to the site where it manifests
What is an effect on the code by handling errors ASAP?
The code is more self-documenting
When a caller cannot handle an error propagated to it and needs to propagate it up, what are the two ways it can do that?
Simply send it up, or reinterpret the information and send a more meaningful message
What is the part of the code that handles errors?
Error-handling code
What do bad programmers end up doing when they do not consider error conditions in the first place?
Long debugging sessions
What are the two main tools we have to prevent software errors according to Code Craft?
Defensive programming and testing
What are the three classes of bugs according to Code Craft?
Failures to compile, run-time crashes, and unexpected behaviors
What is the nastiest type of bug according to Code Craft?
Unexpected behaviors
What is the most common type of program hang according to Code Craft?
An infinite loop
What type of variable, if you use it in a program, will cause the program's behavior to depend on the garbage value in the variable's memory location?
An unitialized variable
What is the first step when debugging some code?
Understanding the code
What error subtype of run-time crashes are usually caught by the compiler, but if they are not, are usually language grammar errors?
Syntactic errors
What is a common syntactic error that is a language grammar error that might happen in a conditional?
mistaking = for a ==
What error subtype of run-time crash would include a Rails app using a version of a gem that was installed from local development rather than the actual released version of the gem?
Build errors
An example of a basic semantic bug is using an uninitialized variable; what will the behavior of the program depend on in this case?
The garbage at the memory location
A common basic semantic fault related to floating point numbers is?
Comparing them for equality
What subtype of semantic bug is caused when memory locations not allocated for the program's use are accessed?
Segmentation faults
What type of semantic bug is when memory is written past what has been allocated for a data structure?
Memory overrun
What type of semantic bug includes infinite loops, deadlock and race conditions, and event-driven code waiting for an event that will never occur?
Program hangs
What is the key to find and fix faults quicker and also introduce less new faults as you do?
Pay attention on a microscopic level while also keeping in mind the big picture.
What is the golden rule of debugging according to Code Craft?
Use your brain
When a compile-time error results in the compiler spitting out a lot of error messages, usually the most important one to look at is:
The first one
What technique to investigate a run-time error has you play the role of the computer, trace program execution and compare your result with reality?
A dry run
What is the single most important characteristic of well-designed code according to Code Craft?
Simplicity
What does Code Craft note you should not assume about obvious-looking code?
That it was easy to design
What does Code Craft call a measure of how related functionality is gathered together and how well the parts inside a module work as a whole?
Cohesion
What does Code Craft call a measure of the interdependency between modules?
Coupling
What idea does Code Craft mention when saying not to decompose modules based on team organization?
Conway's law
Code Craft: sloppy design is most often due to the commercial pressures of the software factory. The irony is that in almost every case:
The costs of doing it properly are lower
What must you do in order to have a clear design for the problem you are solving?
Fully understand all requirements and motivating principles
What characteristic of well-designed code is not present if it is confusingly clever, overly complex, or riddled with special cases?
Elegance
What term refers to the high-level design of a software system and also invokes the building metaphor?
Architecture
What is the single largest influence on the design and future growth of a software system according to Code Craft?
The architecture
What are the two things that Code Craft says architecture mostly concerns itself with?
Components and connections
Code Craft divides the connections in software architecture into what two categories?
Asynchronous and synchronous
What describes a function call that blocks the caller until the implementation has completed the call?
Synchronous
What describes a function call where control is immediately returned to the caller with an arrangement for something to happen later?
Asynchronous
What type of pasta is a metaphor for basically having no architecture?
Spaghetti ball
What type of pasta is a metaphor for layered architecture?
Lasagna
What type of pasta would describe the architecture of the OSI seven-layer reference model for network communication systems?
Lasagna
What type of pasta is a metaphor for the architecture given to you out of the box by a framework like Ruby on Rails?
Canned ravioli
What does Code Craft say is the key to good software architecture?
Simplicity
What is usually seen as the lowest level in a layered architecture?
The hardware interface
What is usually seen as the highest level in a layered architecture?
The user interface
What turn around the pattern of a traditional library where you have the thread of control and explicit calls are made into the library according to Code Craft?
Frameworks (the framework manages the thread of control and makes calls into your supplied code)
Thinking of software as similar to how an oyster makes a pearl or bug fixing as tending to diseased parts of the code is what metaphor?
The growing metaphor
If you were using "growing" as a metaphor for how software changes, what would be an example of something from nature that is similar to how software grows (a progressive accretion of small parts)?
How an oyster makes a pearl
Thinking of software as starting as a single-celled organism and incrementally changing into a large, complex beast is what metaphor?
The evolution metaphor
Using experiences of previous software releases to adapt the code to ensure its long term survival is thinking consistent with what metaphor?
The evolution metaphor
What is the longest phase of software development?
Maintenance
What phase does most of the overall effort in software development go to?
Maintenance
B.W. Boehm observed what percentage of total software development time is spent in maintenance?
40-80 percent
Brooks found what percentage of code changes fixing faults also introduced new faults?
40 percent
What unfortunately happens to code whether you modify it or not?
Code rot
What is the simple answer given by Code Craft as to why we make such a big mess of code?
Complexity
In software development, what commonly pile atop one another and act as nails in the original design's coffin?
Quick-and-dirty fixes
Large classes, large functions, cryptic names, surprising side effects, lack of structure, duplication, high coupling, blurry APIs, implementation details leaking, work-arounds, functions with long parameter lists, code that you can't even consider trying to improve, out of date documentation, warnings, comments saying "Don't touch this" are all forms of code rot that together might be considered?
Syntactic gunk
What form of what Code Craft calls "syntactic gunk" could taking its elimination too far lead to what APoSD calls "classitis"?
Large classes
What two forms of higher-level code rot are harder to see than typical syntactic gunk (that you may only notice once you are deeply immersed in the system)?
Modifications that fudge the original code architecture or subtly circumvent program conventions
To dispel the belief that doing software development properly always takes more time, what must you factor in?
Time saved later
What does Code Craft say are the cornerstones of modern software engineering?
Modularity and information hiding
Code Craft says that simplicity or performance is almost always more desirable?
Simplicity
In software design according to Code Craft, you should not be satisfied with any changes that do what?
Leave the system in a worse state