Tuesday, 14 May 2013

Tips for Writing Better And More Comprehensive CSS

CSS language is not very difficult to master, but if you are using it for a large project, it can be very difficult to manage if you do not follow a defined approach while writing CSS code.
Here are few tips that will help you write better and easy to manage CSS code.

Doctype
Initially we need to use those long Doctypes that were almost impossible to remember.
Now we just need to use <!DOCTYPE html> on the top of your document, we have a much cleaner and better solution.
Nevertheless, some people still forgets to specify it. This is mandatory for a validated and organized HTML document.

ID and Classes

An ID is a unique identifier which allows us to target a specific element on the page and since it is unique it can only be used once in a page.
On the other hand, we have classes which allow us to do exactly the opposite. Classes are used when you have the same element more than once on a page.

How not to do it:
<div id="block">
   <div id="btn"></div>
   <div id="btn"></div>
</div>

How you should do it:
<div id="block">
   <div class="btn"></div>
   <div class="btn"></div>
</div>

Do not use inline styling

Inline styling is a very common practice and unfortunately a bad one.
It has nothing to do with invalid code or bad markup, but with organized code and structure.
This can become a problem in case where you have 30 pages and you need to remove an inline style you have applied to the same div on every single page. For this task it would take your lot of precious time.
If we are using class in the same case then by just doing change at one place it will get reflect where ever it is used, which is pretty fast and effective.

How not to do it:
<div style="width: 100%; background: #fff;"></div>

How you should do it:
<div id="wrap"></div>

Ove use of divs and CSS Classes

While working on your project, you know how to use divs, ids, and classes.
Inline styling is not your thing (fortunately) and you love to create styles and apply them everywhere.
That's great, but don't write more than you have to.
Having a div with an unordered list inside and a class applied to each li element is unnecessary.

How not to do it:
<div id="navigation">
   <ul>
      <li class="left"></li>
      <li class="left"></li>
      <li class="left"></li>
   </ul>
</div>

How you should do it
<ul id="navigation">
   <li></li>
   <li></li>
   <li></li>
</ul>

And in your style sheet
#navigation li { float: left; }

Browser Resolution

According to the W3C's statistics, 13.8% of internet users have a 1024×768 screen resolution, and 85.1% use a bigger screen resolution.
So the question arises is that "What resolution we should design for?" Besides, though 13.8% seems to be a fairly low number, it still represents millions of internet users.

How you should do it

Consider everyone's needs, and especially your target audience.

Block and Inline elements

Differentiating block from inline elements can be a a delicate matter for beginners.
A block element is displayed on a new line taking by default 100% width of the containing element, like divs (<div>) or paragraphs (<p>).
An inline element is displayed with no line breaks meaning that it starts on the same line, taking only his own width, like span (<span>) or image (<img>).
You can also change the way an element is displayed, this means that you can change an inline element to be display as a block and vice versa.

How you should do it
span { display: block; }


Use comments to organize your code

This is something purely optional but I highly recommend its use. It not only helps you find the section or element your are looking for, but also makes your life easier when you need to know which div your </div> is closing.

How you should do it
<!-- Begin #header -->
<div id="header">
<!-- End #header -->
</div>

Stylesheet:
/* --------------------------------------------------------------
Header
-------------------------------------------------------------- */
#header { background: #fff; }


Cross-Browser Compatibility

When you decide to make something, you should place yourself in the role of the end-user and imagine that even today some of them still use browsers like IE6.
A page in renders differently in Firefox than in Chrome or Internet Explorer.
There are some useful tools available in market today to check how your page renders in different browsers. You can make use of it.


Don’t use heading tags randomly

Heading tags are not just there to make it pretty, they establish the importance of your content which makes them valuable for SEO.
There are six Heading tags: h1, h2, h3, h4, h5, and h6.
H1 is the most important, so you should use it for your web page or business name only.
The rest of the tags should be used according to title or content importance.
Also, you don't need to have heading tags everywhere on your document.

How not to do it:
<h6>Post title</h6>
<h1>Text content</h1>

How you should do it:
<h2>Post title</h2>
<p>Text content</p>

Use absolute position only when you have to

When you're starting out, you can easily become addicted to the use of absolute positioning.
This is because it is an easy way of placing elements, however this property should not be used excessively.
Since elements with absolute position lose their normal flow, it is almost impossible to align them with other sections on the page.

You simply can't tell a normal element to be on the left side of an element with absolute position.

Thursday, 21 March 2013

What is MVC Architecture


MVC stands for Model-View-Controller. Model means data, view means representation and Controller means business logic. 

It has been used for the first time in Smalltalk and then Java adopted this pattern and made it popular.
The model view controller pattern is the most popular used pattern in today's world web applications. 

The MVC pattern is a process of dividing an application into three parts: the model, the view, and the controller.
Design pattern is a code structure that allows common coding frameworks to be replicated quickly.

The model is responsible for managing the data. It stores and retrieves entities used by an application, usually from a database.

The view (presentation) is responsible to display the data provided by the model in a specific format.

The controller handles the model and view layers to work together. 

Normally the controller receives a request from the client, invoke the model to perform the requested operations and send the data to the View. 

The view format the data to be presented to the user, in a web application as an html output.

Example

A bike is a real-world example of MVC. With a bike you have two views: the interior and the exterior. Both take input from the controller: the driver. The brakes, wheel and other controls represent the model: they take input from the controller (driver) and hand them off to the views (interior/exterior) for presentation.

There are many frameworks available today which follow the MVC pattern in PHP. Some of them are Zend Studio framework, CodeIgniter framework, PHP Smart etc.

Wednesday, 20 February 2013

Features and advantages of Drupal


By using Drupal CMS, developers can generate user-friendly and search engine friendly websites. We can easily apply different SEO strategies for websites created in Drupal.

Drupal is an open source and free content management software used for developing websites. It is one of the best solution for controlling the web page. Websites created in Drupal are mostly used in the group places like discussion boards, difficult web programs like blogs and eCommerce websites.

Drupal is now one of the popular platform for developing hi-tech websites and provides the best features for the developers. Most commonly Website owners, developers and consumers prefer Drupal for creating a website.

Drupal comes with various techniques which enables developers and designers to save time and money. Using Drupal Programmers can develop a user-friendly web design.


Advantages of selecting Drupal CMS for website development are as follows:

1. Flexible infrastructure which allows to gain benefits from ready made designs from the Drupal.

2. User registration and maintenance, menu management, layout customization, system administration and RSS-Feeds such basic features can be used to create simple sites, single or multi user blogs, forums, community websites.

3. Drupal has simple interface to utilize and the interface can be easily modify.

4. Drupal offers you the basic building blocks of websites in a module-styled format where content and rules can be created quickly. 

5. Site created in Drupal are highly secure.

6. Using Drupal, you can design and develop best web pages that has the same look in all major browsers.

7. Drupal offers various features for mobile based website and it reduces the requirements of arranging the factors on the mobile website.

8. Drupal is considered to be the one of best option for creating a responsive web design which can be viewed on all devices.

9. Anyone can use Drupal which is available free of cost.

Thursday, 14 February 2013

Magento eCommerce Software

Magento is an open source e-commerce web application. It comes with a variety of tools, required for building a successful online shop.
Magento comes with a lot of built-in capabilities, such as coupon codes, promo pricing, detailed statistics and SEO options.

The Magento eCommerce system Robust and powerful solution both for small and middle sized companies and large corporations.

Magento offers a free "Community" edition, one should have hands on experience of PHP and html in order to set a customized store live.
While there is lot of help available on forums and offered by the Magneto community but you cannot obtain support from Magento until you purchase the Enterprise edition.

Magento is popular for its use of the EAV model and especially for its use of object-oriented programming (OOP).
Magento is much more versatile and adaptable. We can use Magento for storing large range of data.

Below are some new features that the latest version 1.7 includes:
Auto-generation of Coupon Codes
  • New improved layered navigation and price bucket algorithm
  • It integrates Zend_Captcha on most customer related forms
  • Redesigned and rebuilt HTML 5 iPhone theme.
  • System backup
  • Rollback functionality
  • Manage currency symbols
  • VAT number validation
  • Brand new REST API.
  • Set base prices for each customer group
  • Re-factored Indexers
  • Cookie Message
  • Integrated Bank Transfer payment methods and Cash On Delivery
The Magento Community Edition is available for free download.
The premium, Magento Enterprise Edition solution is available based on an annual subscription.

Wednesday, 6 February 2013

Symfony -High Performance PHP Framework

Symfony:

Symfony is a one of the most popular php framework.It is very easy to learn, it is fast and flexible. Mostly it is used to build robust applications in short time. 

While learning Symfony one really feels that he is learning 
- Fundamentals of the web 
- Best practices of web development  
- How to use the latest PHP libraries in Symfony or Independently. 

Symfony allows developers to build better and more easily maintainable websites with PHP. 

Key features of Symfony2:

1. Dependency Injection Container for the rescue

One of the common problem faced in big application made in symfony1 was that developers used to make services, classes, helpers all over the code. 
Some were found in main library, few in applications library and some in modules library folders. 
In a big project, finding proper class was not so easy. 
Symfony2 uses Dependency Injection Container, which unifies access to main services, which is very helpful for developer. 

2. Templates are made simple

In Symfony1 the templates were written in pure PHP which was good, because it was eliminating templating engine overhead and was very handy for PHP developers to use their functions. 
Developer used to add “helper functions” on top of template, but Symfony2 by default uses Twig Templating engine (PHP templating is still available). 
Twig is very fast and easy to read and develop. Twig offers inheritance model, and provides many points of extensions. 
Twig is very similar to Django templating engine, which is one of best.

3. Bundles systems

In Symfony2 Bundles systems is one of the core concept.
Project inner mechanisms, third-party plugins and developers code is organized into the bundles. 
Bundles are easy to work with and they can be moved between applications without taking any big effort. 
Another most important and nice concept is Components which is core of the framework. 
Components works independent and can be used outside of Symfony2 in batch processing or even for building your own framework.

4. Doctrine2

By default Doctrine2 is bundled in Symfony. Doctrine2 offers ORM layer, as well as MongoDB mapping.
Doctrine is fast and has different approach on data accessing. Doctrine uses annotations, which is very good  way of keeping metadata configuration in one place.

There are few more good features like:
 - Totally new security layer,
 - Full support to PHP 5.3,
 - Brand new forms component,
 - Independent validators,
 - Code Generators,
 - Support to huge amount of third party bundles,
 - Helpful community.

Friday, 18 January 2013

How PHP Is Better Than Its Alternatives?



This article may useful for PHP Programmers who remember their old golden core PHP Programming Days. Now a days place of  Core PHP Programming is occupied by Content management systems and Frameworks :-)  This article is an old article written by me in 2005. I remember i refereed some text books to prepare this article. At that time PHP 4.x was released.So this is dedicated to PHP Programmers :-)

What is the need of PHP in today's world? The days of static HTML websites with few CGI scripts are over. Today's websites must be dynamic. Everyone needs dynamic websites with top functionalists. So biggest decision facing the creator or developer is choosing best technology platform from hundreds of technologies.

Let us look at some technologies similar to PHP.

Perl has adapted well to being a CGI solution and it is used to build complex web solutions. Micro soft provides active server pages with Internet information server. Middle-ware like Allie Cold Fusion is another solution. We can also find lists of hundreds of web technologies, costing thousands of dollars.

Why PHP is better than all of these alternatives?
Here is an overview

PHP is Best
PHP is faster to code and execute. The same PHP code runs unaltered on different web servers and different operation systems.

Open source
PHP is free. So anyone can visit PHP official website and download complete source code. There is very little risk in trying PHP, and its license allows the code to be used to develop applications with no royalties.

PHP runs on all major operating system platforms. It is designed to integrate with the Apache web server. Apache is one of popular free web server on the internet.

PHP also works with other web servers including Microsoft Internet information server.

Modifiable
PHP is specially designed to allow for future extension of functionality. It is coded in C and provides a good Application Programming Interface. Also rich set of functions available in PHP are evidence that they are often do.

PHP language was written for web page creation. Pearl, Java and C are also good programming languages for driving web applications. But why PHP is even better than these is the ease of communication with web experience. Application built on PHP is rapidly and easily developed because the code is encapsulated in the web pages themselves.

Support
Support for PHP is free and readily available. Questions to the mailing list are answered within hours.

Custom bug tracking system on the PHP system shows each problem along with the resolution.

Popularity
Internet services providers find PHP to be an alternative way to allow their customers to code web applications without the risks exposed by CGI.

Large number of PHP Developers, Freelance Programmers, Onshore and Offshore Development and Outsourcing Firms are available worldwide.

Websites coded in PHP will have the option of moving from one host to another as well as a choice of programmers to add functionality.

Coding skills developed in other structured languages can be applied to PHP. PHP takes inspiration from both Perl and C. So experienced Perl and C programmers learn PHP very quickly.

Conferences and Releases
Regular Conferences are one more strong backbone for Developers. You can find various conferences date and places at official website of PHP.
Recently, PHP 5.5.0 Alpha 2 released. As web technology grows, PHP also updated and release with new functionality.
These are some major reasons which made PHP better than its alternatives.
For Custom PHP Programming and to Hire PHP Developers you can connect here

Friday, 16 November 2012

Kohana Framework


Here i will share one of solved question related to Kohana Framework development.. May be helpful for Kohana Developers.

Question: 

I'm implementing captcha for my project in Kohana. I have configured and created captcha which was already added to Kohana modules by client'e developer. I could display the captcha but, I'm not able to reset it. I created a reset link and using ajax created a new captcha. I tried to replace the image using JS, but the first image remains as it is.

How can I reset the captcha ?

Answer:

I have faced issue of changing image (but not for captch) using jQuery and to resolve it I have added below code:
 append code with your URL: '?' + new Date().getTime());

I will come with more QA Soon.