Search This Blog

Friday, June 3, 2016

Ultrasonic sensor: A more sophisticated scanning and decision making - The AuRGent Project

I will start by saying "its been too long", to say its due to research projects at the university. However, I made some decent improvements in my AuRGent robot project, previously you just saw a basic navigation with hard coded movement. Recently I took the liberty of purchasing an ultrasonic sensor servo mount and hooked it up to my Arduino board, thus allowing the Robot to make some sort of decision based on its precepts from the sensor. Keep on reading, more details below.

The Sensor, mount and Servo

From the figure below, you see exactly how i mounted the sensor to the mount and thus to the servo, this allows me to program the ultrasonic range sensor to scan 165 °, taking readings at 0 ° (the right distance), at 90 ° (the center distance) and at 165 ° (the left distance). Why 165 you ask? Well i left some room to accommodate the error in servo (keep in mind you have to experiment to find your value).
What happens here is, as the robot navigate, the sensor is at 90 °, now whenever there is an obstacle in >=40cm, the bot stops, scans around taking a reading of both left and right and then makes a decision to take the path (left or right) with the highest distance to another obstacle. Okay okay am just going to give you the code.
    cm = get_distance();
    motor_speed = get_motor_speed(cm);
    type = bot_move(motor_speed, cm); 
    if( type == 1){
        servo2.write(0); 
        delay(500);
        right = get_distance(); //scan to the right
        delay(500);
        servo2.write(165);
        delay(600);
        left = get_distance(); //scan to the left
        delay(500);
        servo2.write(90); //return to center
        delay(100);
        compareDistance();
    }
What you see here is the loop, we get the distance from the sensor with the
get_distance()
function.
    int get_distance(){
        // establish variables for duration of the ping,
        // and the distance result in inches and centimeters:
        long duration, cm;
        digitalWrite(trig, LOW);
        delayMicroseconds(5);
        digitalWrite(trig, HIGH);
        delayMicroseconds(15);
        digitalWrite(trig, LOW);
        duration = pulseIn(echo, HIGH);
        cm = microseconds_to_centimeters(duration); //Converting distance to cm
        return cm;
    }
Based on that (left and right), the distance is read by the function
compareDistance()
which makes the decision on which path to take next.
    void compareDistance(){
  
        if (left>right) //if left is less obstructed 
        {
            turn_left();
            delay(500); 
        }
        else if (right>left) //if right is less obstructed
        {
            turn_right();
            delay(500);
        }
        else //if they are equally obstructed
        {
            turn_right();
            delay(1000);
        }
    }
That easy right?

Well you have seen most of the rest of the code in my previous posts, however i have restructured some movements, like for instance the function calls to left, right, back and forward in specialized function calls. Am just gonna give it to you and you figure out the rest. But just for argument sake, here are some specialised function calls you can find in the code:

  • get_motor_speed()
    function just takes in a distance as argument and uses
    map()
    to find a suitable speed for the bot given the distance, setting it to the global motor_speed variable.
  • set_speed()
    function takes in the motorspeed as argument and sets it to each of the motors (front left and right, back left and right).
  • bot_move()
    function on the other hand takes both the distance and speed based on the previous functions, decides how should the bot move given this variables, it also sets the speed of the motors.
Now you ask doesn't bot_move and compareDistance() do the same thing? No not the same, you see the first decides on whether to keep going forward, go backwards, go left or go right even at the initial state where there is no current reading yet. However, the prior only apply's only when we encounter and obstacle while going in a forward direction, then it decides to turn left or right.

Current AuRGent Structure

I think i can say we covered the most important aspects of this issue, if you need the full code kindly go to my repo GitHub and the video for this feature will be made available momentarily on my channel YouTube

Coming soon: Upgrades

  • FSM (Finite State Machine): So honestly i hate my implementation with the bunch of if-then-else, on my defense, this solution was a preliminary hack solution. However in the next issue on this project, i will introduce FSM and a refactored version of my code which will also be in the repo.
  • Reinforcement Learning: I am still designing my policy matrix to enable my bot to learn from experience and come up with its own optimal policy instead of my approximate policy in the current implementation.
  • Task and path finding: I will also implement using a GPS and Compass module a feature to enable navigation from a given state to another with (as much as i can) optimal solution.
Thanks and if you love my posts and videos, don't forget to share, comment on improvements i can make to either the post, videos or projects, learning never ends.

Monday, December 21, 2015

Hooking up SainSmart Motor Shield, Ultrasonic Range Finder with Arduino to Control my Chassis.

Its been long since the last post on the series, a lot has changed since then.

Motors to Motor Shield


I had problems with the right motor shield to use, however i finally settled with the sain smart motor shield, which has its library called AFMotor with a guide at the link on how to set it up.
Once you install in your arduino IDE, all is left is to connect it to your arduino like this:

and then first import the library with some few definitions.

#include 
#define MAX_SPEED 120
#define MIN_SPEED 95

You speed can vary, so make sure you experiment with various speed.
In my case i have 4 motors i want to control, so i hooked up the front motors to M1 and M2 respectively and the back to M3 and M4, then declare the motor instances like this:

 AF_DCMotor motorlf(1);
 AF_DCMotor motorrf(2);
 AF_DCMotor motorlb(3);
 AF_DCMotor motorrb(4);


after this, you will need to put this code in your setup. Setting the speed

   motorlf.setSpeed(MIN_SPEED);
   motorrf.setSpeed(MIN_SPEED);
   motorlb.setSpeed(SLOW_SPEED);
   motorrb.setSpeed(SLOW_SPEED);


then for each motor you can use for example
 motorlf.run(FORWARD);
 motorrf.run(BACKWARD);

The rest is basic programming. Also take not that if you want to turn right, you can set the left wheel to run forward and the right wheel to run backward, the converse for turning left.

Ultrasonic Range Finder


For the sensor, hook up the VCC to arduino board 5v, Gnd to Gnd, Trig to pin 12, echo to pin 13 like in the image above, you can see the 2 wires running into the board at both ends.
Then also define this in your code
 #define trig  12 
 #define echo 13 

and in setup add
   pinMode (trig,OUTPUT);
   pinMode (echo,INPUT);
  // initialize serial communication:
   Serial.begin(9600);  

then in your loop
   digitalWrite(trig, LOW);
   delayMicroseconds(2);
   digitalWrite(trig, HIGH);
   delayMicroseconds(10);
   digitalWrite(trig, LOW);
   duration = pulseIn(echo, HIGH);
   cm = (duration / 2) / 29.1;
    if(cm > 25){

     move_forward();

   }else{
    
     turn_right();
     delay(300);
    
   }

So what this basically does is it sets a low pulse for about 2 microseconds to ensure a clean high pulse for a longer period, set back to low and reads the echo using pulseIn. Thats the duration. You can see the calculation to CM in the code above.
Finally our robot looks like this

Upload your code and start your bot. Anytime it encounters an obstacle less than 25 cm, it turns right, from this you can make even more sophisticated computations.
Check out my Youtube video for detailed explanation. Earn free bitcoin

Monday, August 3, 2015

Multi Chassis 4WD Assembly

So its been quite sometime now, since i last blogged. Well recently i took upon myself an interesting hardware hack project which will last for sometime i think, but i promise to blog every step of it. Today was the first step towards this and i managed to assemble the multi chassis kit together. First of, the kit comes together with a short manual of the assembly, however i find it not really comprehensible, but it does get the job done.
This are all the parts, yea, you heard me right really all the parts, so basically the DC Motors go in first, you screw them with an M'2.5*20 (the shorter round head) screw at the top, and the longer M'2.5*25 screw at the bottom holding them with M2.5 nylon screw. So it basically looks like this with all the motors in.
Next we attach the battery case to the chassis top frame and screw it with the M'3*8 flat-head screw. Then you will need to attach four distance holders at the area specified with M3.8 screw so we can attach the chassis top frame to the bottom. Now in total you will need 8 M3.8 screws, 4 to hold the four distance holders to the bottom chassis frame, and four to attach the top chassis frame to the holders. After which to make sure your wires are exposed so as to easily attach them to whatever micro-controller you are going to be using. In my case i will be using the Arduino UNO R3 which i will introduce in the next phase of the project. You can see how the finished product looks like.
If you are interested in a visual look, I posted a Video to YouTube highlighting some important things one might need, but overall the assembly shouldn't take more than 10 minutes. Until next time. Tschüß

Saturday, January 24, 2015

Money hinders potentials

This is not the traditional write up for this blog, however something in my mind that have to be said.
I have been and still wondering why money should be a factor against potentials, there are lots of geniuses out there, raw ideas from bright minds and skills yet to be furnaced. But most of the time, all those cannot be mined without money, why?
Why can't an organization see a good idea and fund it? Why can't an institution see a determined potential and sponsor it? Why can't a country recognize bright minds and buy them. Why do people have to always struggle in order to contribute? I just can't understand the world's logic.

Potentials denied the right to mature in innovators, skilled tarnished and turned into homeless men, great minds ignored in place of radicals that destroy systems. Why does the world have to operate this way, why is it difficult to find a few .5 percent that really understand what is important?

Why why and why????

Monday, September 8, 2014

Good/Bad Software Engineers

After reading Katsuya Noguchi post on Good Software Engineers vs Bad Software Engineers, i was driven to re-share this post because he outlined all the important qualities of a Good Software Engineer, from Problem Solving, good coding practice, documentation to learning for other developers through reviews.

This is a must read blog post for all developers, the link below to the post. Good Software Engineer / Bad Software Engineer

Friday, April 18, 2014

Login problem after upgrade to Ubuntu 14.04 (Trusty Tahr) from 12.04 (Precise Pangolin) via Terminal

So as most people know, yesterday a new LTS version of Ubuntu was released, version 14.04 code name Trusty Tahr. I upgraded to this version, but not without some complications, if you are like me who only upgrade to Long Term Support versions and you are a bit too comfortable with the terminal, well my first advice will be DO NOT upgrade directly from the terminal, use the Update Manager instead. Although complications can happen either ways, but graphically it might be better.

If you are like me, and you happen to run the command;

$do-realease-upgrade -d

After running this, i simply followed the steps of normal upgrade, and it was successful with minor errors which is almost unavoidable, after restarting my system, i first i booted to the login and was still seeing 12.04, that was weird but then tried to login, i landed on a black page.

Well since at first i thought it was an issue with the unity, which probably is, i opened one of my TTY's and tried running an update and then re installing ubuntu-desktop  but still the error persisted, even created a new user as though a similar problem happened in 12.04, it was a problem with the config file and creating a new user will actually resolve the issue, but not in my case.

I am an opensource guy and one of the habbit is hitting the communities, i visited the Ubuntu G+ community, asked for suggestion, obviously, at least someone have encountered the same problem as you did, well the first response i got was to backup and reload my OS, however i was a bit positive a waited a few more hours.  This morning i got a response that made my breakthrough from +Matthew Rhodes who had same problem as i did and suggested an easy fix.

Since you have access to your TTY, go into one by hitting CTR+ALT+F1 then login with your credentials. After that, run this commands;

$sudo apt-get update

$sudo apt-get upgrade


Wait for it to complete the upgrade and then restart. This should fix your problem, but optionally if it doesn't, do this instead;

$sudo apt-get update

$sudo apt-get dist-upgrade


PROBLEM
You might encounter a minor error and you can't run apt utility with an error saying, "unmet dependencies" you can resolve this with

$sudo apt-get -f install

$sudo apt-get autoclean

$sudo apt-get autoremove

$sudo apt-get update


I wish you an adventurous Linux hack.

Monday, April 7, 2014

You wanna learn to Code?

Recently i have been getting questions:  "how can i learn to program?", "How can i become a professional programmer?" Well i have rather than an answer, but a guideline. I can only show you the door, you will be the one to walk through it.

First things first, to go into this world you need to prepare your mind, be ready to learn, be ready to code at least bunch of hours a week, if you are not enthusiastic or curious about how things work, its time to start changing your mindset. Be ready to face problems that will literally turn your brain into a hyper multitasking machine, most of all be ready to see the world differently because this world you are stepping into, you haven't heard of anything like it before.

OK i didn't mean to scare you that way, fortunate for you, this days there are more easier ways to get exposed to the programming world, unlike years ago that we literally go through books and manuals in order to learn. A bunch of web applications are developed to guide you through the basics of programming in various languages, and i am going to talk about a few here.

Codecademy 
This site my favorite, why you ask? well because it has a comprehensive introduction to Python which happens to be my favorite language, aside that if you are interested in web development, there are courses for HTML, CSS, JavaScript, Ruby and each contains a project at the end to test if you actually learnt something. This site presents you with an interactive way of learning, using an online interpreter for various languages, you can follow instructions from each chapter, write the code in the editor instantly and test your code if it works. Also there are hints to somewhat "difficult" tasks in case you can't find your way. Also you gather points from actually completing modules, and they have something called streak, which is just a measurement of  consecutive days you spent completing tasks. Additionally, after completing a language training, you can choose to start learning some API's like that of twitter, facebook e.t.c and guess what? its completely free.

Code School
This web platform is similar to Codecademy in a way, with HTML, CSS, JavaScript, Ruby (Ruby on Rails). But it additionally have courses on Objective-C, iOS development, using version control systems (GIT), JQuery and a bunch of other API's. Though unlike Codecademy, some courses have charges.

Haskell
If you are curious about functional programming languages, haskell is a  place to start, this site gives a short introduction to haskell programming language interactively, giving you an overview of the concept and learning some basic syntax.

There are many other sites you can use to learn aside this one's, sites such as  Cousera  and  Udacity  where you can find full university course lectures in video with interactive course works and  tasks, which you can do to test your knowledge and also certificates are awarded in some courses to those who satisfy the requirements of the courses.

Not being in school is not an excuse to not educate yourself, this is the 21st century, you can go to school online and self educate yourself at home.

Wednesday, April 2, 2014

Future of development cost.

Development cost depends on various factors such as, availability of developers of the given domain, size of the project, number of technologies to be used (i.e if more than one, is there need to get a developer for each technology or one developer with knowledge of all can handle the job).

This days there has been a call for everyone to know how to code, with tech celebrities and entrepreneurs supporting the project "Code a day" (code.org) and schools introducing programming at elementary level. Even though not everyone will want to follow this path as a career, there will be a huge amount of hubby developers. If this is the case, everyone will probably develop his or her own software, that really doesn't seem practical but with availability of open source tools out there for anyone to fork, build and use, anything could happen.

So what happens when 80% of the population knows how to code, and each person either freelance to get extra cash or works as a full time professional. With this much developers, probably a lot of people will be competing for one job, this means that people can bid for a job, and everyone will like to make his or her price as low as possible in order to get the job, which will probably affect the amount it takes to develop a particular kind of product.

As it is right now in sites like freelancer.com, odesk.com e.t.c, the bids to develop a particular program are so low i am beginning to think how much it will be when we have more developers. But ironically we need more developers, a lot of countries outsource their development jobs to countries like india, and china where professionals do a work for less price, and some countries outsource because there are no good developers to get the job done where they are.

This is just a personal evaluation as i can't predict the future, and i know many of you are thinking about the same thing. Give me your feedback on what you think will happen to development in the future.  

Thursday, January 16, 2014

Hobbyist Programmers

The world as we know it now heavily depends on computers, with this comes a great need for professional programmers. However, there are a great community of computer programmers that sole lonely code for fun, extra cash, community or to automate their daily work.

This group of programmers are known as "Hobbyist Programmers". For the large industries and closed source community who believe every piece of code should be sold, do not understand the idea of someone coding for fun or to give back to the community. But this community of programmers are the real hackers as we know it, those whose room window illuminate deep in the middle of the night, those who have sleepless nights and long hours of coding just to make the world a little better and a comfortable place to live in. The Open Source community which is the largest community of programmers consists of hobbyist programmers.

This community makes it possible to have a bunch of documentations, tools, source codes and so much tutorials on the world wide web, it is practically a matter of take and plug nowadays in a matter of developing a computer program or mobile applications.

However, what does it mean for the future of computer programming? is it possible for all of us to learn how to code? what if we are all computer literates and every single one of us can code? who is gonna use your application when everyone can simply make his? how will this change the world that we know and the lifestyle we live?

I will tackle this issues on my next issue, before then, everyone can live a comment below regarding this matter and in the next blog i will discuss my opinion and the opinions left in the comments.

Friday, January 3, 2014

Conscious or Unconscious dream?

So for the past week i have been having this weird problem with sleep, when i go to bed 3:00 AM, of course with my earphones on and connected to the soundbox, i tend to live within the musics themselves, having something i feel like a dream that goes with the rhythm of the music but at the same time still feeling conscious enough that i actually know what song is playing. It is so weird to me because, before a week ago, when i plug my earphones to sleep, i fall deep asleep after atmost 5 songs.

I wake by 6:00 AM and do whatever it is that i do, feeling as if i haven't slept at night which i am not sure i actually did. By 11:00 - 12:00 AM i feel this strong urge to sleep which i definitely succum to wether i like it or not, sleep till between 5:00 - 7:00 PM where i wake again, work till 3:00 AM and continue the Circle.

The problem is, it seems impossible to break the cycle, for the fact that during the day i can't seem to force myself to stay awake till night time, and during nighttime, i can't force myself to sleep properly, rather finding myself in this realm between being asleep and awake.

Whatever it is, i have a very serious week ahead of me, where i have two major examinations, a couple of coding to do for my work colleague and games to play, yes you heard me right, games. I play games, and not talking about games like Dota or LoL (i play does too sometimes), but games such as CheckIO, some might not see the logic behind solving problems as games, well i do. Also Farmville 2, Candy Crush, Criminal Case and Pet Rescue Saga are so addictive to me, well now i don't like the fact of saying that i am addicted, but rather they are mandatory to my daily living.

Monday, December 9, 2013

Programming then and Programming now.

I get why people always say programming back in the day was way more difficult than our days now, not all of that is correct. Yes it was difficult to get your hands on documentations and even if you do, you probably have to go through a library of books, even if you managed to do that, it is difficult to get your hands on a terminal, you either had to pay for a time on a time-sharing machine or be part of some computing laboratory to be able to actually program something. Now if all this are managed, writing programs are not so complicated, in the sense that, the programs that are considered cutting edge back then are what we now our days call high school projects, and not much programming languages that you have to stress yourself on learning, only a few existed. No much development standards to adhere to, most of the programs are terminal based, so you don't have to worry about dealing with user interfaces or making your program fancy enough for your users (i.e users back then are mostly computer scientists and mathematicians who are well intelligible and care more about functions than design), and also there are less programs to be your competition, so anyway at all you write your programs, people will still use it.

Now talking about the modern day programming, it is a lot easier for a nine year old to start programming computers, there are lots of materials, documentations, video and even interactive tutorial at anyones disposal on the internet, programming languages are in variety, different types with different paradigms, languages that have been simplified and are much more readable by even someone who has little knowledge on programming. Besides that, there are lots of tools and lots of reuseable codes that someone can easily get his hands on, thanks to the Open Source Community. But having all this at ones disposal will not make that person a good programmer and will definitely not ensure the development of a cutting edge software, now it is fair enough to say that every software have been developed, of course that is not true but to come up with an idea that has never been implemented is nearly impossible. Even if one managed to come up with such an idea, one needs to learn the best and recent technologies used in his/her area of development, implementing to this days standards is way more difficult than it used to be, and trying to develop it in such a way that is sheds a light and shine above all the softwares out there will take months, if not years of sleepless nights of tweaking, debugging and re-coding (depending on the software size). Another point is, back in the day, computing technologies might last for 10-15 years, but this days, technologies change so fast and the field evolve more quickly, to the point that in the lifetime of a software (depending how big) it is possible to tune it to meet 3-4 different generations of technologies.

This analysis is a personal opinion and not meant to start a war between old school and modern developers, but simply to point out that simplicity of software development greatly depends on the perspective and what is put into consideration. Bitching about how hard it is, or stating all the if's will not change anything, so raise your head up, grab a pc and start hacking because before your are able to say "Jack Robinson" someone has put out that idea roaming in your head for quite sometime now and technology has evolved.

Friday, November 22, 2013

Source Control

Source control also known as version control and revision control have been a great technology for managing the changes in computer programs also allowing multiple developers to work on a project without interrupting each others work. It has been here for a while now and there are numerous distributed model tools are developed for this purpose, tools such as Git, Mercurial, SVK, Codeville, Bitkeeper e.t.c. Though some of this tools are proprietary softwares, Open Source community has provided open version of this tools, the most widely used being Git.

Some of this tools are integrated in a more user friendly environments such as IDE's and Web based application, such as the Git, which makes it easy to create and manage git repositories straight from Eclipse, github.com, bitbucket.org. Personally i make use of the both github and bitbucket to manage my projects.

The idea of version control systems is to keep a sequential record of a file from the first revision to the latest. Programmers usually use the concept of branching to keep parallel stable versions of code. Each developer assigned to work in a feature works on a separate branch of his own, after which sends a pull request and it is then merged into the master after being reviewed allowing multiple developers to work concurrently.

Git works in almost different way than other know VCS's, it specifically treats is data as a set of files and anytime one stores some data or makes changes, git takes a snapshot of the files and saves the reference to it. Also whenever a file is not changed git doesn't store the files again making it a bit more efficient. Git has various workflows; Centralised workflow, Gitflow workflow, Branch workflow and Forking workflow. This workflows are a design way to handle or manage your data, create a branch from master, work on it, merge back to master.

The basic branch workflow involves creating a repository, initialize git with git init, clone the repository with the command git clone [url], do your work in the branch created on your system, add all the files git add * or add the individually git add [file], commit your changes with a comment with git commit -m "comment", and push it to master with git push origin master. Master is the original project history and it is not advised to work on master but on the dedicated feature branch, this avoid the problem of the master containing broken codes.

This is just a summary of Source control with specifics on Git, a more detailed tutorial will be in place in future. A lot of companies use version control for projects and it is advised to learn how they work and work on some yourself as it will serve a great deal when working in teams.

Thursday, October 10, 2013

Building Kivy app to Android apk

Days back i began setting up kivy-python-for-android environment in order to build my kivy app into an android apk, i was faced with alot of difficulties as it is my first time building this. However i accomplished my goal and will share my experience with also difficulties i face and how i was able to solve them.

      After developing kivy application, kivy developers have provided a somewhat detailed steps to building an apk. According to the page http://kivy.org/docs/guide/packaging-android.html one needs:

  • A Linux system (Virtual machine)
  • Java 
  • Python 2.7
  • Jinja2
  • Apache Ant and,
  • Android SDK
Installing this prerequisites and getting the environment up and running is pretty easy (if you know what you are doing of course) however, during this process, a lot can possibly go wrong. After following each of the steps presented on this page http://python-for-android.readthedocs.org/en/latest/prerequisites/ there are some key things to note

  1. You need to install android API level 8 or 14 and pretty much any NDK version as i tested.
  2. Exporting each of the appropriate paths such as the ANDROIDSDK, ANDROIDNDK, ANDROIDNDKVER, ANDROIDAPI, PATH.
After exporting the PATH at the end, i discovered that the part to my /etc/bin was overridden, as a result of that, i was not able to run most of the shell commands. When that happens simply restarting the shell session or just opening a new session will do the trick. NOTE: after restarting a shell session, you will need to re-export all the paths again.

After setting up all the prerequisites, cloning python-for-android repo using git is a pretty smooth process, however the problem arises when trying to build your distribution. The "distribute.sh" script is found in the /path/python-for-android/ directory and runing it as specified in the kivy page might result to an empty  /python-for-android/dist/default and no matter what you do, it will continue to be empty
And in this way, if you run the build.py script it will keep throwing some errors like "Error: missing object name for verb "update"" blah blah blah. When you see such an error the way to solve it is:

  •  To simply delete the /dist/ directory 
  • Run "./distribute.sh -m "kivy"" 
  • Check the /dist/default/ directory if its empty
  • If not, you are ready to go.
You can now run your build.py script with the proper parameters as stated in the kivy apk build page, after which you can find your .apk in the /dist/default/bin directory.

NOTE: You can simply download the kivy virtual machine, which comes with all the dependencies pre installed, all you need to do is to configure your paths, build your distribution and build your app.

Have fun Hacking....
  

Wednesday, August 28, 2013

Develop 5 attributes that will help your software projects succeed

Have you ever wondered why there are so many failed projects out there, or why whenever you start a project you lose interest in it and just want to move to the next. Well i am here to give you some reasons "WHY" and "HOW" you can avoid this or at least reduce the rate failures.
     Firstly, lets establish the grounds of what a failed project really meant? Most people will agree that, a Software Project is tagged as "FAILED" if:

  • It does not conform to the required specification,
  • It is not cost effective (i.e more resources have been allocated to it than its worth )
  • It is incomplete due to lost of focus or the inability to control its development due to complexity.
  • It took longer time to be delivered and its no more needed or newer technologies have come into play and the used is considered outdated. 
This are a few points that will determine the success of a Software Project, however, the real question is; why does this happen? The simple answer will be, lack of professionalism amongst software developers. With this statement, i mean; software developers should not take on work beyond their scope and competence, software developers should be able to recognise the type of problem and the best suited methodologies and development models for it and finally software developers should be aware of time, cost effectiveness and quality throughout development process.
    With this pointers we are ready to draw out the required attributes in order for Software Projects to succeed.

  1. Accepting projects within your scope and competence: As i said earlier, a lot of developers take on works that are beyond their competence. This can really be a career ender because one will start working on a project and later realize that he does not have the required skills and in order to acquire the skills, a lot of time will be wasted and in turn failure to deliver product when expected. So i really advice, before you start any project analyze all skills required to work on it, and if you do not have at least 80% of those skills, do not accept it.   
  2. Comprehension of a Project: Most developers do not pay attention to clients when they lay down their specifications of what functionalities they need the software to provide. This is a vital requirement because without fully recognising who the client is and understanding what the client wants, the whole project will be in jeopardy because development will head in a total different direction leading to its failure.
  3. Knowing the right methodologies and development models to apply: This is a must for every developer, without knowing the right tool for the job, development can really be time consuming, ineffective and waste of resources which will then lead to the project failing. For instance, know when to reinvent the wheel and know when to reuse. Prototyping and incremental development are a very effective methods to apply to development compared to methods such as the waterfall model because, at any instance of time, one has a working product and this can really be a good in terms product delivery and progress measurement.
  4. Laziness is a Virtue: This was said to me by one of my colleagues, a brilliant mind. Come to think about it, lazy developers tend to be more effective and productive because they are always trying to find ways to minimize workload and this can lead to reuse of already existing tools, finding the most effective yet short approaches to problem solving and reducing the complexity of a system by a large degree.
  5. Finishing a project before starting the next: A lot of us think we are supermen and can handle multiple projects simultaneously. Even though some succeed in this, it is a really bad idea in terms of lack of concentration leading to increase in development time and the inability to complete either project. It is a really good practice to put time constraints on each project, this will help you to concentrate on everything needed for the development of one project without having to worry about the progress of others. This will help you deliver as much products in short period and also reduce task conflict.
By practicing this, you should be able to start a project, keep it alive and deliver the end product in time without losing interest or having any sort of conflicts and distractions.  

Thursday, August 1, 2013

Recursion: Divide and Conquer method

Recursion by a simple definition is the event when a function contains a call to itself. This method of solving problems  as i stated above is the divide and conquer method, we basically take a problem, divide it into smaller segments of it self and solve it mostly using the same algorithm and then combine those solutions back together.

Why is recursion important? 

I have asked and been asked this question a lot of times, and i will try to answer to the best of my knowledge.
First of all, some will say it is easier to use iteration instead of recursion and sometimes it is more effective since recursion can take a lot of memory and time when it gets too deep. But there are some scenarios and problems such as:

  • Iterating through linked list, binary trees, and some other level based data structures.
  • Searching games and exploring possible scenarios such as in chess, checkers etc.
  • Searching files in different locations in a system (i.e recursion can get to the root)

Recursion is your best solution for this type of problems, since it moves from one level to a deeper level till it gets to the root then comes back with or without a result, using a single algorithm that is called over and over again. Writing algorithm for this in an iterative manner can really get complicated.
Of course recursion is not normally easy to comprehend and can be confusing because of the inability to visualize the levels and what happen at each level, but once one understands the concept behind recursion, it is really fun and time saver.

There are two major segments of recursion one needs to know;

  • Termination segment, and
  • Call to itself 

this two have to be considered, when to terminate recursion is very important because if it is not dealt with, it can grow and fill the memory until there are no more space causing the system to terminate and also lose of data.

Examples:

The most popular problem solved recursively is finding the factorial of a number
e.g (5! = 5x4x3x2x1). solution in C:

int factorial(int number){

//termination segment
 if(number == 0 || number ==1){
   return 1;
 }

//recursion: calling itself in a deeper level
 if(number > 1){
   return number * factorial(number - 1)
 }
}

Also another example can be writing a Fibonacci function recursively.
Solution in Python:

def fibonacci(number):

#terminates when number is 1 or 0 returning the number
 if number < 2:
   return number

#compute the fibonacci sequence
 else:
   return (fibonacci(number - 1)+fibonacci(number - 2))

Another example can be searching for an element in an array.
Solution in Java:

// we pass the array, the value to be searched and the// position is returned, initialized to zero
public in search(int array[], int value, int position){
 if(array[position] == value){
   return position;

//as long as we have not reach the end //of array, we keep searching
 } else if(position < array.length){
   search(value, position + 1);
 }

// returning -1 when not found, Note: i used -1 because// index of an array starts from 0.
 return -1;
}


Leave your comments below if you found this materail to be helpful and ideas on what you will love to see in one of my series. Have fun hacking.

Thursday, July 25, 2013

Avoid complexity, simplify your code.

Over the years i have written a bunch of codes that function inside other applications or independently and in all my doings, i keep one thing in mind, simplicity.

There are a lot of people who write complex codes and think by doing so, it makes them look very good, and the fact that others can't read their code makes them superior. Is that true? well i can tell you for sure that a lot of those programmers cannot come to manage, fix or even read the code they wrote 2 years ago. Einstein once said "If you can't explain it to six year old, you don't understand it yourself", this brings us down to a serious series of questions!
     
      1. Do i really know what i am writing?
      2. Can i explain it to a kid and he will understand what i am saying?
      3. Do i know what every line in my code does?

Well if you can answer does questions and they turn out to be positive, then you really know your shit.
Talking about simplicity, are the use of third party softwares/libraries good or bad? this is a very difficult question and has multiple response depending on the scenario.
One, if you need a function from a library to integrate into your source code and that function happens to be one out of say two or three functions, definitely it is a good idea to just use that library instead of trying to reinvent the wheel. But what if a library contains hundreds of features and you happen to need only one feature, is it wise to integrate this whole system into your software and cause complexity and inefficiency because of one single feature? why not just write the feature from scratch and make the job a whole lot easier for future managers of your work, who knows it might be you, and at that point, the failure of one single feature in your system which is likely not what you use will cause you time, energy and productivity.

Another point to this is modular development, i am a fan of modular development and currently writing my thesis on it. What is the idea? simple, break your project into independent pieces that communicate with each other and function as a whole system i.e. each module performs a particular function. Why is this important? well lets take for instance, you have a system that monitors the weather and logs the information to the database and also to an online cloud storage. Now, the easiest modular way to do this, is to break it into modules, one module gathering information, another module logging in a database and another uploading to the cloud. So at this point you have three modules communicating together, if one module fails, lets say the one responsible for uploading online, your system is not a total failure, still it can gather info and store in the database, and all you have to do is to fix the module responsible for upload to the cloud.

Lastly, the idea of Object Oriented development is great, but a lot of developers tend to abuse this paradigm in the sense that, this days you will find an application with a lot of classes which could have been easily written into two small functions. Even though the idea of reuse is good, but if it is not necessary, do not write dormant classes in the hope that there will be need for it in the future, you can simply write it when you need it and avoid the whole complexity.

Well i hope developers will start simplifying their systems and make the job of managing, extension and debugging much more easier to those who will likely work on their codes in the future.

Tuesday, July 9, 2013

The concepts: Hackers, Crackers, Social Engineers DECODED

Over the years i have heard and had a lot of debates on this topics with colleagues and random strangers, truth be told, i am not an expert on this but i pretty much have ideas of all of this topics.
So i am gonna try and decode the actual facts behind this group of people and make references.

First of all lets talk about HACKERS, this subculture emerged from the academia around 1960s from the MITs Tech Model Railroad Club and MIT Artificial Intelligence Laboratory. According to wikipedia, a hacker is someone who loves programming and enjoys playful cleverness, now in this statement it is clear that a hacker loves to explore the unexplored, going to different levels to see how vulnerable a system is and devising a way to make it more secure. On a different level, a hacker can be considered to be someone who explores the limitation of a system and then tries to extend it to ensure a better performance, flexibility and availability of more functionalities. Hackers are not limited to programming, their are a lot of hardware hackers, system security hackers and in a lot of other Engineering and Science fields.
There is no doubt that hackers are the reason we are in the state of technology right now, if we look back to the history of some notable hackers such as Richard Stallman, Donald Knuth, Dennis Ritchie, Paul Graham, Larry Wall, Steve Wozniak (this guy was obsessed with technology, always finding a way to better things, even in the days where a single person cannot afford a computer, he had a dream of making his own computer, he worked hard, tweaked and hacked out the first Apple Computer. This man i refer to as the Hardware Hacker god) e.t.c all this people at the time shared a common goal; they wanted to make their own programs, extend systems, invent new ways of doing things and also showing their cleverness in doing things in an exciting manner and ways no one could ever think is possible. This men are heros in the Hacker/Programmer subculture, they made technology seem like a piece of cake, now our days, hackers are seen as criminals as portrayed by the media, those who break into systems to exploit them and cause damages were as this people are actually not hackers but crackers. This two sets have been confused a lot, hackers have ethics, this days the people we refer to as hacker community is the well known Open Source community.

On the other hand, CRACKERs mostly have almost same skills as HACKERs but different vision, unlike hackers who have ethics and have vision to make better tools and technology, crackers actually exploit those technologies not to better them but to destroy them, using their skills in fraud, causing damages and looking for fame by causing economic disasters. This group of people often referred to as the BLACK Hats are driven by some sort of motivation, mostly against the government and they think the only way they can be heard is through CYBER TERRORISM.

SOCAIL ENGINEERS are another set of frauds, they mind trick people into giving them vital intel such as bank informations and they use those intel to suck people dry, this group also refer to themselves as hackers but actually its just a kind of a shield because i know they do not have any qualities to earn the name.

The media has it wrong about the true hackers and the true hacker subculture, and they use this to implant some kind of ideas in peoples mind that makes them hate hackers, were as the actual enemies wrap themselves by using this term.

I believe from this short note, people will see that hackers are not the bad guys here, if we don't recognize this notable creators, the least we can do is to preserve the name for good. The real hackers are underground working so hard to make the cyber world a better place and are not driven by monetary or material things but are driven by the fun in creation, the fun in hacking, showing off their cleverness, they write tools, make our systems better and extend them all for FREE which in this case not necessary FREE for PRICE but FREE for FREEDOM, having the freedom to use systems, twist it the way you want and modify to your taste. All this privileges are not given by proprietary systems.  

Friday, May 31, 2013

The Art in Programming (TAP)

Programming is an art, even though this discipline falls under sciences and in some places engineering there are many attributes of art that is needed in programming in order to be successful, and this are:

  1. Creativity 
  2. Imagination
  3. Design and,
  4. Expression
These are not all what it takes to be a programmer but part of a bigger list, some others are, critical thinking, problem solving, programming languages skills, analysis and algorithms.
      A lot coders when given a specification to write a software according to that specification, they directly jump into coding as if it is their personal projects, which still if it is its not an excuse.
The good practice of programming is to actually know what you want to achieve at the end of the project, then try to design or sketch your problem or specification in a structural manner, identifying each object or components functionality, its properties, behaviors and relationship with other components and also with its environment. Establishing this grounds will move you a step further to solving your problem and also whatever you do afterwards will not be blind coding. Now after establishing the structure next you need to start coding, but also you need to use a particular development model according to what you are planing to develop, this helps to make a standard which makes the probability of your project failing less.
During development process (Coding) it is important to take note of some very important features:

  • Commenting - This is a very big issue amongst developers, sometimes because of laziness but it is very important in times when you need help from someone in your development or after a long period you decide to go back to an old project i.e i have friends that after 6 months whatever code they have written becomes very difficult for them to read or modify.
  • Use of Patterns - A pattern is an idea that has been developed to help solve a particular reoccurring problems in programming, for instance if you have a collection and you by means want to manipulate its contents, instead of writing complicated and cumbersome for loops and going form index to index, you can instead use an Iterator pattern that makes it very easy and efficient to iterate through a collection.
  • Refactoring - A lot of developers write spagetti code, and unstructured some times making it impossible to know what method goes where, what variable belongs to what or the relationship between two components or objects. Refactoring is just a process of changing the internal structure of a code and still the code behaves the same way, if one makes a habit to refactoring, then you will find it very easy to modify, change, read, debug a particular segment or body of code. Indentation is another very useful aspect of refactoring because it makes your code readable.
  • Testing - this is a very important phenomenon that helps in developing less buggy codes or softwares. Testing should be done in units, components, and system at large and some times good to also invite people to test your work. Test-Driven development is a very efficient way of developing softwares, because at every stage completed you need to test and see if the code segment actually does what it suppose to, in this manner, we reduce the stress of complex debugging, and also develop the right product.
When one takes all this points together and makes it a habit, you will realize that you have become more effective, productive and also make maintenance an easy process.
     I myself have improved my coding skills over the years and have become a better programmer, i can feel it and i have also come to realize that programming its not about just writing a sleek of code that works, but also beautifying the code b well indentation, refactoring and commenting e.t.c

When you take all this into a consideration, you will share your experience with me.
Happy hacking and keep coding!        

Tuesday, April 2, 2013

Programming Language Selection

When you search for the best programming languages on Google you get approximately 81 million results, this is because every programmer want's the best tools to use, but the ironical part is that every tool is the best for a certain job.
There have been ratings a lot on the most used programming languages, even though there are variations from site to site; C, Java, C++, Objective C, C#, PHP, Python, Javascript, Ruby, Visual Basic are on top of the list. One might ask C/C++ have been around for decades and are regarded as old fashion programming languages, why are they still in use in this modern day technologies? This answer is simple but a bit long, all the modern day programming languages revolve around this languages, from the chart below you can see that Java is a derivative from C++ hence from C, Python is a derivative from Perl, Tcl and Smalltalk hence origin can be traced back to C and Fortran, C# is a derivative of Java, delphi and visual basic, hence can be traced back to C, Fortran and Pascal. This shows us that all this languages are derived from ancient languages, but why? why are languages reinvented; because we need specifics, we need to adapt to modern technology we need more solutions to our problem, if a new language is written, there was a need for it and it doesn't come to replace other languages but to serve its own purpose this brings me to a conclusion, every language is most important for someone because he is working on problems that require that specific language, or makes it easier to implement in that language.
Image from www.authenticsociety.com 

    This brings me back to my original purpose of this blog, what language should you use, which is the best. My answer to you is think of the area you are most interested in, for example simple interactive web pages you need HTML, CSS (of course) then you can include Javascript to make it interactive. If is a dynamic web site, PHP, Ruby or Python with SQL good choice, Java EE has proven to be very useful and reliable. Coming down to Mobile apps, depending on the platform native Android app development is done in Java but now we have special ways to write applications on android without the use of Java for Example. SL4A project has provided a way for us to write applications in Javascript, python, lua etc and run them on android even though on the background this languages call Java methods through RPC. Kivy is another framework that is good for Rapid application development, that can be compiled to run on multiple platforms such as android, ios, mac, windows e.t.c , kivy is a python library.

Personally i use multiple languages C, Java, Python, PL/SQL, PHP, Shell etc and i use each when its needed. We all in our careers will use multiple languages but it is good to have a main language and the rest are supplements.

Sunday, March 10, 2013

Real Hackers Hacking.... Called Hacks.

Who is a hacker, what does a real hacker means when he says "i am working on a hack" or "i am hacking" the correct answer to that is; He is solving a problem without using a design pattern or any specific method and in many cases the end point of such program or project is not obvious, this person is creative and have good critical thinking abilities, programming skills and mathematical skills. In this blog i will be talking about hacking in terms of "Programming" which is the traditional usage, but a lot of engineering fields use this term.

According to Eric Raymond the compiler of The New Hackers Dictionary defines a "good hack" as a clever solution to a programming problem and "hacking" is the act of doing it. But this days people refer hackers to be those bad guys who break into bank accounts or send a malicious warm that will sabotage an entire system, but actually what they are referring to is a bunch of "Social Engineers" or "Crackers" as the case may be. 
If we consider the digital world, hackers are the revolutionists, those who take the time, in creating something so beautiful that others enjoy using without even knowing how it came about, and also hackers find pleasure in developing such a world without asking for a price or compensation, but the joy of seeing it work alone is satisfying. History have recorded such hackers who revolutionize the way we live today, people such as John McCarthy, Denise Ritchie, Steve Wozniak, Tim Berners-lee, Richard Stallman, Linus Torvalds e.t.c. This men have work endlessly with or without pay to develop a digital world that we all totally rely on today for our daily activities, and the least we can do in their honor is to preserve the righteous name to only those who follow the ethics and continue where they left off. I am proud to be a hacker, if you are one you should be proud too but don't act in an unworthy manner.