пятница, 13 мая 2016 г.

Минутка поэзии



когда я тоже стану шефом 
я программистов буду чтить 
и над душрй висеть не буду 
как распоследнейшая блядь 

вторник, 12 апреля 2016 г.

Java exersises

Arrays
  •  Specify array that has length n. Input n from command line.Fill array using random values.Find minimum value.
  •  Specify array that has length 10 and fill randomly.Sort array
  • Find number of occurrences of some number in given array of numbers. 
  • Find duplicate number in the following array{1,4,5,1,6,7,8,9,11}


вторник, 5 апреля 2016 г.

Which of SELECT, UPDATE, DELETE, performance is mostly affected by indexes?

I have found answer on this blog:

The number of indexes on a table is the most dominant factor for insert
performance. The more indexes a table has, the slower the execution becomes. The insert statement is the only operation that cannot directly benefit from indexing because it has no where clause.


среда, 30 марта 2016 г.

Test design. Specification based or black box techniques

Here are the list of techniques according to ISTQB:
  • Equivalence partitioning
  • Boundary value analysis
  • Decision tables
  • Use case tests
  • State-based tests
  • Pairwise tests
  • Classification trees
  • Defect-taxonomy tests
  • Error-guessing tests
  • Checklist-based tests
  • Exploratory tests
  • Software attacks
Equivalence partitioning: A black-box test design technique in which test cases are designed to
execute representatives from equivalence partitions. In principle, test cases are designed to cover
each partition at least once.

Boundary value analysis: A black-box test design technique in which test cases are designed based
on boundary values.
boundary value: An input value or output value that is on the edge of an equivalence partition or at
the smallest incremental distance on either side of an edge, such as, for example the minimum or maximum value of a range.

Cause-effect graphing: A black-box test design technique in which test cases are designed from
cause-effect graphs.

Decision table testing: A black-box test design technique in which test cases are designed to execute
the combinations of inputs and/or stimuli (causes) shown in a decision table.

Use case testing: A black-box test design technique in which test cases are designed to execute user
scenarios.

State transition testing: A black-box test design technique in which test cases are designed to execute
valid and invalid state transitions.

Pairwise testing: A black-box test design technique in which test cases are designed to execute all
possible discrete combinations of each pair of input parameters



вторник, 29 марта 2016 г.

High level vs low level test cases

ISTQB Glossary

test design: The process of transforming general testing objectives into tangible test conditions and
test cases.

test design specification: A document specifying the test conditions (coverage items) for a test item,
specifying the detailed test approach, and identifying the associated high-level test cases.
high-level test case: A test case without concrete (implementation-level) values for input data and
expected results. Logical operators are used; instances of the actual values are not yet defined and/or
available.
low-level test case: A test case with concrete (implementation-level) values for input data and
expected results. Logical operators from high-level test cases are replaced by actual values that
correspond to the objectives of the logical operators.

вторник, 1 марта 2016 г.

Наконец-то, я нашла официальное название! Чайка-менеджмент

Чайка-менеджмент (Seagull management) -
Стиль управления, при котором менеджер, внезапно налетев на объект, поднимает много шума, всюду гадит, а затем так же внезапно улетает, оставив после себя полный беспорядок

среда, 24 февраля 2016 г.

Create Array vs ArrayList vs Hashmap

Array vs Arraylist differences

  • Array has fixed size Vs Arraylist has flexible size


One option how to create array and specify values :

int[] myIntArray = new int[]{1,2,3}; // Initialization and values 
String[] myStringArray = new String[]{"a","b","c"}

Second 2 options will give you error "Array constants can only be used in initializers". So please dont use them.
 private int[] myNumbers; 
myNumbers= new int[3]; //Initialization
myNumbers={1,2,3};

int[] myIntArray = new int[3]; 

int[] myIntArray = {1,2,3}; 

ArrayList
ArrayList<Class> myList = new ArrayList<Class>();

вторник, 23 февраля 2016 г.

Java arrays.Specify array by console . Sorting algorithms for arrays Bubble and Selection sort

Specify array by console input:
import java.util.Scanner; // import library
private static Scanner scanner = new Scanner(System.in);
public static int[] getIntegers(int number){
  int[] values = new int[number];
  for (int i=0; i<values.length; i++){
   values[i] = scanner.nextInt();
  }
  return values;
 }
int myIntegers[] = getIntegers(5); //create integer array using method

Sorting algorithms:

Bubble Sort- Ascending

 for(int i = arr.length-1 ; i > 0 ; i--){
     for(int j = 0 ; j < i ; j++){
         
         if( arr[j] > arr[j+1] ){ // descending order   if( arr[j] <arr[j+1] )
             int tmp = arr[j];
             arr[j] = arr[j+1];
             arr[j+1] = tmp;
         }
     }

Selection sort - ascending 
for (int i=0; i <arr.length -1;i++){
  int min_i=i;
  for (int j=i+1;j<arr.length;j++){
   if(arr[j]<arr[min_i]){ // descending order if(arr[j]>arr[min_i])

    min_i=j;
   }
  }
  int temp=arr[i];
  arr[i]=arr[min_i];
  arr[min_i]=temp;
 }

пятница, 12 февраля 2016 г.

Java access modificators

Lets lets about access using trusted source- Oracle documentation

A class may be declared with the modifier public, in which case that class is visible to all classes everywhere.

If a class has no modifier (the default, also known as package-private), it is visible only within its own package

The private modifier specifies that the member can only be accessed in its own class.

The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package

Access Levels
ModifierClassPackageSubclassWorld
publicYYYY
protectedYYYN
no modifierYYNN
privateYNNN



.

Constructor.Getters and setters and how to generate them

Constructor is a special code block which is used to initialized all necessary states of class.
Main things that you should know about constructor:

  • It has to have the same name as class
  • It doesn't have a return type.
  • It is a first thing that runs when you initialize an object
  • In Java every class has a constructor even if you don't specify it
How to generate:
Eclipse:  Source>Generate Constructor using Fields
Idea: Code>Generate>Constructor

Example:
public class BankAccount {
String accountEmail;   //variable
public BankAccount(){ //java constructor
}

Getters - set values to instance variables. Has void type and return nothing
Setters - retrieve values and expose variables. Has type of variable and return variable.

How to generate getters and setters:
Eclipse:  Source>Generate Gettersa and Setters
Idea: Code>Generate>Getters and Setters

Example:
String accountEmail;   //variable  //getter 
public String getAccountEmail() {
return accountEmail;
}

public void setAccountEmail(String accountEmail) { //setter
this.accountEmail = accountEmail;
}



среда, 10 февраля 2016 г.

DDL vs DML

Data Definition Language (DDL) statements are used to define the database structure or schema. 
Some examples:
 1. CREATE - to create objects in the database 
 2. ALTER - alters the structure of the database 
 3. DROP - delete objects from the database 
 4. TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed 
 5. COMMENT - add comments to the data dictionary 
 6. RENAME - rename an object 


Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples: 
1. SELECT - retrieve data from the a database 
 2. INSERT - insert data into a table or UPDATE - updates existing data within a table 
 3. DELETE - deletes all records from a table, the space for the records remain 
 4. MERGE - UPSERT operation (insert or update) 
 5. CALL - call a PL/SQL or Java subprogram 
 6. EXPLAIN PLAN - explain access path to data 
 7. LOCK TABLE - control concurrency

Views vs materialized views

Best explanation I found here 

What is View in database:

Views are logical virtual table created by “select query” but the result is not stored anywhere in the disk and every time we need to fire the query when we need data, so always we get updated or latest data from original tables. Performance of the view depend upon our select query. If we want to improve the performance of view we should avoid to use join statement in our query or if we need multiple joins between table always try to use index based column for joining as we know index based columns are faster than non index based column. View allow to store definition of the query in the database itself.

What is Materialized View in database:

Materialized views are also logical view of our data driven by select query but the result of the query will get stored in the table or disk, also definition of the query will also store in the database .When we see the performance of Materialized view it is better than normal View because the data of materialized view will stored in table and table may be indexed so faster for joining also joining is done at the time of materialized views refresh time so no need to every time fire join statement as in case of view.

Difference between View vs Materialized View in database:Based upon on our understanding of View and Materialized View, Let’s see, some short difference between them :

1) First difference between View and materialized view is that, In Views query result is not stored in the disk or database but Materialized view allow to store query result in disk or table.

2) Another difference between View vs materialized view is that, when we create view using any table, rowid of view is same as original table but in case of Materialized view rowid is different.

3) One more difference between View and materialized view in database is that, In case of View we always get latest data but in case of Materialized view we need to refresh the view for getting latest data.

4) Performance of View is less than Materialized view.

5) This is continuation of first difference between View and Materialized View, In case of view its only the logical view of table no separate copy of table but in case of Materialized view we get physically separate copy of table

6) Last difference between View vs Materialized View is that, In case of Materialized view we need extra trigger or some automatic method so that we can keep MV refreshed, this is not required for views in database.

When to Use View vs Materialized View in SQLMostly in application we use views because they are more feasible, only logical representation of table data no extra space needed. We easily get replica of data and we can perform our operation on that data without affecting actual table data but when we see performance which is crucial for large application they use materialized view where Query Response time matters so Materialized views are used mostly with data ware housing or business intelligence application.

That’s all on difference between View and materialized View in database or SQL. I suggest always prepare this question in good detail and if you can get some hands on practice like creating Views, getting data from Views then try that as well.

вторник, 9 февраля 2016 г.

SQL constrainsts

Constraints are part of a database schema definition.
A constraint is usually associated with a table and is created with a CREATE CONSTRAINT or CREATE ASSERTION SQL statement.
They define certain properties that data in a database must comply with. They can apply to a column, a whole table, more than one table or an entire schema. 
Common kinds of constraints are:
  • not null - each value in a column must not be NULL
  • unique - value(s) in specified column(s) must be unique for each row in a table
  • primary key - value(s) in specified column(s) must be unique for each row in a table and not beNULL; normally each table in a database should have a primary key - it is used to identify individual records
  • foreign key - value(s) in specified column(s) must reference an existing record in another table (via it's primary key or some other unique constraint)
  • check - an expression is specified, which must evaluate to true for constraint to be satisfied
  • default - Specifies a default value for a column


понедельник, 8 февраля 2016 г.

Database ACID Properties. Transactions

The most usefull explanation I've found in this blog from Anvesh Patel

Transactions are tools to achieve the ACID properties.

Database ACID Properties:
ACID properties are very old and important concept of database theory. I know that you can find lots of posts on this topic, but still I would like to start my journey with this topic as one of very important and my favorite theory of Database system.
Database System plays with lots of different types of transactions where all transaction has certain characteristic. This characteristic is known ACID Properties.
ACID Properties take grantee for all database transactions to accomplish all tasks.
Many times interviewers ask this question in an interview that, What is ACID Property in database?
Here I am going to explain with a simple example.
A = Atomicity
C = Consistency
I = Isolation
D = Durability
First, 
Atomicity: means either all or none, for example,
One Application is going to insert 30 records in one block of transaction. During this insertion any serious problem occurs and at this point only 12 records have been processed. In this state transaction is not going to insert only 12 records it will roll back this whole transaction so this will process either all or none.
Second, 
Consistency: means to bring database from one valid state to another.
There should be always defined some data rule, constraint, trigger at database end as well as application end.
Whatever data is going to insert they all should be validated by defining rules and ensure that there are no invalid data is going to insert in database so this way it will manage consistency of the database. In any case running transaction violate rule at that same time entire transaction will be a rollback.
Consistency is a very general term, which demands that the data must meet all validation rules.If rules are not meet the entire transaction must be cancelled and the affected rows rolled back to their pre-transaction state.
Third, 
Isolation: means each transaction is unaware of another transaction.
In one shop seller is selling items very fast and due to this number of items is also decreasing in stocks and at other side one person is also adding new items in stocks.
Here, this both transactions is different and totally unaware of another. These properties ensure that one transaction is not interrupted by another transaction. For database transaction this one of the important properties because any database system is going with lots of concurrent and parallel transaction where Isolation property is very much require and ensure that all transactions is defined under proper isolation level. A different database technology has different type of default Isolation level like,
Oracle has READ_COMMITTED
MySQL has REPETABLE_READ
MSSQL has READ_COMMITTED
PostgreSQL has READ_COMMITTED
DB2 has READ_COMMITTED
Generally READ_COMMITTED Isolation level is most preferable, but many times it’s also required to show READ_UNCOMMITTED data in a data history kind of pages.
Fourth,
Durability: means to keep committed data forever.
Application inserted 30 records in one transaction and this transaction is completed and committed successfully in the database that means this record persist forever in database until and unless it’s not deleted by any application users or database users.
ACID Property is one important concept of database system.


пятница, 5 февраля 2016 г.

Type of Joins. Inner vs Outer join

We have 2 tables. Lets practice!
Table 1                                   
ID 
Name
1
Dan
2
Bob
3
Elly

Table 2
ID 
Job position
2
QA
3
Dev
4
Trainee


Example: SELECT * FROM table1 INNER JOIN table2 on table1.ID=table2.ID
Result:
ID 
Name
ID 
Job position
2
Bob
2
QA
3
Elly
3
Dev



Example: SELECT * FROM table1 LEFT JOIN table2 on table1.ID=table2.ID
Result:
ID 
Name
ID 
Job position
1
Dan
Null
Null
2
Bob
2
QA
3
Elly
3
Dev

Example: SELECT * FROM table1 RIGHT JOIN table2 on table1.ID=table2.ID
Result:
ID 
Name
ID 
Job position
2
Bob
2
QA
3
Elly
3
Dev
Null
Null
4
Trainee


Example: SELECT * FROM table1, table2  
Result will be always Count(*) from table1 multiply by count(*) from table 2,
so in our example it is 3*3=9


ID 
Name
ID 
Job position
1
Dan
2
QA
1
Dan
3
Dev
1
Dan
4
Trainee
2
Bob
2
QA
2
Bob
3
Dev
2
Bob
4
Trainee
3
Elly
2
QA
3
Elly
3
Dev
3
Elly
4
Trainee