Refactoring Goldenseal (Mar 29)

Back in Summer 2014 we realized that Goldenseal needed a major overhaul. Apple stopped updating the Carbon and QuickTime frameworks that we used, so it was just a matter of time until it stopped working.  We searched for and tried out several different subcontractors to rewrite the GUI (graphic user interface).

Meanwhile, our staff finished one additional update to Goldenseal, but then started to refactor the existing code. The first thing was to remove old crud left over from 68K Macs. Then we converted 32-bit code to 64-bit, removed anything dependent on the doomed Carbon and QuickTime, replaced the NeoAccess database, and eliminated most of the old PowerPlant framework.

Last September we gave up on subcontractors, and started GUI programming in-house. For that we use the Cocoa and MFC frameworks for Mac & Windows, respectively. However, we probably still spend half our time refactoring the existing code.

Refactoring is a lot like remodeling an old house. Some things we tear out and replace. Some, we scrape off the crud and leave them. Our rule of thumb for refactoring was expressed very clearly this week in The Daily WTF: “Thinking is hard, and I’m not very good at it. Every block of code should be simple and obvious, because if it makes me think, I’ll probably screw it up and break something.”

This week we are replacing the PowerPlant array classes. The analogy for that is more like tearing out the main beams, because they are used everywhere. We wrote a replacement more than a year ago, and have used it in new code long enough that it’s well-tested.  Now it’s time to shift over entirely.

Refactoring is also a chance to make design changes. The maximum array length is currently a 32-bit number (4 billion max) but we probably will make it 64-bit (9 quintillion).  Nobody will ever need the extra space, but it may help us stay compatible with future CPUs.

Meanwhile, we’ve finished about half of of the Mac data entry interface. It now allows a main window and/or separate windows, and shows almost all of the fields.  The only hard things left are the tables, used in itemized estimates etc. One is starting to work, and we’re gaining on the others.  Best guess is a few more weeks until we release an ‘alpha’ version for folks to try out.

Dennis Kolva
Programming Director

How we program Goldenseal Pro (Mar 20)

In movies, programmers usually sit at a terminal and type pages of dense computer code, at breakneck speed.

In reality, programming new GUI code tends to go more like this:

  1. Try a few Google searches to see if someone has written a tutorial on how to make the new thing.  If not, search Stack Overflow for related questions.
  2.  If that is not enough, look through the list of Cocoa or MFC classes for anything already designed to do the new thing.  Search again for tutorials on how to use those.
  3. If desperate, check the indexes of a few reference books. Try more searches with slightly different words.  Or give up, and try a completely different approach.
  4. After getting a vague idea of how to proceed, search Google and GitHub for sample code.  Apple and Microsoft both have tons.
  5. If there are sample projects, run them and see if they do the job.  If so, step through the code in the debugger and try to understand it.
  6. If no samples, search.  Probably some smaller code samples, somewhere.
  7. Copy/paste the likeliest code into the actual project.  Tweak as necessary.  If totally desperate, write a few lines of brand new code. It rarely takes more than 5 or 6 lines to do the job. Often it’s just 1 or 2.
  8. Run it and see if it works.  If not, step through the code in the debugger and find where it breaks.
  9. Test it, tweak it, test some more, tweak some more.  This requires a small amount of typing, but most of the time is spent running the program, dozens or hundreds of times per day.
  10. In some cases, throw it all out and try a different approach. Repeat steps 1 to 9.

If it weren’t for debuggers, it would be nearly impossible to write complex software. “Debugger” sounds like something you can wave at bugs to kill them, but unfortunately it’s not that easy.  Instead, you set a “break point”, then run the program. When it gets to the break, you step through one line at a time, and see exactly what changes when.  Sometimes the problem is obvious, and sometimes it takes many trials.

Dennis Kolva
Programming Director

Goldenseal Pro Progress Report (Mar 11)

We are making gradual progress on the new Macintosh interface. Here’s a screen shot link showing what it looks like now:

There is an outline view on the left that replaces all the old pull-down menus. There’s a “book” to navigate through records, and tabs at the bottom to switch between what used to be separate windows.  We will still let you open multiple windows, but they will be optional.

When we first started the Pro update, the plan was to have subcontractors rewrite Carbon to Cocoa (Mac) and QuickTime to MFC (Windows), keeping the same appearance.   That way the contract specs were easy, since it just had to match what we already had.  The plan was to start redesign work after the conversion was finished.

Now that we’re doing the work in-house, it makes more sense to combine the redesign with the general code updating.  So far we have made many more changes than first expected, but it’s also looking much better than expected.

Cocoa is not easy to master, and it probably will take us at least another month before all the basics are working on the Mac version.  No insurmountable problems, but there are many details that each take a day or two to finish.  Fortunately, we only have to do this once.  It’s going to be a real pleasure when we can get back to writing plain old C++ business code.

Dennis Kolva
Programming Director
Turtle Creek Software

Breakdown Tables (Feb 28)

Last week we added top controls to the Mac version, so it looked sort of like a Windows ribbon. It didn’t take long to find that it was too cluttered, and not all that useful.  So the main window got one more redesign, and we are quite happy with the final product.  It’s possible we will remove ribbons from the Windows app also, but we’ll get the Mac interface further along before we go back and decide on the final Windows appearance.  It’s kind of a leap-frog process, jumping between platforms every few weeks.

There is still one big design issue left, which is the breakdown tables for itemizing smaller details in Estimates and other records. 

When we first wrote Goldenseal estimating/accounting software, none of the C++ libraries had good tables. We had to write that interface from scratch, and probably spent a programmer-year or two on it.  Tables have complicated code that has not aged well. Fortunately, both Cocoa and MFC have mature table classes.  We can get reliable appearance, scroll-wheel support, column sorting, and other pleasant features for much less work than the original.

The big design question is, where to put them?  Currently, Goldenseal switches between entirely different layouts when you click the Breakdown popup on the left side of the screen. There are at least two different types of tables that can sit below the other fields, plus a no-table view.

Many users have found that system confusing, so we probably will simplify to a single layout, with just one type of breakdown table. Cocoa has “drawers” that can open out to the right, and that seems like a great place to put the (optional) breakdowns.  It fits particularly well with the new single-window setup, and today’s wider screens.

Dennis Kolva
Programming Director


Goldenseal Pro Progress Report (Feb 22)

It only took a day or two to set up the main application window in Goldenseal for Windows.  Still many details to finish, but the basic appearance looks good.

The Mac version was a different story. We tried one approach and just couldn’t get it to work. So we started over with a different approach, and could not get that working, either.  

Out of sheer frustration, we downloaded about 50 sample Cocoa apps from Apple and elsewhere, hoping to find something similar that we could use as a working example.  Nothing was close, though we did find some useful samples that will help us when coding other parts of the project.

Yesterday we started over for a 3rd time, building things one small step at a time, and getting each bit to work before moving on to the next step.  That went more smoothly.  Maybe we finally found the right approach, or maybe we just made every possible mistake, and couldn’t help but do it right eventually!  Anyhow, Goldenseal for Mac now has a single window that lets you navigate through all parts of the program.  Still many details to finish, but the basic appearance looks very good.

It took almost two months to design the new interface, and then get it working similarly on both platforms.  A bit of a digression from our original plan, but it probably will end up being worth the extra time.

Dennis Kolva
Programming Director
Turtle Creek Software

Vanilla Programming (Feb 6)

Last week, we discovered a huge trove of Microsoft sample code.  It included the interface source code for most of their apps (Office, Internet Explorer, File Explorer, Outlook…). It also had about 100 sample apps, showing how different features work. We spent most of the week building and running their code, and learned a lot.

Among the samples was RibbonGadgets, with all possible types of controls on a ribbon. We spent a few days trying to merge it into our code, so we could start with a working sample, and then modify it to suit our needs.  Unfortunately, ribbon setup is complicated and very fragile, and we just could not merge it. We finally gave up, and are now building a ribbon from scratch. Slower, but we can test at each step and make sure it still works.

We are building Goldenseal Pro for Windows to be as “vanilla” as we can, using the same MFC classes that run Microsoft’s apps. That way, there is less risk of incompatibilities in the future, and more likelihood that our code will upgrade automatically in future versions of Windows. The goal is Volvo station wagon, not Ferrari.  Boxy but reliable.

On the Mac side, Cocoa has no built-in ribbon interface. It does have toolbars, but not the kind we need. Fortunately, the screen layout tools in Cocoa are much more flexible than in Windows, so we can still create a similar appearance on both platforms. Being “vanilla” is tougher on Mac because Apple changes it so often, but at least we’ll be current for a while.

Enough interface is working now, that we can tell it’s going to be nifty. The main window will have almost everything that is now in pull-down menus, but organized better. It will be much more understandable for beginners, and not too hard a switch for current users.

We’ll release an ‘alpha’ version after we finish the new ribbon interface. That way, you can check it out and give feedback. The first release will also let you import your existing data, so you can see if it converts properly to the new format. If not, we’ll have plenty of time to fix the bugs.

Dennis Kolva
Programming Director

Ribbons, Goldenseal & Screen Size (Jan 27)

We started out designing software for the small monitors of the 1980s (Mac Plus was 512 x 342, and VGA was 640 x 480). It was tough fitting everything onto such a small screen, and we spent a lot of time trying to save a pixel or two.

Goldenseal was first designed for 800 x 640 monitors, then we upped it to 1024 x 768.  One estimate alone could fill up that much space, so we had to ‘hide’ most of the navigation in the menu bar at the top.  Running a business requires a few hundred possible screens and actions, so we split them up into 9 or 10 menus, with divider bars and submenus to organize them a little. It worked, but was relatively unfriendly for beginners, and not the ideal way to navigate through your company info.

These days, 1920 x 1080 is common for desktop screens: equal to 2 million pixels, 11 Mac Plus screens, or almost 7 VGAs.  Even cheap laptops have a million pixels to work with. Goldenseal Pro can stretch out now. We can use that extra space to make it easier to use.

Most of the menu commands are moving to the outline view on the left (called a tree view in Windows). It makes them easier to find, and easier to organize. There will be a Favorites folder where you can put your most common tasks, ready to access with a single click.

Almost all of the other menu commands can also move. Some will be on-screen buttons, and some will reside in right-click menus.

We started work on a Windows toolbar, but soon discovered ribbons. They are basically a fatter toolbar that also replace the pull-down menus. Now standard in MS Office. They look perfect for Goldenseal Pro. Everything on the left side and/or top of our current screens can go there, plus the few remaining commands in the top menus.

The Mac does not have ribbons built into Cocoa, and Apple’s OS design does not seem to be headed that way.  That means it’s going to be a design challenge to get Goldenseal Pro to look similar on the two platforms, but also stay true to the individual spirits of Mac & Windows. We’ll be working on it gradually over the next month or 2, while we also tackle the nitty-gritty of getting smaller details to work.

Dennis Kolva
Programming Director

Goldenseal Pro- Bank Accounts Change (Jan 20)

Goldenseal currently has 7 different types of bank accounts: Cash, Checking, Credit Cards, Escrows, Investments, Loans and Savings.

Our current interface for entering bank transactions is not that great. With the new outline view we can improve it, by showing your bank accounts individually on the left, so it’s easier to view them. 

These days, there is not much distinction between those 7 account types. People write checks from credit card or loan accounts, and use debit cards from checking or savings. It really doesn’t matter accounting-wise how we classify them, so we are considering consolidating all bank accounts into a single class, plus “other investments” for miscellaneous assets. We can add a popup menu so it’s still posssible to classify bank accounts by cash/checking/loan etc in reports.

If we go with this change, the converter from Goldenseal to Goldenseal Pro can translate existing accounts automatically. The only complexity will be asking users where to put each Investment account (it might be a bank account for an IRA, and an “other investment” for gold bars, etc).

User comments appreciated.

Dennis Kolva
Programming Director

Goldenseal Pro Progress (Jan 19)

Goldenseal Pro for Windows now fetches screen layouts from resources, and draws fields on the screen. It was an exciting milestone to reach, because now we can actually see what we are doing, after we make programming changes. The same code is used to make reports, printed forms, and Custom Layouts screens, so it opens up most of the software features.

Handling resources is not easy on Windows. We had to import 338 layouts, then individually rename them, then go through a third time and renumber them. Unfortunately, there are 375 menu resources that need the same treatment. Maybe we can find a faster way to do it.

The Windows code is almost caught up with the Mac version, so we will be alternating between them, from here on out.

The MFC libraries we are using on Windows are totally designed for creating Microsoft products. Doing anything that looks different is much harder. So, it looks like we will have a tool bar at the top and a status bar on the bottom, pretty much like Excel or Word.

The Goldenseal Pro software now uses Unicode for most text.  Unicode includes characters from all languages, and also extra stuff like emojis (including the infamous U+1F4A9). Unfortunately, Windows uses UTF-16 (2 bytes per character) while the Mac uses UTF-8 (1 byte). One of many small, annoying differences between the platforms. 

There are still many details left to complete, before Goldenseal Pro can go live. But, we’ve gotten through the hardest parts. The work is growing more rewarding, with tangible results coming faster. It’s kind of how it feels when a winter construction project gets closed-in and waterproof.

Dennis Kolva
Programming Director


Windows & MFC (Jan 6)

We are making good progress on the Windows version. It was easy to get the new outline view working, since we could use a ‘wizard’ that set it up automatically. After a week of programming, the Windows version already opens files, converts old Goldenseal accounting files to Pro format, and shows the main window. It took more than a month to get to the same point using Cocoa on Macintosh.

We use something called MFC (Microsoft Foundation Classes) for the Window interface code. MFC has been around since 1992, and is still being improved (and used heavily).  MFC is entirely C++, so it’s easy to tie in with our code. In fact, we already use quite a bit of MFC already, in the current Goldenseal for Windows.

Writing good code in C++ takes skill and practice.  Writing apps for Windows and Mac also requires a great deal of patience, since it means working with libraries from massive, semi-monopoly corporations that don’t need to make life easier for their software developers. MFC’s maturity is great, but it also means that many parts still read like DOS from the early 90’s.  Hopefully, we won’t need to spend too much time looking at code such as LPCTSTR lpszItem, LPCTSTR szFilePath.

Dennis Kolva
Programming Director