Design note: start with code, then refactor
This note goes with the worked example in EK9 Standard Types and the single file section of Packaging in EK9. It explains the way of working EK9 is designed for, and why the language has so many constructs.
Start writing code
You can start with a 'grand plan' and fill in the blanks: see the big picture and put lots of structure in up front. Or you can start coding and see where it takes you. EK9 supports both.
I prefer the second. That may run counter to what you have been taught: sit for days designing and procrastinating, with UML and slide decks. Instead:
- Do the bits you know need doing, and come at the problem from different angles and points of view. Worry about how it all fits later.
- Write prototypes, pull bits from here and there, duplicate, then resolve the duplication. Write unit tests to exercise the code, sometimes before the code exists.
- Don't be afraid to delete code, and don't get emotionally attached to it: don't invest too much effort too early.
- When you see complexity or potential reuse, refactor: pull it apart, encapsulate, use abstractions. Move things about or delete them.
Then the solution drops into place, and you will have enjoyed getting there.
What it looks like
The standard types worked example was built this way. The first version was a single program. Bigger blocks of code were pulled out into functions, then broken into smaller functions: all functions and no classes. Breaking them down further made it simpler to pull some into classes as methods, many of them private. The next steps would be components, and text constructs for the output strings.
Why EK9 has so many constructs
There is a reason EK9 has so many constructs: use each one when it feels the time is right, and if the time is never right, don't use it. The freedom to relocate processing, from program to function to class to component, is why EK9 has evolved the way it has.
The package construct follows the same idea. It is staged: one file needs no package; a few files need a list of files; a project directory needs one line to include everything; publishing adds a version, a license and capabilities. Each stage is added only when the project needs it.
Development with EK9 is designed to be enjoyable and fluid.