Final Review Ryan Zack Kristiyan Jeffery Alok Topics
- Slides: 49
Final Review Ryan, Zack, Kristiyan, Jeffery, Alok
Topics 1. 2. 3. 4. 5. 6. 7. Git TDD & JUnit Makefile Unix Shell Scripting Ant & XML Java Logging API Profiling
Git
Git Things you should know ● What is git? ● What is distributed version control? o What is centralized version control? ● What is a push? ● What does a “staged file” mean? ● General git commands
Git ● ● ● ● git status o Gives the status of all of the modified, newly added or newly removed files in the local files git log o Prints a log of all the recent git commands git add o Stages a file to be committed git remove o Removes a tracking of a file git commit o Makes all the staged changes git push o Puts all of the changes to a remote repo git pull o Gets all the changes from a remote repo
Git Visualized
TDD & JUnit
Test Driven Development ● JUnit is a tool for Test Driven Development [TDD] ● In TDD, tests are written before the software itself. ● You must understand the system before writing tests for it! ● Regression testing -> change to code = build project + run tests
Unit Testing ● What is a unit? o Unit is a single method! You are testing individual methods (units) from the class they belong to! ● Why should you use Unit Testing? o increased productivity o goal driven-code o and more. . . ● Why you should not use it? o Does NOT test the full software o Consumes too much time o etc. .
And now JUnit itself! ● JUnit is a widely used framework for unit (remember what this is? ) testing of Java software! ● JUnit: o Define and execute tests and test suites § Test Suites has many tests! o Write and debug code o and more…
JUnit Terminology ● Test fixture sets up the data needed to run tests. ● Unit Test - A piece of code written by developer that executes a particular part of the code being tested. ● Test case - Tests the response of a single method to a particular set of inputs. ● Test suite - Collection of test cases. ● Test runner - Software that runs your tests. ● Integration test - how well classes work together. Not good in JUnit. http: //www. vogella. com/tutorials/JUnit/article. html <- Useful source! http: //ieng 6. ucsd. edu/~cs 15 u/lab 3/page 3. html <- More info there!
● Test in JUnit that returns without failing or throwing an exception is considered pass. ● Failure happens when JUnit assertion fails. ● Goal for perfect implementation is to pass all tests, and for imperfect is to fail at least one test.
Other Frameworks ● ● JUnit - JAVA cpp. Unit - C++ PHPUnit - PHP NUnit -. NET ● All have: 1. Test Runner 2. Test Cases 3. Test fixtures 4. Test suites 5. Test Execution
Makefiles
Makefiles Questions you should know the answer to about Makefiles ● What is the point of a Makefile? o Why don’t we just compile it again? o Why don’t we just use a shell script? ● What is the format of a Makefile? ● How do we define variables in Makefiles? ● How do we make in a subdirectory?
The Makefile Format The format is just something you should memorize. Dependencies can be files. If a dependency is more recent, than the target will be made. Format: target: dependencies action Basic Example: default: javac *. java clean: rm *. class new: clean, default
The Makefile Format Real Example: CXX DEFINES CXXFLAGS $(DEFINES) INCPATH = g++ = -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB = -pipe -std=c++11 -O 2 -Wall -W -D_REENTRANT -f. PIE = -I/software/common/qt-5. 0. 1/mkspecs/linux-g+ boggleutil. o: boggleutil. cpp boggleutil. h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o boggleutil. cpp
Declaring Variables For makefiles, we can define by simply creating a variable in all caps (by convention) and setting it equal to a string. When we use the variable, it will be replaced by the string we set it to. Basic Example: COMPILE SRC = javac = *. java $(COMPILE) $(SRC) Real Example: DEFINES CFLAGS = -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB = -pipe -O 2 -Wall -W -D_REENTRANT -f. PIE $(DEFINES)
Making in a directory To make in a subdirectory do: make -C directory/ target As an example there is: make -C lib/ new So in a makefile it may look like clean: make -C lib/ clean make -C bin/ clean rm *. class
Unix/Shell Scripting
Piping/Filtering ● A pipe is a way to send the output of one command to another; the output of the first becomes the input of the second o To make a pipe, put a vertical bar ‘|’ on the commandline between two commands ● Examples: o ls -l | grep Apr o ls | wc -l o man ksh | grep "history" | wc -l ● A filter is a program that takes input from another program and transforms it in some way
Shell Scripting ● Lines starting with # are comments, but the first line #! is not a comment; it indicates the location of the shell that will be run ● Quote characters o “ double quote: if a string is enclosed in “ “ the references to variables will be replaced with their values o ‘ single quote: taken literally o ` back quote: treated as command § echo “Date is: ” `date`
Shell Scripting (declarations) ● Array declarations: o y=(Hello hi hey) o To access declared variables, use $ and braces § echo ${y[0]} → Hello is printed ● Declarations must not include spaces around equals sign
Shell Syntax ● Instead of using braces {} to control logic flow and statement blocks, shell uses terminating words: o if, then/ fi for i in {1. . 10} o case / esac do o for, done if [ $[i % 2] = 1 ]; o while, done then echo $i “is odd” else echo $i “is even” fi done
Examples for (( c=1; c<=5; c++ )) do echo "Welcome $c times" done _____________ c=0 while [ $c -lt 10 ] do echo The counter is $c let c=c+1 done echo “Enter read fruit case $fruit apple) echo ; ; banana) echo ; ; *) echo ; ; esac a fruit: ” in “Apple” “Banana” “Something else”
http: //www. dreamsyssoft. com/unix-shell-scripting/ifelse-tutorial. php
Examples (more) ls | while read line do echo “Hello ${line}!” done ____________ filename=$1 while read line do echo “Hello ${line}!” done < “$filename” filename=$1 cat $filename | while read line do echo “Hello ${line}!” done
What you should know ● ● ● Know the difference between echo and cat Variable declarations How to call variables How strings “”, ``, ‘’ work in bash How to use simple constructs like if statements, for loops, etc Commands like cd, rm, mv, cp, etc Site to test: http: //www. compileonline. com/execute_bash_online. php
XML & Ant
XML ● Sibling of HTML ● <tag></tag> and <title></title> and <midterm></midterm> ● XML Data Components o Elements § Hierarchical structure with open-close tag pairs § Nesting, same names is allowed, order matters § <review mdate=” 2014 -06 -01”. . . > <presenter>Kristiyan Dzhamalov</presenter> </review> o Attributes § named values are not hierarchical, order does NOT matter § mdate=” 2014 -06 -01”
XML Example <review> <presenter name=“Kristiyan” > <topic>Ant</topic> <topic>XML</topic> <topic>JUnit</topic> </presenter> <presenter name=“Zack”> <topic>Makefile</topic> </presenter> … and more… </review>
Ant - Another Neat Tool ● ● ● Tool for automated software builds - Very useful in industry with Java dev. Similar to make Uses XML to describe the building process and its dependencies By default the XML file is named build. xml You can obtain the value of a variable using ${property_name} How to make a variable? o <property name=”public. dir” location=”public” />
Ant - Cont. ● Each Ant XML file contains: o 1 project and at least 1 target o Targets have multiple tasks ● Projects contain 3 attributes - name, default and basedir o <project name=”Mid. Rev 2” default=”jar” basedir=”. ”> o default means which target to compile if not specified ● Target contains a name and optionally depends and description ● There can be dependencies between targets ● Task represents an action that needs execution ● Read lecture slides and lab
Java Logging API Link to lecture slide
Java Logging API ● Why use it? o The Java Logging API provides a standardized process of logging statements (automatically recording diagnostic output from a program) o Better than using System. out. println() statements scattered throughout your code o You can leave all logging statements in your code and control which ones are printed out using “logging. properties” file
General Concepts ● Each log message has an associated log Level ● The Level class specifies the importance and urgency of a log message ● Seven standard log levels ranging from FINEST (the lowest priority) to SEVERE (the highest priority).
Severity Levels (Descending order) 1. 2. 3. 4. 5. SEVERE: Used for logging fatal runtime error events WARNING INFO CONFIG FINE: Usually at the level of object creation, catch clauses for exceptions that do not constitute errors, and so on. 6. FINER: Entering and exiting should be used for tracing method entry and exit; arguments and return values can be specified. 7. FINEST: This level of tracing can be used to track the state of instance variables in a class e. g. before a method call, inside a method or a loop and after a method call.
Tracing ● Tracing involves logging messages which report the state of the application at different stages of execution ● Useful for following the flow of your program
Loggers and Handlers ● Loggers are objects that allow the application to log without regard to where the output is sent/stored ● Handlers receive the log message from the logger and export it to a certain target. ● Examples of Handlers: o Console. Handler: Write the log message to console o File. Handler: Writes the log message to file
Profiling
Profiling - Why ? - What ? - How ?
What ? ● ● ● Memory CPU Usage HDD Usage (Swap files etc) Network Usage Battery In short, any resource that your application depends on
How ?
hprof
hprof heap=dump|sites|all This option helps in the analysis of memory usage. It tells HPROF to generate stack traces, from which you can see where memory was allocated. heap=dump option, you get a dump of all live objects in the heap=sites, you get a sorted list of sites with the most heavily allocated objects at the top. The default value all gives both types of output.
hprof
hprof
UNIX Time
Thank you ! Have a nice Summer !
- Half life 2 build 2187
- Uncontrollable spending ap gov
- Jeffrey schor
- Lot's wife jeffrey r holland
- Dr stephen jeffery
- Jeffery
- Jeffery klaehn
- Jeffery ha
- Al shawn jeffery
- Dr alok adholeya
- Zack coker
- Zack wolf
- Dr alok mohan
- Furness definition
- Alok vijayant
- Selfservicerecovery portal.se.com
- Zack weinberg cmu
- Cache do alok
- Alok
- The boy saw the man with the telescope
- Alok kumar jagadev
- Alok kumar jagadev
- Zack olson md
- Evidence and claim examples
- Perspectometer
- Zachary g. ives
- Alok kipo mena
- Alok gupta md
- World history spring final exam review answers
- World history final exam study guide
- Spanish 1 answer key
- Human body systems final exam
- Truss practice problems poe
- Ied final exam review
- World history semester 2 final review packet
- World history b semester exam review practice
- Principles of business final exam answer key
- Bm3final
- Environmental science a final exam
- World history final exam study guide
- Us history final exam semester 2
- Algebra 1 final review packet
- Geometry final review
- English 4 semester 2 exam
- Physics 20 final exam practice
- Financial accounting final exam multiple choice
- Statics final review
- The crucible final exam
- Physical science final exam study guide
- Mat 1033 final exam answers