7. S ingle Responsibility Principle
O pen / Closed Principle
L iskov’s Substitution Principle
I nterface Segregation Principle
D ependency Inversion Principle
8. “ALL THE NEWS THAT’S FIT TO DEPLOY” LATE EDITION
The Software Dev Times
VOL XI...NO 12,345 OSLO, WEDNESDAY, JUNE 8, 2011 FREE AS IN BEER
SHOCK-SOLID!
MYSTERIOUS SOFTWARE CRAFTSMAN
COINED THE SOLID ACRONYM!
Bob might not be
your uncle
By A. NORÅS &
K. HENNEY
Ut enim ad minim veniam, quis nostrud exerc.
Irure dolor in reprehend incididunt ut labore et
dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse molestaie Etiam sit amet est
cillum. Tia non ob ea soluad incommod quae
egen ium improb fugiend. Officia deserunt
mollit anim id est laborum Et harumd dereud.
Neque pecun modut neque
Consectetuer arcu ipsum ornare pellentesque
vehicula, in vehicula diam, ornare magna erat
felis wisi a risus. Justo fermentum id. Malesuada
eleifend, tortor molestie, a fusce a vel et. Mauris NO COMMENT. The software craftsman claimed to have discovered that a set of
at suspendisse, neque aliquam faucibus principles could be abbreviated “SOLID”, declined to comment on the matter.
adipiscing, vivamus in. Wisi mattis leo suscipit
nec amet, nisl fermentum tempor ac a, augue in
Sociosqu netus semper aenean Ut enim ad minim veniam, quis nostrud
eleifend in venenatis, cras sit id in vestibulum
suspendisse dictum, arcu enim conubia exerc. Irure dolor in reprehend
felis. Molestie ornare amet vel id fusce, rem
leo nulla ac nibh, purus hendrerit ut incididunt ut labore et dolore magna
volutpat platea. Magnis vel, lacinia nisl, vel
mattis nec maecenas, quo ac, vivamus aliqua. Ut enim ad minim veniam, quis
nostra nunc eleifend arcu leo, in dignissim
praesent metus eget viverra ante. nostrud exercitation ullamco laboris nisi
lorem vivamus laoreet.
Natoque placerat sed sit hendrerit, ut aliquip ex ea commodo consequat.
dapibus eleifend velit molestiae leo a, ut Duis aute irure dolor in reprehenderit in
Donec arcu risus diam amet sit. Congue tortor
lorem sit et lacus aliquam. Sodales nulla voluptate velit esse molestaie cillum. Tia
cursus risus vestibulum commodo nisl, luctus
erat et luctus faucibus aperiam sapien. non ob ea soluad incommod quae egen
augue amet quis aenean odio etiammaecenas sit,
Leo inceptos augue nec pulvinar rutrum ium improb fugiend. Officia deserunt
donec velit iusto, morbi felis elit et nibh.
aliquam mauris, wisi hasellus fames ac, mollit anim id est laborum Et harumd
Vestibulum volutpat dui lacus consectetuer ut,
commodo eligendi dictumst, dapibus dereud.
mauris at etiam suspendisse, eu wisi rhoncus
morbi auctor.
eget nibh velit, eget posuere sem in a sit.
12. prin·ci·ple /ˈprinsəpəl/
Noun 4. a natural law forming
1. a fundamental truth the basis for the
or prop osit ion t hat construction or working
serves as the foundation of a machine.
for a system of belief or
behaviour or for a chain
of reasoning. para·skevi·de·katri·a·ph
o·bia /ˈpærəskevidekaˈtriəˈfōbēə/
Adjective, Noun
2. morally correct
behaviour and attitudes. 1. fear of Friday the
13th.
3. a general scienti c Etymology: e word
theorem or law that has
numerous special was devised by Dr.
applications across a Donald Dossey who told
wide eld. his patients that "when
you learn to pronounce
it, you're cured.
23. Java
public class HeatingSystem {
public void turnOn() ...
public void turnOff() ...
...
}
public class Timer {
public Timer(TimeOfDay toExpire, Runnable toDo) ...
public void run() ...
public void cancel() ...
...
}
24. Java
public class TurnOn implements Runnable {
private HeatingSystem toTurnOn;
public TurnOn(HeatingSystem toRun) {
toTurnOn = toRun;
}
public void run() {
toTurnOn.turnOn();
}
}
public class TurnOff implements Runnable {
private HeatingSystem toTurnOff;
public TurnOff(HeatingSystem toRun) {
toTurnOff = toRun;
}
public void run() {
toTurnOff.turnOff();
}
}
25. Java
Timer turningOn =
new Timer(timeOn, new TurnOn(heatingSystem));
Timer turningOff =
new Timer(timeOff, new TurnOff(heatingSystem));
26. Java
Timer turningOn =
new Timer(
timeToTurnOn,
new Runnable() {
public void run() {
heatingSystem.turnOn();
}
});
Timer turningOff =
new Timer(
timeToTurnOff,
new Runnable() {
public void run() {
heatingSystem.turnOff();
}
});
43. “ OOP to me means only
messaging, local retention
and protection and hiding of
state-process, and extreme
late-binding of all things. It
can be done in Smalltalk and
in LISP. There are possibly
other systems in which this
is possible, but I'm not
aware of them.
•Allan Kay
44. C
#include <windows.h>
#include <stdio.h>
typedef int (__cdecl *MYPROC)(LPWSTR);
VOID main(VOID)
{
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
hinstLib = LoadLibrary(TEXT("echo.dll"));
if (hinstLib != NULL)
{
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "echo");
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
(ProcAdd) (L"Hello my world!n");
}
fFreeResult = FreeLibrary(hinstLib);
}
if (!fRunTimeLinkSuccess)
printf("Hello everybody's world!n");
}
68. JavaScript
function Shoebox() {
var things = ["Nike 42", "Adidas 41", "Adidas 43", "Paul Smith 41"];
def(this, "find", function(brand) {
var result = [];
for (var i=0; i<things.length; i++) {
if (things[i].indexOf(brand) !== -1) result.push(things[i]);
}
return result;
});
def(this, "find", function(brand,size) {
var result = [];
for (var i=0; i<things.length; i++) {
if (things[i].indexOf(brand) !== -1 || parseInt(things[i].match(/d+/),10) === size)
result.push(things[i]);
}
return result;
});
}
function def(obj, name, fn) {
var implFn = obj[name];
obj[name]=function() {
if (fn.length === arguments.length) return fn.apply(this,arguments);
else if (typeof implFn === "function") return implFn.apply(this,arguments);
};
};
69. Visual Basic
Public Class Book
<Key> _
Public Property ISBN() As String
' ...
End Property
<StringLength(256)> _
Public Property Title() As String
' ...
End Property
Public Property AuthorSSN() As String
' ...
End Property
<RelatedTo(RelatedProperty := Books, Key := AuthorSSN, RelatedKey := SSN)> _
Public Property Author() As Person
' ...
End Property
End Class
70.
71. F unctional
L oose
U nit Testable
I ntrospective
D
72. F unctional
L oose
U nit Testable
I ntrospective
D
82. F unctional
L oose
U nit Testable
I ntrospective
‘D dempotent
83.
84.
85.
86.
87.
88. e venerable master Qc Na was walking with his student, Anton.
Hoping to prompt the master into a discussion, Anton said "Master, I have
heard that objects are a very good thing — is this true?"
Qc Na looked pityingly at his student and replied, "Foolish pupil — objects
are merely a poor man's closures."
Chastised, Anton took his leave from his master and returned to his cell,
intent on studying closures. He carefully read the entire "Lambda: e
Ultimate..." series of papers and its cousins, and implemented a small
Scheme interpreter with a closure-based object system. He learned much,
and looked forward to informing his master of his progress.
On his next walk with Qc Na, Anton attempted to impress his master by
saying "Master, I have diligently studied the matter, and now understand
that objects are truly a poor man's closures."
Qc Na responded by hitting Anton with his stick, saying "When will you
learn? Closures are a poor man's object." At that moment, Anton became
enlightened.
http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/msg03277.html