I'm tryng to be pointed in the right direction because I would like to improve my programming skills and I'm reading some books (like Modernizing Legacy Applications in PHP by P. M. Jones) but I'm confused.
Lets say I have an HTML block that shows the five most read articles on my website and in this block we have an header, an heading, an intro text, the list of the five articles and a footer. And this block is inserted in the content of many different pages of my website.
In my own (awful) programming "style" a will create a method in an "Articles" class named "getMostReadBlock()" that will return the HTML code and I will call it everywhere I what to insert that block of HTML code.
I understand this is not the way but I'm not sure how to do it better. I understand I need a ArticlesGateway to retrieve my 5 articles from the database and than pass the data to some code that will build my HTML block (with header, heading, intro text, ecc.). But where is the right place to put that code that I want to call everywhere I want that HTML block?
I'm refactoring an existing application, I can't rewrite from scratch.
Aucun commentaire:
Enregistrer un commentaire