SlideShare a Scribd company logo
THE PRAGMATIC
PROGRAMMER
CHAPTER 3
THE BASIC TOOLS
HEADLINES
The Power Of Plain Text
Shell Games
Power Editing
Source Code Control
Debugging
Text Manipulation
Code Generators
PLAIN TEXT
As programmers our base material = KNOWLEDGE
We gather requirements as knowledge and then express in our
designs.
We believe the best format for storing it is PLAIN TEXT
HUMAN-READABLE AND SELF-DESCRIBING !!
Fieldl9=467abe DrawingType=UMLActivityDrawing
myprop.uses_menus=FALSE Contrast this with 0010010101110101
DRAWBACKS
2 major drawbacks to using plain text:
1.It may take more space to store than a compressed binary format.
2.It may be more expensive to interpret and process a plain text file.
SOLUTION IS
METADATA !
THE POWER OF
PLAIN TEXT
Insurance Against Obsolescence
As long as the data survives, you will have a chance to be able to use it.
<FIELD10>123-45-6789</FIELD10> AC27123456789B11P
<FIELD10>567-89-0123</FIELD10> XY43567890123QTYL
<FIELD10>901-23-4567</FIELD10> 6T2190123456788AM
Leverage
Virtually every tool in the computing universe can operate on plain
text.
Easier Testing
It is a simple matter to add, update, or modify the test data without
having to create any special tools.
THE UNIX
PHILOSOPHY
The philosophy is enabled by using a common underlying format-line
oriented, plain text file.
Databases used for system administration
-users
-passwords
-network config, all kept in a plain text files.
SUMMARY
YOU NEED TO ENSURE THAT ALL PARTIES CAN COMMUNICATE USING A COMMON STANDART.
PLAIN TEXT IS THAT STANDART.
SHELL GAMES For a programmer manipulating files of text, workbench is
the command shell.
You can launch applications, debuggers, browsers, editors, and
utilities. You can search for files, query the status of the system.
If you do all your work using GUIs, you are missing out on the full
capabilities of your environment.
A benefit of GUIs is WYSIWYG—WHAT YOU SEE IS
WHAT YOU GET.
The disadvantage is WYSIAYG—WHAT YOU SEE IS ALL
YOU GET.
SHELL VS GUI
POWER
EDITING
One Editor
We think it is better to know one editor very well, and use it for all
editing tasks: code, documentation, system administration, and so
on…
If you use a single editor (or set of key bindings) across all text editing
activities, you don't have to stop and think to accomplish text
manipulation
Editor Feautures
CONFIGURABLE
EXTENSIABLE
PROGRAMMABLE
Also have:
Syntax highlighting
Auto-completion
Auto-indentation
Initial code or document boilerplate
Tie-in to help systems
IDE-like features (compile, debug, and so on)
The pragmatic programmer
SOURCE CODE
CONTROL
One of the important things we look for in a
user interface is the key—a single button
that forgives us our mistakes !!!!!
Source code control systems, or the more widely
scoped configuration management
systems, keep track of every change you make
in your source code and documentation.
Who made changes in this line of code?
What's the difference between the current version
and last week's?
How many lines of code did we change in this release?
DEBUGGING
In 1873 Edison first confronted what he later called a bug when he
began developing a quadruplex telegraph system.
On September 9, 1945, a Harvard technical team looked at Panel F
and found something unusual between points in Relay 70.It was a
moth, which they promptly removed and taped in the log book.
DON’T PANIC
Don't waste a single neuron on the train of thought that
begins "but that can't happen" because quite clearly it
can, and has…
It is very important to step back a pace, and
actually think about what could be causing the
symptoms that you believe indicate a bug.
WHERE TO
START?
Before you start to look at the bug, make sure that you are
working on code that compiled cleanly—without warnings
When trying to solve any problem,
you need to gather all the relevant data.
DEBUGGING
STRATEGIES
Bug Reproducing
We want a bug that can be reproduced with a single command
Visualize your data
The simplest example of this is a straightforward "variable name =
data value" approach, which may be implemented as printed text.
The DDD debugger has some visualization capabilities, and is freely
available .It is interesting to note that DDD works with multiple
languages, including Ada, C, C++, Fortran, Java, Modula, Pascal,
Perl, and Python (clearly an orthogonal design).
DEBUGGING
STRATEGIES
Tracing
Debuggers generally focus on the state of the program now.
Sometimes you need more—you need to watch the state of a program
or a data structure over time.
Rubber Ducking
DEBUGGING
STRATEGIES
Process Of Elimination
It is possible that a bug exists in the OS, the compiler, or a third-party
product—but this should not be your first thought
It is generally more profitable to assume that the application code is
incorrectly calling into a library than to assume that the library itself is
broken
DEBUGGING
CHECKLIST
• • Is the problem being reported a direct result of
the underlying bug, or merely a symptom?
• • Is the bug really in the compiler? Is it in the OS?
Or is it in your code?
• • If you explained this problem in detail to a
coworker, what would you say?
• • If the suspect code passes its unit tests, are the
tests complete enough? What happens if you run
the unit test with this data?
• • Do the conditions that caused this bug exist
anywhere else in the system?
DEBUGGING
CHALLENGES
• • Debugging is challenge
enough...
TEXT
MANIPULATIO
N
Pragmatic Programmers manipulate text the same way woodworkers
shape wood. In previous sections we discussed some specific tools—
shells, editors, debugger.
We happen to prefer Perl for hacking out short scripts.
Kernighan and Pike built the same program in five different
languages.
The Perl version was the shortest (17 lines, compared with C's 150).
With Perl you can manipulate text, interact with programs, talk over
networks, drive Web pages, perform arbitrary precision arithmetic,
and write programs.
CODE
GENERATORS
We need to achieve the same functionality, but in different
contexts. We need to repeat information in different places.
A programmer can build a code generator. Once built, it can
be used throughout the life of the project at virtually no cost.
WRITE CODE
THAT WRITE
CODES
1. Passive code generators
Run once to produce a result. From that point forward, the
result becomes freestanding—it is divorced from the code
generator.
2. Active code generators
The result is a throw-away—it can always be reproduced by
the code generator.
ANY
QUESTIONS?
THANKS FOR
LISTENING…
Leylim Yalçın

More Related Content

PPTX
Lab symbols ppt 2
PDF
Mobile application development React Native - Tidepool Labs
PPTX
THE BASIC TOOLS
PDF
Programming Languages #devcon2013
PDF
Os Keysholistic
ODP
Novice Programmers Workshop
PPT
APIs And SDKs Breaking Into And Succeeding In A Specialty Market
PDF
Tiny C Projects 1st Edition Daniel Gookin
Lab symbols ppt 2
Mobile application development React Native - Tidepool Labs
THE BASIC TOOLS
Programming Languages #devcon2013
Os Keysholistic
Novice Programmers Workshop
APIs And SDKs Breaking Into And Succeeding In A Specialty Market
Tiny C Projects 1st Edition Daniel Gookin

Similar to The pragmatic programmer (20)

PDF
On Impact in Software Engineering Research (HU Berlin 2021)
PDF
Systems se
PPT
PHP - Introduction to PHP Bugs - Debugging
PDF
On Impact in Software Engineering Research (Dagstuhl 2020)
PPTX
Austin Python Learners Meetup - Everything you need to know about programming...
PPTX
EMBEDDED SYSTEMS Lecture 4 IDE AND MICROCONTROLLERS.pptx
PPTX
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
PDF
Cois240 lesson01
PPTX
Programming Development LifeCycle11.pptx
KEY
Tweakers Anonymous
PPT
computer programming introduction ppt.ppt
PPT
ss5.ppt
PPTX
Introduction to Coding
PDF
system-software-tools
DOC
Ex11 mini project
PPTX
Cp 111 lecture 2
PPTX
Computer programing 111 lecture 2
ODP
Preventing Complexity in Game Programming
PDF
PyData Texas 2015 Keynote
PPT
debugging (1).ppt
On Impact in Software Engineering Research (HU Berlin 2021)
Systems se
PHP - Introduction to PHP Bugs - Debugging
On Impact in Software Engineering Research (Dagstuhl 2020)
Austin Python Learners Meetup - Everything you need to know about programming...
EMBEDDED SYSTEMS Lecture 4 IDE AND MICROCONTROLLERS.pptx
Speaking 'Development Language' (Or, how to get your hands dirty with technic...
Cois240 lesson01
Programming Development LifeCycle11.pptx
Tweakers Anonymous
computer programming introduction ppt.ppt
ss5.ppt
Introduction to Coding
system-software-tools
Ex11 mini project
Cp 111 lecture 2
Computer programing 111 lecture 2
Preventing Complexity in Game Programming
PyData Texas 2015 Keynote
debugging (1).ppt
Ad

Recently uploaded (20)

PPTX
OOP with Java - Java Introduction (Basics)
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
additive manufacturing of ss316l using mig welding
PPTX
web development for engineering and engineering
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Sustainable Sites - Green Building Construction
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
composite construction of structures.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
Digital Logic Computer Design lecture notes
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Geodesy 1.pptx...............................................
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
OOP with Java - Java Introduction (Basics)
Model Code of Practice - Construction Work - 21102022 .pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
additive manufacturing of ss316l using mig welding
web development for engineering and engineering
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Sustainable Sites - Green Building Construction
Embodied AI: Ushering in the Next Era of Intelligent Systems
Automation-in-Manufacturing-Chapter-Introduction.pdf
composite construction of structures.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
UNIT 4 Total Quality Management .pptx
CYBER-CRIMES AND SECURITY A guide to understanding
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Digital Logic Computer Design lecture notes
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Lecture Notes Electrical Wiring System Components
Geodesy 1.pptx...............................................
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Ad

The pragmatic programmer

  • 2. HEADLINES The Power Of Plain Text Shell Games Power Editing Source Code Control Debugging Text Manipulation Code Generators
  • 3. PLAIN TEXT As programmers our base material = KNOWLEDGE We gather requirements as knowledge and then express in our designs. We believe the best format for storing it is PLAIN TEXT HUMAN-READABLE AND SELF-DESCRIBING !! Fieldl9=467abe DrawingType=UMLActivityDrawing myprop.uses_menus=FALSE Contrast this with 0010010101110101
  • 4. DRAWBACKS 2 major drawbacks to using plain text: 1.It may take more space to store than a compressed binary format. 2.It may be more expensive to interpret and process a plain text file.
  • 6. THE POWER OF PLAIN TEXT Insurance Against Obsolescence As long as the data survives, you will have a chance to be able to use it. <FIELD10>123-45-6789</FIELD10> AC27123456789B11P <FIELD10>567-89-0123</FIELD10> XY43567890123QTYL <FIELD10>901-23-4567</FIELD10> 6T2190123456788AM Leverage Virtually every tool in the computing universe can operate on plain text. Easier Testing It is a simple matter to add, update, or modify the test data without having to create any special tools.
  • 7. THE UNIX PHILOSOPHY The philosophy is enabled by using a common underlying format-line oriented, plain text file. Databases used for system administration -users -passwords -network config, all kept in a plain text files.
  • 8. SUMMARY YOU NEED TO ENSURE THAT ALL PARTIES CAN COMMUNICATE USING A COMMON STANDART. PLAIN TEXT IS THAT STANDART.
  • 9. SHELL GAMES For a programmer manipulating files of text, workbench is the command shell. You can launch applications, debuggers, browsers, editors, and utilities. You can search for files, query the status of the system. If you do all your work using GUIs, you are missing out on the full capabilities of your environment. A benefit of GUIs is WYSIWYG—WHAT YOU SEE IS WHAT YOU GET. The disadvantage is WYSIAYG—WHAT YOU SEE IS ALL YOU GET.
  • 11. POWER EDITING One Editor We think it is better to know one editor very well, and use it for all editing tasks: code, documentation, system administration, and so on… If you use a single editor (or set of key bindings) across all text editing activities, you don't have to stop and think to accomplish text manipulation
  • 12. Editor Feautures CONFIGURABLE EXTENSIABLE PROGRAMMABLE Also have: Syntax highlighting Auto-completion Auto-indentation Initial code or document boilerplate Tie-in to help systems IDE-like features (compile, debug, and so on)
  • 14. SOURCE CODE CONTROL One of the important things we look for in a user interface is the key—a single button that forgives us our mistakes !!!!! Source code control systems, or the more widely scoped configuration management systems, keep track of every change you make in your source code and documentation. Who made changes in this line of code? What's the difference between the current version and last week's? How many lines of code did we change in this release?
  • 15. DEBUGGING In 1873 Edison first confronted what he later called a bug when he began developing a quadruplex telegraph system. On September 9, 1945, a Harvard technical team looked at Panel F and found something unusual between points in Relay 70.It was a moth, which they promptly removed and taped in the log book.
  • 16. DON’T PANIC Don't waste a single neuron on the train of thought that begins "but that can't happen" because quite clearly it can, and has… It is very important to step back a pace, and actually think about what could be causing the symptoms that you believe indicate a bug.
  • 17. WHERE TO START? Before you start to look at the bug, make sure that you are working on code that compiled cleanly—without warnings When trying to solve any problem, you need to gather all the relevant data.
  • 18. DEBUGGING STRATEGIES Bug Reproducing We want a bug that can be reproduced with a single command Visualize your data The simplest example of this is a straightforward "variable name = data value" approach, which may be implemented as printed text. The DDD debugger has some visualization capabilities, and is freely available .It is interesting to note that DDD works with multiple languages, including Ada, C, C++, Fortran, Java, Modula, Pascal, Perl, and Python (clearly an orthogonal design).
  • 19. DEBUGGING STRATEGIES Tracing Debuggers generally focus on the state of the program now. Sometimes you need more—you need to watch the state of a program or a data structure over time. Rubber Ducking
  • 20. DEBUGGING STRATEGIES Process Of Elimination It is possible that a bug exists in the OS, the compiler, or a third-party product—but this should not be your first thought It is generally more profitable to assume that the application code is incorrectly calling into a library than to assume that the library itself is broken
  • 21. DEBUGGING CHECKLIST • • Is the problem being reported a direct result of the underlying bug, or merely a symptom? • • Is the bug really in the compiler? Is it in the OS? Or is it in your code? • • If you explained this problem in detail to a coworker, what would you say? • • If the suspect code passes its unit tests, are the tests complete enough? What happens if you run the unit test with this data? • • Do the conditions that caused this bug exist anywhere else in the system?
  • 22. DEBUGGING CHALLENGES • • Debugging is challenge enough...
  • 23. TEXT MANIPULATIO N Pragmatic Programmers manipulate text the same way woodworkers shape wood. In previous sections we discussed some specific tools— shells, editors, debugger. We happen to prefer Perl for hacking out short scripts. Kernighan and Pike built the same program in five different languages. The Perl version was the shortest (17 lines, compared with C's 150). With Perl you can manipulate text, interact with programs, talk over networks, drive Web pages, perform arbitrary precision arithmetic, and write programs.
  • 24. CODE GENERATORS We need to achieve the same functionality, but in different contexts. We need to repeat information in different places. A programmer can build a code generator. Once built, it can be used throughout the life of the project at virtually no cost.
  • 25. WRITE CODE THAT WRITE CODES 1. Passive code generators Run once to produce a result. From that point forward, the result becomes freestanding—it is divorced from the code generator. 2. Active code generators The result is a throw-away—it can always be reproduced by the code generator.