-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
443 lines (429 loc) · 22.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pragmatic Software Development Tips</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/base.css">
<link id="theme" rel="stylesheet" href="css/themes/light.css">
</head>
<body>
<noscript>
Javascript disabled!
</noscript>
<div id="wrapper" class=""></div>
<div class="card">
<input id="tipNumber" type="hidden">
<div id="tip">
<div id="title"></div>
<div id="desc"></div>
</div>
</div>
<div id="settings" class="">
<div class="container">
<div class="card">
<h1>Settings</h1>
<div>
<h2>Theme</h2>
<ul class="themes">
<li><a href="#" onclick="changeTheme('light')">Light</a></li>
<li><a href="#" onclick="changeTheme('dark')">Dark</a></li>
<li><a href="#" onclick="changeTheme('nightfall')">Nightfall</a></li>
</ul>
</div>
<div>
<h2>Auto Reload</h2>
<p>
<label for="autoReloadToggle">Enable reload</label>
<input id="autoReloadToggle" type="checkbox" onchange="toggleAutoReload()" />
</p>
<p>
<label for="timeoutMins">Time out interval</label>
<input id="timeoutMins" type="number" onKeyUp="setTimeout(this.value)" onChange="setTimeout(this.value)" min="0" max="1000"/>
</p>
</div>
<span class="settings-toggle"><a href="#" onclick="toggleSettings()" title="Close Settings"><i class="fa fa-times fa-2x"></i></a></span>
</div>
</div>
</div>
<footer>
<div>
<span id="github"><a target="_blank" href="https://github.com/braydie/PragProgTips" title="View on GitHub"><i class="fa fa-github fa-2x"></i></a></span>
<a target="_blank" href="http://pragprog.com/the-pragmatic-programmer/extracts/tips">Read more Pragmatic Software Development Tips</a>
<span class="settings-toggle"><a href="#" onclick="toggleSettings()" title="Toggle Settings"><i class="fa fa-cog fa-2x"></i></a></span>
</div>
</footer>
<script>
function showTip(itemNumber) {
if(itemNumber == null)
{
itemNumber = Math.floor(Math.random()*Tips.length);
}
var item = Tips[itemNumber];
document.getElementById("title").innerHTML = item.title;
document.getElementById("desc").innerHTML = item.desc;
document.getElementById("tipNumber").value = itemNumber;
}
function toggleSettings() {
var settingsPane = document.getElementById("settings");
var wrapper = document.getElementById("wrapper");
if(settingsPane.className.indexOf("active") > -1)
{
settingsPane.className = "";
wrapper.className = "";
}
else
{
settingsPane.className = "active";
wrapper.className = "active";
}
}
function changeTheme(themeName) {
var cssLink = document.getElementById("theme");
cssLink.setAttribute("href", "css/themes/" + themeName + ".css");
localStorage.setItem("Theme", themeName);
}
function toggleAutoReload() {
var enableReload = localStorage.getItem("enableReload");
if(enableReload === "true")
{
localStorage.setItem("enableReload", false);
document.getElementById("timeoutMins").disabled = true;
clearTimeout(timeoutId);
}
else
{
localStorage.setItem("enableReload", true);
document.getElementById("timeoutMins").disabled = false;
setTimeout(document.getElementById("timeoutMins").value);
}
}
function setTimeout(Minutes)
{
var timeout = parseInt(Minutes, 10);
if(timeout > 0)
{
clearTimeout(timeoutId);
timeoutId = setInterval("showTip()", timeout * 1000 * 60);
localStorage.setItem("timeoutMins", timeout);
}
else
{
clearTimeout(timeoutId);
}
}
var timeoutId = null;
var Tips = [{
"title": "Care About Your Craft",
"desc": "Why spend your life developing software unless you care about doing it well?"
},
{
"title": "Provide Options, Don’t Make Lame Excuses",
"desc": "Instead of excuses, provide options. Don’t say it can’t be done; explain what can be done."
},
{
"title": "Be a Catalyst for Change",
"desc": "You can’t force change on people. Instead, show them how the future might be and help them participate in creating it."
},
{
"title": "Make Quality a Requirements Issue",
"desc": "Involve your users in determining the project’s real quality requirements."
},
{
"title": "Critically Analyze What You Read and Hear",
"desc": "Don’t be swayed by vendors, media hype, or dogma. Analyze information in terms of you and your project."
},
{
"title": "DRY - Don’t Repeat Yourself",
"desc": "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system."
},
{
"title": "Eliminate Effects Between Unrelated Things",
"desc": "Design components that are self-contained, independent, and have a single, well-defined purpose."
},
{
"title": "Use Tracer Bullets to Find the Target",
"desc": "Tracer bullets let you home in on your target by trying things and seeing how close they land."
},
{
"title": "Program Close to the Problem Domain",
"desc": "Design and code in your user’s language."
},
{
"title": "Iterate the Schedule with the Code",
"desc": "Use experience you gain as you implement to refine the project time scales."
},
{
"title": "Use the Power of Command Shells",
"desc": "Use the shell when graphical user interfaces don’t cut it."
},
{
"title": "Always Use Source Code Control",
"desc": "Source code control is a time machine for your work - you can go back."
},
{
"title": "Don’t Panic When Debugging",
"desc": "Take a deep breath and THINK! about what could be causing the bug."
},
{
"title": "Don’t Assume It - Prove It",
"desc": "Prove your assumptions in the actual environment - with real data and boundary conditions."
},
{
"title": "Write Code That Writes Code",
"desc": "Code generators increase your productivity and help avoid duplication."
},
{
"title": "Design with Contracts",
"desc": "Use contracts to document and verify that code does no more and no less than it claims to do."
},
{
"title": "Use Assertions to Prevent the Impossible",
"desc": "Assertions validate your assumptions. Use them to protect your code from an uncertain world."
},
{
"title": "Finish What You Start",
"desc": "Where possible, the routine or object that allocates a resource should be responsible for deallocating it."
},
{
"title": "Configure, Don’t Integrate",
"desc": "Implement technology choices for an application as configuration options, not through integration or engineering."
},
{
"title": "Analyze Workflow to Improve Concurrency",
"desc": "Exploit concurrency in your user’s workflow."
},
{
"title": "Always Design for Concurrency",
"desc": "Allow for concurrency, and you’ll design cleaner interfaces with fewer assumptions."
},
{
"title": "Use Blackboards to Coordinate Workflow",
"desc": "Use blackboards to coordinate disparate facts and agents, while maintaining independence and isolation among participants."
},
{
"title": "Estimate the Order of Your Algorithms",
"desc": "Get a feel for how long things are likely to take before you write code."
},
{
"title": "Refactor Early, Refactor Often",
"desc": "Just as you might weed and rearrange a garden, rewrite, rework, and re-architect code when it needs it. Fix the root of the problem."
},
{
"title": "Test Your Software, or Your Users Will",
"desc": "Test ruthlessly. Don’t make your users find bugs for you."
},
{
"title": "Don’t Gather Requirements - Dig for Them",
"desc": "Requirements rarely lie on the surface. They’re buried deep beneath layers of assumptions, misconceptions, and politics."
},
{
"title": "Abstractions Live Longer than Details",
"desc" :"Invest in the abstraction, not the implementation. Abstractions can survive the barrage of changes from different implementations and new technologies."
},
{
"title": "Don’t Think Outside the Box - <i>Find</i> the Box",
"desc": "When faced with an impossible problem, identify the real constraints. Ask yourself: “Does it have to be done this way? Does it have to be done at all?”"
},
{
"title": "Some Things Are Better Done than Described",
"desc": "Don’t fall into the specification spiral - at some point you need to start coding."
},
{
"title": "Costly Tools Don’t Produce Better Designs",
"desc": "Beware of vendor hype, industry dogma, and the aura of the price tag. Judge tools on their merits."
},
{
"title": "Don’t Use Manual Procedures",
"desc": "A shell script or batch file will execute the same instructions, in the same order, time after time."
},
{
"title": "Coding Ain’t Done ’Til All the Tests Run",
"desc": "’Nuff said."
},
{
"title": "Test State Coverage, Not Code Coverage",
"desc": "Identify and test significant program states. Just testing lines of code isn’t enough."
},
{
"title": "English is Just a Programming Language",
"desc": "Write documents as you would write code: honor the DRY principle, use metadata, MVC, automatic generation, and so on."
},
{
"title": "Gently Exceed Your Users’ Expectations",
"desc": "Come to understand your users’ expectations, then deliver just that little bit more."
},
{
"title": "Think! About Your Work",
"desc": "Turn off the autopilot and take control. Constantly critique and appraise your work."
},
{
"title": "Don’t Live with Broken Windows",
"desc": "Fix bad designs, wrong decisions, and poor code when you see them."
},
{
"title": "Remember the Big Picture",
"desc": "Don’t get so engrossed in the details that you forget to check what’s happening around you."
},
{
"title": "Invest Regularly in Your Knowledge Portfolio",
"desc": "Make learning a habit."
},
{
"title": "It’s Both What You Say and the Way You Say It",
"desc": "There’s no point in having great ideas if you don’t communicate them effectively."
},
{
"title": "Make It Easy to Reuse",
"desc": "If it’s easy to reuse, people will. Create an environment that supports reuse."
},
{
"title": "There Are No Final Decisions",
"desc": "No decision is cast in stone. Instead, consider each as being written in the sand at the beach, and plan for change."
},
{
"title": "Prototype to Learn",
"desc": "Prototyping is a learning experience. Its value lies not in the code you produce, but in the lessons you learn."
},
{
"title": "Estimate to Avoid Surprises",
"desc": "Estimate before you start. You’ll spot potential problems up front."
},
{
"title": "Keep Knowledge in Plain Text",
"desc": "Plain text won’t become obsolete. It helps leverage your work and simplifies debugging and testing."
},
{
"title": "Use a Single Editor Well",
"desc": "The editor should be an extension of your hand; make sure your editor is configurable, extensible, and programmable."
},
{
"title": "Fix the Problem, Not the Blame",
"desc": "It doesn’t really matter whether the bug is your fault or someone else’s - it is still your problem, and it still needs to be fixed."
},
{
"title": "“select” Isn’t Broken",
"desc": "It is rare to find a bug in the OS or the compiler, or even a third-party product or library. The bug is most likely in the application."
},
{
"title": "Learn a Text Manipulation Language",
"desc": "You spend a large part of each day working with text. Why not have the computer do some of it for you?"
},
{
"title": "You Can’t Write Perfect Software",
"desc": "Software can’t be perfect. Protect your code and users from the inevitable errors."
},
{
"title": "Crash Early",
"desc": "A dead program normally does a lot less damage than a crippled one."
},
{
"title": "Use Exceptions for Exceptional Problems",
"desc": "Exceptions can suffer from all the readability and maintainability problems of classic spaghetti code. Reserve exceptions for exceptional things."
},
{
"title": "Minimize Coupling Between Modules",
"desc": "Avoid coupling by writing “shy” code and applying the Law of Demeter."
},
{
"title": "Put Abstractions in Code, Details in Metadata",
"desc": "Program for the general case, and put the specifics outside the compiled code base."
},
{
"title": "Design Using Services",
"desc": "Design in terms of services - independent, concurrent objects behind well-defined, consistent interfaces."
},
{
"title": "Separate Views from Models",
"desc": "Gain flexibility at low cost by designing your application in terms of models and views."
},
{
"title": "Don’t Program by Coincidence",
"desc": "Rely only on reliable things. Beware of accidental complexity, and don’t confuse a happy coincidence with a purposeful plan."
},
{
"title": "Test Your Estimates",
"desc": "Mathematical analysis of algorithms doesn’t tell you everything. Try timing your code in its target environment."
},
{
"title": "Design to Test",
"desc": "Start thinking about testing before you write a line of code."
},
{
"title": "Don’t Use Wizard Code You Don’t Understand",
"desc": "Wizards can generate reams of code. Make sure you understand all of it before you incorporate it into your project."
},
{
"title": "Work with a User to Think Like a User",
"desc": "It’s the best way to gain insight into how the system will really be used."
},
{
"title": "Use a Project Glossary",
"desc": "Create and maintain a single source of all the specific terms and vocabulary for a project."
},
{
"title": "Start When You’re Ready",
"desc": "You’ve been building experience all your life. Don’t ignore niggling doubts."
},
{
"title": "Don’t Be a Slave to Formal Methods",
"desc": "Don’t blindly adopt any technique without putting it into the context of your development practices and capabilities."
},
{
"title": "Organize Teams Around Functionality",
"desc": "Don’t separate designers from coders, testers from data modelers. Build teams the way you build code."
},
{
"title": "Test Early. Test Often. Test Automatically.",
"desc": "Tests that run with every build are much more effective than test plans that sit on a shelf."
},
{
"title": "Use Saboteurs to Test Your Testing",
"desc": "Introduce bugs on purpose in a separate copy of the source to verify that testing will catch them."
},
{
"title": "Find Bugs Once",
"desc": "Once a human tester finds a bug, it should be the last time a human tester finds that bug. Automatic tests should check for it from then on."
},
{
"title": "Build Documentation In, Don’t Bolt It On",
"desc": "Documentation created separately from code is less likely to be correct and up to date."
},
{
"title": "Sign Your Work",
"desc": "Craftsmen of an earlier age were proud to sign their work. You should be, too."
}
];
window.onload = function() {
if(localStorage.getItem("enableReload") != null)
{
var reloadEnabled = (localStorage.getItem("enableReload") === "true");
document.getElementById("autoReloadToggle").checked = reloadEnabled;
document.getElementById("timeoutMins").disabled = !reloadEnabled;
document.getElementById("timeoutMins").value = localStorage.getItem("timeoutMins");
if(reloadEnabled)
{
setTimeout(document.getElementById("timeoutMins").value);
}
}
else
{
localStorage.setItem("enableReload", false);
localStorage.setItem("timeoutMins", 0);
document.getElementById("timeoutMins").disabled = true;
}
showTip();
}
if(localStorage.getItem("Theme") != null)
{
changeTheme(localStorage.getItem("Theme"));
}
else
{
changeTheme("light");
}
</script>
</body>
</html>