Skip to content
Advertisement

Can I improve this code to a more oriented OOP paradigm?

I am improving this code to a student, here is the image: enter image description here

So I rewrite this using list compreenssion and oriented to a formal class, so the second question is: Can I improve yet more this code?

JavaScript

Advertisement

Answer

Yes you can improve your code to be more “Object Oriented”.

It doesn’t make sence that Aluno contains a list, Aluno should represent a single student instance.

Below is a sample code. Note that my sample code can be improved, you can, for instances, add a Person class that stores common attributes to Student and Professor class, like birth date, id, etc.

JavaScript

Outputs:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement