SlideShare a Scribd company logo
1 of 43
Download to read offline
Object-Oriented
Software Engineering
Prof. Dr. Tom Mens
tom.mens@umons.ac.be
Software Engineering Lab
http://informatique.umons.ac.be/genlog
University of Mons
Belgium
Refactoring Case Study
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 2
PART I : LAN case study
Ø Explanation of several concrete refactorings
based on the evolution of a Local Area Network
simulation implemented in Java
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 3
workstation 1
fileserver 1
workstation 2printer 1
workstation 3
1. originate(p)
2. send(p)
3. accept(p)
4. send(p)
5. accept(p)
6. send(p)7. accept(p)
8.print(p)
Running example: LAN
simulation
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 4
UML class diagram
accept(p:Packet)
originate(p:Packet)
Workstation
contents
Packet
accept(p:Packet)
send(p:Packet)
Node
originator
name
accept(p:Packet)
print(p:Packet)
PrintServer
accept(p:Packet)
save(p:Packet)
FileServer
addressee
nextNode
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 5
Java source code
public class Node {
public String name;
public Node nextNode;
public void accept(Packet p) {
this.send(p); }
protected void send(Packet p) {
nextNode.accept(p); }
}
public class Packet {
public String contents;
public Node originator;
public Node addressee;
}
public class Printserver extends Node {
public void print(Packet p) {
System.out.println(p.contents);
}
public void accept(Packet p) {
if (p.addressee == this)
this.print(p);
else
super.accept(p);
}
}
public class Workstation extends Node {
public void originate(Packet p) {
p.originator = this;
this.send(p);
}
public void accept(Packet p) {
if (p.originator == this)
System.err.println("no destination");
else super.accept(p);
}
}
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 6
General Approach
Ø  Incrementally add new functionality in a two-phase
process:
Ø  Restructure the code to make it easier to add the functionality
Ø  Add the required functionality
Ø  Problem
Ø  How can we be sure that the existing behaviour is preserved
after the new functionality has been added?
Ø  Solution
Ø  Use regression tests (unit tests)
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 7
Revised Approach
Ø  Interleave the two-phase process with unit testing:
Ø  Write unit tests (regression tests) that test the original behaviour
Ø  Restructure the code to make it easier to add the functionality
Ø  Check if the unit tests still work (and modify them if not)
Ø  Add the required functionality
Ø  Check if the tests still work (and modify them if not)
Ø  Step 3 is necessary because refactorings can affect the
unit tests
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 8
Change requests
Ø CR1: Add logging functionality to the Node class
Ø CR2: Add two kinds of Printservers
Ø ASCIIPrintserver and PostscriptPrintserver
Ø CR3: Separate Documents from Printservers
Ø Allow ASCIIDocument to be printed on ASCIIPrinter
and PostscriptPrinter
Ø add new kind of PDFDocument that can be printed on
a PDFPrinter and PostscriptPrinter
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 9
Change Request 1
Ø  Add logging behaviour to basic LAN example.
Ø  In a simplistic increment, we can simply add the following code before
each send:
System.out.println( name + "sends to" + nextNode.name);
Ø  To make it more reusable, we perform a refactoring first:
Ø  encapsulate all variables that are used more than once
by introducing accessor methods
Ø  e.g. replace
public String name
by
private String name
public String getName()
public void setName(String n)
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 10
CR1: Add logging functionality
Ø As a second step, we add the logging functionality in
a separate log method
Ø e.g. replace
protected void send(Packet p) {
this.log();
this.getNextNode().accept(p);
}
protected void log() {
System.out.println(
this.getName() + "sends to" +
getNextNode().getName());
}
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 11
CR1: Refactoring
Encapsulate Field
Fowler 1999, page 206
There is a public field
Make it private and provide accessors
public class Node {
private String name;
private Node nextNode;
public String getName() {
return this.name; }
public void setName(String s) {
this.name = s; }
public Node getNextNode() {
return this.nextNode; }
public void setNextNode(Node n) {
this.nextNode = n; }
public void accept(Packet p) {
this.send(p); }
protected void send(Packet p) {
System.out.println(
this.getNextNode().accept(p); }
}
public class Node {
public String name;
public Node nextNode;
public void accept(Packet p) {
this.send(p); }
protected void send(Packet p) {
System.out.println(
nextNode.accept(p); }
}
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 12
CR1: Add log method
public class Node {
private String name;
private Node nextNode;
public String getName() {
return this.name; }
public void setName(String s) {
this.name = s; }
public Node getNextNode() {
return this.nextNode; }
public void setNextNode(Node n) {
this.nextNode = n; }
public void accept(Packet p) {
this.send(p); }
protected void log() {
System.out.println(
this.getName() + "sends to” +
getNextNode().getName()); }
protected void send(Packet p) {
this.log(p);
this.getNextNode().accept(p); }
}
public class Node {
private String name;
private Node nextNode;
public String getName() {
return this.name; }
public void setName(String s) {
this.name = s; }
public Node getNextNode() {
return this.nextNode; }
public void setNextNode(Node n) {
this.nextNode = n; }
public void accept(Packet p) {
this.send(p); }
protected void send(Packet p) {
this.getNextNode().accept(p); }
}
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 13
Change request 2
Ø Add behaviour for distinguishing between two
kinds of Printserver:
Ø An ASCIIPrinter that can only print
plain ASCII text files
Ø A PostscriptPrinter that can print
both Postscript and ASCII text
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 14
CR2: Initial situation
Node «class»
accept «operation»
Printserver «class»
accept «operation»
print «operation»
«inherit»
«invoke»
super
«invoke»
if (p.addressee == this)
this.print(p);
else
super.accept(p);
this.send(p);
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 15
• Add 2 subclasses ASCIIPrinter and
PSPrinter of Printserver
• Add 2 methods isASCII and isPS in
Printserver to check whether the contents
of the Packet to be printed is in the desired
format
• Push down methods print and accept
(see next slide)
CR2: Step 1
Node «class»
accept «operation»
Printserver «class»
accept «operation»
print «operation»
«inherit»
«invoke»
«invoke»
PSPrinter «class»
isASCII «operation»
isPS «operation»
ASCIIPrinter «class»
«inherit»«inherit»
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 16
CR2: Step 2 – Refactoring
Push Down Method
Fowler 1999, page 328
Behaviour on a superclass is relevant only for some of its subclasses
Move it to those subclasses
public class Printserver extends Node
{ ...
public void print(Packet p) {
System.out.println(
"Printing packet with contents" +
p.getContents()); }
public void accept(Packet p) {
if (p.getAddressee() == this)
this.print(p);
else super.accept(p); }
}
public class ASCIIPrinter extends
Printserver
{ ... }
public class PSPrinter extends
Printserver
{ ... }
public class Printserver extends Node
{ ... }
public class ASCIIPrinter extends Printserver
{ ...
public void print(Packet p) {
System.out.println(
"Printing packet with contents" +
p.getContents()); }
public void accept(Packet p) {
if (p.getAddressee() == this)
this.print(p);
else super.accept(p); }
}
public class PSPrinter extends Printserver
{ ...
public void print(Packet p) {
// same body as above }
public void accept(Packet p) {
// same body as above }
}
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 17
• Create abstract method print
in Printserver
• Add extra calls from accept in both
Printserver subclasses to
isASCII and isPS
• Change print functionality in both
Printserver subclasses
PSPrinter «class»ASCIIPrinter «class»
CR2: Step 3
Node «class»
accept «operation»
Printserver «class»
print «operation»
«inherit»«invoke»
accept «operation»
print «operation»
accept «operation»
print «operation»
«invoke»
«invoke»
«invoke»
«invoke»
«invoke»
«invoke»
isASCII «operation»
isPS «operation»
«inherit»«inherit»
if (p.getAddressee() == this)
if (this.isPS(p.getContents()))
this.print(p);
else super.accept(p);
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 18
CR2: Resulting situation
public class ASCIIPrinter extends Printserver
{ ...
public void print(Packet p) {
System.out.println(
"Printing packet with contents " +
p.getContents() +
" on ASCII printer " +
this.getName()); }
public void accept(Packet p) {
if (p.getAddressee() == this) {
if (this.isAscii(p.getContents()))
this.print(p);
}
else
super.accept(p); }
}
public class PSPrinter extends Printserver
{ ...
public void print(Packet p) {
System.out.println(
"Printing packet with contents " +
this.interpretString(p.getContents()) +
" on postscript printer " +
this.getName()); }
public void accept(Packet p) {
if (p.getAddressee() == this) {
if (this.isPostscript(p.getContents()))
this.print(p);
}
else
super.accept(p); }
}
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 19
Change request 3
Ø  Add a new kind of printer, PDFprinter, that can print
either PDF documents or (after conversion) PS
documents
Ø  Problem
Ø  different types of printers can process different types of
documents, but this is hard-coded in the printer implementation
Ø  E.g., an ASCII file can be printed on a AsciiPrinter or
PostscriptPrinter, a PS file can be printed on a PostscriptPrinter or
PDFPrinter
Ø  Solution
a)  Increase flexibility by decoupling the kinds of documents from
the kinds of printers
b)  Introduce Document class hierarchy
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 20
CR3a - Refactorings
Ø Refactor the commonalities in the behaviour of
the accept method in ASCIIPrinter and
PSPrinter
Ø Consolidate Conditional Expression
Ø Extract Method
Ø Pull Up Method
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 21
CR3a: Step 1 – Refactoring
Consolidate Conditional Expression
Fowler 1999, page 240
You have a sequence of conditional tests with the same result
Combine them into a single conditional expression and extract it
public class ASCIIPrinter extends Printserver
{ ...
public void accept(Packet p) {
if (p.getAddressee() == this) {
if (this.isASCII(p.getContents()))
this.print(p);
}
else
super.accept(p); }
}
public class ASCIIPrinter extends Printserver
{ ...
public void accept(Packet p) {
if ((p.getAddressee() == this) &&
(this.isASCII(p.getContents())))
this.print(p);
else
super.accept(p); }
}
and similarly for PSPrinter...
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 22
Use the Extract Method refactoring to
factor out the conditional expression into
a separate method isDestFor
(see also next slide)
PSPrinter «class»ASCIIPrinter «class»
CR3a: Step 2 – Refactoring
Extract Method
Node «class»
accept «operation»
Printserver «class»
accept «operation»
print «operation»
«inherit»
accept «operation»
print «operation»
accept «operation»
print «operation»
«invoke»
«invoke»
«invoke»
«invoke»
«invoke»
«invoke»
isASCII «operation»
isPS «operation»
«inherit»«inherit»
isDestFor «operation» isDestFor «operation»
if (this.isDestFor(p))
this.print(p);
else super.accept(p);
return
(p.getAddressee() == this) &&
(this.isASCII(p.getContents()));
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 23
CR3a: Step 2 – Refactoring
Extract Method
Fowler 1999, page 110
You have a code fragment that can be grouped together
Turn the fragment into a method whose name explains the purpose of the method
public class ASCIIPrinter extends Printserver
{ ...
public void accept(Packet p) {
if ((p.getAddressee() == this) &&
(this.isASCII(p.getContents())))
this.print(p);
else
super.accept(p); }
}
public class ASCIIPrinter extends Printserver
{ ...
public void accept(Packet p) {
if (this.isDestFor(p))
this.print(p);
else
super.accept(p); }
public boolean isDestFor(Packet p) {
return ((p.getAddressee() == this) &&
(this.isASCII(p.getContents()))); }
}
and similarly for PSPrinter...
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 24
PSPrinter «class»ASCIIPrinter «class»
CR3a: Step 3 – Refactoring
Pull Up Method
Node «class»
accept «operation»
Printserver «class»
accept «operation»
print «operation»
«inherit»«invoke»
print «operation» print «operation»
«invoke»
«invoke»
«invoke»
isASCII «operation»
isPS «operation»
«inherit»«inherit»
isDestFor «operation» isDestFor «operation»
isDestFor «operation»
«invoke»
• Use the Pull Up Method refactoring to
move the identical implementation of
accept in both subclasses to the
common parent Printserver
• Specify isDestFor as an abstract method
in PrintServer
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 25
CR3a: Step 3 – Refactoring
Pull Up Method
Fowler 1999, page 322
You have methods with identical results on subclasses
Move them to the superclass
public abstract class Printserver
{ ...
}
public class ASCIIPrinter extends Printserver
{ ...
public void accept(Packet p) {
if (this.isDestinationFor(p))
this.print(p);
else
super.accept(p); }
}
public class PSPrinter extends Printserver
{ ...
public void accept(Packet p) {
if (this.isDestinationFor(p))
this.print(p);
else
super.accept(p); }
}
public abstract class Printserver
{ ...
public void accept(Packet p) {
if (this.isDestinationFor(p))
this.print(p);
else
super.accept(p); }
abstract boolean isDestFor(Packet p);
}
public class ASCIIPrinter extends Printserver
{ ...
}
public class PSPrinter extends Printserver
{ ...
}
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 26
CR3a: Intermediate Result
Packet «class»
«invoke»
«inherit»«inherit»
String getContents() «op»
{ return this.contents }
void setContents(String c) «op»
{ this.contents = c }
Printserver «class»
boolean isASCII(String s) «op»
boolean isPS (String s) «op»
PSPrinter «class»
void print(Packet p) «op»
{ … p.getContents() … }
boolean isDestFor(Packet p) «op»
{ …this.isPS(p.getContents()… }
ASCIIPrinter «class»
void print(Packet p) «op»
{ … p.getContents() … }
boolean isDestFor(Packet p) «op»
{ …this.isASCII(p.getContents()… }
String contents «attribute»
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 27
CR3b
Add Document hierarchy
Ø Refactoring Replace data value with object to
introduce Document class
Ø Make entire Document hierarchy
Ø Implement methods in this hierarchy
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 28
CR3b: Step 1 – Refactoring
Replace data value with object
Packet «class»
«invoke»
«inherit»«inherit»
String getContents() «op»
{ return this.doc.contents }
void setContents(String c) «op»
{ this.doc.contents = c }
Printserver «class»
boolean isASCII(String s) «op»
boolean isPS (String s) «op»
PSPrinter «class»
void print(Packet p) «op»
{ … p.getContents() … }
boolean isDestFor(Packet p) «op»
{ …this.isPS(p.getContents()… }
ASCIIPrinter «class»
void print(Packet p) «op»
{ … p.getContents() … }
boolean isDestFor(Packet p) «op»
{ …this.isASCII(p.getContents()… }
Document «class»
String contents «attribute»Document doc «attribute»
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 29
CR3b: Step 1 – Refactoring
Replace data value with object
Fowler 1999, page 175
You have a data item that needs additional data or behaviour
Turn the data item into an object
public class Packet
{ ...
private String contents;
public Packet(String s, Node n) {
this.setContents(s);
... }
public String getContents() {
return this.contents; }
public void setContents(String s) {
this.contents = s; }
}
public class Packet
{ ...
private Document doc;
public Packet(String s, Node n) {
this.setContents(s);
... }
public String getContents() {
return this.doc.contents; }
public void setContents(String s) {
this.doc.contents = s; }
}
public class Document {
...
public String contents;
}
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 30
CR3b: Step 2 – Refactoring
Use double dispatch
Ø Printing a document depends not only on the
type of Printserver, but also on the type of
Document
Ø for each type of Document, define a different print
method (e.g., printASCII, printPS)
Ø each type of printer (e.g., ASCIIPrinter, PSPrinter)
provides its own specific implementation for (some of)
these methods
Ø Use double dispatch …
… if you have a dispatched interpretation between two
families of objects ([Beck 1997], page 55)
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 31
CR3b: Resulting situation
«invoke»
«inherit»«inherit»
Printserver «class»
void printASCII(ASCIIDocument d)
void printPS(PSDocument d)
PSPrintserver «class»
void printPS(PSDocument d)
ASCIIPrintserver «class»
void printASCII(ASCIIDocument d)
boolean isDestFor(Packet p) { …}
void accept(Packet p) «op»
{ if (this.isDestFor(p)) p.doc.printOn(this) …}
Document «class»
String contents «attribute»
abstract void printOn(Printserver p) «op»
ASCIIDocument «class»
void printOn(Printserver p) «op»
{ p.printASCII(this) }
«inherit»
PSDocument «class»
void printOn(Printserver p) «op»
{ p.printPS(this) }
void printASCII(PSDocument d)
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 32
PART I : LAN case study
END OF
PART I
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 33
Part II: Assignment
Ø  Implement change requests of the LAN examples using
the proposed two-phase process interleaved with unit
testing:
Ø  Write unit tests (regression tests) that test the original behaviour
Ø  Restructure the code to make it easier to add the functionality
Ø  Check if the unit tests still work (and modify them if not)
Ø  Add the required functionality
Ø  Check if the tests still work (and modify them if not)
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 34
Change Requests ctd.
Ø  CR4: Add file servers
Ø  When these special kinds of nodes accept a packet, they store
its contents as a file on disk.
Ø  CR5: Acknowledge receipt of packets
Ø  When a packet is accepted by the node to which it was
addressed, this node should send a message back to the
sender of the packet to acknowledge its receipt.
Ø  CR6: Provide routers
Ø  These are special kinds of nodes that link two LANs together.
Packets can be sent to nodes in the same LAN, or to nodes in
another LAN.
Ø  As many routers can be added as needed.
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 35
workstation 1
action: send
CR6: Router connecting 2 LANs
router 1
Tom’s PCprinter 1
workstation 3
originator
fileserver 1
workstation 5
printer 3printer 4
addressee
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 36
CR7: New kinds of packets
Ø  Add 3 new kinds of packets:
Ø  counting and collecting packets traverse the entire
network and process all nodes in the network
Ø  a counting packet counts all nodes of each type (workstations,
asciiprinters, psprinters, …) found in the network
Ø  a collecting packet collects the addresses of each type of node
(workstations, asciiprinters, psprinters, …) found in the network
Ø  broadcasting packets are processed by multiple nodes
in the network
Ø Up to now, when a packet reaches its addressee node, the packet
is handled and the transmission of the packet is terminated. With
broadcasting, a packet can be sent to more than one addressee
node in the network at the same time. For example, broadcasting
makes it possible to save the contents of the same packet on
different fileservers of the LAN, or to print the contents of a packet
on all printers in the network
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 37
Change Requests ctd.
Ø CR8: Add user interface for input
Ø CR9: Add visual execution (output)
Ø CR10: Allow for other kinds of network
structures
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 38
CR8: Add User Interface
Ø Add a user interface for dynamically creating/
modifying a LAN
Ø Creating new nodes
Ø Inserting/removing nodes from the LAN
Ø Changing the order of nodes in the LAN
Ø Creating new packets
Ø Executing the LAN by originating a given packet from
a given workstation
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 39
CR8: Add User Interface
Local Area Network Creator
Available nodes
!Workstations
- Tom’s PC
- Dirk’s Mac
!Fileservers
- fs2
!Printers
!ASCII
- Ascii Printer 2
!Postscript
- Laserwriter 2
- Laserwriter 3
Nodes in the LAN
- Serge’s PC
- workstation 2
-  Ascii Printer 1
-  Laserwriter 1
insert
remove
Add Remove Execute
Packets in the LAN
- p1
- p2
-  p3
-  p4
Add Remove
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 40
CR9: Add a visual execution
Ø Add a visual interface that simulates the
execution of the network
Ø It displays all nodes in the network and their
connections
Ø It shows how packets traverse the network
Ø It shows the actions performed on each node
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 41
workstation 1
action: send
CR9: Example of visual execution
router 1
Tom’s PCprinter 1
workstation 3
originator
fileserver 1
workstation 5
printer 3printer 4
addressee
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 42
CR10: New kinds of networks
Ø Allow for other kinds of networks than token ring
networks such as:
Ø Star network
Ø Bidirectional token ring network
March 2016 Tom Mens, Service de Génie Logiciel, UMONS 43
PART II : Assignment
END OF
PART II

More Related Content

What's hot

Psycopg2 postgres python DDL Operaytions (select , Insert , update, create ta...
Psycopg2 postgres python DDL Operaytions (select , Insert , update, create ta...Psycopg2 postgres python DDL Operaytions (select , Insert , update, create ta...
Psycopg2 postgres python DDL Operaytions (select , Insert , update, create ta...sachin kumar
 
Hpx runtime system
Hpx runtime systemHpx runtime system
Hpx runtime systemCOMAQA.BY
 
streamparse and pystorm: simple reliable parallel processing with storm
streamparse and pystorm: simple reliable parallel processing with stormstreamparse and pystorm: simple reliable parallel processing with storm
streamparse and pystorm: simple reliable parallel processing with stormDaniel Blanchard
 
Stackless Python 101
Stackless Python 101Stackless Python 101
Stackless Python 101guest162fd90
 
Dagger & rxjava & retrofit
Dagger & rxjava & retrofitDagger & rxjava & retrofit
Dagger & rxjava & retrofitTed Liang
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Chih-Hsuan Kuo
 
HPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычисленийHPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычисленийPlatonov Sergey
 
Concurrency in Go by Denys Goldiner.pdf
Concurrency in Go by Denys Goldiner.pdfConcurrency in Go by Denys Goldiner.pdf
Concurrency in Go by Denys Goldiner.pdfDenys Goldiner
 
Rust Synchronization Primitives
Rust Synchronization PrimitivesRust Synchronization Primitives
Rust Synchronization PrimitivesCorey Richardson
 
Concurrency: Rubies, plural
Concurrency: Rubies, pluralConcurrency: Rubies, plural
Concurrency: Rubies, pluralehuard
 
Concurrency: Rubies, Plural
Concurrency: Rubies, PluralConcurrency: Rubies, Plural
Concurrency: Rubies, PluralEleanor McHugh
 
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
Gor Nishanov,  C++ Coroutines – a negative overhead abstractionGor Nishanov,  C++ Coroutines – a negative overhead abstraction
Gor Nishanov, C++ Coroutines – a negative overhead abstractionSergey Platonov
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoChih-Hsuan Kuo
 
The Ring programming language version 1.6 book - Part 37 of 189
The Ring programming language version 1.6 book - Part 37 of 189The Ring programming language version 1.6 book - Part 37 of 189
The Ring programming language version 1.6 book - Part 37 of 189Mahmoud Samir Fayed
 

What's hot (20)

Psycopg2 postgres python DDL Operaytions (select , Insert , update, create ta...
Psycopg2 postgres python DDL Operaytions (select , Insert , update, create ta...Psycopg2 postgres python DDL Operaytions (select , Insert , update, create ta...
Psycopg2 postgres python DDL Operaytions (select , Insert , update, create ta...
 
Hpx runtime system
Hpx runtime systemHpx runtime system
Hpx runtime system
 
Computer Science Homework Help
Computer Science Homework HelpComputer Science Homework Help
Computer Science Homework Help
 
streamparse and pystorm: simple reliable parallel processing with storm
streamparse and pystorm: simple reliable parallel processing with stormstreamparse and pystorm: simple reliable parallel processing with storm
streamparse and pystorm: simple reliable parallel processing with storm
 
Stackless Python 101
Stackless Python 101Stackless Python 101
Stackless Python 101
 
Dagger & rxjava & retrofit
Dagger & rxjava & retrofitDagger & rxjava & retrofit
Dagger & rxjava & retrofit
 
Operating System Assignment Help
Operating System Assignment HelpOperating System Assignment Help
Operating System Assignment Help
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
 
Thread
ThreadThread
Thread
 
Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36Effective Modern C++ - Item 35 & 36
Effective Modern C++ - Item 35 & 36
 
HPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычисленийHPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычислений
 
Concurrency in Go by Denys Goldiner.pdf
Concurrency in Go by Denys Goldiner.pdfConcurrency in Go by Denys Goldiner.pdf
Concurrency in Go by Denys Goldiner.pdf
 
Rust Synchronization Primitives
Rust Synchronization PrimitivesRust Synchronization Primitives
Rust Synchronization Primitives
 
Csharp_Chap13
Csharp_Chap13Csharp_Chap13
Csharp_Chap13
 
Concurrency: Rubies, plural
Concurrency: Rubies, pluralConcurrency: Rubies, plural
Concurrency: Rubies, plural
 
Concurrency: Rubies, Plural
Concurrency: Rubies, PluralConcurrency: Rubies, Plural
Concurrency: Rubies, Plural
 
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
Gor Nishanov,  C++ Coroutines – a negative overhead abstractionGor Nishanov,  C++ Coroutines – a negative overhead abstraction
Gor Nishanov, C++ Coroutines – a negative overhead abstraction
 
Use C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in GeckoUse C++ to Manipulate mozSettings in Gecko
Use C++ to Manipulate mozSettings in Gecko
 
The Ring programming language version 1.6 book - Part 37 of 189
The Ring programming language version 1.6 book - Part 37 of 189The Ring programming language version 1.6 book - Part 37 of 189
The Ring programming language version 1.6 book - Part 37 of 189
 
Lecture1 r
Lecture1 rLecture1 r
Lecture1 r
 

Viewers also liked

Semiotica de-la-imagen-periodico
Semiotica de-la-imagen-periodicoSemiotica de-la-imagen-periodico
Semiotica de-la-imagen-periodicoSamara Flores
 
3 わがまちのプラチナ構想【北九州】pdf
3 わがまちのプラチナ構想【北九州】pdf3 わがまちのプラチナ構想【北九州】pdf
3 わがまちのプラチナ構想【北九州】pdfplatinumhandbook
 
Jacob Lenard Resume 1
Jacob Lenard Resume 1Jacob Lenard Resume 1
Jacob Lenard Resume 1Jacob Lenard
 
第3期わが街のプラチナ構想 鎌倉市
第3期わが街のプラチナ構想 鎌倉市第3期わが街のプラチナ構想 鎌倉市
第3期わが街のプラチナ構想 鎌倉市platinumhandbook
 
第4期わが街のプラチナ構想 秋田県
第4期わが街のプラチナ構想 秋田県第4期わが街のプラチナ構想 秋田県
第4期わが街のプラチナ構想 秋田県platinumhandbook
 
Virus y vacunas informaticas
Virus y vacunas       informaticasVirus y vacunas       informaticas
Virus y vacunas informaticasmartlaur
 
Mobile Attention Management Identifying and Harnessing Factors that Determine...
Mobile Attention Management Identifying and Harnessing Factors that Determine...Mobile Attention Management Identifying and Harnessing Factors that Determine...
Mobile Attention Management Identifying and Harnessing Factors that Determine...Veljko Pejovic
 
Analisis del-periodico-1
Analisis del-periodico-1Analisis del-periodico-1
Analisis del-periodico-1Samara Flores
 
第3期わが街のプラチナ構想 埼玉県
第3期わが街のプラチナ構想 埼玉県第3期わが街のプラチナ構想 埼玉県
第3期わが街のプラチナ構想 埼玉県platinumhandbook
 
Understanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesUnderstanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesJ S Jodha
 
Unit 4 hw 8 - pointslope, parallel & perp
Unit 4   hw 8 - pointslope, parallel & perpUnit 4   hw 8 - pointslope, parallel & perp
Unit 4 hw 8 - pointslope, parallel & perpLori Rapp
 

Viewers also liked (20)

Wagamachi01 01
Wagamachi01 01Wagamachi01 01
Wagamachi01 01
 
Semiotica de-la-imagen-periodico
Semiotica de-la-imagen-periodicoSemiotica de-la-imagen-periodico
Semiotica de-la-imagen-periodico
 
Modulo 2
Modulo 2Modulo 2
Modulo 2
 
3 わがまちのプラチナ構想【北九州】pdf
3 わがまちのプラチナ構想【北九州】pdf3 わがまちのプラチナ構想【北九州】pdf
3 わがまちのプラチナ構想【北九州】pdf
 
Jacob Lenard Resume 1
Jacob Lenard Resume 1Jacob Lenard Resume 1
Jacob Lenard Resume 1
 
第3期わが街のプラチナ構想 鎌倉市
第3期わが街のプラチナ構想 鎌倉市第3期わが街のプラチナ構想 鎌倉市
第3期わが街のプラチナ構想 鎌倉市
 
第4期わが街のプラチナ構想 秋田県
第4期わが街のプラチナ構想 秋田県第4期わが街のプラチナ構想 秋田県
第4期わが街のプラチナ構想 秋田県
 
Primera actividad
Primera actividadPrimera actividad
Primera actividad
 
Cordova 101
Cordova 101Cordova 101
Cordova 101
 
Virus y vacunas informaticas
Virus y vacunas       informaticasVirus y vacunas       informaticas
Virus y vacunas informaticas
 
Mobile Attention Management Identifying and Harnessing Factors that Determine...
Mobile Attention Management Identifying and Harnessing Factors that Determine...Mobile Attention Management Identifying and Harnessing Factors that Determine...
Mobile Attention Management Identifying and Harnessing Factors that Determine...
 
Analisis del-periodico-1
Analisis del-periodico-1Analisis del-periodico-1
Analisis del-periodico-1
 
Cs final
Cs finalCs final
Cs final
 
第3期わが街のプラチナ構想 埼玉県
第3期わが街のプラチナ構想 埼玉県第3期わが街のプラチナ構想 埼玉県
第3期わが街のプラチナ構想 埼玉県
 
Pasante de-moda
Pasante de-modaPasante de-moda
Pasante de-moda
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Analisis noticiero
Analisis noticieroAnalisis noticiero
Analisis noticiero
 
Understanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesUnderstanding NuGet implementation for Enterprises
Understanding NuGet implementation for Enterprises
 
Unit 4 hw 8 - pointslope, parallel & perp
Unit 4   hw 8 - pointslope, parallel & perpUnit 4   hw 8 - pointslope, parallel & perp
Unit 4 hw 8 - pointslope, parallel & perp
 
Cb
CbCb
Cb
 

Similar to Object-Oriented Software Engineering Refactoring Case Study

A Deep Dive into Structured Streaming in Apache Spark
A Deep Dive into Structured Streaming in Apache Spark A Deep Dive into Structured Streaming in Apache Spark
A Deep Dive into Structured Streaming in Apache Spark Anyscale
 
Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...
Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...
Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...confluent
 
What's new in Python 3.11
What's new in Python 3.11What's new in Python 3.11
What's new in Python 3.11Henry Schreiner
 
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das Databricks
 
Phil Bartie QGIS PLPython
Phil Bartie QGIS PLPythonPhil Bartie QGIS PLPython
Phil Bartie QGIS PLPythonRoss McDonald
 
CodeFest 2013. Rauschmayer A. — An overview of ECMAScript 6, the next version...
CodeFest 2013. Rauschmayer A. — An overview of ECMAScript 6, the next version...CodeFest 2013. Rauschmayer A. — An overview of ECMAScript 6, the next version...
CodeFest 2013. Rauschmayer A. — An overview of ECMAScript 6, the next version...CodeFest
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manualsameer farooq
 
ch06-file-processing.ppt
ch06-file-processing.pptch06-file-processing.ppt
ch06-file-processing.pptMahyuddin8
 
Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Ruslan Shevchenko
 
Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0Anyscale
 
(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_iNico Ludwig
 
Functional Reactive Programming without Black Magic (UIKonf 2015)
Functional Reactive Programming without Black Magic (UIKonf 2015)Functional Reactive Programming without Black Magic (UIKonf 2015)
Functional Reactive Programming without Black Magic (UIKonf 2015)Jens Ravens
 
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel write Python code, get Fortran ...
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel  write Python code, get Fortran ...SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel  write Python code, get Fortran ...
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel write Python code, get Fortran ...South Tyrol Free Software Conference
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packagesAjay Ohri
 
Jafka guide
Jafka guideJafka guide
Jafka guideAdy Liu
 
Introduction to Apache Flink
Introduction to Apache FlinkIntroduction to Apache Flink
Introduction to Apache Flinkmxmxm
 

Similar to Object-Oriented Software Engineering Refactoring Case Study (20)

A Deep Dive into Structured Streaming in Apache Spark
A Deep Dive into Structured Streaming in Apache Spark A Deep Dive into Structured Streaming in Apache Spark
A Deep Dive into Structured Streaming in Apache Spark
 
Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...
Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...
Kafka Summit NYC 2017 - Easy, Scalable, Fault-tolerant Stream Processing with...
 
What's new in Python 3.11
What's new in Python 3.11What's new in Python 3.11
What's new in Python 3.11
 
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das
Apache Spark 2.0: A Deep Dive Into Structured Streaming - by Tathagata Das
 
Phil Bartie QGIS PLPython
Phil Bartie QGIS PLPythonPhil Bartie QGIS PLPython
Phil Bartie QGIS PLPython
 
CodeFest 2013. Rauschmayer A. — An overview of ECMAScript 6, the next version...
CodeFest 2013. Rauschmayer A. — An overview of ECMAScript 6, the next version...CodeFest 2013. Rauschmayer A. — An overview of ECMAScript 6, the next version...
CodeFest 2013. Rauschmayer A. — An overview of ECMAScript 6, the next version...
 
Dsp lab manual 15 11-2016
Dsp lab manual 15 11-2016Dsp lab manual 15 11-2016
Dsp lab manual 15 11-2016
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
 
ch06-file-processing.ppt
ch06-file-processing.pptch06-file-processing.ppt
ch06-file-processing.ppt
 
Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version] Implementation of 'go-like' language constructions in scala [english version]
Implementation of 'go-like' language constructions in scala [english version]
 
Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0Continuous Application with Structured Streaming 2.0
Continuous Application with Structured Streaming 2.0
 
(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i(2) c sharp introduction_basics_part_i
(2) c sharp introduction_basics_part_i
 
Functional Reactive Programming without Black Magic (UIKonf 2015)
Functional Reactive Programming without Black Magic (UIKonf 2015)Functional Reactive Programming without Black Magic (UIKonf 2015)
Functional Reactive Programming without Black Magic (UIKonf 2015)
 
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel write Python code, get Fortran ...
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel  write Python code, get Fortran ...SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel  write Python code, get Fortran ...
SFSCON23 - Emily Bourne Yaman Güçlü - Pyccel write Python code, get Fortran ...
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packages
 
Modern frontend in react.js
Modern frontend in react.jsModern frontend in react.js
Modern frontend in react.js
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
Jafka guide
Jafka guideJafka guide
Jafka guide
 
Introduction to Apache Flink
Introduction to Apache FlinkIntroduction to Apache Flink
Introduction to Apache Flink
 

More from Tom Mens

How to be(come) a successful PhD student
How to be(come) a successful PhD studentHow to be(come) a successful PhD student
How to be(come) a successful PhD studentTom Mens
 
Recognising bot activity in collaborative software development
Recognising bot activity in collaborative software developmentRecognising bot activity in collaborative software development
Recognising bot activity in collaborative software developmentTom Mens
 
A Dataset of Bot and Human Activities in GitHub
A Dataset of Bot and Human Activities in GitHubA Dataset of Bot and Human Activities in GitHub
A Dataset of Bot and Human Activities in GitHubTom Mens
 
The (r)evolution of CI/CD on GitHub
 The (r)evolution of CI/CD on GitHub The (r)evolution of CI/CD on GitHub
The (r)evolution of CI/CD on GitHubTom Mens
 
Nurturing the Software Ecosystems of the Future
Nurturing the Software Ecosystems of the FutureNurturing the Software Ecosystems of the Future
Nurturing the Software Ecosystems of the FutureTom Mens
 
Comment programmer un robot en 30 minutes?
Comment programmer un robot en 30 minutes?Comment programmer un robot en 30 minutes?
Comment programmer un robot en 30 minutes?Tom Mens
 
On the rise and fall of CI services in GitHub
On the rise and fall of CI services in GitHubOn the rise and fall of CI services in GitHub
On the rise and fall of CI services in GitHubTom Mens
 
On backporting practices in package dependency networks
On backporting practices in package dependency networksOn backporting practices in package dependency networks
On backporting practices in package dependency networksTom Mens
 
Comparing semantic versioning practices in Cargo, npm, Packagist and Rubygems
Comparing semantic versioning practices in Cargo, npm, Packagist and RubygemsComparing semantic versioning practices in Cargo, npm, Packagist and Rubygems
Comparing semantic versioning practices in Cargo, npm, Packagist and RubygemsTom Mens
 
Lost in Zero Space
Lost in Zero SpaceLost in Zero Space
Lost in Zero SpaceTom Mens
 
Evaluating a bot detection model on git commit messages
Evaluating a bot detection model on git commit messagesEvaluating a bot detection model on git commit messages
Evaluating a bot detection model on git commit messagesTom Mens
 
Is my software ecosystem healthy? It depends!
Is my software ecosystem healthy? It depends!Is my software ecosystem healthy? It depends!
Is my software ecosystem healthy? It depends!Tom Mens
 
Bot or not? Detecting bots in GitHub pull request activity based on comment s...
Bot or not? Detecting bots in GitHub pull request activity based on comment s...Bot or not? Detecting bots in GitHub pull request activity based on comment s...
Bot or not? Detecting bots in GitHub pull request activity based on comment s...Tom Mens
 
On the fragility of open source software packaging ecosystems
On the fragility of open source software packaging ecosystemsOn the fragility of open source software packaging ecosystems
On the fragility of open source software packaging ecosystemsTom Mens
 
How magic is zero? An Empirical Analysis of Initial Development Releases in S...
How magic is zero? An Empirical Analysis of Initial Development Releases in S...How magic is zero? An Empirical Analysis of Initial Development Releases in S...
How magic is zero? An Empirical Analysis of Initial Development Releases in S...Tom Mens
 
Comparing dependency issues across software package distributions (FOSDEM 2020)
Comparing dependency issues across software package distributions (FOSDEM 2020)Comparing dependency issues across software package distributions (FOSDEM 2020)
Comparing dependency issues across software package distributions (FOSDEM 2020)Tom Mens
 
Measuring Technical Lag in Software Deployments (CHAOSScon 2020)
Measuring Technical Lag in Software Deployments (CHAOSScon 2020)Measuring Technical Lag in Software Deployments (CHAOSScon 2020)
Measuring Technical Lag in Software Deployments (CHAOSScon 2020)Tom Mens
 
SecoHealth 2019 Research Achievements
SecoHealth 2019 Research AchievementsSecoHealth 2019 Research Achievements
SecoHealth 2019 Research AchievementsTom Mens
 
SECO-Assist 2019 research seminar
SECO-Assist 2019 research seminarSECO-Assist 2019 research seminar
SECO-Assist 2019 research seminarTom Mens
 
Empirically Analysing the Socio-Technical Health of Software Package Managers
Empirically Analysing the Socio-Technical Health of Software Package ManagersEmpirically Analysing the Socio-Technical Health of Software Package Managers
Empirically Analysing the Socio-Technical Health of Software Package ManagersTom Mens
 

More from Tom Mens (20)

How to be(come) a successful PhD student
How to be(come) a successful PhD studentHow to be(come) a successful PhD student
How to be(come) a successful PhD student
 
Recognising bot activity in collaborative software development
Recognising bot activity in collaborative software developmentRecognising bot activity in collaborative software development
Recognising bot activity in collaborative software development
 
A Dataset of Bot and Human Activities in GitHub
A Dataset of Bot and Human Activities in GitHubA Dataset of Bot and Human Activities in GitHub
A Dataset of Bot and Human Activities in GitHub
 
The (r)evolution of CI/CD on GitHub
 The (r)evolution of CI/CD on GitHub The (r)evolution of CI/CD on GitHub
The (r)evolution of CI/CD on GitHub
 
Nurturing the Software Ecosystems of the Future
Nurturing the Software Ecosystems of the FutureNurturing the Software Ecosystems of the Future
Nurturing the Software Ecosystems of the Future
 
Comment programmer un robot en 30 minutes?
Comment programmer un robot en 30 minutes?Comment programmer un robot en 30 minutes?
Comment programmer un robot en 30 minutes?
 
On the rise and fall of CI services in GitHub
On the rise and fall of CI services in GitHubOn the rise and fall of CI services in GitHub
On the rise and fall of CI services in GitHub
 
On backporting practices in package dependency networks
On backporting practices in package dependency networksOn backporting practices in package dependency networks
On backporting practices in package dependency networks
 
Comparing semantic versioning practices in Cargo, npm, Packagist and Rubygems
Comparing semantic versioning practices in Cargo, npm, Packagist and RubygemsComparing semantic versioning practices in Cargo, npm, Packagist and Rubygems
Comparing semantic versioning practices in Cargo, npm, Packagist and Rubygems
 
Lost in Zero Space
Lost in Zero SpaceLost in Zero Space
Lost in Zero Space
 
Evaluating a bot detection model on git commit messages
Evaluating a bot detection model on git commit messagesEvaluating a bot detection model on git commit messages
Evaluating a bot detection model on git commit messages
 
Is my software ecosystem healthy? It depends!
Is my software ecosystem healthy? It depends!Is my software ecosystem healthy? It depends!
Is my software ecosystem healthy? It depends!
 
Bot or not? Detecting bots in GitHub pull request activity based on comment s...
Bot or not? Detecting bots in GitHub pull request activity based on comment s...Bot or not? Detecting bots in GitHub pull request activity based on comment s...
Bot or not? Detecting bots in GitHub pull request activity based on comment s...
 
On the fragility of open source software packaging ecosystems
On the fragility of open source software packaging ecosystemsOn the fragility of open source software packaging ecosystems
On the fragility of open source software packaging ecosystems
 
How magic is zero? An Empirical Analysis of Initial Development Releases in S...
How magic is zero? An Empirical Analysis of Initial Development Releases in S...How magic is zero? An Empirical Analysis of Initial Development Releases in S...
How magic is zero? An Empirical Analysis of Initial Development Releases in S...
 
Comparing dependency issues across software package distributions (FOSDEM 2020)
Comparing dependency issues across software package distributions (FOSDEM 2020)Comparing dependency issues across software package distributions (FOSDEM 2020)
Comparing dependency issues across software package distributions (FOSDEM 2020)
 
Measuring Technical Lag in Software Deployments (CHAOSScon 2020)
Measuring Technical Lag in Software Deployments (CHAOSScon 2020)Measuring Technical Lag in Software Deployments (CHAOSScon 2020)
Measuring Technical Lag in Software Deployments (CHAOSScon 2020)
 
SecoHealth 2019 Research Achievements
SecoHealth 2019 Research AchievementsSecoHealth 2019 Research Achievements
SecoHealth 2019 Research Achievements
 
SECO-Assist 2019 research seminar
SECO-Assist 2019 research seminarSECO-Assist 2019 research seminar
SECO-Assist 2019 research seminar
 
Empirically Analysing the Socio-Technical Health of Software Package Managers
Empirically Analysing the Socio-Technical Health of Software Package ManagersEmpirically Analysing the Socio-Technical Health of Software Package Managers
Empirically Analysing the Socio-Technical Health of Software Package Managers
 

Recently uploaded

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 

Recently uploaded (20)

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 

Object-Oriented Software Engineering Refactoring Case Study

  • 1. Object-Oriented Software Engineering Prof. Dr. Tom Mens tom.mens@umons.ac.be Software Engineering Lab http://informatique.umons.ac.be/genlog University of Mons Belgium Refactoring Case Study
  • 2. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 2 PART I : LAN case study Ø Explanation of several concrete refactorings based on the evolution of a Local Area Network simulation implemented in Java
  • 3. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 3 workstation 1 fileserver 1 workstation 2printer 1 workstation 3 1. originate(p) 2. send(p) 3. accept(p) 4. send(p) 5. accept(p) 6. send(p)7. accept(p) 8.print(p) Running example: LAN simulation
  • 4. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 4 UML class diagram accept(p:Packet) originate(p:Packet) Workstation contents Packet accept(p:Packet) send(p:Packet) Node originator name accept(p:Packet) print(p:Packet) PrintServer accept(p:Packet) save(p:Packet) FileServer addressee nextNode
  • 5. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 5 Java source code public class Node { public String name; public Node nextNode; public void accept(Packet p) { this.send(p); } protected void send(Packet p) { nextNode.accept(p); } } public class Packet { public String contents; public Node originator; public Node addressee; } public class Printserver extends Node { public void print(Packet p) { System.out.println(p.contents); } public void accept(Packet p) { if (p.addressee == this) this.print(p); else super.accept(p); } } public class Workstation extends Node { public void originate(Packet p) { p.originator = this; this.send(p); } public void accept(Packet p) { if (p.originator == this) System.err.println("no destination"); else super.accept(p); } }
  • 6. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 6 General Approach Ø  Incrementally add new functionality in a two-phase process: Ø  Restructure the code to make it easier to add the functionality Ø  Add the required functionality Ø  Problem Ø  How can we be sure that the existing behaviour is preserved after the new functionality has been added? Ø  Solution Ø  Use regression tests (unit tests)
  • 7. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 7 Revised Approach Ø  Interleave the two-phase process with unit testing: Ø  Write unit tests (regression tests) that test the original behaviour Ø  Restructure the code to make it easier to add the functionality Ø  Check if the unit tests still work (and modify them if not) Ø  Add the required functionality Ø  Check if the tests still work (and modify them if not) Ø  Step 3 is necessary because refactorings can affect the unit tests
  • 8. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 8 Change requests Ø CR1: Add logging functionality to the Node class Ø CR2: Add two kinds of Printservers Ø ASCIIPrintserver and PostscriptPrintserver Ø CR3: Separate Documents from Printservers Ø Allow ASCIIDocument to be printed on ASCIIPrinter and PostscriptPrinter Ø add new kind of PDFDocument that can be printed on a PDFPrinter and PostscriptPrinter
  • 9. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 9 Change Request 1 Ø  Add logging behaviour to basic LAN example. Ø  In a simplistic increment, we can simply add the following code before each send: System.out.println( name + "sends to" + nextNode.name); Ø  To make it more reusable, we perform a refactoring first: Ø  encapsulate all variables that are used more than once by introducing accessor methods Ø  e.g. replace public String name by private String name public String getName() public void setName(String n)
  • 10. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 10 CR1: Add logging functionality Ø As a second step, we add the logging functionality in a separate log method Ø e.g. replace protected void send(Packet p) { this.log(); this.getNextNode().accept(p); } protected void log() { System.out.println( this.getName() + "sends to" + getNextNode().getName()); }
  • 11. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 11 CR1: Refactoring Encapsulate Field Fowler 1999, page 206 There is a public field Make it private and provide accessors public class Node { private String name; private Node nextNode; public String getName() { return this.name; } public void setName(String s) { this.name = s; } public Node getNextNode() { return this.nextNode; } public void setNextNode(Node n) { this.nextNode = n; } public void accept(Packet p) { this.send(p); } protected void send(Packet p) { System.out.println( this.getNextNode().accept(p); } } public class Node { public String name; public Node nextNode; public void accept(Packet p) { this.send(p); } protected void send(Packet p) { System.out.println( nextNode.accept(p); } }
  • 12. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 12 CR1: Add log method public class Node { private String name; private Node nextNode; public String getName() { return this.name; } public void setName(String s) { this.name = s; } public Node getNextNode() { return this.nextNode; } public void setNextNode(Node n) { this.nextNode = n; } public void accept(Packet p) { this.send(p); } protected void log() { System.out.println( this.getName() + "sends to” + getNextNode().getName()); } protected void send(Packet p) { this.log(p); this.getNextNode().accept(p); } } public class Node { private String name; private Node nextNode; public String getName() { return this.name; } public void setName(String s) { this.name = s; } public Node getNextNode() { return this.nextNode; } public void setNextNode(Node n) { this.nextNode = n; } public void accept(Packet p) { this.send(p); } protected void send(Packet p) { this.getNextNode().accept(p); } }
  • 13. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 13 Change request 2 Ø Add behaviour for distinguishing between two kinds of Printserver: Ø An ASCIIPrinter that can only print plain ASCII text files Ø A PostscriptPrinter that can print both Postscript and ASCII text
  • 14. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 14 CR2: Initial situation Node «class» accept «operation» Printserver «class» accept «operation» print «operation» «inherit» «invoke» super «invoke» if (p.addressee == this) this.print(p); else super.accept(p); this.send(p);
  • 15. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 15 • Add 2 subclasses ASCIIPrinter and PSPrinter of Printserver • Add 2 methods isASCII and isPS in Printserver to check whether the contents of the Packet to be printed is in the desired format • Push down methods print and accept (see next slide) CR2: Step 1 Node «class» accept «operation» Printserver «class» accept «operation» print «operation» «inherit» «invoke» «invoke» PSPrinter «class» isASCII «operation» isPS «operation» ASCIIPrinter «class» «inherit»«inherit»
  • 16. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 16 CR2: Step 2 – Refactoring Push Down Method Fowler 1999, page 328 Behaviour on a superclass is relevant only for some of its subclasses Move it to those subclasses public class Printserver extends Node { ... public void print(Packet p) { System.out.println( "Printing packet with contents" + p.getContents()); } public void accept(Packet p) { if (p.getAddressee() == this) this.print(p); else super.accept(p); } } public class ASCIIPrinter extends Printserver { ... } public class PSPrinter extends Printserver { ... } public class Printserver extends Node { ... } public class ASCIIPrinter extends Printserver { ... public void print(Packet p) { System.out.println( "Printing packet with contents" + p.getContents()); } public void accept(Packet p) { if (p.getAddressee() == this) this.print(p); else super.accept(p); } } public class PSPrinter extends Printserver { ... public void print(Packet p) { // same body as above } public void accept(Packet p) { // same body as above } }
  • 17. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 17 • Create abstract method print in Printserver • Add extra calls from accept in both Printserver subclasses to isASCII and isPS • Change print functionality in both Printserver subclasses PSPrinter «class»ASCIIPrinter «class» CR2: Step 3 Node «class» accept «operation» Printserver «class» print «operation» «inherit»«invoke» accept «operation» print «operation» accept «operation» print «operation» «invoke» «invoke» «invoke» «invoke» «invoke» «invoke» isASCII «operation» isPS «operation» «inherit»«inherit» if (p.getAddressee() == this) if (this.isPS(p.getContents())) this.print(p); else super.accept(p);
  • 18. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 18 CR2: Resulting situation public class ASCIIPrinter extends Printserver { ... public void print(Packet p) { System.out.println( "Printing packet with contents " + p.getContents() + " on ASCII printer " + this.getName()); } public void accept(Packet p) { if (p.getAddressee() == this) { if (this.isAscii(p.getContents())) this.print(p); } else super.accept(p); } } public class PSPrinter extends Printserver { ... public void print(Packet p) { System.out.println( "Printing packet with contents " + this.interpretString(p.getContents()) + " on postscript printer " + this.getName()); } public void accept(Packet p) { if (p.getAddressee() == this) { if (this.isPostscript(p.getContents())) this.print(p); } else super.accept(p); } }
  • 19. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 19 Change request 3 Ø  Add a new kind of printer, PDFprinter, that can print either PDF documents or (after conversion) PS documents Ø  Problem Ø  different types of printers can process different types of documents, but this is hard-coded in the printer implementation Ø  E.g., an ASCII file can be printed on a AsciiPrinter or PostscriptPrinter, a PS file can be printed on a PostscriptPrinter or PDFPrinter Ø  Solution a)  Increase flexibility by decoupling the kinds of documents from the kinds of printers b)  Introduce Document class hierarchy
  • 20. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 20 CR3a - Refactorings Ø Refactor the commonalities in the behaviour of the accept method in ASCIIPrinter and PSPrinter Ø Consolidate Conditional Expression Ø Extract Method Ø Pull Up Method
  • 21. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 21 CR3a: Step 1 – Refactoring Consolidate Conditional Expression Fowler 1999, page 240 You have a sequence of conditional tests with the same result Combine them into a single conditional expression and extract it public class ASCIIPrinter extends Printserver { ... public void accept(Packet p) { if (p.getAddressee() == this) { if (this.isASCII(p.getContents())) this.print(p); } else super.accept(p); } } public class ASCIIPrinter extends Printserver { ... public void accept(Packet p) { if ((p.getAddressee() == this) && (this.isASCII(p.getContents()))) this.print(p); else super.accept(p); } } and similarly for PSPrinter...
  • 22. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 22 Use the Extract Method refactoring to factor out the conditional expression into a separate method isDestFor (see also next slide) PSPrinter «class»ASCIIPrinter «class» CR3a: Step 2 – Refactoring Extract Method Node «class» accept «operation» Printserver «class» accept «operation» print «operation» «inherit» accept «operation» print «operation» accept «operation» print «operation» «invoke» «invoke» «invoke» «invoke» «invoke» «invoke» isASCII «operation» isPS «operation» «inherit»«inherit» isDestFor «operation» isDestFor «operation» if (this.isDestFor(p)) this.print(p); else super.accept(p); return (p.getAddressee() == this) && (this.isASCII(p.getContents()));
  • 23. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 23 CR3a: Step 2 – Refactoring Extract Method Fowler 1999, page 110 You have a code fragment that can be grouped together Turn the fragment into a method whose name explains the purpose of the method public class ASCIIPrinter extends Printserver { ... public void accept(Packet p) { if ((p.getAddressee() == this) && (this.isASCII(p.getContents()))) this.print(p); else super.accept(p); } } public class ASCIIPrinter extends Printserver { ... public void accept(Packet p) { if (this.isDestFor(p)) this.print(p); else super.accept(p); } public boolean isDestFor(Packet p) { return ((p.getAddressee() == this) && (this.isASCII(p.getContents()))); } } and similarly for PSPrinter...
  • 24. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 24 PSPrinter «class»ASCIIPrinter «class» CR3a: Step 3 – Refactoring Pull Up Method Node «class» accept «operation» Printserver «class» accept «operation» print «operation» «inherit»«invoke» print «operation» print «operation» «invoke» «invoke» «invoke» isASCII «operation» isPS «operation» «inherit»«inherit» isDestFor «operation» isDestFor «operation» isDestFor «operation» «invoke» • Use the Pull Up Method refactoring to move the identical implementation of accept in both subclasses to the common parent Printserver • Specify isDestFor as an abstract method in PrintServer
  • 25. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 25 CR3a: Step 3 – Refactoring Pull Up Method Fowler 1999, page 322 You have methods with identical results on subclasses Move them to the superclass public abstract class Printserver { ... } public class ASCIIPrinter extends Printserver { ... public void accept(Packet p) { if (this.isDestinationFor(p)) this.print(p); else super.accept(p); } } public class PSPrinter extends Printserver { ... public void accept(Packet p) { if (this.isDestinationFor(p)) this.print(p); else super.accept(p); } } public abstract class Printserver { ... public void accept(Packet p) { if (this.isDestinationFor(p)) this.print(p); else super.accept(p); } abstract boolean isDestFor(Packet p); } public class ASCIIPrinter extends Printserver { ... } public class PSPrinter extends Printserver { ... }
  • 26. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 26 CR3a: Intermediate Result Packet «class» «invoke» «inherit»«inherit» String getContents() «op» { return this.contents } void setContents(String c) «op» { this.contents = c } Printserver «class» boolean isASCII(String s) «op» boolean isPS (String s) «op» PSPrinter «class» void print(Packet p) «op» { … p.getContents() … } boolean isDestFor(Packet p) «op» { …this.isPS(p.getContents()… } ASCIIPrinter «class» void print(Packet p) «op» { … p.getContents() … } boolean isDestFor(Packet p) «op» { …this.isASCII(p.getContents()… } String contents «attribute»
  • 27. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 27 CR3b Add Document hierarchy Ø Refactoring Replace data value with object to introduce Document class Ø Make entire Document hierarchy Ø Implement methods in this hierarchy
  • 28. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 28 CR3b: Step 1 – Refactoring Replace data value with object Packet «class» «invoke» «inherit»«inherit» String getContents() «op» { return this.doc.contents } void setContents(String c) «op» { this.doc.contents = c } Printserver «class» boolean isASCII(String s) «op» boolean isPS (String s) «op» PSPrinter «class» void print(Packet p) «op» { … p.getContents() … } boolean isDestFor(Packet p) «op» { …this.isPS(p.getContents()… } ASCIIPrinter «class» void print(Packet p) «op» { … p.getContents() … } boolean isDestFor(Packet p) «op» { …this.isASCII(p.getContents()… } Document «class» String contents «attribute»Document doc «attribute»
  • 29. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 29 CR3b: Step 1 – Refactoring Replace data value with object Fowler 1999, page 175 You have a data item that needs additional data or behaviour Turn the data item into an object public class Packet { ... private String contents; public Packet(String s, Node n) { this.setContents(s); ... } public String getContents() { return this.contents; } public void setContents(String s) { this.contents = s; } } public class Packet { ... private Document doc; public Packet(String s, Node n) { this.setContents(s); ... } public String getContents() { return this.doc.contents; } public void setContents(String s) { this.doc.contents = s; } } public class Document { ... public String contents; }
  • 30. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 30 CR3b: Step 2 – Refactoring Use double dispatch Ø Printing a document depends not only on the type of Printserver, but also on the type of Document Ø for each type of Document, define a different print method (e.g., printASCII, printPS) Ø each type of printer (e.g., ASCIIPrinter, PSPrinter) provides its own specific implementation for (some of) these methods Ø Use double dispatch … … if you have a dispatched interpretation between two families of objects ([Beck 1997], page 55)
  • 31. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 31 CR3b: Resulting situation «invoke» «inherit»«inherit» Printserver «class» void printASCII(ASCIIDocument d) void printPS(PSDocument d) PSPrintserver «class» void printPS(PSDocument d) ASCIIPrintserver «class» void printASCII(ASCIIDocument d) boolean isDestFor(Packet p) { …} void accept(Packet p) «op» { if (this.isDestFor(p)) p.doc.printOn(this) …} Document «class» String contents «attribute» abstract void printOn(Printserver p) «op» ASCIIDocument «class» void printOn(Printserver p) «op» { p.printASCII(this) } «inherit» PSDocument «class» void printOn(Printserver p) «op» { p.printPS(this) } void printASCII(PSDocument d)
  • 32. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 32 PART I : LAN case study END OF PART I
  • 33. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 33 Part II: Assignment Ø  Implement change requests of the LAN examples using the proposed two-phase process interleaved with unit testing: Ø  Write unit tests (regression tests) that test the original behaviour Ø  Restructure the code to make it easier to add the functionality Ø  Check if the unit tests still work (and modify them if not) Ø  Add the required functionality Ø  Check if the tests still work (and modify them if not)
  • 34. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 34 Change Requests ctd. Ø  CR4: Add file servers Ø  When these special kinds of nodes accept a packet, they store its contents as a file on disk. Ø  CR5: Acknowledge receipt of packets Ø  When a packet is accepted by the node to which it was addressed, this node should send a message back to the sender of the packet to acknowledge its receipt. Ø  CR6: Provide routers Ø  These are special kinds of nodes that link two LANs together. Packets can be sent to nodes in the same LAN, or to nodes in another LAN. Ø  As many routers can be added as needed.
  • 35. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 35 workstation 1 action: send CR6: Router connecting 2 LANs router 1 Tom’s PCprinter 1 workstation 3 originator fileserver 1 workstation 5 printer 3printer 4 addressee
  • 36. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 36 CR7: New kinds of packets Ø  Add 3 new kinds of packets: Ø  counting and collecting packets traverse the entire network and process all nodes in the network Ø  a counting packet counts all nodes of each type (workstations, asciiprinters, psprinters, …) found in the network Ø  a collecting packet collects the addresses of each type of node (workstations, asciiprinters, psprinters, …) found in the network Ø  broadcasting packets are processed by multiple nodes in the network Ø Up to now, when a packet reaches its addressee node, the packet is handled and the transmission of the packet is terminated. With broadcasting, a packet can be sent to more than one addressee node in the network at the same time. For example, broadcasting makes it possible to save the contents of the same packet on different fileservers of the LAN, or to print the contents of a packet on all printers in the network
  • 37. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 37 Change Requests ctd. Ø CR8: Add user interface for input Ø CR9: Add visual execution (output) Ø CR10: Allow for other kinds of network structures
  • 38. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 38 CR8: Add User Interface Ø Add a user interface for dynamically creating/ modifying a LAN Ø Creating new nodes Ø Inserting/removing nodes from the LAN Ø Changing the order of nodes in the LAN Ø Creating new packets Ø Executing the LAN by originating a given packet from a given workstation
  • 39. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 39 CR8: Add User Interface Local Area Network Creator Available nodes !Workstations - Tom’s PC - Dirk’s Mac !Fileservers - fs2 !Printers !ASCII - Ascii Printer 2 !Postscript - Laserwriter 2 - Laserwriter 3 Nodes in the LAN - Serge’s PC - workstation 2 -  Ascii Printer 1 -  Laserwriter 1 insert remove Add Remove Execute Packets in the LAN - p1 - p2 -  p3 -  p4 Add Remove
  • 40. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 40 CR9: Add a visual execution Ø Add a visual interface that simulates the execution of the network Ø It displays all nodes in the network and their connections Ø It shows how packets traverse the network Ø It shows the actions performed on each node
  • 41. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 41 workstation 1 action: send CR9: Example of visual execution router 1 Tom’s PCprinter 1 workstation 3 originator fileserver 1 workstation 5 printer 3printer 4 addressee
  • 42. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 42 CR10: New kinds of networks Ø Allow for other kinds of networks than token ring networks such as: Ø Star network Ø Bidirectional token ring network
  • 43. March 2016 Tom Mens, Service de Génie Logiciel, UMONS 43 PART II : Assignment END OF PART II