Coding Style

As I've mentioned before, I've written Solitaire online using an old fashioned coding style. This was partly as an experiment, and partly as I wasn't familiar enough with typescript to realise that it 'sort of' has classes and inheritance - my background being more of the C++ variety.

I'm using a more traditional object orientated approach elsewhere.

I know the reasons for not using globals. I know the reasons for a more structured approach. I know that the code on this site is a mess.

However, there is one part of it that has worked very very well, and that is using globals which are included and set in external files.

I'm not advocating doing this in general, but sometimes simple can be best.

I've now added maybe eighty games of solitaire, and now all I am having to do is to create a new javascript file, set a few bools and the job is done. More or less.

In hindsight, I've made the following observations which if you are writing generic Solitaire sites, might be useful.

1. I should have thought more about the problem domain. What can a card do? How can lists of cards be ordered? Where can cards be placed?

2. I've arrays tables accessed by indexes to contain lists of cards etc. I should have written proper accessor functions for these.

3. I took the non OOP approach too far.

4. Objects don't know how to draw themselves. This was a mistake.

5. I should have used a modular design for the card layout.

But these are insignificant due to my initial (and current) design which was flawed.

It is important to think of the Foundations, Tableau piles etc as individually defined lists. This allows you to control what each pile does and how it can be manipulated.