Showing posts with label Approaches.. Show all posts
Showing posts with label Approaches.. Show all posts

Sunday, May 27, 2012

Java: Why JavaBeans?

Ok dears here is a short description about Java Beans as there is a confusion of using it as commented on blog "JavaBean enhancements in Java 7"

The official definition of a bean, as given in the JavaBeans specification, is:
"A bean is a reusable software component based on Sun's JavaBeans specification that can be manipulated visually in a builder tool."
Once you implement a bean, others can use it in a builder environment (such as NetBeans). Instead of having to write tedious code, they can simply drop your bean into a GUI form and customize it with dialog boxes.

Note:
------------
I'd like to address a common confusion before going any further: The JavaBeans that we discuss in this chapter have little in common with Enterprise JavaBeans (EJB). Enterprise JavaBeans are server-side components with support for transactions, persistence, replication, and security. At a very basic level, they too are components that can be manipulated in builder tools. However, the Enterprise JavaBeans technology is quite a bit more complex than the "Standard Edition" JavaBeans technology.

That does not mean that standard JavaBeans components are limited to client-side programming. Web technologies such as JavaServer Faces (JSF) and JavaServer Pages (JSP) rely heavily on the JavaBeans component model.

Why Beans?
----------------
Programmers with experience in Visual Basic will immediately know why beans are so important. Programmers coming from an environment in which the tradition is to "roll your own" for everything often find it hard to believe that Visual Basic is one of the most successful examples of reusable object technology. For those who have never worked with Visual Basic, here, in a nutshell, is how you build a Visual Basic application:
  1. You build the interface by dropping components (called controls in Visual Basic) onto a form window.

  2. Through property inspectors, you set properties of the components such as height, color, or other behavior.

  3. The property inspectors also list the events to which components can react. Some events can be hooked up through dialog boxes. For other events, you write short snippets of event handling code.

I do not want to imply that Visual Basic is a good solution for every problem. It is clearly optimized for a particular kind of problem—UI-intensive Windows programs. The JavaBeans technology was invented to make Java technology competitive in this arena. It enables vendors to create Visual Basic-style development environments. These environments make it possible to build user interfaces with a minimum of programming.


Saturday, April 21, 2012

Architecture: Modeling & Designing Software Projects Architecture

When I model and design the architecture of software project, first thing I consider is what is the software project type?

My experience in this field of projects architecture has taught me that most applications fails into seven software types, each type has its own technology's, communication patterns, architectural patterns and design steps.

The software categories are:

1. Object oriented Software:
The object-oriented design uses the concepts of information hiding, classes, and inheritance. This results in the design of a sequential object-oriented software architecture, which would be implemented as a sequential program with one thread of control.
2. Client / Server Software.
In these systems, a client is a requester of services and a server is a provider of services. Typical servers are file servers, database servers, and line printer servers. Client/server architectures are based on client/service architectural patterns, the simplest of which consists of one service and multiple clients. This pattern has several variations, which will be described next. In addition, certain decisions need to be considered about the design of client/server architectures, such as whether the server should be designed as a sequential or concurrent subsystem, what architectural structure patterns to use for the design of the client/server architecture, and what architectural communication patterns to use for interaction between the clients and the services.

Also differentiates between a server and a service. A server is a hardware/ software system that provides one or more services for multiple clients. A service in a client/server system is an application software component that fulfills the needs of multiple clients. Because services execute on servers, there is sometimes confusion between the two terms, and the two terms are sometimes used interchangeably. Sometimes, a server will support just one service or perhaps more than one; on the other hand, a large service might span more than one server node. In client/server systems, the service executes on a fixed server node(s) and the client has a fixed connection to the server.
3. Service-Oriented Architecture.
SOA is a distributed software architecture that consists of multiple autonomous services. The services are distributed such that they can execute on different nodes with different service providers. With a SOA, the goal is to develop software applications that are composed of distributed services, such that individual services can execute on different platforms and be implemented in different languages. Standard protocols are provided to allow services to communicate with each other and to exchange information. In order to allow applications to discover and communicate with services, each service has a service description; the service description defines the name of the service, the location of the service, and its data exchange requirements.

A service provider supports services used by multiple clients. Usually, a client will sign up for a service provided by a service provider, such as an Internet, email, or Voice over Internet Protocol (VoIP) service. Unlike client/server architectures, in which a client communicates with a specific service provided on a fixed server configuration, this chapter describes SOAs, which build on the concept of loosely coupled services that can be discovered and linked to by clients (also referred to as service consumers or service requesters) with the assistance of service brokers. This document describes how to design SOAs, how to design services, and how to reuse services.
4. Distributed Component-Based Software.
In the design of software architectures for a distributed component-based software design; the component-based software architecture for the distributed application is developed. The software application is structured into components, and the interfaces between the components are defined. To assist with this process, guidelines are provided for determining the components. Components are designed to be configurable so that each component instance can be deployed to a different node in a geographically distributed environment.

Components are initially designed using the subsystem structuring criteria. Additional component configuration criteria are used to ensure that components are indeed configurable – in other words, that they can be effectively deployed to distributed physical nodes in a distributed environment.
5. Concurrent Real-Time Software.
The real-time software is a concurrent architecture usually, having to deal with multiple streams of input events. They are typically state-dependent, with either centralized or decentralized control.

Real-time software architectures are concurrent architectures that usually have to deal with multiple streams of input events. They are typically state-dependent, with either centralized or decentralized control. Thus, the design of finite state machines, state-dependent interaction modeling, and the control patterns, are very important in the design of real-time software architectures.
6. Software Product Line.
It is architectures for families of products that need to capture both the commonality and variability in the family.

A software product line (SPL) consists of a family of software systems that have some common functionality and some variable. Software product line engineering involves developing the requirements, architecture, and component implementations for a family of systems, from which products (family members) are derived and configured.

The problems of developing individual software systems are scaled upwards when developing SPLs because of the increased complexity due to variability management.

As with single systems, a better understanding of a SPL can be obtained by considering the multiple views, such as requirements models, static models, and dynamic models of the product line. A graphical modeling language such as UML helps in developing, understanding, and communicating the different views. A key view in the multiple views of a SPL is the feature modeling view. The feature model is crucial for managing variability and product derivation because it describes the product line requirements in terms of commonality and variability, and defines the product line dependencies. Furthermore, it is desirable to have a development approach that promotes software evolution, such that original development and subsequent maintenance are both treated using feature-driven evolution.
7. Framework Software.
A software framework is an abstraction in which software providing generic functionality can be selectively changed by user code, thus providing application specific software. It is a collection of software libraries providing a defined application programming interface (API). It is a universal, reusable software platform used to develop applications, products and solutions.

Software Frameworks include support programs, compilers, code libraries, an application programming interface (API) and tool sets that bring together all the different components to enable development of a project or solution.

Frameworks contain key distinguishing features that separate them from normal libraries:

7.1. Inversion of control - In a framework, unlike in libraries or normal user applications, the overall program's flow of control is not dictated by the caller, but by the framework.

7.2. Default behavior - A framework has a default behavior. This default behavior must actually be some useful behavior and not a series of no-ops.

7.3. Extensibility - A framework can be extended by the user usually by selective overriding or specialized by user code providing specific functionality.

7.4. Non-modifiable framework code - The framework code, in general, is not allowed to be modified. Users can extend the framework, but not modify its code.
-----------------------------------------------------------------------
Last thing is very important should be considered when architecting any project. It is Non-Functional requirements and should be taken into consideration when designing such software types from the modeling and design stage not when implementing the project.

In my architecture document I called it Software quality attributes.

Software quality attributes:
Refer to the nonfunctional requirements of software, which can have a profound effect on the quality of a software product. Many of these attributes can be addressed and evaluated at the time the software architecture is developed. Software quality attributes include maintainability, modifiability, testability, traceability, scalability, reusability, performance, availability, and security.

Some software quality attributes are also system quality attributes because they need both the hardware and software to achieve high quality. Examples of these quality attributes are performance, availability, and security. Other software quality attributes are purely software in nature because they rely entirely on the quality of the software. Examples of these quality attributes are maintainability, modifiability, testability, and traceability.


Wednesday, April 11, 2012

JPA: Dynamic search builder, the power of annotation, reflection and generics.

JPA (Java persistence API) is a powerful tool for domain objects mapping, and object oriented view perspective of database.

Always I used to use JPA in my projects, but JPA2 introduces extra feature that facilitate the generic way of persisting, merging, deleting and searching. Also introduces dynamic criteria API, which I was looking for.

But with time I have to change the dynamic query or do it myself or else to create new dynamic one which the panic way.

I need a component to search dynamically based on passed object attributes value, and not changed by the time.

For example if I have Bank that has (id, name, address, and state object), and I have created a bank object with name and address has values construct the JPQL SELECT statement (SELECT b FROM Bank b where b.name = :name AND b.address = :address) and search by it and so on.

I have developed a component to implement the above case called DynamicQueryBuilder with advanced techniques, and configurations.

In this article I will describe how I built this component with support of annotation, reflection and generics. In the code snippets you will find a brief description about each line of code and methods, the annotation developed to support the component and I will describe also the overall functionality of the component and how to call it to work dynamically…

Friday, January 20, 2012

JEE6: Part 3- The Java EE 6 Platform introduction

Part 1 | Part 2 | Part 3

EJB Technology, Even Easier to Use
Enterprise JavaBeans technology is the server-side component architecture for developing and deploying business applications in Java EE. Applications that you write using EJB technology are scalable, transactional, and secure. EJB 3.0, which is part of the Java EE 5 platform, made the technology a lot easier to use. Description:

The latest release of the technology, JSR 318: Enterprise JavaBeans 3.1, which is available in the Java EE 6 platform, further simplifies the technology and makes many improvements that reflect common usage patterns.

Some improvements made in EJB 3.1 are as follows:
  •  No-interface view. Allows you to specify an enterprise bean using only a bean class without having to write a separate business interface.
  • Singletons. Let's you easily share state between multiple instances of an enterprise bean component or between multiple enterprise bean components in an application.
  •  Asynchronous session bean invocation. Enables you to invoke session bean methods asynchronously by specifying an annotation.
  •  Simplified Packaging. Removes the restriction that enterprise bean classes must be packaged in an ejb-jar file. You can now place EJB classes directly in a WAR file.
  • EJB Lite. Is a subset of EJB 3.1 for inclusion in a variety of Java EE profiles.

JEE6: Part 2- The Java EE 6 Platform introduction

Part 1 | Part 2 | Part 3

Enhanced Web Tier Capabilities
Some of the most significant enhancements made in Java EE 6 appear in the web tier. As mentioned earlier, one of the goals of Java EE 6 is to make the platform more extensible, and two key improvements in the area of extensibility are web fragments and shared framework pluggability. These two new features are provided in Java EE 6 by Servlet 3.0 technology. Servlet 3.0, JSR 315, the latest version of Servlet technology, offers some other valuable enhancements such as support for asynchronous processing and support for annotations.

Another important Java EE 6 web tier technology is JSF 2.0, the latest version of JSF technology. Among its benefits, JSF 2.0 simplifies page and component authoring through Facelets, and adds support for asynchronous JavaScript and XML (commonly referred to as Ajax), and annotations.

Saturday, January 14, 2012

JEE6: Part 1- The Java EE 6 Platform introduction

Part 1 | Part 2 | Part 3

Java Platform, Enterprise Edition (Java EE) is the industry-standard platform for building enterprise-class applications coded in the Java programming language. Based on the solid foundation of Java Platform, Standard Edition (Java SE), Java EE adds libraries and system services that support the scalability, accessibility, security, integrity, and other requirements of enterprise-class applications.

Since its initial release in 1999, Java EE has matured into a functionally rich, high performance platform. Recent releases of the platform have also stressed simplicity and ease of use. In fact, with the current release of the platform, Java EE 5, development of Java enterprise applications has never been easier or faster.

Java EE 6 adds significant new technologies and extends the usability improvements made in previous Java EE releases.
Progress continues. The next release of the platform, Java EE 6, adds significant new technologies, some of which have been inspired by the vibrant Java EE community. It also further simplifies the platform, extending the usability improvements made in previous Java EE releases.


This article highlights some of the significant enhancements in Java EE 6; it consists of three parts Part 1, 2 and 3.

Thursday, November 17, 2011

SDLC: Software life cycle activities

Whichever software life cycle is adopted, the software engineering activities briefly described in the following sections will need to be carried out.

1- Requirements Analysis and Specification
In this phase, the user’s requirements are identified and analyzed. The requirements of the system to be  developed are specified in a Software Requirements Specification (SRS). The SRS is an external specification of the software. Its goal is to provide a complete description of what the system’s external behavior is without describing how the system works internally. The issues of what constitutes a SRS are described lucidly in Davis (1993).

With some systems, such as embedded systems, in which the software is part of a larger hardware/software system, it is likely that a systems requirements analysis and specification phase precedes the software requirements analysis and specification.

With this approach, system functional requirements are allocated to software and hardware before software requirements analysis begins (Davis 1993).

2- Architectural Design
A software architecture (Bass, Clements, and Kazman 2003; Shaw and Garlan 1996) separates the overall structure of the system, in terms of components and their interconnections, from the internal details of the individual components. The emphasis on components and their interconnections is sometimes referred to as programming-in-the-large, and detailed design of individual components is referred to as programming-in-the-small. During this phase, the system is structured into its constituent components and the interfaces between these components are defined.

3- Detailed Design
During the detailed design phase, the algorithmic details of each system component are defined. This is often achieved using a Program Design Language (PDL) notation, also referred to as Structured English or pseudocode. Internal data structures are also designed.

4- Coding
During the coding phase, each component is coded in the programming language selected for the project. Usually a set of coding and documentation standards have to be adhered to.

5- Software testing
Because of the difficulty of detecting errors and then locating and correcting the detected errors, software systems are usually tested in several stages (Ammann and Offutt 2008). Unit and integration testing are “white box” testing approaches, requiring knowledge of the internals of the software; system testing is a “black box” testing approach based on the software requirements specification, without knowledge
of the software internals.

5.1 Unit Testing
In unit testing, an individual component is tested before it is combined with other components. Unit testing approaches use test-coverage criteria. Frequently used test-coverage criteria are statement coverage and branch coverage.

Statement coverage requires that each statement should be executed at least once.
Branch coverage requires that every possible outcome of each branch should be tested at least once.

5.2 Integration Testing
Integration testing involves combining tested components into progressively more complex groupings of components and then testing these groupings until the whole software system has been put together and the interfaces tested.

5.3 System Testing
System testing is the process of testing an integrated hardware and software system to verify that the system meets its specified requirements (IEEE 1990). The whole system or major subsystems are tested to determine conformance with the requirements specification. To achieve greater objectivity, it is preferable to have system testing performed by an independent test team.

During system testing, several features of the software system need to be tested (Beizer 1995). These include the following:

■ Functional testing. To determine that the system performs the functions described in the requirements                specification.

■ Load (stress) testing. To determine whether the system can handle the large and varied workload it is expected to handle when operational.

■ Performance testing. To test that the system meets its response time requirements.

5.4 Acceptance Testing
The user organization or its representative usually carries out acceptance testing, typically at the user installation, prior to acceptance of the system. Most of the issues relating to system testing also apply to acceptance testing.

Thanks to Dr. Hassan Gomma 2011 book "Software Modeling and Design".


Sunday, November 6, 2011

UML: When to use each UML2 Diagram?

As I have studied from the book titled "UML Distilled 3rd Edition (Author Martin Fowler)", it is very handy book and useful for reviewing the UML 2 diagrams and techniques of usage.

Here are my summary for each UML diagram usage.

------------------------------------------------------------------------------------------------------------

When to use UML in development life cycle?

In requirements analysis:
The activity of requirements analysis involves trying to figure out what the Users and customers of a software effort want the System to do. A number of UML techniques can come in handy here:
  1. Use cases, which describe how people interact with the System. 
  2. A class diagram drawn from the conceptual perspective, which can be a good way of building up a rigorous vocabulary of the domain.
  3. An activity diagram, which can Show the work flow of the organization, showing how Software and human activities interact. An activity diagram can Show the context for use cases and also the details of how a complicated use case works.
  4. A state diagram, which can be useful if a concept has an interesting life cycle, with various states and events that change that state.

In design:
When you are doing design, you can get more technical with your diagrams. You can use more notations and be more precise about your notation. Some useful techniques are:
  1. Class diagrams from a software perspective. These show the classes in the software and how they interrelate.
  2. Sequence diagrams for common scenarios. A valuable approach is to pick the most important and interesting scenarios from the use cases and use CRC cards or sequence diagrams to figure out what happens in the software.
  3. Package diagrams to show the large-scale organization of the software.
  4. State diagrams for classes with complex life histories.
  5. Deployment diagrams to show the physical layout of the software.

  
When to use Class diagram?
Class diagrams are the backbone of the UML, so you will find yourself using them all the time. The trouble with class diagrams is that they are so rich; they can be overwhelming to use. Here are a few tips:
  1.  Don't try to use all the notations available to you. Start with the simple stuff: classes, associations, attributes, generalization, and constraints. Introduce other notations only when you need them.
  2.  I've found conceptual class diagrams very useful in exploring the language of a business. For this to work, you have to work hard and keeping software out of the discussion and keeping the notation very simple.
  3. Don't draw models for everything; instead, concentrate on the key areas. It is better to have a few diagrams that you use and keep up to date than to have many forgotten, obsolete models.

 The biggest danger with class diagrams is that you can focus exclusively on structure and ignore behavior. Therefore, when drawing class diagrams to understand software, always do them in conjunction with some form of behavioral technique. If you're going well, you'11 find yourself swapping between the techniques frequently.


When to Use Sequence Diagrams?
You should use sequence diagrams when you want to look at the behavior of several objects within a single use case. Sequence diagrams are good at showing collaborations among the objects; they are not so good at precise definition of the behavior.

If you want to look at the behavior of a single object across many use cases, use a state diagram. If you want to look at behavior across many use cases or many threads, consider an activity diagram.

If you want to explore multiple alternative interactions quickly, you may be better off with CRC cards, as that avoids a lot of drawing and erasing. It's often handy to have a CRC card session to explore design alternatives and then use sequence diagrams to capture any interactions that you want to refer to later. Other useful forms of interaction diagrams are communication diagrams, for showing connections; and timing diagrams, for showing timing constraints.


When to Use Object Diagrams?
Object diagrams are useful for showing examples of objects connected together. In many situations, you can define a structure precisely which a class diagram, but the structure is still difficult to understand. In these situations, a couple of object diagram examples can make all the difference.


When to Use Package Diagrams?
I find package diagrams extremely useful in larger-scale systems to get a picture of the dependencies between major elements of a System. These diagrams correspond well to common programming structures. Plotting diagrams of packages and dependencies helps you keep an application's dependencies under control. Package diagrams represent a compile-time grouping mechanism.

For showing how objects are composed at runtime, use a composite structure diagram.


When to Use Deployment Diagrams?
They are very handy in showing what is deployed where, so any nontrivial deployment can make good use of them.


When to Use "Use Cases"?
Use cases are a valuable tool to help understand the functional requirements of a system. A first pass at use cases should be made early on. More detailed versions of use cases should be worked just prior to developing that use case.

It is important to remember that use cases represent an external view of the system. As such, don't expect any correlations between use cases and the classes inside the System.

The more I see of use cases, the less valuable the use case diagram seems to be. With use cases, concentrate your energy on their text rather than on the diagram. Despite the fact that the UML has nothing to say about the use case text, it is the text that contains all the value in the technique.

A big danger of use cases is that people make them too complicated and get stuck. Usually, you'll get less hurt by doing too little than by doing too much. A couple of pages per use case is just fine for most cases. If you have too little, at least you'll have a short, readable document that's a starting point for questions. If you have too much, hardly anyone will read and understand it.


When to Use Stare Diagrams?
Stare diagrams are good at describing the behavior of an object across several use cases. Stare diagrams are not very good at describing behavior that involves a number of objects collaborating. As such, it is useful to combine state diagrams which other techniques. For instance, interaction diagrams are good at describing the behavior of several objects in a single use case, and activity diagrams are good at showing the general sequence of activities for several objects and use cases.

Not everyone finds state diagrams natural. Keep an eye on how people are working with them. It may be that your team does not find state diagrams useful to its way of working. That is not a big problem; as always, you should remember to use the mix of techniques that works for you.

If you do use state diagrams, don't try to draw them for every class in the System. Although this approach is often used by high-ceremony completest, it is almost always a waste of effort. Use state diagrams only for those classes that exhibit interesting behavior, where building the state diagram helps you understand what is going on. Many people find that UI and control objects have the kind of behavior that is useful to depict which a state diagram.


When to Use Activity Diagrams?
The great strength of activity diagrams lies in the fact that they Support and encourage parallel behavior. This makes them a great tool for work flow and process modeling, and indeed much of the push in UML 2 has come from people involved in work flow.

You can also use an activity diagram as a UML-compliant flowchart. Although this allows you to do flowcharts in a way that sticks with the UML, it's hardly very exciting. In principle, you can take advantages of the forks and joins to describe parallel algorithms for concurrent programs. Although I don't travel in concurrent circles that muck, I haven't seen muck evidence of people using them there. I think the reason is that most of the complexity of concurrent programming is in avoiding contention an data, and activity diagrams don't help muck which that.

The main strength of doing this may come with people using UML as a programming language. In this case, activity diagrams represent an important technique to represent behavioral logic. I've often seen activity diagrams used to describe a use case. The danger of this approach is that often, domain experts don't follow them easily. If so, you'd be better off which the usual textual form.


When to Use Communication Diagrams?
The main question with communication diagrams is when to use them rather than the more common sequence diagrams. A strong part of the decision is personal preference: Some people like one over the other. Often, that drives the choice more than anything else. On the whole, most people seem to prefer sequence diagrams, and for once, I'm with the majority.

A more rational approach says that sequence diagrams are better when you want to emphasize the sequence of calls and that communication diagrams are better when you want to emphasize the links. Many people find that communication diagrams are easier to alter an a whiteboard, so they are a good approach for exploring alternatives, although in Chose Gases, I often prefer CRC cards.


When to Use Composite Structures?
Composite structures are new to UML 2, although some older methods had some similar ideal. A good way of thinking about the difference between packages and composite structures is that packages are a compile-time grouping, while composite structures show runtime groupings.

As such, they are a natural fit for showing components and how they are broken into parts; hence, much of this notation is used in component diagrams.

Because composite structures are new to the UML, it's too early to tell how effective they will turn out in practice; many members of the UML committee think that these diagrams will become a very valuable addition.


When to Use Component Diagrams?
Use component diagrams when you are dividing your System into components and want to Show their interrelationships through Interfaces or the breakdown of components into a lower-level structure.


When to Use Collaborations Diagrams?
Collaborations have been around since UML 1, but I admit I've hardly used them, even in my patterns writing. Collaborations do provide a way to group chunks of interaction behavior when roles are played by different classes. In practice, however, I've not found that they've been a compelling diagram type.


When to Use Interaction Overview Diagrams?
These are new for UML 2, and it's too early to get muck Sense of how well they will work out in practice. I'm not keen an them, as I think that they mix two styles that don't really mix that well. Either draw an activity diagram or use a sequence diagram, depending on what better serves your purpose.


When to Use Timing Diagrams?
Timing diagrams are useful for showing timing constraints between state changes an different objects. The diagrams are particularly familiar to hardware engineers.