How to keep class object during form process If I have an object (e.g. student object - this is my own custom class)

I would like to initiate this object during 'student registration' form initialization (or form build) and keep the object until I finish with the form (form submitted).

Is there any placeholder for me to hold this object in the FormBase class?
Where I should declare my class? And how to keep the object?

Example in my code:

&lt;?PHP

namespace bla;

use bla
use bla
use bla

class myCreateForm extends FormBase {

  private $student; // i want to initiate this (new student()) and keep until form submit
  /* where i should declare this? and how to keep it? */

  /**
   * Class constructor.
   */
  public function __construct($param) {
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'id_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    //a lot of code here code here
    return $form;
  }

  public function validateForm(array &amp;$form, FormStateInterface $form_state) {
    //a lot of code here code here
  }

  public function submitForm(array &amp;$form, FormStateInterface $form_state) {
    $output = $this-&gt;student-&gt;save(); // at the end, i would like to have my own save process which my class will handle it.
    drupal_set_message($output);
  }

}
No, if this is a value object then a service not the answer.

I would recommend you look at entities. Drupal will do a ton of work for you if you use (content) entities for your value objects.

See https://www.drupal.org/node/2192175 for example for documentation, also check out the entity module for additional functionality that is not yet in Drupal core.

With content entities, there is a standard EntityForm class that contains an entity and allows you to save it.

That said, what you are doing basically works, $this->student will be available, but be aware that on the first form submission, formBuild() is called again, so it will build another object. The same for entities. If you really want to prevent that, you need to store your object in the database, e.g. with the tempstore API.