![]() I’d then have to start delving further into InDesign’s object model, which is a bit of a mess. The most important thing is to write a test that ensures the bars are all the correct width. If I make it more customisable, I think it would be worth test-driving the layout changes. The error handling’s a bit rubbish as well. You can’t customise anything apart from the fonts, so if you standardly use a different barcode design you’d need to do manual work to each barcode. I haven’t written tests for the rendering code, but that would be a good next step. Every time I changed something, or refactored, rather than checking to see if the barcodes still came out correctly I could just run the tests and get instant feedback. Also in that file are a number of tests used to ensure that barcode_library.js was doing the right thing. I used some of the basics from that to construct a very basic testing framework, contained in barcode_test.js. I’ve been reading Test-Driven JavaScript Development – an excellent book. Take the example of a barcode scanner app in the image shown below, which captures the image of the barcode and converts it to the code linked to it. Then the rendering code takes the barcode from the GUI, uses the library to get the bar widths, and draws the barcode with these widths and the fonts selected by the user.īecause I wanted to make the plugin easy to use, I wrote a shell script to concatenate the relevant JavaScript files and remove the #import lines. ![]() The GUI code doesn’t contain any logic, it just lets the user enter the relevant details. barcode_library doesn’t know anything about InDesign, all it does is produce a data structure giving the relative bar widths. Really barcode_main.js should be split up into two files, one for the GUI and one for rendering the barcode.Įach part of the code does one thing. barcode_main.js (the GUI and code for rendering the barcode).barcode_test.js (test code for testing barcode_library.js).barcode_library.js (the actual barcode logic).If you don’t know how to install an InDesign script, see these instructions on InDesign Secrets. The script file is available to download here. It’s fairly simple – just put in your ISBN, and choose the font for the ISBN and for the numbers under the bars. InDesign barcode makerįirst off, this is a barcode maker for InDesign. It’s a demonstration of test-driven development for producing InDesign plugins. Loftware Spectrum enterprise software integrates SAP, Oracle and other enterprise applications to produce mission-critical barcode labels, documents, and RFID Smart tags across the supply chain. It’s an example of writing structured, modular code for an InDesign plugin. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |