Posted inExperience / Information Technology

Qt – Printing – Taxes – Pt. 3

report browser

Before I get too far with this post let me tell you the source which uses the lp command is now up on Sourceforge. It is in the xpnsqt_v3-o directory. Took a bit to get uploaded. Probably shouldn’t have tried during the window when most IT shops are performing system upgrades. Factories and offices may shut down Christmas to New Years, but IT departments tend to work overtime. That’s when you can roll out all updates while impacting the fewest number of people.

When one progresses to the level in their career where they legitimately are an application architect, not someone who just has the title, but someone who has the actual skills, most of the current trends in software development will morally and ethically offend you. Hacking on the fly keeps getting new names to justify it, currently called AGILE, but has had many names in the past. It’s all just a scam to justify hacking out software while looking six inches in front of your shoes.

Development of The Four Holy Documents, the mandate of software engineering, exists for multiple purposes. The oft overlooked purpose is training of developers so their skill level will rise to that of Software Architect. It re-enforces looking all the way down the road so the software you deliver has at least a snowball’s chance in Hell of being right. Let’s take a look at an example. You can find the source on woboq.

QTextEdit comment

Above is the comment for the QTextEdit::print() method. Read it carefully. The only thing used to determine if a document has been paginated is setting of the physical page size. This is the common mindset of developers who exist only in the PC world. Every “document” is just a continuous stream of text which can be broken anywhere. If you have been reading this series then you know this mindset is nowhere near true. Business reporting requirements mandate page and control headings be carried over to the next physical page when a break has to occur. In the ASCII world you paginate by inserting the Form Feed (0X0c) character. You don’t fill every sheet of paper to the edge. You also don’t fill it with blank lines as that is an inefficient use of storage as well as network bandwidth. (Another significant architect level concern, efficient use of resources.)

You will find another common thing done in PC only software is allowing the user to set the font to one of their choosing. While this is fine in a word processor where you might have a document which doesn’t need any hard page breaks, it is not fine in the business world. Speaking as an author who has written many books, there are rules to printed books just like there are rules to business reports. Hard page breaks are necessary when laying out a printed book because chapters must start on a facing page. Consumers of books will not long tolerate one which starts chapters on the back of a page. You’ve have been conditioned to expect this since your earliest school textbooks.

Allowing a user to set the font of a report browser where the physical page breaks are only identifiable via the page headings might seem like a dandy idea, until the user tries to print it and page headings start appearing a long way down a sheet they mentally expect to be a page. The only way to successfully do this is to completely regenerate the report every time a user chooses a new font. Remember what I said earlier about “efficient use of resources?” In an age where people spend countless resources watching funny cat videos online, Software Architects are a dying breed. That’s why you are starting to see such a decline in software quality. If you take issue with that then read up on MAC OS release which allowed users to log in as root without a password. Things like that don’t happen when there is an architect and The Four Holy Documents. That’s one of the first things you test.

While it is true that regenerating this particular report wouldn’t waste as many resources as a funny cat video, it is also true that doing so is an architectural catastrophe. Why? Division of labor. One module creates the report. Another module allows the user to browse and print the report. Allowing the browser to generate the report now means you don’t have a reusable browser. Take a look at the browser for this application.

browser header

 

browser cpp 1

browser cpp 2

It doesn’t care about the file or how it was created. In a shop writing a desktop application such a browser would be written once early on in the project and used in hundreds of places. If it has to have the ability to regenerate the report every time a new font is selected, it quickly becomes a hack. Every place it gets used has to do some tiny hack to it because each report will require a unique set of parameters. What you end up with is something that kinda-sorta works some of the time and a support nightmare.

Let us not forget the original Java annoyance before the introduction of Monospace. When using a proportional font it is almost impossible to attain decimal alignment for numeric columns. What you end up with is a bunch of numbers swimming down the page in a drunken column.

I’m as far as I need to go with this Open Source project. If time allows over the New Years break I will try to create an example which shows you just how horrible this code becomes trying to work with font selection, pagination, and printing.

Roland Hughes started his IT career in the early 1980s. He quickly became a consultant and president of Logikal Solutions, a software consulting firm specializing in OpenVMS application and C++/Qt touchscreen/embedded Linux development. Early in his career he became involved in what is now called cross platform development. Given the dearth of useful books on the subject he ventured into the world of professional author in 1995 writing the first of the "Zinc It!" book series for John Gordon Burke Publisher, Inc.

A decade later he released a massive (nearly 800 pages) tome "The Minimum You Need to Know to Be an OpenVMS Application Developer" which tried to encapsulate the essential skills gained over what was nearly a 20 year career at that point. From there "The Minimum You Need to Know" book series was born.

Three years later he wrote his first novel "Infinite Exposure" which got much notice from people involved in the banking and financial security worlds. Some of the attacks predicted in that book have since come to pass. While it was not originally intended to be a trilogy, it became the first book of "The Earth That Was" trilogy:
Infinite Exposure
Lesedi - The Greatest Lie Ever Told
John Smith - Last Known Survivor of the Microsoft Wars

When he is not consulting Roland Hughes posts about technology and sometimes politics on his blog. He also has regularly scheduled Sunday posts appearing on the Interesting Authors blog.