Doorgaan naar hoofdcontent

Posts

Posts uit juni, 2018 tonen

And along comes a visitor

Every time I look at a visitor pattern, I wonder, why. What is the use of this thing? Especially, when I consider modularity, I just don't understand. Let's say I have different objects: Door Engine Wheel Blinker Trunk Chair (all of them are CarParts , of course) When there's a cross-cutting concern which needs to be handled, the discussion arises: do you modify all the objects (say, they need a getCustomerValue, getBuildValue, getProductionTime, getSupplier, getRequiredComponents , for example, since we're using these parts in a factory and we need those), or maybe do you want all Supplier code to be in the same spot (since else knowledge of all suppliers gets scattered around, and you'd want it in a single spot) For the last, the code would get pretty messy. it would look something like Suppliers.getSupplierOf(Carpart part) { if(part instanceOf Door) {   return "supplierOne"; } if( part instanceOf Engine) {    if(((...

xml modification

So I wanted to modify some xml. And yes, that might mean xslt. However, the modification wasn't nice... in Java, it was fine, but to do that in xslt... rather not. So, I ventured into the world of 'how do you call java from xslt'. Of course, you can. Of course, you need to use Saxon. Of course, then you need a PAYED version of Saxon ... Sigh. I guess I'll stick to flat xslt and a lot of work then. Just to remember how it *can* be done: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:imro="http://www.geonovum.nl/imro/2012/1.1" xmlns:gml="http://www.opengis.net/gml/3.2"  xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java" >     <xsl:output method="xml" encoding="utf-8" indent="yes"/>     <!-- Identity template : copy all text nodes, elements and attributes -->       <xsl:template match=...