Knowledge7

The Linux and Mobile Solution Provider

  • About
  • Training
  • Services
  • Clients
  • In the news
  • Blog
  • Contact Us
You are here: Home / Archives for Avinash Meetoo

Do you want to buy great books?

Would you like to buy carefully selected American edition books on Linux, web design, PHP, MySQL and Java? And, would you like to buy them cheaper than on Amazon.com?

Now you can!

We are happy to launch our book store. Nothing fancy. No e-commerce. No credit cards. Only solid books at affordable prices which you collect the books immediately after payment (cheque or cash).

What do you think of that?

Our forthcoming training courses

  • No training courses are scheduled.

Managing State

This topic is part of our Web Application Development in Java training

HTTP is stateless.

As many applications require requests coming from the same client to be associated, web applications have the responsibility to maintain this state in a special object called a session. Fortunately, Java servlets fully support sessions.

Within a servlet, a session of class HttpSession is obtained by calling the getSession() method of the HTTP request. A session object can then be manipulated with getAttribute()/setAttribute()/removeAttribute().

After some time, a session expires. To control the lifetime of a session, the following methods are used: setMaxInactiveInterval() and invalidate().

Implementing a shopping cart

Enhance the web application developed previously so that users can add specific songs to a shopping cart. Multiple users browsing from different computers should be able to have their distinct shopping carts. Each user should be able to clear his own cart at any time.

Back.

This topic is part of our Web Application Development in Java training

Our forthcoming training courses

  • No training courses are scheduled.

Picks of the Week #2

You want to receive our Picks of the Week every Monday morning?

Thank you for reading the second edition of the Knowledge7’s Picks of the Week.

Every week, Avinash Meetoo will make you discover interesting articles and websites to help you broaden your understanding of the world of open source software and information technology in general.


Top 100 of the Best (Useful) OpenSource Applications
For some people, Linux is only for servers. For people like me, Linux is also a great desktop operating system capable of being better than anything from Seattle or Cuppertino. For the past few years, Ubuntu Linux has really made Linux easy to install and easy to use at home. The latest version is rock solid and features myriads of open source applications especially developed for home users. Here is a list of the top 100 of the best and useful open source applications from various categories courtesy of UbuntuLinuxHelp.com: audio, 2D graphics, 3D graphics, video, utilities, software development, etc. Try them. They are all free. And powerful.

Dates in PHP and MySQL
PHP is a powerful server-side programming language for building web applications. Wikipedia and Facebook are both written in PHP. MySQL is a powerful relational database. Both are open source software and, arguably, power most of the websites in existence. One relatively complex issue when using MySQL with PHP is how to transfer dates to and from the database as MySQL has no less than three ways to store them (using the DATETIME, DATE, and TIMESTAMP types). This article explores the tradeoffs between the various solutions which exist.

jQuery Mobile Tutorial: Basics
Last week, I talked about jQuery Mobile, an advanced Javascript library based on jQuery (obviously) for building mobile web applications. This week, I have just stumbled upon this interesting introductory tutorial on CodeForest, a web development and programming blog. The tutorial explains how to create a basic jQuery Mobile page, use external and internal linking and, even, how to change the theme of your application. Interestingly, the title (i.e. Basics) would imply that other tutorials will shortly follow and I’m sure they’ll all be useful for developing jQuery Mobile applications.

Cofoja: Contracts for Java
Building software is hard. And building software without bugs is much harder. One of the way to master complexity is to use Object-Oriented Programming. Objects are abstractions and communicate by exchanging messages. One way to enhance the semantics of messages is to use contracts (in the same sense Bertrand Meyer used them in his Eiffel programming language.) Cofoja is a new open source software from Google which adds contracts to the Java programming language. With Cofoja it becomes possible to enforce that, for example, a method should take a parameter within a specific range. Google uses Java for its Web Toolkit which is used, for example, for building Gmail.

PhoneGap
PhoneGap is a (yet another) library to build mobile web applications. The idea is to build the application using HTML5 and Javascript and rely on the PhoneGap API to get full access to the underlying features of the mobile phone on which the application is running like the accelerometer, the camera, geo location, contacts, notifications and storage. PhoneGap works with a lot of different smartphones: Android, iPhones, BlackBerry, Windows and Symbian. Thanks to PhoneGap, it becomes possible to build powerful mobile applications which behave and have the same capabilities of native applications without having to learn Objective-C (iPhone) or Java (Android). Life is cool. And it’s cooler when you realise that PhoneGap is open source software.

Our forthcoming training courses

  • No training courses are scheduled.

Picks of the Week #1

You want to receive our Picks of the Week every Monday morning?

Thank you for reading the first edition of the Knowledge7’s Picks of the Week.

Every week, Avinash Meetoo will make you discover interesting articles and websites to help you broaden your understanding of the world of open source software and information technology in general.


Instapaper
Instapaper is “a simple tool to save web pages for reading later” and is 100% free. While browsing, I frequently come across interesting articles that I would like to read at a later time. Up to now, I generally bookmarked the articles… and forget about them later. Instapaper allows me to collect those articles in one central place and read them when I have some free time either on my laptop or using my mobile phone. Instapaper can also print excerpts from the articles so that I can peruse them while relaxing on the beach for example. Now that we’ll be doing this Knowledge7’s Picks of the Week regularly, you have a great incentive to try Instapaper 🙂

BSD for Linux Users
Ever asked yourself the difference between BSD Unix (FreeBSD, OpenBSD, Mac OS X, etc.) and Linux? Want to know the differences between the two main types of open source licences: GPL and BSD? Always wondered how the cathedral compares to the bazaar? Read this great set of articles by Matt Fuller to understand those deep philosophical and technical differences. Matt is a BSD user and the articles are written from his perspective but they are all very well written and straight to the point. As a bonus, you’ll also learn that “Windows Causes Stupidity” and that the “Stupidity” is not an insult.

StackOverflow
StackOverflow describes itself as “a programming Question & Answer site that’s free. Free to ask questions, free to answer questions, free to read, free to index, built with plain old HTML, no fake rot13 text on the home page, no scammy Google-cloaking tactics, no salespeople, no Javascript windows dropping down in front of the answer asking for $12.95 to go away.” And that’s precisely what it is! StackOverflow has really become THE place on the Internet where programmers can find solutions to complex problems by asking those who got the same issues before. It’s much better than fishing in the dark with Google Search (now that our Web is so polluted with spam blogs and websites).

Android-Powered Smartphones
I have a confession to make: I wrote this article myself for the TechKnow magazine. But, heck, why not telling you about it? In it, I explore the world of Android-powered smartphones (like my own Google Nexus One) and try to understand how a mobile platform which was launched in October 2008 has managed to be present on HALF of the smartphones being purchased in the USA at this very moment (the iPhone is at 23%). Is that because Android runs Linux inside? Or is it because it’s open source software which can be used and modified freely by any phone manufacturer? Or is it simply because it’s the best mobile platform ever?

jQuery Mobile
Speaking of smartphones, here is the jQuery mobile framework for building mobile websites having “a unified user interface across all popular mobile platforms” (Android, iPhone, BlackBerry, Symbian, Windows, etc). jQuery Mobile is obviously based on jQuery which is pretty much the standard Javascript framework in use by millions of popular websites all over the planet. Now that smartphones are so pervasive, one cannot develop a website for desktop computers only anymore and jQuery mobile seems to be a worthy candidate framework for building mobile websites. Note that jQuery Mobile is still an alpha release (so expect things to break from time to time) but it’s exciting news nevertheless.

Our forthcoming training courses

  • No training courses are scheduled.

Become a Linux, PHP/MySQL or Java expert

In just two weeks, we will start the following MQA-approved training courses at Knowledge7:

  • Linux System Administration
  • Web Development with PHP and MySQL
  • Web Application Development in Java

A few places are still available. Do not hesitate to call Liliane or myself on 5834-9001 if you need any additional information.

Topics to be covered during the Linux course include: Linux installation and package management, Hardware and architecture, Text editing and processing, Process management and automation, User management and file permissions, the File-system Hierarchy Standard, Devices and Linux File-systems, TCP/IP networking and the X Window system. The course is designed for Linux beginners.

During the PHP/MySQL course, we will cover: semantic W3C compliant web pages, CSS frameworks, using templates and filters in PHP, the MySQL database, using sessions and cookies, parsing XML and JSON documents, file access and performance tuning. The course is designed for people who know about HTML and CSS and who wish to master server-side software development.

Finally, the Java course covers installing and configuring a servlet/JSP web container, using servlets, Java Database Connectivity (JDBC), managing state, creating JavaServer Pages (JSP), using JSP Custom Tags, using Struts actions, adding workflow with interceptors, building views and using UI Component tags. This course is designed for people who are conversant both with the Java programming language as well as object-oriented programming and who wish to master Java for web development.

Our forthcoming training courses

  • No training courses are scheduled.

Object-Oriented Principles

This topic is part of our Object-Oriented Programming in PHP training

Developing software using object-oriented principles require a programmer to have a sound understanding of a number of important concepts:

  • Object-Oriented Analysis: what is the problem to be solved?
  • Object-Oriented Design: how are we going to solve the problem
  • Object-Oriented Programming: actually implementing the solution using an Object-Oriented Programming Language

The best way to learn Object-Oriented Analysis and Design is to read

where it is shown how to use the Unified Modeling Language (UML) and Design Patterns when developing software.

A Design Pattern is a solution which experienced software developers have been using over the years when they have to solve a given type of problem. The most popular book covering the fundamental Design Patterns is:

This topic is part of our Object-Oriented Programming in PHP training

Our forthcoming training courses

  • No training courses are scheduled.

Accessing MySQL with PHP

This topic is part of our Web Development with PHP and MySQL training

PHP can access MySQL databases using a number of libraries. Two of them are mysqli and PDO, both part of standard PHP. mysqli provides functions to manipulate data in a MySQL database. PDO, as stated on the PHP website:

The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.

PDO provides a data-access abstraction layer, which means that, regardless of which database you’re using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn’t rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility.

PDO ships with PHP 5.1

The work to do is to modify the web application being written to make it save orders to a MySQL database instead of in a text file. The first thing to do is to decide upon a schema (i.e. tables and columns). The application will use PDO.

Prepared statements

In order to increase performance and security, it is advisable to use prepared statements when this is possible.

The work to do is to add to the web application a second report. This report should give, for each customer, the amount of phones bought and the cost. In case, the amount is more than 20, that customer should get 20% for this phone. If the number of phones is between 10 and 19, the customer should get 10% off.

This topic is part of our Web Development with PHP and MySQL training

Our forthcoming training courses

  • No training courses are scheduled.

Parsing JSON and XML documents

This topic is part of our Web Development with PHP and MySQL training

Flickr has a public API which can return a JSON response containing a list of photos on Flickr tagged with a specific keyword.

The work to do is to add to the web application a feature where one can see recent photos on Flickr tagged with the name of the mobile phone being examined. For example, when someone is looking at the Nokia E75, he/she should be able to see Flickr photos tagged with nokiae75.

RSS (which is XML) is also very common on the web. For instance, all blogs have a RSS feed including Nokia’s where the latest news on Nokia mobile phones can be easily read.

The work to do is to add these latest news on the homepage on the web application. For that, the RSS feed needs to be read from the Nokia’s blog, parsed as an XML file and the appropriate HMTL generated.

This topic is part of our Web Development with PHP and MySQL training

Our forthcoming training courses

  • No training courses are scheduled.

Using filters and templates in PHP

This topic is part of our Web Development with PHP and MySQL training

An order form can be added to the website created before in order to transform it into an e-commerce website. When someone orders a phone, the order should be saved to a text file. A reporting facility can also be added.

Filters were recently added to PHP in order to provide sanitization as well as validation facilities. The work to do is to make sure that any data being submitted from the order form is properly sanitized and validated. This helps in making the web application more secure.

Usual PHP scripts mix both programming elements (the PHP) with HTML markup. This tends to make the web application less maintainable and can prevent web designers and programmers from working at the same time.

One common solution to that problem is to use a templating engine like Smarty. This engine allows the programmer to separate PHP from HTML markup while increasing flexibility. The work to do is to rewrite the web application to use Smarty.

This topic is part of our Web Development with PHP and MySQL training

Our forthcoming training courses

  • No training courses are scheduled.

Object-Oriented Programming

This topic is part of our Object-Oriented Programming in PHP training

When version 5.0 was released in 2004, PHP became a full-fledged Object-Oriented Programming Language (similar to Java and C#).

Exercises

We will implement a web application which manages people, dogs and cars in a number of steps until we have explored the most important object-oriented constructs found in PHP5:

  1. Implement the Person and Dog classes (+ required constructors, methods, attributes) and instantiate one object from each class.
  2. Add visibility constructs (private for attributes / public for methods).
  3. Add the Car class with its association as shown in the above diagram. Given that PHP is dynamically typed, what is the risk here?
  4. Use type hints to prevent type mismatch.
  5. Implement the Nameable interface as well as the Nameables class (use an array to hold references). Implement getNames() using foreach(). Use type hints to prevent type mismatch.
  6. Use an exceptions for error handling when someone attempts to create a Car with no number.
  7. Replace the exception by a custom exception.
  8. Use inheritance (sparingly) to create a specialized version of Person called Doctor with a special behaviour for getName().
  9. Replace the array in Nameables by a SplDoublyLinkedList of the Standard PHP library.
  10. Use mktime to make sure that each Car created has a registration date of 25 December 2010 at 10:00
  11. Use strtotime to make sure that each Car created has a first servicing date which is next Saturday at 10:00.
  12. Use strtotime to make sure that each Car created has a second servicing date which is exactly three months after the first one.
  13. Use a static attribute which are shared among all Cars to keep a count of all Cars which have been instantiated.
This topic is part of our Object-Oriented Programming in PHP training

Our forthcoming training courses

  • No training courses are scheduled.
« Previous Page
Next Page »

Looking for something?

Want to know more?

Get our newsletter

Discover the latest news, tips and tricks on Linux, the Web and Mobile technologies every week for FREE

This work is licensed by Knowledge7 under an Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.