Monday, 26 August 2013

what MCV design patterns and entity bean ?

Introduction

MVC is a design pattern (a general design solution for problem solving) widely used in software design. 
MVC Stands for Model Controller View. 
MVC is achieved through 3 components: 
  • the model contains the data and provides methods for accessing them;
  • The view displays the data in the model;
  • the controller receives the commands(usually through the view) and implement them by changing the status of the other two components

This pattern ensures the division between business logic(managed by the model) and user interface (run by and view controller). 
Wanting to apply this pattern to the Java EE, you can use the following Java technologies applied to various components of the pattern. 
Model: This component can be implemented through the entity bean and session bean Controller: It can be implemented by the servlet. View: The latter through jsp and / or jsf. 
In general terms, entity objects encapsulate the business policy and data for
  • the logical structure of the business, such as product lines, departments, sales, and regions
  • business documents, such as invoices, change orders, and service requests
  • physical items, such as warehouses, employees, and equipment

The entity bean will be an abstraction and then to represent the data, the session bean can perform operations on the entity, the servlet will collect input from jsp (you) to make requests to the session bean and communicate results to jsp and so on. 


Related issue :


Java Web Services #Interview Questions and Answers ?

Q. What are the different application integration styles?

A. There are a number of different integration styles like

1. Shared database
2. batch file transfer
3. Invoking remote procedures (RPC)
4. Exchanging asynchronous messages over a message oriented middle-ware (MOM).

What is functional/declarative programming versus imperative programming?

Imperative Programming 

is what most professional programmers use in their day-to-day jobs.
It's the name given to languages like C, C++, Java, COBOL, etc. In imperative programming, you tell the computer what to do. "Computer, add x and y," or "Computer, slap a dialog box onto the screen." And (usually) the computer goes and does it. This is where most of us spend our lives, in looping structures and if-then-else statements and the like.

Functional Programming

it seeks to describe what you want done rather than specify how you want something done..
It's probably best understood in contrast to imperative programming. 

What is HTTP methods ? #web

  • Options Get information about how the server allows to communicate with.
  • GET Retrieve a resource.
  • POST Create a new resource.
  • PUT Send data to the server.
  • DELETE Delete an existing resource.
  • TRACE Return the request headers sent by the client.

Thursday, 22 August 2013

How To Check If Two Or More Rows Have The Same Field Value ?


you want to filter details from db.


The Problem :


I want to select the first row with the last name "usama" and then I want to skip the next row which has the same field "usama".

Sunday, 18 August 2013

Read file and convert it to Array list #java

here is an simple demo of how to read a file and insert it's data into array list separated by new lines.


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class FileArrayProvider {

    public String[] readLines(String filename) throws IOException {
        FileReader fileReader = new FileReader(filename);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        List<String> lines = new ArrayList<String>();
        String line = null;
        while ((line = bufferedReader.readLine()) != null) {
            lines.add(line);
        }
        bufferedReader.close();
        return lines.toArray(new String[lines.size()]);
    }
}

Monday, 12 August 2013

how to start PHP / Mysql Connection

here is a simple connection between php and mysql. in 5 steps .


Step 1
create the db 

CREATE DATABASE `mydb`;
USE `mydb`;
CREATE TABLE `employee` (
   `id` int UNIQUE NOT NULL AUTO_INCREMENT,
   `first_name` varchar(40),
   `last_name` varchar(50),
   PRIMARY KEY(id)
);
INSERT INTO cars VALUES('usama','saad');
INSERT INTO cars VALUES('hasan','hamaky');
INSERT INTO cars VALUES('noor','sobhy');