Download
the basic tools n.
Skip this Video
Loading SlideShow in 5 Seconds..
The Basic Tools PowerPoint Presentation
Download Presentation
The Basic Tools

The Basic Tools

118 Vues Download Presentation
Télécharger la présentation

The Basic Tools

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. The Basic Tools CSSE 514 Programming Methods 4/26/01

  2. Overview • Plain Text • The Command Shell • Editors • Source Code Control • Debugging • Text Manipulation • Code Generators References: • Andrew Hunt, David Thomas, The Pragmatic Programmer, Addison Wesley, 2000 • Marc Eisenstadt, "My Hairiest Bug War Stories", CACM, April 1996 • Stephen McConnell, Code Complete, Microsoft Press, 1995

  3. Plain Text • What is Plain Text? • Plain text is the medium that developers express themselves in • Is made up of printable characters that can be read and understood by people • Can be structured • Tends to be at a higher level than a straight binary encoding • The problem with most binary encoding is that the context necessary to understand the data is separate form the data itself • Tip 20 - Keep knowledge in Plain Text

  4. Plain Text • Drawbacks • It may take more space to store than some compressed binary format • It may be computationally more expensive to interpret and process a plain text file • Advantages • Insurance against obsolescence • Leverage • Easier testing

  5. Plain Text • Insurance Against Obsolescence • Human-readable and self-describing forms of data will outlive all other forms of data and the applications that created them • Leverage • Almost every tool can operate on plain text • Easier Testing • By using plain text to represent your synthetic data to drive system tests, then you won't need special tools to add, update, or modify the test data • Lowest Common Denominator • In heterogeneous environments, the advantages of plain text far outweigh any disadvantages

  6. The Command Shell • For a developer, the command shell is similar to the carpenter's workbench • A developer can use the command shell to invoke the full repertoire of tools, including: • applications • debuggers • browsers • editors • utilities • Can search for files, query the status of the system, and filter output from the command prompt

  7. The Command Shell • Why is the command line any better than a GUI for a developer? • A GUI is often faster and more convenient for some simple operations, including: • Moving files • Reading MIME-encoded email • Typing letters • If you do all your work in a GUI you might be missing out on the full capabilities of your environment • GUI environments are normally limited to the capabilities that their designers intended

  8. The Command Shell • As a software developer you are constantly performing ad hoc operations, for example: Find all .c files modified more recently than your Makefile shell: find . -name '*.c' -newer Makefile -print GUI: • open the Explorer • navigate to the correct directory • click on the Makefile and note modification time • bring up Tools/Find and enter *.c for the file specification • select the date tab and enter the date you noted for the Makefile in the first date field • hit OK

  9. The Command Shell • Shell Utilities and Windows Systems • Cygnus Solutions Cygwin • Offers more than 120 Unix utilities such as ls, grep, and find • David Korn's UWIN • Tom Christiansen's Perl Power Tools

  10. Editors • Probably the most used tool of the software developer • It is better to know one editor well, and use it for all editing tasks, including: • Coding • Documentation • Memos • System administration • You need to be proficient in your editor of choice • Make sure the editor you choose is available on all the platforms you use

  11. Editor Features • There are some basic capabilities that every decent editor should have: • It should be configurable • It should be extensible • It should be programmable • In addition, many editors support features that are specific to a particular programming language: • Syntax highlighting • Auto-completion • Auto-indentation • Initial code or document boilerplate • Tie-in to help systems • IDE-like features • compile • debug • etc.

  12. Productivity • Why is a fully functional editor necessary for a developer to be productive? • Cursor movement • Streamline common operations • Templates for creating new files that include: • Name of the class or module filled in (derived from filename) • Author name and/or copywrite statements • Skeletons for constructs in that language (constructor and destructor declarations, for example)

  13. Source Code Control • Source code control is like a giant UNDO button for projects • Source code control systems and configuration management systems keep track of every change you make in your source code or documentation • A good SCCS will let you track changes and answer questions such as: • 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? • Which files get changes most often?

  14. Source Code Control • An SCCS will let you identify releases of your software so that you will always be able to regenerate the release • You can use an SCCS to manage branches in the development tree • An SCCS can keep the files it maintains in a central repository • Some products allow multiple users to work concurrently on the same set of files or even on the same file • An SCCS will enable your project to have builds that are automated and repeatable

  15. Debugging • In a study by Marc Eisenstadt, informants reported four major bug-catching techniques: • Gather data. There are 6 subtechniques: • Step and study. Single-step through the code, monitoring data. • Wrap and profile. Wrap a suspect function inside a variant that gathers data before and after the function executes. • Print and peruse. Embed print statements. • Dump and diff. A core dump or extensive print statements corresponding to two different runs are compared using a file comparator • Conditional break and inspect. Insert a conditional break point and examine data • Specialist profile tool. Use an off-the-shelf tool like Mem or Heap Scramble to detect memory leaks or corrupt or illegal memory references • Inspeculation. Inspect, think simulate • Expert recognized cliches. Get help. • Controlled Experiments. Test a hypothesis.

  16. Debugging • Steve McConnell suggests a 5 step process: • Stabilize the error. Find the smallest test case that produces the error. • Locate the source of the error. Here you can use the scientific method: gather data, form a hypothesis, design an experiment, test the hypothesis, and repeat as needed. • Fix the error. Since defect corrections have a 50% chance of being wrong, make sure you understand the problem. Make one change at a time, and save the original source. • Test the fix. • Look for similar errors • Always document errors, look for their cause, and take steps to avoid making them again.

  17. Text Manipulation • Often we need to perform some transformation to text not readily handled by our basic tool set. We need a general-purpose text manipulation tool. • Common text manipulation tools include: • Perl • TCL • Python • These languages can help you quickly hack up utilities and prototype ideas -- jobs that might take five or ten times as long using conventional languages.

  18. Text Manipulation • Areas where the authors found text manipulation languages useful include: • Database schema maintenance • Java property access • Test data generation • Book writing • C to Object Pascal interface • Generating Web documentation

  19. Code Generators • As developers we often need to achieve the same functionality but in different contexts • Code generators can help buy writing the code for us • There are two main types of code generators: • Passive code generators • Active code generators

  20. Passive Code Generators • Passive code generators are basically parameterized templates • Passive code generators have many uses including: • Creating new source files • Performing one-off conversions among programming languages • Producing lookup tables and other resources that are expensive to compute at runtime

  21. Active Code Generators • Active code generation is NOT duplication • Whenever you find yourself trying to get two disparate environments to work together, you should consider using active code generators • An example would be using an active code generator to take a database schema and use it to generate the source code for the low-level structures needed to represent it in your programming language