Monday, January 23, 2012

Awad Khalil invited you to Dropbox

Awad Khalil wants you to try Dropbox! Dropbox lets you bring all your photos, docs and videos with you anywhere and share them easily.

Get started here.

- The Dropbox Team

Monday, October 31, 2011

scjp question and answer by photos











               
                          






                   









                   




               







                  








                        











                       




9.  b





10. a,c,f









                                  

Thursday, October 27, 2011

Creational Patterns




All of the creational patterns deal with the best way to create
instances of objects. This is important because your program should not
depend on how objects are created and arranged. In Java, of course, the
simplest way to create an instance of an object is by using the new operator.
Fred = new Fred(); //instance of Fred class
However, this really amounts to hard coding, depending on how you
create the object within your program. In many cases, the exact nature of the
object that is created could vary with the needs of the program and
abstracting the creation process into a special "creator" class can make your
program more flexible and general.
The Factory Method provides a simple decision making class that
returns one of several possible subclasses of an abstract base class depending
on the data that are provided.
The Abstract Factory Method provides an interface to create and
return one of several families of related objects.
The Builder Pattern separates the construction of a complex object
from its representation, so that several different representations can be created
depending on the needs of the program.
The Prototype Pattern starts with an initialized and instantiated
class and copies or clones it to make new instances rather than creating new
instances.
The Singleton Pattern is a class of which there can be no more than
one instance. It provides a single global point of access to that instance.


--
Posted By م /عوض خليل سيد to Engineering lessons at 10/27/2011 05:23:00 PM



--
Eng: Awad Khalil Sayed
Team leader
Mobile:+20104940612

Design Patterns definition




We all talk about the way we do things in our everyday work,
hobbies and home life and recognize repeating patterns all the time.
  •  Sticky buns are like dinner rolls, but I add brown sugar and nut filling to
them.
  •  Her front garden is like mine, but, in mine I use astilbe.
  •  This end table is constructed like that one, but in this one, the doors
replace drawers.
We see the same thing in programming, when we tell a colleague
how we accomplished a tricky bit of programming so he doesn't have to
recreate it from scratch. We simply recognize effective ways for objects to
communicate while maintaining their own separate existences.
Some useful definitions of design patterns have emerged as the
literature in his field has expanded:
  • Design patterns are recurring solutions to design problems you see over
et. al., 1998).

  • Design patterns constitute a set of rules describing how to accomplish
certain tasks in the realm of software development." (Pree, 1994)
  • Design patterns focus more on reuse of recurring architectural design
themes, while frameworks focus on detailed design… and
implementation." (Coplien & Schmidt, 1995).
  • A pattern addresses a recurring design problem that arises in specific
design situations and presents a solution to it" (Buschmann, et. al. 1996)
  • Patterns identify and specify abstractions that are above the level of
single classes and instances, or of components." (Gamma, et al., 1993)
But while it is helpful to draw analogies to architecture, cabinet
making and logic, design patterns are not just about the design of objects, but
about the communication between objects. In fact, we sometimes think of
them as communication patterns. It is the design of simple, but elegant,
methods of communication that makes many design patterns so important.
Design patterns can exist at many levels from very low level specific
solutions to broadly generalized system issues. There are now in fact
hundreds of patterns in the literature. They have been discussed in articles
and at conferences of all levels of granularity. Some are examples which have
wide applicability and a few (Kurata, 1998) solve but a single problem.
It has become apparent that you don't just write a design pattern off
the top of your head. In fact, most such patterns are discovered rather than
written. The process of looking for these patterns is called "pattern mining,"
and is worthy of a book of its own.
The 23 design patterns selected for inclusion in the original Design
Patterns book were ones which had several known applications and which
were on a middle level of generality, where they could easily cross
application areas and encompass several objects.
The authors divided these patterns into three types creational,
structural and behavioral.
  • Creational patterns are ones that create objects for you, rather than
having you instantiate objects directly. This gives your program more
flexibility in deciding which objects need to be created for a given case.
  •  Structural patterns help you compose groups of objects into larger
structures, such as complex user interfaces or accounting data.

  •  Behavioral patterns help you define the communication between objects
in your system and how the flow is controlled in a complex program.
We'll be looking at Java versions of these patterns in the chapters that
follow.


--
Posted By م /عوض خليل سيد to Engineering lessons at 10/27/2011 05:20:00 PM



--
Eng: Awad Khalil Sayed
Team leader
Mobile:+20104940612

What’s a Mapplet?

Mapplets are small web applications that run within Google Maps. They are a
type of Google Gadget—the framework that allows developers to create small
web applications that can run within iGoogle, Google Maps, Orkut, or any web
page outside Google. Mapplets use the basic concepts and APIs of Google
Gadgets, though they are specifically used within the Google Maps realm.
In its basic form, a Mapplet is an XML file that contains the HTML and
JavaScript that make up your application. Mapplets have two components:
?? A web application that is displayed on the Google Maps site at
http://maps.google.com. This application is typically displayed in the lowerleft
corner of the page on http://maps.google.com.
?? JavaScript that lets you control the map on http://maps.google.com, retrieve
external data, or even store and retrieve user preferences.
After you create your Mapplet, it's up to you to host the Mapplet XML file
containing your HTML and JavaScript. When a user installs your Mapplet,
Google will grab the Mapplet XML file from your server and display it within an
<iframe> element on http://maps.google.com. (An <iframe> is an HTML element
that is used to embed HTML from another web site in a web page.) In this case,
Google uses an <iframe> element to embed your Mapplet in
http://maps.google.com.
Google will cache your Mapplet source and serve it from its own servers at
http://gmodules.com. This is done for a few reasons:
?? To restrict your Mapplet's JavaScript from doing anything harmful such as
accessing a user's cookies on http://maps.google.com
?? To reduce the load on your site from the potential high number of users you'll
have
You'll learn more about how to create Mapplets in this chapter, but before you
do, let's take a look at a live Mapplet. Open your browser to
http://maps.google.com/. Click the My Maps tab, and you will see a list of
Featured Content along with any maps you have created. Select the one about gas
 prices, and you'll see a Mapplet in action. Figure 1-1 shows the Gas Prices from
GasBuddy.com Mapplet. This Mapplet consists of the application, at the bottom
of the left column, and all the map interaction. If the Gas Prices Mapplet is
available in your list of featured Mapplets, give it try—enter your ZIP/postal
code in the search box, and see what the gas prices are in your area.

Monday, October 24, 2011

What Is a JSP Page?

A JSP page is a text document that contains two types of text: static data, which can be expressed
in any text-based format (such as HTML, SVG,WML, and XML), and JSP elements, which
construct dynamic content.
The recommended file extension for the source file of a JSP page is .jsp. The page can be
composed of a top file that includes other files that contain either a complete JSP page or a
fragment of a JSP page. The recommended extension for the source file of a fragment of a JSP
page is .jspf.
The JSP elements in a JSP page can be expressed in two syntaxes, standard and XML, though
any given file can use only one syntax. A JSP page in XML syntax is an XML document and can
be manipulated by tools and APIs for XML documents. This chapter and Chapters Chapter 7,
“JavaServer Pages Standard Tag Library,” through Chapter 9, “Scripting in JSP Pages,”
document only the standard syntax. The XML syntax is covered in Chapter 6, “JavaServer Pages
Documents.”

The source code for this example is in the tut-install/javaeetutorial5/examples/web/date/
directory. The JSP page, index.jsp, appears below; it is a typical mixture of static HTML
markup and JSP elements. If you have developed web pages, you are probably familiar with the
HTML document structure statements (<head>, <body>, and so on) and the HTML statements
that create a form (<form>) and a menu (<select>).
The lines in bold in the example code contain the following types of JSP constructs:
■ A page directive (<%@page ... %>) sets the content type returned by the page.
■ Tag library directives (<%@taglib ... %>) import custom tag libraries.
■ jsp:useBean is a standard element that creates an object containing a collection of locales
and initializes an identifier that points to that object.
■ JSP expression language expressions (${ }) retrieve the value of object properties. The
values are used to set custom tag attribute values and create dynamic content.
■ Custom tags (see Chapter 8, “Custom Tags in JSP Pages”) set a variable (c:set), iterate over
a collection of locale names (c:forEach), and conditionally insert HTML text into the
response (c:if, c:choose, c:when, c:otherwise).
■ jsp:setProperty is another standard element that sets the value of an object property.
■ A function (f:equals) tests the equality of an attribute and the current item of a collection.
(A built-in == operator is usually used to test equality.)
Here is the JSP page:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/cor"
prefix="c" %>
<%@ taglib uri="/functions" prefix="f" %>
<html>
<head><title>Localized Dates</title></head>
<body bgcolor="white">
<jsp:useBean id="locales" scope="application"
class="mypkg.MyLocales"/>
<form name="localeForm" action="index.jsp" method="post">
<c:set var="selectedLocaleString" value="${param.locale}" />
<c:set var="selectedFlag"
value="${!empty selectedLocaleString}" />
<b>Locale:</b>
<select name=locale>
<c:forEach var="localeString" items="${locales.localeNames}" >
<c:choose>
<c:when test="${selectedFlag}">
<c:choose>
<c:when
test="${f:equals(selectedLocaleString, localeString)}" >
<option selected>${localeString}</option>
</c:when>
<c:otherwise>
<option>${localeString}</option>
</c:otherwise>
</c:choose>
</c:when>
<c:otherwise>
<option>${localeString}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>
<input type="submit" name="Submit" value="Get Date">
</form>
<c:if test="${selectedFlag}" >
<jsp:setProperty name="locales"
property="selectedLocaleString"
value="${selectedLocaleString}" />
<jsp:useBean id="date" class="mypkg.MyDate"/>
<jsp:setProperty name="date" property="locale"
value="${locales.selectedLocale}"/>
<b>Date: </b>${date.date}</c:if>
</body>
</html>

To deploy the date application withNetBeans IDE, follow these steps:
1. Start the Application Server.
2. InNetBeans IDE, select File→Open Project.
3. In the Open Project dialog, navigate to:
tut-install/javaeetutorial5/examples/web/
4. Select the date folder.
5. Select the Open asMain Project check box.
6. Click Open Project.
7. In the Projects tab, right-click the date project, and select Undeploy andDeploy.
To deploy the date application with the Ant tool, follow these steps:
1. In a terminal window, go to tut-install/javaeetutorial5/examples/web/date/.
2. Type ant. This command will spawn any necessary compilations, copy files to the
tut-install/javaeetutorial5/examples/web/date/build/ directory, and create aWAR
file.
3. Start the Application Server.
4. Type ant deploy.
To run the example, do the following:
1. Set the character encoding in your browser to UTF-8.
2. Open your browser to http://localhost:8080/date.
3. You will see a combo box whose entries are locales. Select a locale and click GetDate. You
will see the date expressed in a manner appropriate for that locale.
Some of the characters might not display properly if you don’t have the appropriate language
files installed on your machine. Consult the user guide or online help for your operating system
to determine how you can install these language files.

What Is Ajax?

What Is Ajax?

Ajax stands for Asynchronous Javascript And XML. Although strictly speaking Ajax itself is not a technology, it mixes well-known programming techniques in an uncommon way to enable web developers to build Internet applications with much more appealing user interfaces than those to which we have become accustomed.
When using popular desktop applications, we expect the results of our work to be made available immediately, without fuss, and without us having to wait for the whole screen to be redrawn by the program. While using a spreadsheet such as Excel, for instance, we expect the changes we make in one cell to propagate immediately through the neighboring cells while we continue to type, scroll the page, or use the mouse.
Unfortunately, this sort of interaction has seldom been available to users of web-based applications. Much more common is the experience of entering data into form fields, clicking on a button or link, and then sitting back while the page slowly reloads to exhibit the results of the request. In addition, we often find that the majority of the reloaded page consists of elements that are identical to those of the previous page and that have therefore been reloaded unnecessarily; background images, logos, and menus are frequent offenders.
Ajax promises us a solution to this problem. By working as an extra layer between the user's browser and the web server, Ajax handles server communications in the background, submitting server requests and processing the returned data. The results may then be integrated seamlessly into the page being viewed, without that page needing to be refreshed or a new one loaded.
In Ajax applications, such server requests are not necessarily synchronized with user actions such as clicking on buttons or links. A well-written Ajax application may already have asked of the server, and received, the data required by the userperhaps before the user even knew she wanted it. This is the meaning of the asynchronous part of the Ajax acronym.
The parts of an Ajax application that happen "under the hood" of the user's browser, such as sending server queries and dealing with the returned data, are written in JavaScript, and XML is an increasingly popular means of coding and transferring formatted information used by Ajax to efficiently transfer data between server and client.
We'll look at all these techniques, and how they can be made to work together, as we work through the lessons.