Making Steaks from Sacred Cows
-
Upload
kevlin-henney -
Category
Software
-
view
333 -
download
0
Transcript of Making Steaks from Sacred Cows
![Page 2: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/2.jpg)
© BBC
![Page 3: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/3.jpg)
I see Keep Out signs
as suggestions more
than actual orders.
Like Dry Clean Only.
![Page 4: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/4.jpg)
Cargo cult programming is a style of computer programming characterized by the ritual inclusion of code or program structures that serve no real purpose.
Cargo cult programming can also refer to the results of applying a design pattern or coding style blindly without understanding the reasons behind that design principle.
http://en.wikipedia.org/wiki/Cargo_cult_programming
![Page 5: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/5.jpg)
![Page 6: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/6.jpg)
Une Idée
![Page 7: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/7.jpg)
Rien n'est plus
dangereux qu'une
idée, quand on n'a
qu'une idée.
Émile-Auguste Chartier
![Page 8: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/8.jpg)
Nothing is more
dangerous than an
idea, when you have
only one idea.
Émile-Auguste Chartier
![Page 9: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/9.jpg)
Nothing is more
dangerous than an
IDE, when you have
only one IDE.
![Page 10: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/10.jpg)
I currently have an average of 15-25 imports in each source file, which is seriously making my code mixed-up and confusing.
Is too many imports in your code a bad thing?
Is there any way around this?
http://stackoverflow.com/questions/8485689/too-many-imports-spamming-my-code
![Page 11: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/11.jpg)
It's normal in Java world to have a lot of imports.
Not importing whole packages is good practice.
It's a good practice to import class by class instead of importing whole packages.
http://stackoverflow.com/questions/8485689/too-many-imports-spamming-my-code
![Page 12: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/12.jpg)
Why?
![Page 13: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/13.jpg)
It is not a problem. Any IDE will manage imports and show them to you only when needed.
Most IDEs support code folding where all the imports are folded down to one line. I rarely even see my imports these days as the IDE manages them and hides them as well.
Any good IDE, such as Eclipse, will collapse the imports in one line, and you can expand them when needed, so they won't clutter your view.
http://stackoverflow.com/questions/8485689/too-many-imports-spamming-my-code
![Page 14: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/14.jpg)
![Page 15: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/15.jpg)
It is not a problem. Any IDE will manage imports and show them to you only when needed.
Most IDEs support code folding where all the imports are folded down to one line. I rarely even see my imports these days as the IDE manages them and hides them as well.
Any good IDE, such as Eclipse, will collapse the imports in one line, and you can expand them when needed, so they won't clutter your view.
http://stackoverflow.com/questions/8485689/too-many-imports-spamming-my-code
![Page 16: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/16.jpg)
It is not a problem. Any IDE will manage imports and show them to you only when needed.
Most IDEs support code folding where all the imports are folded down to one line. I rarely even see my imports these days as the IDE manages them and hides them as well.
Any good IDE, such as Eclipse, will collapse the imports in one line, and you can expand them when needed, so they won't clutter your view.
http://stackoverflow.com/questions/8485689/too-many-imports-spamming-my-code
![Page 17: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/17.jpg)
What is the Matrix?
Control.
The Matrix is a computer-generated
dream world built to keep us under
control in order to change a human
being into this.
© Warner Bros.
![Page 18: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/18.jpg)
I currently have an average of 15-25 imports in each source file, which is seriously making my code mixed-up and confusing.
Yes?
Is too many imports in your code a bad thing?
Yes.
Is there any way around this?
Yes!
![Page 19: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/19.jpg)
![Page 20: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/20.jpg)
Avoid Long Import Lists by Using Wildcards
Long lists of imports are daunting to the reader.
We don't want to clutter up the tops of our
modules with 80 lines of imports. Rather we
want the imports to be a concise statement
about which packages we collaborate with.
![Page 21: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/21.jpg)
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
![Page 22: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/22.jpg)
import java.util.*;
![Page 23: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/23.jpg)
import java.beans.Introspector;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
![Page 24: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/24.jpg)
import java.beans.*;
import java.lang.reflect.*;
import java.util.*;
![Page 25: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/25.jpg)
import java.awt.*;
import java.util.*;
List?
![Page 26: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/26.jpg)
import java.awt.*;
import java.util.*;
import java.util.List;
![Page 27: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/27.jpg)
![Page 28: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/28.jpg)
Open–Closed Principle
![Page 29: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/29.jpg)
![Page 30: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/30.jpg)
The principle stated that a good module
structure should be both open and closed:
Closed, because clients need the
module's services to proceed with their
own development, and once they have
settled on a version of the module should
not be affected by the introduction of new
services they do not need.
Open, because there is no guarantee that
we will include right from the start every
service potentially useful to some client.
![Page 31: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/31.jpg)
[...] A good module structure
should be [...] closed [...] because
clients need the module's
services to proceed with their
own development, and once
they have settled on a version of
the module should not be
affected by the introduction of
new services they do not need.
![Page 32: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/32.jpg)
Published Interface is a term I used (first in Refactoring) to refer to a class interface that's used outside the code base that it's defined in.
Martin Fowler http://martinfowler.com/bliki/PublishedInterface.html
![Page 33: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/33.jpg)
![Page 34: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/34.jpg)
There is no problem changing a
method name if you have access to
all the code that calls that method.
Even if the method is public, as long
as you can reach and change all the
callers, you can rename the method.
![Page 35: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/35.jpg)
There is a problem only if the
interface is being used by code that
you cannot find and change. When
this happens, I say that the interface
becomes a published interface (a
step beyond a public interface).
![Page 36: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/36.jpg)
Published Interface is a term I used (first in Refactoring) to refer to a class interface that's used outside the code base that it's defined in.
The distinction between published and public is actually more important than that between public and private.
The reason is that with a non-published interface you can change it and update the calling code since it is all within a single code base. [...] But anything published so you can't reach the calling code needs more complicated treatment.
Martin Fowler http://martinfowler.com/bliki/PublishedInterface.html
![Page 37: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/37.jpg)
[...] A good module structure
should be [...] open [...] because
there is no guarantee that we will
include right from the start every
service potentially useful to some
client.
![Page 38: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/38.jpg)
extends
![Page 39: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/39.jpg)
A myth in the object-oriented design
community goes something like this:
If you use object-oriented technology,
you can take any class someone else
wrote, and, by using it as a base class,
refine it to do a similar task.
Robert B Murray
C++ Strategies and Tactics
![Page 40: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/40.jpg)
![Page 41: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/41.jpg)
Design and implement for
inheritance or else prohibit it
By now, it should be apparent that
designing a class for inheritance places
substantial limitations on the class.
![Page 42: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/42.jpg)
![Page 43: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/43.jpg)
Bertrand Meyer gave us guidance as long ago as 1988 when he coined the now famous open-closed principle. To paraphrase him:
Software entites (classes, modules, functions, etc.) should be open for extension, but closed for modification.
Robert C Martin "The Open-Closed Principle"
C++ Report, January 1996
![Page 44: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/44.jpg)
http://blog.8thlight.com/uncle-bob/2014/05/12/TheOpenClosedPrinciple.html
![Page 45: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/45.jpg)
http://blog.8thlight.com/uncle-bob/2014/05/12/TheOpenClosedPrinciple.html
I've heard it said that the OCP is wrong, unworkable, impractical, and not for real programmers with real work to do. The rise of plugin architectures makes it plain that these views are utter nonsense. On the contrary, a strong plugin architecture is likely to be the most important aspect of future software systems.
![Page 46: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/46.jpg)
public abstract class Shape
{
...
}
public class Square : Shape
{
...
public void DrawSquare() ...
}
public class Circle : Shape
{
...
public void DrawCircle() ...
}
![Page 47: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/47.jpg)
public abstract class Shape ...
public class Square : Shape ...
public class Circle : Shape ...
static void DrawAllShapes(Shape[] list)
{
foreach(Shape s in list)
if(s is Square)
(s as Square).DrawSquare();
else if(s is Circle)
(s as Circle).DrawCircle();
}
![Page 48: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/48.jpg)
public abstract class Shape ...
public class Square : Shape ...
public class Circle : Shape ...
static void DrawAllShapes(Shape[] list)
{
foreach(Shape s in list)
if(s is Square)
(s as Square).DrawSquare();
else if(s is Circle)
(s as Circle).DrawCircle();
}
![Page 49: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/49.jpg)
public abstract class Shape
{
...
public abstract void Draw();
}
public class Square : Shape
{
...
public override void Draw() ...
}
public class Circle : Shape
{
...
public override void Draw() ...
}
![Page 50: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/50.jpg)
public abstract class Shape ...
public class Square : Shape ...
public class Circle : Shape ...
static void DrawAllShapes(Shape[] list)
{
foreach(Shape s in list)
s.Draw();
}
![Page 51: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/51.jpg)
public abstract class Shape ...
public class Square : Shape ...
public class Circle : Shape ...
static void DrawAllShapes(Shape[] list)
{
foreach(Shape s in list)
s.Draw();
}
![Page 52: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/52.jpg)
public abstract class Shape ...
public class Square : Shape ...
public class Circle : Shape ...
static void DrawAllShapes(Shape[] list)
{
foreach(Shape s in list)
s.Draw();
}
![Page 53: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/53.jpg)
Bertrand Meyer gave us guidance as long ago as 1988 when he coined the now famous open-closed principle. To paraphrase him:
Software entites (classes, modules, functions, etc.) should be open for extension, but closed for modification.
Robert C Martin "The Open-Closed Principle"
C++ Report, January 1996
![Page 54: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/54.jpg)
Bertrand Meyer gave us guidance as long ago as 1988 when he coined the now famous open-closed principle. To paraphrase him:
Software entites (classes, modules, functions, etc.) should be open for extension, but closed for modification.
Robert C Martin "The Open-Closed Principle"
C++ Report, January 1996
![Page 55: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/55.jpg)
This double requirement looks like a
dilemma, and classical module
structures offer no clue.
This double requirement looks like a
dilemma, and classical module
structures offer no clue. But
inheritance solves it.
This double requirement looks like a
dilemma, and classical module
structures offer no clue. But
inheritance solves it. A class is
closed, since it may be compiled,
stored in a library, baselined, and
used by client classes. But it is also
open, since any new class may use
it as parent, adding new features.
![Page 56: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/56.jpg)
public abstract class Shape ...
public class Square : Shape ...
public class Circle : Shape ...
static void DrawAllShapes(Shape[] list)
{
foreach(Shape s in list)
if(s is Square)
(s as Square).DrawSquare();
else if(s is Circle)
(s as Circle).DrawCircle();
}
![Page 57: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/57.jpg)
public abstract class Shape ...
public class Square : Shape ...
public class Circle : Shape ...
static void DrawAllShapes(Shape[] list)
{
foreach(Shape s in list)
if(s is Square)
(s as Square).DrawSquare();
else if(s is Circle)
(s as Circle).DrawCircle();
}
![Page 58: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/58.jpg)
public abstract class Shape ...
public class Square : Shape ...
public class Circle : Shape ...
static void DrawAllShapes(Shape[] list)
{
foreach(Shape s in list)
s.Draw();
}
![Page 59: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/59.jpg)
public abstract class Shape ...
public class Square : Shape ...
public class Circle : Shape ...
static void DrawAllShapes(Shape[] list)
{
foreach(Shape s in list)
s.Draw();
}
![Page 60: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/60.jpg)
Don't publish
interfaces prematurely.
Modify your code
ownership policies to
smooth refactoring.
![Page 61: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/61.jpg)
![Page 62: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/62.jpg)
Constructors that throw
![Page 63: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/63.jpg)
Do not throw from a constructor.
Do not throw from a constructor?
![Page 64: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/64.jpg)
![Page 65: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/65.jpg)
Immutable Value
The internal state of a value
object is set at construction
and no subsequent
modifications are allowed.
![Page 66: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/66.jpg)
To some, the most important
aspect of exceptions is that they
provide a general mechanism for
reporting errors detected in a
constructor.
Bjarne Stroustrup
The Design and Evolution of C++
![Page 67: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/67.jpg)
Naomi Epel The Observation Deck
![Page 68: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/68.jpg)
Exceptional Naming
![Page 69: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/69.jpg)
![Page 70: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/70.jpg)
ClassNotFoundException
EnumConstantNotPresentException
IllegalArgumentException
IllegalAccessException
IndexOutOfBoundsException
NegativeArraySizeException
NoSuchMethodException
TypeNotPresentException
UnsupportedOperationException
![Page 71: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/71.jpg)
ClassNotFound
EnumConstantNotPresent
IllegalArgument
IllegalAccess
IndexOutOfBounds
NegativeArraySize
NoSuchMethod
TypeNotPresent
UnsupportedOperation
![Page 72: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/72.jpg)
ArithmeticException
ArrayStoreException
ClassCastException
InstantiationException
NullPointerException
SecurityException
![Page 73: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/73.jpg)
Arithmetic
ArrayStore
ClassCast
Instantiation
NullPointer
Security
![Page 74: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/74.jpg)
IntegerDivisionByZero
IllegalArrayElementType
CastToNonSubclass
ClassCannotBeInstantiated
NullDereferenced
SecurityViolation
![Page 75: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/75.jpg)
Omit needless words.
William Strunk and E B White
The Elements of Style
![Page 76: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/76.jpg)
![Page 77: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/77.jpg)
Shoulda Woulda Coulda
![Page 78: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/78.jpg)
public static bool IsLeapYear(int year) ...
[Test] public void TestIsLeapYear() ...
![Page 79: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/79.jpg)
function test
test
test
![Page 80: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/80.jpg)
method test
test
test
method
method
test
test
![Page 81: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/81.jpg)
YearsNotDivisibleBy4...
YearsDivisibleBy4ButNotBy100...
YearsDivisibleBy100ButNotBy400...
YearsDivisibleBy400...
![Page 82: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/82.jpg)
Years_not_divisible_by_4_...
Years_divisible_by_4_but_not_by_100_...
Years_divisible_by_100_but_not_by_400_...
Years_divisible_by_400_...
![Page 83: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/83.jpg)
Years_not_divisible_by_4_should_not_be_leap_years
Years_divisible_by_4_but_not_by_100_should_be_leap_years
Years_divisible_by_100_but_not_by_400_should_not_be_leap_years
Years_divisible_by_400_should_be_leap_years
![Page 84: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/84.jpg)
![Page 85: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/85.jpg)
Years_not_divisible_by_4_are_not_leap_years
Years_divisible_by_4_but_not_by_100_are_leap_years
Years_divisible_by_100_but_not_by_400_are_not_leap_years
Years_divisible_by_400_are_not_leap_years
![Page 86: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/86.jpg)
Years_not_divisible_by_4_are_not_leap_years
Years_divisible_by_4_but_not_by_100_are_leap_years
Years_divisible_by_100_but_not_by_400_are_not_leap_years
Years_divisible_by_400_are_not_leap_years
![Page 87: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/87.jpg)
Years_not_divisible_by_4_are_not_leap_years
Years_divisible_by_4_but_not_by_100_are_leap_years
Years_divisible_by_100_but_not_by_400_are_not_leap_years
Years_divisible_by_400_are_not_leap_years
![Page 88: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/88.jpg)
![Page 89: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/89.jpg)
Propositions are vehicles for stating how things are or might be.
![Page 90: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/90.jpg)
Thus only indicative sentences which it makes sense to think of as being true or as being false are capable of expressing propositions.
![Page 91: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/91.jpg)
Make definite assertions. Avoid tame, colourless, hesitating, noncommittal language.
Note [...] that when a sentence is made stronger, it usually becomes shorter. Thus brevity is a by-product of vigour.
William Strunk and E B White
The Elements of Style
![Page 92: Making Steaks from Sacred Cows](https://reader031.fdocuments.net/reader031/viewer/2022032217/55a931961a28ab48368b45dd/html5/thumbnails/92.jpg)