sofware development environment

SDE Nguyễn Tiến Đức – 11110033 Đặng Phúc Vinh – 11110159 Đặng Quang Hưng – 11110058 Nguyễn Thanh Tùng – 11110155 GVHD: ThS. Nguyễn Trần Thi Văn 1

Upload: cong-thanh-nguyen

Post on 21-Jan-2017




0 download


Page 1: Sofware development Environment


SDENguyễn Tiến Đức – 11110033

Đặng Phúc Vinh – 11110159Đặng Quang Hưng – 11110058

Nguyễn Thanh Tùng – 11110155 GVHD: ThS. Nguyễn Trần Thi Văn

Page 2: Sofware development Environment


Agenda• Eclipse• Subversive• Log4j• JUnit• Checkstyle

Page 3: Sofware development Environment



Presenter: Đặng Phúc Vinh

Page 4: Sofware development Environment


Eclipse• What is eclipse?• Architecture• Java BuildPath• Debugging a Program• Install plugins (DEMO)

Page 5: Sofware development Environment


What is Eclipse?

• Eclipse is an integrated development environment (IDE)

• Used to develop applications using the Java programming language and other programming languages

Page 6: Sofware development Environment


Eclipse versionVersion Name Date Platform Version

Austin 21 June 2004 3.0

Bravo 28 June 2005 3.1

Callisto 30 June 2006 3.2

Europa 29 June 2007 3.3

Ganymede 25 June 2008 3.4

Galileo 24 June 2009 3.5

Helios 23 June 2010 3.6

Page 7: Sofware development Environment


Eclipse versionVersion Name Date Platform Version

Indigo 22 June 2011 3.7

Juno 27 June 2012 3.8 and 4.2

Kepler 26 June 2013 4.3

Luna 25 June 2014 4.4

Mars 24 June 2015 (planned)


Page 8: Sofware development Environment


Eclipse Architecture?

Page 9: Sofware development Environment


Eclipse Architecture

• Eclipse provides the Rich Client Platform (RCP) for developing general purpose applications

• Equinox OSGi – a standard bundling framework• Core platform – boot Eclipse

Page 10: Sofware development Environment


Eclipse Architecture

• Standard Widget Toolkit (SWT)• JFace: viewer classes to bring

model view controller programming to SWT, file buffers, text handling, text editors.

• Eclipse Workbench: views, editors, perspectives, wizards.

Page 11: Sofware development Environment


Java Build Path

• Used to complie Java project with it dependent classes• Code in source folders• Jars and classes associated with the project• Classes and libraries used in the project

• Java build path can be modified

Page 12: Sofware development Environment


Java Build Path

Page 13: Sofware development Environment



• Breakpoint is a position in code that make program pause to allow programmer reading memory data during the interuption.

Page 14: Sofware development Environment



• Set Break point:

Page 15: Sofware development Environment



• Call stack:

Page 16: Sofware development Environment



• Variables view:

Page 17: Sofware development Environment



• Run menu:

Page 18: Sofware development Environment


DebuggingKey Description

F5 Executes the currently selected line and goes to the next line in your program. If the selected line is a method call the debugger steps into the associated code.

F6 F6 steps over the call, i.e. it executes a method without stepping into it in the debugger.

F7 F7 steps out to the caller of the currently executed method. This finishes the execution of the current method and returns to the caller of this method.

F8 F8 tells the Eclipse debugger to resume the execution of the program code until is reaches the next breakpoint or watchpoint.

Page 19: Sofware development Environment


Install plugin

• Help -> Marketplace -> Popular -> Subversive

Page 20: Sofware development Environment


Install plugin

Page 21: Sofware development Environment



Presenter: Đặng Phúc Vinh

Page 22: Sofware development Environment


Subversive• What is Subversive?• Version Control Terminologies• SVN Life Cycle• Demo

Page 23: Sofware development Environment


What is Subversive?

• A plugin in Eclipse that helps software developers to work together and also maintains complete history of their work.

• Allow developers to work simultaneously• Do not overwrite each other’s changes• Maintain history of every version of everything

Page 24: Sofware development Environment


Version Control Terminologies

• The Repository:• Central place to store all client work• Repository stores files and history• Accessed over a network• Client can store/retrieve their changes

to/from repository• Storing changes, a client makes available

these changes to other people• Retrieving changes; a client takes other

people changes as a working copy

Page 25: Sofware development Environment


Version Control Terminologies

• Trunk:• Is a directory using to store client code• Usually checked out by client to work


Page 26: Sofware development Environment


Version Control Terminologies

• Tags:• Is used to store named snapshots of the

project• Allows to give descriptive and memorable

names to specific version• Ex:

• FIX_ADD_METHOD_ERROR is more memorable than

• Repository UUID: 7ceef8cb-3799-40dd-a067-c216ec2e5247

• Revision: 13

Page 27: Sofware development Environment


Version Control Terminologies

• Branches:• Used to make development process to fork

off into two different directions• Ex:

• Release version 5.0• Create a branch so that development of

6.0 features can be kept separate from 5.0 bug-fixes

Page 28: Sofware development Environment


Version Control Terminologies

• Working copy:• Repository is shared by all the team• Client can’t modify it directly• Client checkout working copy• Working copy is private workplace• Client can do their work within isolated from

the rest of the team

Page 29: Sofware development Environment


Version Control Terminologies

• Commit changes:• Storing changes from private workplace to

central server• Other developer can retrieve these changes

by updating their working copy• Commit is atomic operation

Page 30: Sofware development Environment


SVN Life Cycle

• Create repository: create a new repository• Checkout: create a working copy from the

repository• Update: update working copy• Perform changes: edit, remove…• Review changes: review your changes before

commit• Fix mistakes: undo modifications that have

been made to the working copy• Resolve conflicts:• Commit changes:

Page 31: Sofware development Environment




Page 32: Sofware development Environment



Presenter: Đặng Quang Hưng

Page 33: Sofware development Environment


1. Introduction

• Almost every large application includes its own logging or tracing API.

• In conformance with this rule, the E.U. SEMPER project decided to write its own tracing API. This was in early 1996. After countless enhancements, several incarnations and much work that API has evolved to become log4j, a popular logging package for Java.

Page 34: Sofware development Environment


2. Pros and Cons

• Inserting log statements into code is a low-tech method for debugging it. Debuggers are not always available or applicable. This is usually the case for multithreaded

applications and distributed applications at large.• Logging does have its drawbacks.

It can slow down an application. If too verbose, it can cause scrolling blindness.

Page 35: Sofware development Environment


3. Main component

Page 36: Sofware development Environment


4. Logger hierarchy

• The hierarchy is maintained in the relationship between LoggerConfig objects.

• A LoggerConfig is said to be ancestor of another LoggerConfig if its name followed by a dot is a prefix of the descendant logger name.

• Ex: the LoggerConfig named “” is a parent of the LoggerConfig named “”.

Page 37: Sofware development Environment


4. Logger hierarchy (cont)

• The root LoggerConfig resides at the top of the LoggerConfig hierarchy.

• Logger logger = LogManager.getLogger(LogManager.ROOT_LOGGER_NAME);

• Logger logger = LogManager.getRootLogger();

Page 38: Sofware development Environment


5. LoggerContext

• The LoggerContext acts as the anchor point for the Logging system.

• It is possible to have multiple active LoggerContexts in an application depending on the circumstances.

Page 39: Sofware development Environment


6. Configuration

Every LoggerContext has an active Configuration. The Configuration contains all the Appenders,

context-wide Filters, LoggerConfigs. And contains the reference to the

StrSubstitutor.• During reconfiguration two Configuration objects

will exist. Once all Loggers have been redirected to the new Configuration, the old Configuration will be stopped and discarded.

Page 40: Sofware development Environment


7. Logger

• Loggers are created by calling LogManager.getLogger()

• The Logger itself performs no direct actions. It simply has a name and is associated with a

LoggerConfig. It extends AbstractLogger and implements the

required methods.

Page 41: Sofware development Environment


7. Logger (cont) – Retrieve Loggers

• Calling the LogManager.getLogger() method with the same name will always return a reference to the exact same Logger object.

• Logger x = LogManager.getLogger("wombat");• Logger y = LogManager.getLogger("wombat"); x and y refer to exactly the same Logger object.

Page 42: Sofware development Environment


8. LoggerConfig

• LoggerConfig objects are created when Loggers are declared in the logging configuration. The LoggerConfig contains a set of Filters that

must allow the LogEvent to pass before it will be passed to any Appenders.

It contains references to the set of Appenders that should be used to process the event.

Page 43: Sofware development Environment


8. LoggerConfig - Log levels

• LoggerConfigs will be assigned a Log Level.• The set of built-in levels includes TRACE, DEBUG,


Page 44: Sofware development Environment


9. Appenders

• Appenders are responsible for delivering LogEvents to their destination.

• Appenders always have a name so that they can be referenced from Loggers.

Page 45: Sofware development Environment


9.1 ConsoleAppender

• ConsoleAppender writes its output to either System.err or System.out with System.err being the default target.

<Appenders> <Console name="STDOUT" target="SYSTEM_OUT"> <PatternLayout pattern="%m%n"/> </Console></Appenders>

Page 46: Sofware development Environment


9.2 FileAppender

• The FileAppender is an OutputStreamAppender that writes to the File named in the fileName parameter.

<Appenders> <File name="MyFile" fileName="logs/app.log"> <PatternLayout> <Pattern>%d %p %c{1.} [%t] %m%n</Pattern> </PatternLayout> </File></Appenders>

Page 47: Sofware development Environment


9.3 AsyncAppender

• The AsyncAppender accepts references to other Appenders and causes LogEvents to be written to them on a separate Thread.

<File name="MyFile" fileName="logs/app.log"> <PatternLayout> <Pattern>%d %p %c{1.} [%t] %m%n</Pattern> </PatternLayout></File><Async name="Async"> <AppenderRef ref="MyFile"/></Async>

Page 48: Sofware development Environment


10. Layout

• An Appender uses a Layout to format a LogEvent into a form that meets the needs of whatever will be consuming the log event.

Page 49: Sofware development Environment


10.1 JSONLayout

• Appends a series of JSON events as strings serialized as bytes.

Parameter Type Description

compact boolean If true, the appender does not use end-of-lines and indentation. Defaults to false.

complete boolean If true, the appender includes the JSON header and footer. Defaults to false.

locationInfo boolean If true, the appender includes the location information in the generated JSON. Defaults to false.

Page 50: Sofware development Environment


10.2 HTMLLayout

• The HTMLLayout generates an HTML page and adds each LogEvent to a row in a table.

Parameter Type Description

contentType String The value to assign to the Content-Type header. The default is "text/html"

locationInfo boolean If true, the filename and line number will be included in the HTML output. The default value is false

title String A String that will appear as the HTML title

Page 51: Sofware development Environment


10.3 PatternLayout

• A flexible layout configurable with pattern string.• The goal of this class is to format a LogEvent and

return the results.• The format of the result depends on the

conversion pattern.

Page 52: Sofware development Environment


10.3 PatternLayout (cont)

Pattern Description


Outputs the name of the logger that published the logging event.


Outputs the fully qualified class name of the caller issuing the logging request


Outputs the date of the logging event

m, msgmessage

Outputs the application supplied message associated with the logging event

n Outputs the platform dependent line separator character or characters.

Page 53: Sofware development Environment


11.1 TimeFilter

• The time filter can be used to restrict filter to only a certain portion of the day.

Parameter Type Description

start String A time in HH:mm:ss format

end String A time in HH:mm:ss format

onMatch String Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL.

onMismatch String Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is DENY.

Page 54: Sofware development Environment


11. Filters

• Filters allow Log Events to be evaluated to determine if or how they should be published.

• A Filter will be called on one of its filter methods and will return a Result, which is an Enum that has one of 3 values - ACCEPT, DENY or NEUTRAL.

Page 55: Sofware development Environment


11.2 RegexFilter

• The RegexFilter allows the formatted or unformatted message to be compared against a regular expression.

Parameter Type Description

regex String The regular expression

onMatch String Action to take when the filter matches. May be ACCEPT, DENY or NEUTRAL. The default value is NEUTRAL

onMissmatch String Action to take when the filter does not match. May be ACCEPT, DENY or NEUTRAL. The default value is DENY.

Page 56: Sofware development Environment


Unit testing with JUnit

Presenter: Nguyễn Tiến Đức

Page 57: Sofware development Environment

Software Development Cycle

Page 58: Sofware development Environment

Test phases

Page 59: Sofware development Environment


Why writes test?

Toyota’s Prius example

A defect found in the production phase is about 50 times more expensive than if it is found during prototyping. If the defect is found after production it will be about 1,000 – 10,000 times more expensive

Page 60: Sofware development Environment


What is Unit testing?

• A Unit Test is a procedure to validate a single Functionality of an application.

One Functionality One Unit Test

• Unit testing is very essential to every software company to give a quality product to their customers.

Page 61: Sofware development Environment


Junit – an introduction

• JUnit is a unit testing framework for the java programming language.

• It comes from the family of unit testing frameworks, collectively called xUnit, where ‘x’ stands for the programming language, e.g. CPPUnit, JSUnit, PHPUnit, PyUnit, RUnit etc.

Kent Beck and Erich Gamma originally wrote this framework for ‘smalltalk’, and it was called SUnit. Later it rippled into other languages.

Page 62: Sofware development Environment


Why choose Junit?

Of course there are many tools like JUnit, but none like it.

• JUnit is simple and easy to use. • JUnit has the widest IDE support, Eclipse, NetBeans,

IntelliJ IDEA...• JUnit is recognized by popular build tools like, ant,

maven etc.• And… it’s free.

Page 63: Sofware development Environment


Design of JUnit

junit.framework.TestCase is the abstract command class which you subclass into your Test Classes.

junit.framework.TestSuite is a composite of other tests, either TestCase or TestSuite.

Page 64: Sofware development Environment


Design of JUnit

Page 65: Sofware development Environment


What Junit does

• Junit runs a suite of tests and reports results• For each test in the test suite:

– Junit call setup(): create any object you may need for testing

– Junit call one test method: testing…– Junit call teardown(): remove any objects

you created if necesary

Page 66: Sofware development Environment


Write a test case

• Define a subclass of junit.framework.TestCasepublic class CalculatorTest extends TestCase {}

• Define one or more testXXX() methods that can perform the tests and assert expected results. public void testAddition () {

assertEquals (1, 1);}

Page 67: Sofware development Environment


Asserting expectations

• assertEquals (expected, actual) • assertEquals (message, expected, actual) • assertEquals (expected, actual, delta)• assertEquals (message, expected, actual, delta) • assertFalse ((message)condition) • Assert(Not)Null (object) • Assert(Not)Null (message, object) • Assert(Not)Same (expected, actual) • Assert(Not)Same (message, expected, actual) • assertTrue ((message), condition)

Page 68: Sofware development Environment


Write a test case

• Override setUp() method to perform initialization. It will be executed before each of the tests gets executed.

@Overrideprotected void setUp () {calc = new Calculator();


• Override tearDown() method to clean up. It will be executed after each of the tests gets executed.

@Overrideprotected void tearDown () {calc = null;


Page 69: Sofware development Environment


Write a test suite

• Test suilt means bundle a few unit test cases and run it togetherWrite a class with a static method suite() that creates a junit.framework.TestSuite containing all the Tests.

public class AllTests {public static Test suite() {TestSuite suite = new TestSuite();suite.addTestSuite(<test-1>.class);suite.addTestSuite(<test-2>.class);return suite;}


Page 70: Sofware development Environment


Junit 4.xFeature Junit 3.x Junit 4.x

Test case testXXX() method @Test

Run before each test method Override setUp() @Before

Run after each test method Override tearDown() @After

Run before the first test method in the current class is invoked

None @BeforeClass

Run after the all the test in current class have been run

None @AfterClass

Ignore test Comment or remove code


Expected exception Catch exception @Test (expected = Exception.class)

Timeout None @Test(timeout = 100)

Page 71: Sofware development Environment


Java code review with CheckStyle

Presenter: Nguyễn Thanh Tùng

Page 72: Sofware development Environment



1. Why need coding standard ?2. What is CheckStyle ?3. How to CheckStyle works ?4. Use CheckStyle with eclipse5. Demo

Page 73: Sofware development Environment


Why need coding standard ?

• Make the code easier to understand• Easy to maintain and debug• Large companies often have their own styles to the projects

• Ex: Google style Java code :

Page 74: Sofware development Environment


What is CheckStyle ?

• An open source development tool to help programmers write Java code that adheres to a coding standard.

• It automates the process of checking Java code to verify code following standard or not.

• Official web site :

• Current version 6.1

Page 75: Sofware development Environment


How to CheckStyle works ?

• CheckStyle is add-ins component to IDE/Build tool• Coding standard is user pre-defined, and embedded

in each XML file• CheckStyle will depend on XML file to parse code,

then generate checking result to

Page 76: Sofware development Environment


How to CheckStyle works ?

• CheckStyle supports add-ins for various Java IDE and Build tools, such as :– Eclipse– NetBeans– IntelliJ– Maven– Ant– …

Page 77: Sofware development Environment


Use CheckStyle with eclipse

Setup add-in to Eclipse:• Make Eclipse to automatically download and

update the library– Use Eclipse Marketplace

• Manually download library from the official site, and copy to Eclipse plug-ins folder

Page 78: Sofware development Environment


Use CheckStyle with eclipse : Result

Page 79: Sofware development Environment


Use CheckStyle with eclipse : Report

Page 80: Sofware development Environment



Page 81: Sofware development Environment


Thanks for watching