Wednesday, May 10, 2017

More About Git .. ..

Different Types of Color Codes Used in Git

If you have worked in Git based system like github or bitbucket. You may have seen your code is highlighted in different colors within in your commits. I tried to cover what these all colors mean. In good old days there was only git command line tool. Imagine the difficulty. Here is  a summary of what these colors mean git

Though there are differeGnt git based tools. All seems to be using a color scheme similar to above. Following are some examples.

In Git Hub

Supporting tools for Git in Windows

Git was originally a command line tool. But with the evolution of GUI based operating systems, Many GUI tools for git also evolved.

Git Bash and Git GUI

These are from original git developers. Git GUI is a simple tool and Git Bash is a terminal emulator of git enabled.


Source Tree

Source tree is the official GUI of BitBucket. This is a paid software with lots of features than Git GUI.

Git Kraken

Not to be confused with the Kraken in Pirates of Carribean, Git Kraken is more advanced software for managing Git repositories in Windows, Linux and Mac OS. There is a free and paid version. Git Kraken's UI is awesome.

Tuesday, April 25, 2017

Structural Code Coverage For Java With NetBeans

Task
Structural Code Coverage
Tools / Software
JaCoCo, NetBeans, JUnit
Download Link
plugins.netbeans.org/plugin/48750/tikione-jacocoverage
Prerequisites
Netbeans IDE, JUnit libraries, Knowledge of unit testing, OOP and JUnit.
Description
TikiOne JaCoCoverage is a plugin for NetBeans IDE which provides JaCoCo code coverage.

Installation

Go to the download link provided in the above table and download the plugin for your already installed NetBeans version. Extract the downloaded archive to a folder. Open NetBeans IDE. From Tools menu select Plugins. From the Plugins window go to Downloaded tab and add all the 4 .nbm files from the extracted folder and finally click Install. After accepting license agreements IDE will prompt you to restart. Select restart. IDE will restart.

What is Structural Code Coverage?

Structural Code Coverage is a measurement of no. of lines / blocks / segments executed for a given test case.

JaCoCo

JaCoCo is an open source toolkit for measuring and reporting for Java Code Coverage. There are many implementations of JaCoCo (Jenkins JaCoCo, SonarQube JaCoCo etc.). Some distinct features of JaCoCo are,
  • ·         Provides line and branch coverage.
  • ·         We can save the output to a file.
  • ·         Supports recent Java versions.
  • ·         Inspects Java byte code.
  • ·         Easy to execute code coverage tests.
  • ·         Supports many popular IDEs and tools (NetBeans, Eclipse, SonarCube, Jenkins etc.)

There are few disadvantages of JaCoCo and structural code coverage,

  • ·         Code coverage does not reflects effective testing. There are more sophisticated ways for testing in the code level.
  • ·         JaCoCo needs pre written JUnit unit test cases to perform code coverage tests. This is an overhead.
  • ·         Core implementation of JaCoCo has not been updated since long time. There are more modern code coverage tools like CheckMarx used in industrial levels.
Structural Code Coverage Using JaCoCo Plugin for NetBeans IDE
Create an empty Java project. Add a simple class and add a method with some if-else conditions. So we can test branch coverage too. Now create a unit test case for this method using JUnit. After writing the JUnit class check whether you are getting some output from the JUnit test case.

Now left click on your NetBeans project and click Test with JaCoCoverage. Your source code will be highlighted and test result will be opened in your web browser as follows.

Green colored are the code lines which were covered during the test and red colored lines are the code lines which were not covered. Yellow colored lines are lines which were partially covered. Refer line no. 17. Only the true part of the branch has been covered. Yellow colored diamond shows this situation. In line no. 20, neither of atomic conditional statements are not covered. Red colored diamond reflects this situation.

In opened web page you can see a summary of the test. The above gives information about total no. of lines, conditional statements and their covered percentage. Try above unit test with different input values to get different results.

Reviews

  • ·         The plugin discussed in this article is a very nice tool to check code coverage in the Eclipse IDE. I did not talk about how to use it in the Eclipse IDE, because it is very intuitive and very easy to use. - Dr. Song Li – The Code Project
  • ·         Idea is pretty simple. Application is started with a code coverage tool is attached to it, any test are executed and results are gathered.  - Lyudmil Latinov – Automation Rhapsody


Group Details

Batch: Software Engineering (2015), Weekend

IT 15 0172 84
M.M.M.S. Rupasinghe
IT 15 0190 28
L.T. Marasinghe
IT 15 0331 92
T.T.C. Phillips




Monday, March 20, 2017

Do We Really Need Git OR Version Controlling ?

If you are onto software development, you may have heard lot about GIT and some words like Merge, Branch, Commit, It's my branch ! like things. As I belive theoritically learning git concepts is difficult. I will try to explain as much as possible with practical situations.

git vs version controlling ?

Java is a programming language. Likewise git is a version controlling system. There are different other programming languages than Java like PHP, JavaScript etc. Similarly there are other version controlling systems other than git like SVN, Apache Subversion, Rational Clear Case etc.

Why git ?

Git is one of most popular version controlling system or VCS. You may have heard of github.com. It's built upon git concepts. Git is used from startup to larger enterprises and from home to universities where somekind of software development process is happening.

As a university student, How git will help me ?

Let's move on. I have three friends. Movinda, Supun and Philips. We are working on a modern single page website. I'm designing the navigation bar and header. Movinda designs the products section. Philips designs the about us section and Supun designs the contact us form. 

As you know, In a single page website all sections are bundled together in a single HTML file. Therefore all of us must do our work in a single file.

Traditional approaches

  • Wait each one to complete their work. Supun start after Movinda finishes. TIME CONSUMING. One must depend on another.
  • Do parallely in our own computers and then copy and paste our code to a final document - DIFFICULT TO TEST, CODE BECOMES UNREADABLE

Solution !

  • We must be able to work parallaly in the same file.
  • We must be able to undo any changes done
  • Copying and pasting of each members code must happen automatically.
  • Any member must be able to see what other people have done to the page without intefering his or her own work
  • System must acknowledges each ones contribution to the project (Without commenting - Edited by Lanil like that)
That't where the git comes to the game. Git can make your life easy !. I will write more on Git. Keep in touch.

Friday, March 17, 2017

Why Should I Use AngularJS?

There are lot of buzz going about AngularJS.  This article for rookies who wants to know what is AngularJS and why should we use it.

AngularJS is a JavaScript framework backed by Google.

What is a framework now ?


Framework is a set of tools where you can do specific tasks easier than generic tools programming languages. Some examples are

  • Bootstrap frameworks allows you to design beautiful web applications without writing a single CSS statement. 
  • A simple API can be built using ExpressJS framework for NodeJS without using any complex code.
  • Hibernate framework simplifies the trade offs between OOP and relation database

So the AngularJS is also a JavaScript framework. That means we can do many things easily using JavaScript and AngularJS.

What we are going to do ?

I have a simple html page. There I have a text box and a paragraph. What I want to do is, I want to appear the text in the text box in the paragraph. This should be done realtime. i.e: When user types something it should be on paragraph too.

Here is the HTML code

This is how it is done in JavaScript - Option 1

I have added few lines of Javascript after the body tag.


This is how it is done in jQuery(Another JS library) - Option 2

Here you must remove the onchange() attribute in text box. Somewhat simpler than raw JavaScript. Only one line inside the function.


Finally using AngularJS - Option 3

Here we do not have any Scripts or JavaScript functions. But I have added some extra attributes starting with ng-* to the text box and paragraph. Examine carefully the original and below. This does the same as above two methods. Did I wrote any Scripts ?? NO !!!. Saves time and LOCs. 

Wednesday, March 1, 2017

Second Year Final Project


Those days second year students had to do a project for a client in their final semester. The module name was Information Technology Project. From the begining we had make proposals, specifications, schedules and everything needed to be documented. Project's flow went as follows. We developed a system to manage construction project and our client was a medium sized contractor.

  1. Submitting project charter
  2. A presentation introducing the client and the project
  3. Submitting project proposal
  4. Submitting systems requirements specification (SRS)
  5. Presenting the prototype
  6. Presenting the final product
  7. Submitting the project report

The project went for about 3 months and was hugely successful. All team members had good results for the project. Though it was a group project all members were individually assessed. 

Our Team, from left: Bhathiya, Milinda, Movinda
Upeksha, Gajanayake, Pasan and Me.
Most of our collegues developed standalone Java applications. But we were different. We built an advanced web application using PHP. We along used JavaScript, jQuery, Bootstrap for the development and underlying database was made using mySQL. Even we were in second year we used advanced backend PHP frameworks for the development. Our system is modern looking, accessible from anything from anywhere and userfriendly.

Home Page


A screenshot from machine hiring module.

Monday, February 13, 2017

SLIIT Codefest 2013

About three or fouryears after SLIIT started a brand new IT competition series called SLIIT Codefest. This competition was opened for any school and university students.

SLIIT Codefest 2013

Same team participated for Codefest competition which was held at 2013. It was also a nice experience. As usual we were finalists.

Our team at SLIIT Codefest 2013



Scrolling The Code Lines

My First Days at SLIIT

My Self at SLIIT in 2009. Today staff canteen is situated here.
Those days there was a canteen for students here.
In 2009, SLIIT celebrated it's 10th anniversary. Commemorating that there was a big event for about week at SLIIT. There was also a software competition for school students. The name of this competition was Achievers. My school; St. Anne's College was invited to this event and 3 groups from our school including my team got selected for the final rounds. Then I was at grade 9. Those days we built little programs using Visual Basic 6.0. There were two other members; Danushka (Now studying for engineering degree at University of Peradeniya) and Kalindu (Also studying at University of Moratuwa) who were really fluent in programming.

It was 2009 August and we were there at SLIIT for few days. SLIIT was a really different place for us. On the final day of event there was a musical show. I remember Dushyanth Weeraman singing there. Musical show was also sponsored by Rollo chocolate brand of Ceylon Biscuits Limited. Even today you can see in the two pillars which are infront of SLIIT's main entrance, there are some stickers on those pillars depicting Let's Do It. This was stickered for that event. Let's Do It is the marketing slogan of Rollo chocolate.

Our Team. Myself at the middle. Danushka at left.
Kalindu at Right.
In 2009, 10 years old young university SLIIT was at its golden days. I remember the place where today the engineering faculty is situated was a big mud pit and places where the CAHM and new common area and tennis courts situated all were covered with trees.

 After spending unforgettable week at SLIIT we returned. We were sad because we could not win a prize.