When you know a thing, to hold that you know it, and when you do not know a thing, to allow that you do not know it - this is knowledge. -Confucius-

Tuesday, August 6, 2013

Encapsulation - A simple approach to OOP

We wrote a class. And some other developers will use it. And somehow we want to change our class because others use it for their purposes in a way that we don't want to be. It is like there is a variable in our class and we don't want it to be less than zero , but the developers who use our class can easily change it to any value because lack of our code quality. Take a look at this code. class BadClass { ...

Wednesday, July 31, 2013

Test Driven Development example - Part 4 (Simple Unit Testing for Java with NetBeans)

Lets code the all tests in the to do list. (this should be done one by, for the tutorial i used it just to show how to do it) The FibonacciTest.java file will be look like package tdd; import org.junit.Test; import static org.junit.Assert.*; public class FibonacciTest { @Test public void testGetFibonacci_0() { int x = 0; Fibonacci instance = new Fibonacci(); int expResult =...

Test Driven Development example - Part 3 (Simple Unit Testing for Java with NetBeans)

Our 2nd task in the to do list is, [2] getFibonacci(1) ==> 1 now we have a passing code. we have to make it fail. to that we can ask it the 1st Fibonacci number. change the FibonacciTest.java file as below. Here i have introduced a new method for check the result for input 1. Then it will be easy to identify what is going on. package tdd; import org.junit.Test; import static org.junit.Assert.*; public...

Test Driven Development example - Part 2 (Simple Unit Testing for Java with NetBeans)

After following the  previous work now we are good to code :) First of all lets edit the Fibonacci.java file. lets add a new method. package tdd; public class Fibonacci { public void getFibonacci(int x) { } } Now edit the FibonacciTest.java file like below. package tdd; import org.junit.Test; import static org.junit.Assert.*; public class FibonacciTest { public FibonacciTest() { } ...

Saturday, July 20, 2013

Test Driven Development example (Getting started)

There was a workshop in our university to give us an introduction about TDD by OrangeHRM. The followings are based on those experience.  You can read about TDD here . Simply the TDD coding process has 3 rules.(for more details refer this)  1) You are not allowed to write any production code unless it is to make a failing unit test pass.    2) You are not allowed to write any more of a unit...

Tuesday, July 16, 2013

Create a Chrome extenstion to highlight paragraphs on user click event

I started to create a Google chrome extension to highlight the web content. As the first step i was able to create this extension which highlight the whole "p" tag when a user click on it. There are 4 file. (manifest.json, tabcolor.js ,color.js,popup.html (to call the js files,but not necessary,there are other ways )) the manifest.json file looks like { "name": " page color 2.", "version": "1.0", "permissions":...

Thursday, April 4, 2013

SQL TRIGGERs

When we were doing a database project we faced to a little problem when we try to check some constraints on a table on insert , update, delete operations. There is a table called 'infos' and there is a column called age. The values of the age should be greater than 0. So to check that constraint we used SQL CHECK constrain. It appears to be accepted by mySQL as a valid one but when inserts happens we noticed that...