Sunday, 26 February 2012

SOFT332 API Instructions Matthew Smithies


These following instructions will show you how to correctly consume this RESTFUL API for use in the SOFT332 module.



Backend

This web service uses the http commands GET, POST, PUT and DELETE to show and manipulate data on this URL:

http://msmithies.byethost22.com/restInterface/

The SQL database and table are hard coded into the PHP scripts for ease of consumption.

There is a three tiered approach to this restful service that combines client elements with processing then finally database manipulation.

Client side : data you input for the RESTFUL api.

Server side intermediary  : data inputed is formatted as JSON notation.

Serverside : JSON data is used to manipulate the database then return the results.

The field in the table are as follows:

id (Primary Key)
name
job

GET 
In order to view data that is required the primary key field must be used in the url to retrieve a specific row.

To retrieve all of the rows in the api use the 'getid' command at the end of the URL

example

'http://msmithies.byethost22.com/restInterface/getid'

This will retrieve all rows in the table encoded as JSON format. You can use the individual 5 digit id numbers to return individual rows. It is recommended that this is used before using 5 digit numerical id.

example 


'http://msmithies.byethost22.com/restInterface/10001'


No credentials are required for using GET as the REST service acts initially as read only. Checks are conducted to see whether the id is correct, these are not returned as JSON, but a comment appears warning that the id isn't recognised.

Client Side Manipulation


The next three http commands essentially use the same style of execution.

A client has to be made to hold the values of authentication as well as the input for the rows for the database.

Authentication

The two elements essentially required for access for the database is the username and password. 

Username: blah
Password: blah

They will have to be combined within the curl data when the request is sent and they will have to be used for every instance of a POST, PUT or DELETE response.

Inorder to successfully manipulate the database the type names of each piece of data will have to match.

Use these type names:

Username - username of the database, listed above
Password - password of the database, listed above
Request - request you wish to perform (POST, PUT or DELETE)
Id - id of the person(row) in the database table
Name - name of the person(row) in the database table
Job - job of the person(row) in the database table

A number of these elements will have to be used depending on the HTTP request you require, details of data will be noted in the respective request section.

The elements should be combined in a query string before the data is posted.

example pseudocode

$query_string  = "Username=".$username."&";
$query_string .= "Password=".$password."&";
$query_string .= "Request=".$request."&";
$query_string .= "Id=".$id."&";
etc.

Below is an example of the curl attributes that are strongly recommended that you use when data is HTTP posted.

example pseudocode

<?php

 $url="http://msmithies.byethost22.com/restInterface/index.php";

//remember to concatenate the different parts of data strings from forms

 $query_string_data="Username=b22_10289976&Password=frogger0&Request=POST&Id=10005&Name=Batman&Job=Ice creams"

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL,$url);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $query_string_data);

    curl_exec ($curl);
    curl_close ($curl);

?>




POST

POST data requires the authentication of the database. A POST response to insert a new record with the Name and Job of the person(row). The Id is automatically incremented so any Id added to this query will be ignored.

PUT

PUT data requires the authentication of the database. A PUT response to update a record with the Id, Name and Job of the person(row). 

DELETE

PUT data requires the authentication of the database. A DELETE response to delete a record with the unique Id of the person(row). 






Sunday, 29 January 2012

Using location based data in combination with social networking

As the years develop onward social networking trends continues to grow and consume our lives. The paradigm of friendship seems to be growing toward virtual interaction over regular social behaviours. Remember we cannot be friends unless you are on my friends list on Facebook even then I could block you or 'forget' to talk. It is plusible to hypothesis that the ongoing lack of social liability is attractive in the short term and these behavioural patterns continue to grow in western culture. Is this the direction we are traveling as a civilisation or to ask a deeper question is this the right direction for to evolve?

E-safety concerns have always been a priority for computer security professionals. There is a fine line between perceived paranoid scare tactics and full leniency with convenience. It is up to the modern day administrator/manager to understand what is needed for a particular service and reach a fine line between the requirements of privacy and the perceived requirements the users expects. Location based services clash with this model as it puts the end user in control of their personal data exposure. Placing end users in the driving seat forces them with a level of reponsibility not with just themselves but others around them.

Giving the end user an ability to use 'check in' services in a mobile environment combines the virtual friendships with real social interactions of meeting friends allowing social networks to seamlessly blend between the virtual and real. At what point does this socialite sharing cross the boundary in which abuse could follow. If so would it be a it technological issue or the mindset of the end users? 



Tuesday, 17 January 2012

Empirical Software Engineering............... Is the cake here?

Are programmers artists or scientists? Do they craft monolithic structures based upon the will of their hands sculpting the world around them or perhaps delicately placing tiny organisms of Lego in specifically designed pockets point by point. Maybe the differentiation of these individuals spiral even further downward, the way code is written, a self proposed style possibly a kind of virtual fingerprint left behind in every program in every electronic device worldwide. Languages, generalised styles and taught practices may have their own guidelines for conformity but at the end of the day there will always be visionaries who will break rules doing things differently, advancing, perhaps with the normal distribution of the world following suit.

By empirically capturing habits and styles of  effective programmers a hypothesis can be designed, developed and tested to find optimum rates of productivity, efficiency and quality for a given project. The goal of this being to reduce all costs that could effect businesses in both the public and private sectors.

Tests and experiments that reduce the cost of a programmers time could be a programmatic level, cyclomatic complexity, or at a functional/practical level such as programmers working in pairs on the same screen of code tend to reduce the time and increase the quality. These latter tests are not without faults as there could be an array of extraneous variables that may bias the results in a particular fashion.

Reducing cost at a programmatic level is easier to control as a lower cyclomatic complexity can potentially reduce the amount of time for code maintenance. Here is a quick and simple example of how recursion can reduce the amount of complexity in finding a particular number in a range but may add to processing overhead.

int findMe = 5;
int finder = 1;
int maxRange = 10;

function findTheInt() {
    while(finder<maxRange) {
         if(finder==findMe) {
                     print("found number");
                     break;
         } else {
                     finder++;
    }
}
}

// By implementing a recursive function the while loop is taken out therefore reducing the potential maintenance cost.


function findTheIntRecursive() {
         if(finder==findMe) {
                     print("found number");
         } else {
                     finder++;
                     findTheIntRecursive();
    }
}


The next question which tends to be asked is, "Why is this testing necessary aren't effective programmers discovered based upon experience gained in the industry as well as professional accreditation?". This is a true statement but with an empirical system of analysis standards that are the backbone of professional accreditation can be unfolded and tested to be proven to work or even gradually evolve.

Developing an early prototypical model of effective evaluated approaches to reduce all costs sounds like a great idea. In order to gain public appeal practical measures will have to be implemented that would aid understandability and convenience for everyone in the target audience. This would include managers, programmers, directors and clients all of which would require different targeted advantages that would be offered as well as a communication plan that specifically tailor made for each type of individual in the target market. To paraphrase even though the approaches would result in the same outcome they need to be marketed towards the range of the target audience in different ways.

Here are some examples that would be targeted to specific groups...

- Programmers are the technical staff a tool/technique may help there work easier. This could be communicated at a very low level that would satisfy their need to understand at a bottom up level.

- Managers understand the low level advantages but are torn between their team versus management deadlines. The main advantage targeted here as that the reduction of cost in training, design and implementation.

- Directors/Management are interested in the bottom line, the profit margin. If an approach toward manufacturing/development doesn't deliver then it maybe cut from the budget entirely.

UML is an example of an empirical style of using the best elements for software design. It was implemented in the early 1990s, to combine and filter all the best methods of software design documents. Programmers are taught UML but it is rarely used in the industry, why is this? It has been proven that diagrams used in the design of software life cycle are used to communicate an idea to peers rather as formal documentation. Will empirical software engineering be the UML of the next decade only time will tell...

References
http://www.jameslewiscoleman.info/jlc_stuff/project_research/On%20the%20application%20of%20measurement%20theory%20in%20software%20engineering.pdf

http://www.americanscientist.org/issues/pub/empirical-software-engineering

http://alarcos.esi.uclm.es/doc/MetoTecInfInf/Articulos/tichy-hintsreview-ese-2000.pdf

A new start, where is the cake now?

This blog will allow myself to discover where the cake is now, hopefully. Maybe I'll get some work done but who knows.