iSnare.com - Free Content Articles Directory
Authors Contents [Advanced Search][Add OpenSearch][Job Search]
Distribute your articles to thousands of article sites for only $2 and below! Read more...

Index  Computers and Technology
 

Building A Framework For Effective Development

 
[ Contact the Author] [ Send to a Friend] [ Article Publisher] [Make PDF] [ Print] [ Bookmark & Share]
 
Read our Terms of Service before reprinting this article. The submitter specified above has claimed the rights to this article.
Bobby Handzhiev

Wrtiting less PHP code with more results

Most web development companies use their own or third party frameworks to improve their development process. If you want to work as a PHP developer in a company you will most probably need to agree to write your code using their framework. This article is for these developers and companies who want to build their own framework and improve their coding speed, the quality of their code and get paid more for less time. I will share with you the ideas we discovered in PIM Team Bulgaria while working on our PHP framework, but not the framework itself - you need to develope your own one which to suit the most your coding style. Our advises are valid for almost any other programming language.

What is a framework and why I need it?

Don't you get bored when you need to write same or similar types of code again and again? Do you hate when customer wants to change "some unsignificant thing" but you need to change it in 10 different files? Are your scripts too long? Do you write "spagetti" code? If you answer "yes" on some of these questions, then you need a set of functions and classes which will automate most of the tasks, reduce your code size and avoid copy-paste practices. That is framework. It is a set of classes and functions which you just include in your scripts and make your life of a web developer easier.

What to "put" in a framework?

Some people and companies tend to believe that everything should be generated by functions and classes and you should never have a "free flying" PHP code. As a result of that they put everything in objects and extremly complicated functions which try to handle everything for everyone. As a result the code gets hard to read, buggy, hard to change and slow to write and learn.

Other group prefers to write everything for the current situation, again and again for every project and file. They often copy-paste hundreds of rows to save development time and effort, but when they have to modify the code it turns into a pain. And all of this is because they are too lazy to create a framework.

The solution as usually is somewhere in the middle. You should be looking to optimize tasks which are repeated often in the project or in different projetcs. Here are the best propositions:

- Mail functions - its terrible to see most developers putting all the headers in each place where they need to send a mail. Just wrap the mail() function and use the wrapper.

- Database wrappers - you MUST have one. Stop using the built in mysql (or other DB) functions directly into your projects. What will happen if the database must be changed?

- Database functions - do you really need to type manually all the 50 field names of that table and then to manually fill the values from $_POST? Sure, it is often needed when the values come in a different way. But very often, especially in admin panels you just have a form with fields corresponding to the table ones and values in them. Just iterate thru the database fields (hint: "SHOW FIELDS FROM table_name") and insert/update

- HTML code snippets - aren't you tired of creating or copy-pasting date dropdowns, checkboxes, normal dropdowns or radio groups? Create functions for each of these - it could accept parametters as name, values, selected name...

- Formatting specifics such as date, money, phone numbers etc. Yes, the PHP functions like date() allow you to format in any way. But what happens if you have dates on hundred places and the customers decide that instead of mm/dd/yy they want format "dd Month, YYYY"? Don't change it everywhere, don't use the MySQL data formatting. Create your own wrapper and use it.

- Admin panels - each and every admin panel includes screens for add/edit/delete various table contents. Why to do it each time? In PIM Team we created a class called table_editor which simply receives several massives and arguments and handles all the operations on any complex DB table, including the HTML code for the editing webform in less than 20 lines! The admin pages don't need to look nice, but yet our table_editor allows your tables to look perfect with CSS

- File and picture uploading, resizing, thumbnails. You don't really write every time all the codes in your scripts I hope. It would be crazy. You need functions or class for these

- Project sopecific functions. Many websites have specific features like displaying category trees, specific dropdowns, small tables with user's profiles etc etc. You can and must put these in objects or functions and use across your porjects.

Don't overdo your framework

You can't handle everything for every case. Maybe you can but this will make your framework heavy, slow to process and hard to use. The goal of the framework is to make your life easier, not some idealistic idea for pure OOP coding. You need to export functions and objects of things which you do often within different projects or several times in one project. You will only loose time if you try to handle some individual cases.

Important NoticeDISCLAIMER: All information, content, and data in this article are sole opinions and/or findings of the individual user or organization that registered and submitted this article at Isnare.com without any fee. The article is strictly for educational or entertainment purposes only and should not be used in any way, implemented or applied without consultation from a professional. We at Isnare.com do not, in anyway, contribute or include our own findings, facts and opinions in any articles presented in this site. Publishing this article does not constitute Isnare.com's support or sponsorship for this article. Isnare.com is an article publishing service. Please read our Terms of Service for more information.

Bobby Handzhiev is a Senior Developer in http://pimteam.net and an editor for http://knowledgebase.pimteam.net
Article Tags: code [See Dictionary], framework [See Dictionary], functions [See Dictionary]
Got a question about this article? Ask the community!
Article published on February 25, 2006 at Isnare.com
 
Rate [Ratings: 5 / 5] [Votes: 1]

It’s a Mod Chip World!
Submitted by: Michiel Van Kets

No Nintendo Wii game console seems complete without a mod chip installation and with today’s latest mod chip innovations it’s easier than ever to buy and install your own Wii modification chip...

Be Careful When Buying Cheap Adobe Software
Submitted by: Adrianna Noton

When individuals are looking to buy software they always love finding cheap Adobe software However are these really great prices too good to be true...

What is the Difference Between Standard and High Yield Toner Cartridges?
Submitted by: Adriana N

There have been improvements in the manufacturing of printer toner cartridges Toner found in a cartridge is dry powder blended with a polymer that sticks on to the paper as printing takes place...

IPod Battery Guide For Your IPod Nano
Submitted by: Brian H Logan

iPod battery life is an issue to most iPod users The iPod battery weakens over a period of time and it is not easily replaced...

Factors in Selecting a VAR
Submitted by: Lawrence Reaves

Selecting a Value Added reseller (VAR) is crucial and requires pain-staking assessment of their capabilities and track record, including those who are already delivering services into a client, even when the relationship has subsisted for many years...

IDC Market Forecast Predicts Static it Spend to 2013
Submitted by: Lawrence Reaves

An IDC Market Analysis and Forecast for 2009-2013 has been released and the results demonstrate a modest increase in IT spend by SMB’s worldwide – gross IT spend is predicted to rise by a mere 5...

VAR Issues – “Cheap” Usually Means Scalability, Service, And Reliability Are Sacrificed
Submitted by: Shell Harris

Value Added Resellers (VAR’s) come in all flavors, shapes and sizes – they provide a vital service to IT departments who are suffering from severe budgetary constraints, staff and skill shortages and issues in implementing and managing increasingly complex solutions...

Why You Should Buy a Notebook
Submitted by: Roberto Sedycias

The notebook computer is quickly replacing the desktop as most computer owner's favorite machine Not only is it portable for travel, it is also portable for use in the home...

The Clear Advantages Of A Sony Ericsson Satio
Submitted by: Gordon Millisons

Sony Ericsson Satio is a smart phone available at phone shops today with huge support for multimedia, touch screen feature and a lot more...

Did Windows 7 Boom or Bust?
Submitted by: John Dow

It's been a few weeks now since the launch of the Windows 7 release by Microsoft The launch in general was much lower key than past version launches, probably for a couple of reasons...

GBC H312 Laminator Review
Submitted by: Jeff McRitchie

The H312 replaces the H310 in the GBC HeatSeal line of pouch laminators Like its predecessor, this machine is targeted toward small business or home offices that do light to moderate amounts of laminating and need the flexibility to process larger documents...

GBC HeatSeal H435 Laminator Review
Submitted by: Jeff McRitchie

A new addition to GBC's Jam Free line of laminators, the HeatSeal H435 is presented as a laminating solution for small to medium sized organizations that need the flexibility of being able to laminate documents of many sizes, and of thicknesses up to 7mil...

GBC HeatSeal H520 Laminator Review
Submitted by: Jeff McRitchie

Aimed at the medium to large office market, the GBC HeatSeal H520 is designed as a solution for organizations that need to laminate documents of many different sizes...

GBC HeatSeal H535 Turbo Laminator Review
Submitted by: Jeff McRitchie

It is no secret that in today's business world, it's vital to produce top-notch work quickly That is hard to do that when you're waiting around for your laminator to work...

GBC ProClick P50 Binding Punch Review
Submitted by: Jeff McRitchie

As one of the premier manufacturers of binding machines, GBC produces machines both large and small for a wide range of uses...

Isnare.com Footer Divider

© 2004-2009. Isnare Free Articles - An Isnare Online Technologies Free Articles Project. All Rights Reserved.   Privacy Policy