Exam Preparation
Total Page:16
File Type:pdf, Size:1020Kb
Software Engineering Tools Course Summary Created by Tali Gutman, According to lectures by Zvi Gutterman Written in OpenOffice Writer™ I don't promise anything about this summary, it's been adapted from lecture slides and wikipedia. Introduction Syllabus: • Logging • Source Control Management • Build Tools • Documentation Tools • Quality Assurance • Reverse Engineering • Legal Summary What are we looking for? • Software development shortcuts • Stability • Support • Known standards • Easy integration with other products • e.g. IDE plug in, web interface • Simple • Scale well • Supported platforms • Commonly used • Open/close source Reading List - Will be mentioned as we go along Logging Tools Logging - Definition: - Low-tech method for debugging applications - Can also be viewed as an auditing tool [meaning - tool for examination, verification etc...] Basic features of any logging library are: • Control over which logging statements are enabled/disabled • Manage output destinations and output formats >> Central issue is the categorization of logging statements [From Wikipedia] In computerized data logging, a computer program may automatically record events in a certain scope in order to provide an audit trail that can be used to diagnose problems. Examples of physical systems which have logging subsystems include process control systems, and the black box recorders installed in aircraft. Many operating systems and multitudinous computer programs include some form of logging subsystem. Some operating systems provide a syslog service (described in RFC 3164), which allows the filtering and recording of log messages to be performed by a separate dedicated subsystem, rather than placing the onus on each application to provide its own ad hoc logging system. In many cases, the logs are esoteric and hard to understand; they need to be subjected to log analysis in order to make sense of them. Other servers use a splunk to parse log files in order to facilitate troubleshooting; this approach may yield correlations between seemingly-unrelated events on different servers. Other enterprise class solutions such as those from LogLogic collect log data files in volume and make them available for reporting and real-time analysis. [End of Wikipedia bit] Logger – Definition: - Named entities that follow the hierarchical naming rule. [example: A logger named 'com' is the direct parent of a logger named 'com.foo' and an ancestor of a logger named 'com.foo.bar'] (Irrelevant note: Foobar, adaptation of FUBAR, stands for "Fucked Up Beyond All Recognition. Thought you'd like to know) Log4j - A logging package for the Java Language (Ceki Gülcü wrote this logger) Loggers, Appenders and Layouts Log4j has three main components: loggers, appenders and layouts. These three types of components work together to enable developers to log messages according to message type and level, and to control at runtime how these messages are formatted and where they are reported. Log4j Levels: • Loggers may be assigned levels. The set of possible levels, that is DEBUG, INFO, WARN, ERROR and FATAL are defined in the org.apache.log4j.Level class, which I'm adding here: [From class definition] The DEBUG Level designates fine-grained informational events that are most useful to debug an application. The ERROR level designates error events that might still allow the application to continue running. The FATAL level designates very severe error events that will presumably lead the application to abort. The INFO level designates informational messages that highlight the progress of the application at coarse-grained level. The WARN level designates potentially harmful situations. [End of from class bit] • If a given logger is not assigned a level, then it inherits one from its closest ancestor with an assigned level. • A logging request is said to be enabled if its level is higher than or equal to the level of its logger. Otherwise, the request is said to be disabled. A logger without an assigned level will inherit one from the hierarchy. This rule is summarized below. Basic Selection Rule A log request of level p in a logger with (either assigned or inherited, whichever is appropriate) level q, is enabled if p >= q. This rule is at the heart of log4j. It assumes that levels are ordered. For the standard levels, we have DEBUG < INFO < WARN < ERROR < FATAL. Log4j Appenders • Output targets are implemented by appenders. Appenders exist for java.io.Writer, the console, files, Unix syslog, JMS [Java Message Service, it's a middleware for inter- process communications in Java. My deepest apologies to those who did not take OS yet, and my even deeper ones to those who did.], NT Event Log, SMTP and more. • More than one appender can be attached to a logger. • Appenders follow the logger hierarchy in an additive fashion. For example, if a console appender is added to the root logger, then all enabled logging requests will at least print on the console. If in addition a file appender is added to a logger, say C, then enabled logging requests for C and C's children will print on a file and on the console. It is possible to override this default behavior so that appender accumulation is no longer additive by setting the additivity flag to false. The rules governing appender additivity are summarized below. Appender Additivity The output of a log statement of logger C will go to all the appenders in C and its ancestors. This is the meaning of the term "appender additivity". However, if an ancestor of logger C, say P, has the additivity flag set to false, then C's output will be directed to all the appenders in C and it's ancestors up to and including P but not the appenders in any of the ancestors of P. Loggers have their additivity flag set to true by default. Layouts & ObjectRenderers • Users can customize the output of an appender by associating with it a Layout. The layout is responsible for formatting the logging request according to the user's wishes, whereas an appender takes care of sending the formatted output to its destination. The PatternLayout, part of the standard log4j distribution, lets the user specify the output format according to conversion patterns similar to the C language printf function. • Logging output can be formatted also in HTML or XML among other formats. • It is also possible to format the output by message object type by registering an appropriate ObjectRenderer for a given type. [Just as importantly, log4j will render the content of the log message according to user specified criteria. For example, if you frequently need to log Oranges, an object type used in your current project, then you can register an OrangeRenderer that will be invoked whenever an orange needs to be logged. Object rendering follows the class hierarchy. For example, assuming oranges are fruits, if you register an FruitRenderer, all fruits including oranges will be rendered by the FruitRenderer, unless of course you registered an orange specific OrangeRenderer. ] Configuration • Log4j allows both programmatical and script-based configuration • Configuration scripts can be expressed as key=value pairs or in XML format. • Meaning: You can configure via code, or you can read external configuration files. Logging performance: • Performance when logging is turned off is extremely fast but incurs the hidden cost of parameter construction, regardless of whether the message will be logged or not. To avoid the parameter construction cost write: if(logger.isDebugEnabled() { logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i])); } • Performance of logging when logging is turned on is determined by the cost of walking the logger hierarchy. Typical cost of a hierarchy walk is in the range 5 to 15 microseconds. • Actual logging is in order of 100 to 300 microseconds. Conclusion • Log4j is a popular logging package written in Java • One of its distinctive features is the notion of inheritance in loggers. • Log statements can be completely managed using configuration files. They can be selectively enabled or disabled and sent to different output targets in user chosen formats. • Log statements can remain in shipped code without incurring a heavy performance cost. Source Control Management ● Requirements ● Vocabulary ● Project organization ● Versioning ● Tools ○ RCS, CVS ○ Source Safe ○ Clear Case ○ Subversion ○ Additional tools Requirements • Software is made of many files • Source files, documentation, binaries, graphics, etc. • Complex directory tree • Some files are dynamically generated during the build process Which files do we store? In what structure? • Many developers • Need the same files • Privileges • Offline development • Mistakes • Multiple products may be base on the same source code • Distributed development sites • Low communication bandwidth • Archive and logging • When a function was added • Which tools are being used (like Log4j) • Management tool • Great for summary information. • Beware of abuse! Vocabulary http://en.wikipedia.org/wiki/Revision_control#Common_vocabulary http://producingoss.com/html-chunk/vc.html • Repository • The repository is where the file data is stored, often on a server. Sometimes also called a depot. • A database in which changes are stored. Some version control systems are centralized: there is a single, master repository, which stores all changes to the project. Others are decentralized: each developer has his own repository, and changes can be swapped back and forth between repositories arbitrarily. The version control system keeps track of dependencies between changes, and when it's time to make a release, a particular set of changes is approved for that release. The question of whether centralized or decentralized is better is one of the enduring holy wars of software development; try not to fall into the trap of arguing about it on your project lists. • Working copy • The working copy is the local copy of files from a repository, at a specific time or revision. All work done to the files in a repository is done on a working copy, hence the name. • A developer's private directory tree containing the project's source code files, and possibly its web pages or other documents.