Twitter user Data handling

I seem right now to be embroiled in a debate with another programmer on this project who thinks that views have no merits. He proposes a system that PHP looks something like this:

$draw = new Draw;
$nav = $draw->wideHeaderBox().
$draw->left().
    $draw->image().
        Image::get($image,60,array('id'=>'header_image')).
    $draw->imageEnd().
$draw->leftEnd().
$draw->left(10).
    '
'. self::defaultSectionText(). '
'. $draw->leftEnd().

and so on (this is in the controller btw). Now his arguments for this actually make some sense, he claims that if there is a redesign all we need to do is change the HTML in one place and it changes everywhere automatically. For some reason however, this method still rubs me the wrong way, is there any merit to views over this method? I mean besides not having to retype HTML by hand.

2 ANSWERS

February 16, 2017 at 10:06 am admin

HTML time-savers are useful, but they’re only useful when they’re intuitive and easy-to-understand. Having to instantiate a new Draw just doesn’t sound very natural. Furthermore, wideHeaderBox and left will only have significance to someone who intimately knows the system. And what if there is a redesign, like your co-worker muses? What if the wideHeaderBox becomes very narrow? Will you change the markup (and styles, presumable) generated by the PHP method but leave a very inaccurate method name to call the code?

If you guys just have to use HTML generation, you should use it interspersed in view files, and you should use it where it’s really necessary/useful, such as something like this:

HTML::link("Wikipedia", "http://en.wikipedia.org");
HTML::bulleted_list(array(
    HTML::list_item("Dogs"),
    HTML::list_item("Cats"),
    HTML::list_item("Armadillos")
));

In the above example, the method names actually make sense to people who aren’t familiar with your system. They’ll also make more sense to you guys when you go back into a seldom-visited file and wonder what the heck you were doing.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.

Some of our services that will useful on regular basis:

Book Tours & Activities

Access to a thousands of activaties in Costa Rica. Everything from Adventure, Arts and Recreational Activities.

Tranportation Bookings

Booking your trasfers has never been easier. Look up available destications, times and get instant confirmation with just a few clicks.

Investments

Great resource for those who are looking for business and investment opportunities for residential and commercial real estate.

Online Shopping

Shop Online for Costa Rica made products and services. Find Unique and one of kind items.

Services Bookings

Make reservation at your favorite locations and events.

Hotel Bookings

Get access to all the hotels in Costa Rica. Check availability and book

Vacation Rentals

Search all the available vacation home rentals in Costa Rica.

Book A Table

We make it easy for you to make a reservation with your favorite place.

Order Food

Place your oder online and have your food deliver to your location. Restritions apply.

Flight Booking

Look for best deals and book your flights with us.

Rent A Car

Quick, easy online car reservations for Costa Rica.

Bank / ATM

Locate Bank and ATM information

Doctors Appointment

Schedule your appointmens directly with our participating providers.

Spa & Salon

Book your spa and salon treatments directly with our participating providers.

Offers | Promotions | Hot Deals

Explore best offers, promotions and hot deals with AskZipy.

On Demand Services

Book your on damand services directly with our participating providers.

Jobs

Looking for work, search our site to find business who are looking for talent to join their teams.

Photo Album

View photos form all the Ask Zipy adventures and activaties.

Emergency Services

Locate Emergency services locations and contact information.

FAQ

Search our list of faqs to the most common questions people have when visiting and working in Costa Rica.

Order Groceries

Shopping for groceries has never been easier. order your groceries and have them delivered to your location.