I'm developing a project using Ionic, and would like to better organize my classes.
Below is an example of how I would do with PHP:
<?php
trait comportamento {
public function ficarTriste() {
}
public function ficarFeliz() {
}
}
trait acao {
public function falar($texto) {
echo $texto;
}
public function olhar($endereco) {
return file_get_contents($endereco);
}
}
class serHumano {
comportamento;
acao;
//o resto do código
}
$humano = new serHumano();
$humano->ficarFeliz();
$humano->falar('oooi');
As I could do something like this using TypeScript, I used PHP as an example because it's the language I'm most familiar with. If I am not mistaken in C # this is called partial
.
Note: I did not put PHP in tags because the question is not the same, I just used it to demonstrate what I want.