1.2k views
in GUI Development by
Does the programming language Chora provide a constructor? When should it be used?

2 Answers

0 votes
by

Even if the Init() method is a normal method, it has some special rules, since it is a constructor method.

If any class has defined a method called “Init”, Embedded Wizard will call this method automatically after the initialization of all members. The Init() method must be defined with return type void and without arguments. For internal use, one int32 argument would be possible, but this should not be used by Embedded Wizard software developers.

If the Init() method is already defined in a super-class, we need to override the Init() method – BUT: It is not necessary and even not allowed to do a super() call inside the Init() constructor, because the runtime environment takes automatically care, that the Init() constructor is called for all classes, starting from the top super-class down to the last derived class in the class hierarchy. With other words: Never make a super() call within an Init() method!

Usage: The Init() method is very convenient to attach slot method to an observer and to read out start values for the user interface application e.g.: a slider position or whether a checkbox is checked or not.

+1 vote
by
If you need to overwrite the code you put wihin an Init() method, I recommend to add a separate method which can be overwritten. Use e.g. an InitSlot which is called fron Init() by "postsignal InitSlot;". This slot can be derived, you can use super and it is called only once after the init cycle.

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...