51 - Orientação Objetos - Métodos pt 08 - Referência this

51 - Orientação Objetos - Métodos pt 08 - Referência this

Introduction

The video begins with a greeting and introduction to the topic of references in programming.

Understanding References

  • When executing code, it is necessary to call the reference variable to access data located within an object.
  • By using the reference variable, we can assign values and access attributes within the object.
  • The reference variable acts as a control remote, allowing us to activate buttons such as name, sex, age, and print.

Implementing Reference Variables

The instructor demonstrates how to implement reference variables in code.

Using Reference Variables

  • To utilize a reference variable, we need to declare it within our object.
  • We can then call methods or attributes using the reference variable.
  • This allows us to access all available attributes without creating additional variables.

Accessing Object Attributes

The instructor explains how to refer to object attributes using reserved keywords.

Referring to Object Attributes

  • To refer to an attribute within an object, we use the reserved keyword "this".
  • By using "this", we can easily access attributes such as name, city, and sex.
  • We can directly print these attributes by calling them through the reference variable.

Initializing Objects with Reference Variables

The instructor demonstrates how to initialize objects with reference variables.

Initializing Objects

  • Two objects are initialized using the same class.
  • Each object has its own set of attribute values.
  • Both objects act as control remotes for accessing their respective attribute values.

Executing Methods with Reference Variables

The instructor explains how methods are executed using reference variables.

Executing Methods

  • When calling a method through a reference variable, the object associated with that variable executes the method.
  • By calling the print method on different objects, we can access their respective attribute values.

Multiple Reference Variables

The instructor discusses how multiple reference variables can control the same object.

Controlling Objects with Multiple Reference Variables

  • Multiple reference variables can control the same object.
  • These variables act as separate control remotes for accessing and manipulating attributes of the shared object.

Benefits of Using References

The instructor explains the benefits of using references in programming.

Benefits of Using References

  • Using references allows for better code organization and cohesion.
  • It eliminates the need for separate classes solely responsible for printing data.
  • References provide a clear distinction between objects and their associated methods or attributes.

Maintaining High Cohesion

The instructor emphasizes maintaining high cohesion by separating responsibilities in code design.

Separating Responsibilities

  • It is important to separate responsibilities within code design to maintain high cohesion.
  • Printing data should be handled separately from other functionalities within an object-oriented system.
Video description

Melhor, maior, e mais completo curso de Java em português grátis de toda Internet está de volta. Maratona Java Virado No Jiraya. Regravado desde a aula 0, com extrema qualidade, utilizando a última versão do Java, com fonte 22 e fundo branco celestial. O Maratona Java Virado no Jiraya é o único curso que você vai precisar para aprender Java. São mais de 250 aulas onde nós cobrimos praticamente o núcleo inteiro da linguagem. Desde o primeiro Olá mundo, até Orientação a Objetos, Coleções, Conexão com banco de dados, Tratamento de exeções, Threads, Programação funcional e muito mais. Meu amigo... é aula para CARAMBA. Só não aprende Java quem não quer. Centenas de pessoas fizeram o curso anterior e conseguiram entrar no mercado de trabalho, imagina esse que é melhor, mais completo e atualizado. E se você ainda não estiver satisfeito com essa belezura e quiser alavancar na carreira ainda mais rápido com as pessoas mais inteligentes, esforçadas, e gente boa do Brasil, além de ainda ter nosso suporte durante o curso, faça parte do nosso clube de membros https://www.youtube.com/channel/UCjF0OccBT05WxsJb2zNkL4g/join Mais informações e contato: http://devdojo.academy Design de tudo que é bonitinho no DevDojo: https://www.magiesocial.com Facebook: https://www.facebook.com/devdojobr Voz do Cid Moreira nos vídeos: https://www.linkedin.com/in/williamsuane/ Editor de vídeo: https://www.linkedin.com/in/wildneisuane/ (sem esse cara não existiria DevDojo, o mínimo que você pode fazer por um curso desses é ir no LinkedIn e agradecer pelo trabalho dele) Código Fonte: https://github.com/devdojobr/maratona-java-virado-no-jiraya