$30 off During Our Annual Pro Sale. View Details »

Refactoring Disasters – A Story how I failed

October 11, 2021

Refactoring Disasters – A Story how I failed

For my small Open Source project TP-CORE, you can find it on GitHub, I had the gorgeous Idea to replace the iText library for OpenPDF. After I made a plan how I could reach my goal I started all necessary activities. But in real life the things never that easy like we have originally in mind. I failed with my idea and in this talk I will let you know what happened exactly. I talk about my motivation why I wanted the replacements and how was my plan to success all activities. You will get to know how it was when I reached the point, I realized I will not make it. I give a brief explanation what I did that this short adventure did not affect the rest of the project.

Homepage : https://elmar-dott.com
AnchorFM : https://anchor.fm/elmar-dott
Twitter - https://twitter.com/ElmarDott
GitHub - https://github.com/ElmarDott
Lbry - https://lbry.tv/@elmar.dott:8
BitChute - https://www.bitchute.com/channel/3IyCzKdX8IpO/


October 11, 2021

More Decks by ElmarDott

Other Decks in Technology


  1. {j}d d 2021 Po l and on l i n

    e © 2021 ElmarDott Refactoring Disasters – A Story how I failed 0
  2. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Sp e a k e r El ma r Do t t (M. Schulz) studied at HS Merseburg, Germany, computer science and holds an engineers degree in software engineering. He tweets regularly about several technical topics. The main topics in his field of work are Build and Configuration Management, Software Architecture and Release Management. About more than 15 years he is working in different large Web Application projects all over the world. He is an independent consultant / trainer. To share his knowledge he gives talks on conferences, if he is not writing on a new article about software engineering. Mail: elmar.dott@gmail.com + Consultant + Writer + Speaker + Trainer +
  3. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Ag e nd a motivation preparing actions the moment you realize, d***e take a deep breath Witamy, herzlich willkommen, welcome, bienvenido, Добро пожаловатьm, كــــب الهـأ , 歡迎 , אבה ךורב , καλως ΗΡΘΑΤΕ, स्वागत हे, Fàilte, یدمـآشوخ , Üdvözöljük, Vítejte, Dobrodošli, ...
  4. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Wha t i s R e f a c t o r i ng? „Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.“ - Martin Fowler
  5. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Re a s on s • AGPL & proprietary commercial license of current iText 7 • LibrePDF/ OpenPDF is Mozilla Public License Version 2.0 • OpenPDF 5 is a fork of iText 5 Legacy notice! iText 5 is the previous major version of iText's leading PDF SDK. iText 5 has been EOL, and is no longer developed. Switch your project to iText 7, integrating the latest developments. https://kb.itextsupport.com/home/it5kb
  6. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Pr e p a r i ng s • create Branch for version 2.2 • master Branch for version 3.0 • adding a new Implemenation Class: OpenPdfRenderer • secure existing functionality
  7. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s IPdfRenderer renderer = new PdfRendererImpl(); VS. PdfRenderer renderer = new ITextRenderer(); PdfRenderer renderer = new OpenPdfRenderer(); Good Nam e s, Bad Nam e s
  8. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Ap p l i c a t i on Ar c h i t e c t u r e • Java 11 Library • Release 2.1.0 • Maven Build • published on MVN Central Service LAYER Presentation LAYER Business LAYER Application LAYER Domain LAYER Orchestration LAYER API Interfaces RESTful Services Domain Objects Managed Beans Access Java Server Faces Controller Model View DAO Implementation
  9. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s API Chang e s void renderDocumentFromHtml(String file, String htmlTemplate); void writeDocument(PdfReader pdf, String destination); PdfReader readDocument(File pdfDocument); PdfReader removePage(PdfReader pdf, int... pages); https://github.com/ElmarDott/TP-CORE/blob/master/src/main/java/org/europa/together/business/PdfRenderer.java Design Problem:
  10. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s U s e f u l D e s i g n Pa t t e rn Adaptor: also known as Wrapper, coupels an interface to another when they not compatible to each other. Facade: group multiple interfaces together, to a simplified one. Proxy: also an generalization of a complex interface. Can understood as complement to the facade that combines several interfaces into a single one.
  11. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Why m e? import com.lowagie.text.pdf.PdfReader; Import com.itextpdf.text.pdf.PdfReader;
  12. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Me t h od Ov e r l o ad i ng i n Ja v a void writeDocument(com.itextpdf.text.pdf.PdfReader pdf, String destination); void writeDocument(PdfReader pdf, String destination); @deprecated com.itextpdf.text.pdf.PdfReader readDocument(File pdfDocument); PdfReader loadDocument(File pdfDocument);
  13. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Ma ch i n e Ha l l @Override public void renderDocumentFromHtml(final String file, final String template) { try { // ... 88: XMLWorkerHelper worker = XMLWorkerHelper.getInstance(); 89: worker.parseXHtml(pdfWriter, document, new StringReader(html.toString())); document.close(); pdfWriter.close(); } }
  14. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Re s um e e „Never touch a runnig system!“ (N)OR „Never run a touched system!“
  15. © 2021 Jc on 2021 : Ro l i ng

    St on e s Re s ou r c e s [1] Marco Schulz, 2021, Continuous Integration mit Jenkins, Rheinwerk, ISBN: ISBN 978-3-8362-7834-8 https://www.rheinwerk-verlag.de/continuous-integration-mit- jenkins/ [2] https://www.refactoring.com [3] https://github.com/ElmarDott/TP-CORE [4] https://itextpdf.com/en [5] https://github.com/LibrePDF/OpenPDF [6] OpenPDF tutorial: https://www.netjstech.com/2021/02/html- to-pdf-java-flying-saucer-openpdf.html
  16. © 2021 {j j DD 2021 : R e f

    a c t o r i ng D i s a s t e r s Cr e d e n t i a l s --------------------------------------------------------- Homepage : https://elmar-dott.com GitHub : https://github.com/ElmarDott AnchorFM : https://anchor.fm/elmar-dott Twitter : https://twitter.com/ElmarDott Speaker Deck : https://speakerdeck.com/elmardott Lbry : https://lbry.tv/@elmar.dott:8 BitChute : https://www.bitchute.com/channel/3IyCzKdX8IpO/ --------------------------------------------------------- Danke / tank you / Gracias
  17. None