Best Coding Practices For Software and Website Development

Best Coding Practices For Software and Website Development PHP and ASP

Best coding practices are a set of informal rules that the software development community has learned over time which can help improve the quality of software. Many computer programs remain in use for far longer than the original authors ever envisaged (sometimes 40 years or more), so any rules need to facilitate both initial development and subsequent maintenance and enhancement by people other than the original authors.

In the Ninety-ninety rule, Tim Cargill is credited with this explanation as to why programming projects often run late:

  • “The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.”
  • Any guidance which can address this lack of foresight is worth considering.
  • The size of a project or program has a significant effect on error rates, programmer productivity, and the amount of management needed.

Software quality

There are many attributes associated with good software:

  • Some of these can be mutually contradictory (e.g. very fast versus full error checking), and different customers and participants may have different priorities.
  • Sommerville has identified four generalized attributes which are not concerned with what a program does, but how well the program does it:
    • Maintainability
    • Dependability
    • Efficiency
    • Usability
  • Weinberg has identified four targets which a good program should meet:
    • Does a program meet its specification; “correct output for each possible input”.
    • Is the program produced on schedule (and within budget)?
    • How adaptable is the program to cope with changing requirements?
    • Is the program efficient enough for the environment in which it is used?
  • Hoare has identified seventeen objectives related to software quality, including:
    • Clear definition of purpose.
    • The simplicity of use.
    • Ruggedness (difficult to misuse, kind to errors).
    • Early availability (delivered on time when needed).
    • Reliability.
    • Extensibility in the light of experience.
    • Brevity.
    • Efficiency (fast enough for the purpose to which it is put).
    • Minimum cost to develop.
    • Conformity to any relevant standards.


  • Before coding starts, it is important to ensure that all necessary prerequisites have been completed (or have at least progressed far enough to provide a solid foundation for coding).
  • If the various prerequisites are not satisfied then the software is likely to be unsatisfactory, even if it is completed.
  • From Meek & Heath: “What happens before one gets to the coding stage is often of crucial importance to the success of the project.”
  • The prerequisites outlined below cover such matters as:
    • how is development structured? (life cycle)
    • what is the software meant to do? (requirements)
    • the overall structure of the software system (architecture)
    • more detailed design of individual components (design)
    • choice of programming language(s)
  • For small simple projects involving only one person, it may be feasible to combine architecture with design and adopt a very simple life cycle.


  • A software development methodology is a framework that is used to structure, plan, and control the life cycle of a software product.
  • Common methodologies include a waterfall, prototyping, iterative and incremental development, spiral development, agile software development, rapid application development, and extreme programming.
  • The waterfall model is a sequential development approach; in particular, it assumes that the requirements can be completely defined at the start of a project.
  • However, McConnell quotes three studies which indicate that, on average, requirements change by around 25% during a project.
  • The other methodologies mentioned above all attempt to reduce the impact of such requirement changes, often by some form of step-wise, incremental, or iterative approach.


  • McConnell states: “The first prerequisite you need to fulfill before beginning construction is a clear statement of the problem the system is supposed to solve.”
  • Meek and Heath emphasize that a clear, complete, precise, and unambiguous written specification is the target to aim for.
  • Sommerville distinguishes between less detailed user requirements and more detailed system requirements.
  • He also distinguishes between functional requirements (e.g. update a record) and non-functional requirements (e.g. response time must be less than 1 second).


  • Hoare points out: “there are two ways of constructing a software design: one way is to make it so simple that there are obviously no deficiencies; the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.”
  • Software architecture is concerned with deciding what has to be done, and which program component is going to do it (how something is done is left to the detailed design phase, below).
  • This is particularly important when a software system contains more than one program since it effectively defines the interface between these various programs.
  • It should include some consideration of any user interfaces as well, without going into excessive detail.
  • Any non-functional system requirements (response time, reliability, maintainability, etc.) need to be considered at this stage.
  • The software architecture is also of interest to various stakeholders (sponsors, end-users, etc.) since it gives them a chance to check that their requirements can be met.


  • The main purpose of design is to fill in the details which have been glossed over in the architectural design.
  • The intention is that the design should be detailed enough to provide a good guide for actual coding, including details of any particular algorithms to be used.
  • For example, at the architectural level, it may have been noted that some data has to be sorted, while at the design level it is necessary to decide which sorting algorithm is to be used.
  • As a further example, if an object-oriented approach is being used, then the details of the objects must be determined (attributes and methods).

Choice of programming language(s)

  • “No programming language is perfect.
  • There is not even a single best language; there are only languages well suited or perhaps poorly suited for particular purposes.
  • Understanding the problem and associated programming requirements is necessary for choosing the language best suited for the solution.”

From Meek & Heath:

  • “The essence of the art of choosing a language is to start with the problem, decide what its requirements are, and their relative importance since it will probably be impossible to satisfy them all equally well.
  • The available languages should then be measured against the list of requirements, and the most suitable (or least unsatisfactory) chosen.”
  • It is possible that different programming languages may be appropriate for different aspects of the problem.
  • If the languages or their compilers permit, it may be feasible to mix routines written in different languages within the same program.

Coding standards

This section is also really a prerequisite to coding, as McConnell points out:

  • “Establish programming conventions before you begin programming. It’s nearly impossible to change the code to match them later.”
  • There are different conventions for different programming languages, so it may be counterproductive to apply the same conventions across different languages.
  • The use of coding conventions is particularly important when a project involves more than one programmer (there have been projects with thousands of programmers).
  • It is much easier for a programmer to read code written by someone else if all code follows the same conventions.


  • Due to time restrictions or enthusiastic programmers who want immediate results for their code, commenting of code often takes a back seat.
  • Programmers working as a team have found it better to leave comments behind since coding usually follows cycles or more than one person may work on a particular module.
  • However, some commenting can decrease the cost of knowledge transfer between developers working on the same module.
  • In the early days of computing, one commenting practice was to leave a brief description of the following:
    • Name of the module.
    • Purpose of the Module.
    • Description of the Module (In brief).
    • Original Author
    • Modifications
    • Authors who modified code with a description of why it modified.

Naming conventions

  • Use of proper naming conventions is considered good practice.
  • Sometimes programmers tend to use X1, Y1, etc. as variables and forget to replace them with meaningful ones, causing confusion.
  • In order to prevent this waste of time, it is usually considered the good practice to use descriptive names in the code since we deal with real data.
  • Example: A variable for taking in weight as a parameter for a truck can be named TrkWeight or TruckWeightKilograms, with TruckWeightKilograms being the more preferable one, since it is instantly recognizable.

Keep the code simple

  • The code that a programmer writes should be simple.
  • A complicated logic for achieving a simple thing should be kept to a minimum since the code might be modified by another programmer in the future.
  • The logic one programmer implemented may not make perfect sense to another.
  • So, always keep the code as simple as possible.


  • Program code should never ever contain “hard-coded” (literal) values referring to environmental parameters, such as absolute file paths, file names, usernames, hostnames, IP addresses, URLs, UDP/TCP ports.
  • Otherwise, the application will not run on a host that has a different design than anticipated.
  • A careful programmer can parametrize such variables and configure them for the hosting environment outside of the application proper (for example in property files, on an application server, or even in a database).
  • Remember the mantra of a “single point of a definition” (SPOD).
  • As an extension, resources such as XML files should also contain variables rather than literal values, otherwise, the application will not be portable to another environment without editing the XML files.
  • For example, with J2EE applications running in an application server, such environmental parameters can be defined in the scope of the JVM and the application should get the values from there.

Code development: Code building, Testing & Debugging the code and correcting errors

Code building

  1. A best practice for building code involves daily builds and testing, or better still continuous integration, or even continuous delivery.


  1. Testing is an integral part of software development that needs to be planned.
  2. It is also important that testing is done proactively; meaning that test cases are planned before coding starts, and test cases are developed while the application is being designed and coded.

Debugging the code and correcting errors

  1. Programmers tend to write the complete code and then begin debugging and checking for errors.
  2. Though this approach can save time on smaller projects, bigger and complex ones tend to have too many variables and functions that need attention.
  3. Therefore, it is good to debug every module once you are done and not the entire program.
  4. This saves time in the long run so that one does not end up wasting a lot of time on figuring out what is wrong.
  5. Unit tests for individual modules, and/or functional tests for web services and web applications, can help with this.
Best Coding Practices Guidelines in brief (Summary) A general overview of all of the above:
  • Know what the code block must perform.
  • Indicate a brief description of what a variable is for (the reference to commenting).
  • Correct errors as they occur.
  • Keep your code simple.
  • Maintain naming conventions which are uniform throughout.
  • Deployment is the final stage of releasing an application for users.

CMS Layer: Most Powerful PHP CMS Using CodeIgniter

CMS Layer The Most Developer Friendly CMS PHP and ASP

CMS Layer

CMS Layer The Most Developer Friendly CMS

The most flexible platform & programmer-friendly content management system (CMS Layer) all around the world! Build using powerful PHP framework CodeIgniter.

CMS Layer has built-in 100% Optimize SEO Comparable.

CMS Layer Plugin and Extensions are Page, Post, Product, Service, Portfolio, Forum, Package, Video, Slideshow, Classified, Download, Listing, Advertisement, Communities, Payment Gateway, ADP Template and AMP Theme.

Design Timeline using CSS and Jquery

Timeline design is the current web trend that visualizes the data in an interesting way. Today I want to discuss about how to design a timeline in a simple way with JSON data feed , that using CSS pseudo elements such as:before and :after. Pseudo elements are used to apply special effects to selectors. This post is a combination of my previous post, please take a quick look at this demo and try demo script with your WAMP server.

csstimeline PHP and ASP

The ::before selector inserts content before the content of the selected element(s).

CSS Code

padding:20px 0px 20px 0px;
content: ”;
position: absolute;
top: 0px;
bottom: 0px;
width: 5px;
background: #999999 ;
position: absolute;
border-top:3px solid #e8eaed;
border-bottom:3px solid #e8eaed;

Status Update HTML Code
Check my previous postStatus Message Design with CSS
<div class=”stbody”>
<span class=”timeline_square color1″></span>
<div class=”stimg”><img src=”profile.jpg” /></div>
<div class=”sttext”>
<span class=”stdelete” title=”Delete”>X</span>
<b>Srinivas Tamada</b><br/>
9lessons Programming Blog
<div class=”sttime”>10 seconds aga.</div>
<div class=”stexpand”>
//Youtube IFrame Code
This contains Users data feed, you can generate this using PHP code.
“message”:”9lessons Programming Blog . “,
“time”:”16 seconds ago”
“message”:”Everything is possible. “,
“time”:”18 seconds ago”
“message”:”If you are good at something, never do it for free”,
“embed”:”<iframe height=’315′ src=’//’ width=’560′></iframe>”,
“time”:”28 seconds ago”
Contains Jquery and JavaScript code, here $.getJSON parse the JSON data object.
<script src=”js/jquery.min.js”></script>
<script src=”js/jquery.linkify.min.js”></script>
<script src=”js/jquery.livequery.js”></script>
{//Formatting the text that contains URLs (text to link)
$(“.sttext”).livequery(function ()
$(this).linkify({ target: “_blank”});

//Parsing JSON object.
$.getJSON(“users.json”, function(data)
var totalCount=5;
var jsondata=”;
$.each(data.Messages, function(i, M)
//Generating random numbers for different dot colors
var num = Math.ceil(Math.random() * totalCount );
jsondata +='<div class=”stbody”>’
+'<span class=”timeline_square color’+num+'”></span>’
+'<div class=”stimg”><img src=”‘+M.avatar+'” /></div>’
+'<div class=”sttext”><span class=”stdelete”>X</span>’
+'<b>’+M.user +'</b><br/>’
+M.message+'<div class=”sttime”>’+M.time
+'</div><div class=”stexpand”>’+M.embed+'</div></div></div>’;

//Delete record
var A=$(this).parent().parent();
//HTML Code
<div id=”updates”></div>

Deleting record animation effect, please check my previous post CSS3 Animation Effects with Keyframes

CSS code
Random colors for timeline square points.

animation:hinge 1s;
-webkit-animation:hinge 1s; /* Safari and Chrome */


custom Audio Player using Jquery and HTML5

Today I want to discuss how to publish a voice recording messages on newsfeed using Jquery and HTML5 with custom HTML5 audio player. Take a quick look at the live demo, make sure use the microphone for better result.

Newsfeed table contains all the user update details.

CREATE TABLE newsfeed(
userUpdate TEXT,
user_id_fk INT,
audioMessage TEXT,
status ENUM(‘0′,’1’) DEFAULT ‘1’);

You have to include all these JavaScript library files.

<script src=”recorderControl.js”></script>
<script src=”js/jquery.min.2.1.js”></script> //Jquery
<script src=”js/jquery.stopwatch.js”></script> //Jquery Stop Watch
<script src=”recorder.js”></script>
<script type=”text/javascript”>



Custom Audio Player HTML Code
HTML code for custom designed audio player, here the actual HTML5 player is in hidden mode. Number 10 refers to user’s session id.
<div class=”audioContainer”>
<div class=”audioProgress” id=”audioProgress10′” style=”width:0px”></div>
<div class=”audioControl audioPlay” rel=”play” id=”10“></div>
<div class=”audioTime” id=”audioTime10′”>00.00</div>
<div class=”audioBar”></div>
<audio preload=”auto” src=”data:audio/mp3;base64,//sUxAAABAArMFRhgA..” type=”audio/mpeg” class=”a” id=”audio10′”><source></audio>
Audio Player CSS
Focus on colored CSS properties.
border:solid 1px #dedede;
position: absolute;float:left;width:52px;height:48px;;
position: absolute;width: 45px;height: 20px;margin-left:199px;float:right;
height: 3px;
background-color: #cc0000;
position: absolute;width: 147px;margin-left: 53px;
background:url(‘../images/play.png’) no-repeat
background:url(‘../images/pause.png’) no-repeat
Audio JavaScript
Contains JavaScript code $(‘body’).on(‘click’,’.audioControl’, function()audioControlis the CLASS name of the DIV tag. Using $(this).attr(“id”) calling the player ID.
// Utility method that will give audio formatted time
getAudioTimeByDec = function(cTime,duration)
var duration = parseInt(duration),
currentTime = parseInt(cTime),
left = duration – currentTime, second, minute;
second = (left % 60);
minute = Math.floor(left / 60) % 60;
second = second < 10 ? “0”+second : second;
minute = minute < 10 ? “0”+minute : minute;
return minute+”:”+second;

// Custom Audio Control using Jquery
$(“body”).on(“click”,”.audioControl”, function(e)
var ID=$(this).attr(“id”);
var progressArea = $(“#audioProgress”+ID);
var audioTimer = $(“#audioTime”+ID);
var audio = $(“#audio”+ID);
var audioCtrl = $(this);
var R=$(this).attr(‘rel’);
}// Audio Event listener, its listens audio time update events and updates Progress area and Timer area
audio.bind(“timeupdate”, function(e)
var audioDOM = audio.get(0);
var audioPos = (audioDOM.currentTime / audioDOM.duration) * 100;
// Custom Audio Control End

Controlling audio controls with Jquery trigger()

Record Button HTML Code
Contains simple HTML code.

<img src=”images/Microphone.png” id=”recordButton” class=”recordOff”>
<span id=”recordHelp”>Allow your microphone.</span>
<div id=”recordContainer” class=”startContainer”>
<div id=”recordTime”> <span id=”sw_m”>00</span>:<span id=”sw_s”>00</span></div>
<div id=”recordCircle” class=”startRecord”><div id=”recordText”>Record</div></div>
margin: 0px auto;
font-weight: bold;
cursor: pointer;
width: 100px;
height: 100px;
text-align: center;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
Record Button JavaScript
This script calls record.js for recording the audio.
//Record Button
$.stopwatch.startTimer(‘sw’); // Stopwatch Start
startRecording(this); // Audio Recording Start
$.stopwatch.resetTimer(); // Stopwatch Reset
stopRecording(this); // Audio Recording Stop
Modified and included following code in record.js for storing the audio data in Base64 format.
function uploadAudioBase64(audiosrc)
var dataString =’audiosrc=’+audiosrc;
type: “POST”,
url: “uploadAudio.php”,
data: dataString,
cache: false,
success: function(html)
var ID = Number(new Date()); //Timestamp
var A='<div class=”audioContainer”>’
+'<div class=”audioProgress” id=”audioProgress’+ID+'” style=”width:0px”></div>’
+'<div class=”audioControl audioPlay” rel=”play” id=”‘+ID+'”></div>’
+'<div class=”audioTime” id=”audioTime’+ID+'”>00.00</div>’
+'<div class=”audioBar”></div>’
+'<audio preload=”auto” src=”‘+audiosrc+'” type=”audio/mpeg” class=”a” id=”audio’+ID+'”><source></audio>’
var B='<div class=”stbody”><div class=”stimg “>’
+'<a href=””><img src=”″ class=”big_face ” alt=”You” ></a></div>’
+'<div class=”sttext”><div class=”sttext_content”><span class=”sttext_span”><b><a href=””>You</a></b> </span>’
Inserting the audio Base64 data into newsfeed along with user session id.
if($_POST[‘audiosrc’] && !empty($session_id))
$query=mysqli_query($db,”INSERT INTO `newsfeed` (`user_id_fk`, `audioMessage`) VALUES ( ‘$session_id’, ‘$audiosrc’)”)or die(mysqli_error($db));
This way data will store audio data into newsfeed table.
Audio Recording with Jquery and HTML5 PHP and ASP
Database connection you have to modify username, password and database values.
define(‘DB_SERVER’, ‘localhost’);
define(‘DB_USERNAME’, ‘username’);
define(‘DB_PASSWORD’, ‘password’);
define(‘DB_DATABASE’, ‘database’);
$db = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD,DB_DATABASE) or die(mysqli_connect_error());
$path = “uploads/”; //Images upload folder

Make Your Design Business More Efficient using 6 Tools

Whether you run a design agency or operate as a freelancer, you quickly learn the value of efficiency. The slower you and your team members are, the more time wasted on badly-designed processes, the less work you get done – and the less money you make. You want to make sure your dirty work is quick and easy, in order to clear more time for what actually matters. The good news are that you’ve got plenty of tools to help you do that. Here are six you’ll surely find useful.

1. Webydo
Webydo is an intuitive and easy to use tool for building websites without having to write code. You can use it to execute your vision quickly and efficiently from scratch, with all the features and responsivity your client requires. It creates sites that are even simple to manage in the long run, so you can leave your clients with a fully operating, immediately published website which they can easily update with new material whenever they want PHP and ASP

2. Flow
Flow is a great task management tool for small teams. It helps you keep up with all the work being done by all of your colleagues at once. You’ll find it easy to keep updated with the team and always be on top of deadlines and workloads. The nice thing is that Flow is a good middle ground: not too simplistic (so better than a sticky note with a to-do list) but not too heavy either (so might fit you better than Sharepoint.)2 PHP and ASP

3. Google Analytics
This one’s a no-brainer: Google Analytics is a go-to tool for many web designers and managers. It’s where you get all the info you need in one place about how your website’s doing, who is visiting it and how often, where they’re coming from, how much revenue you’re making, what you conversion rate is and so much more. Google, as everyone is slowly realizing, sees all – and with Google Analytics you can catch a glimpse too.3 PHP and ASP

4. Niice
Remember wasting hours gazing at Pinterest boards? Well Niice is all about creative inspiration too, with a more professional twist. If you’re stuck and need to look at what others are doing, if you need new directions for your work or even if you just enjoy looking at beautiful things other people do on Behance, Dribbble and such, go visit Niice and a good (and inspiration-full) time is guaranteed.4 PHP and ASP

5. Primer
Primer is one of those tools which are so, so simple but at the same time brilliantly useful. It lets you paste your HTML into a window, and based on that piece of HTML, outputs blank CSS based on the same classes and IDs you used. It will create your basis for you and let you develop it from there, which is great for those of us who like starting with markups and applying styling later. It also happens to have a comfortingly simplistic design 5 PHP and ASP

6. InVision
InVision is a terrific tool for designing prototypes and collaborating with team members. In not too many clicks it will transform your basic designs and vision into interactive prototypes with buttons, animations, clickability and everything else the site needs, without having to use HTML. It’s a useful first step on the way to the final, meticulously designed website that your agency so loves to deliver.6 PHP and ASP