I want to start making short videos about PHP from time to time. The idea is that they are quick to produce - so this is more me explaining my thought process as I program something how it is done in the real world and with any silly mistakes left in. Here we want to have a class representing a news item and some sort of feed system (JSON/XML). In the future there may be more classes - like a blog class.
Normally we should always program the simplest method possible. The obvious simplest method would be to have a feed class for each type (possibly inherited) and hard code in the fields. This is what AI coding would probably give you. However, it's unsatisfactory because the Feed class is not generic and more importantly because any future programmer changing classes like the news item class would need to know that they also need to edit the hard coded fields in the relevant code.
So here my argument is that you should make the trade off. Using attributes and reflection we can make a generic feed class and simultaneously make it obvious to somebody editing the news item (or future blog class) that they need to add an attribute to enable the field and they only need to work on the one file (without needing to know the other one exists). Because future work is more likely to be on the other classes, this trade off in the feed class is well worth it.
Nesta página do site você pode assistir ao vídeo on-line PHP Reflection and Attributes for Feed Example duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Chris Ridings 24 Outubro 2025, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 82 vezes e gostou 3 espectadores. Boa visualização!