Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Thursday, March 10, 2011

Inheritance and Polymorphism

Inheritance and polymorphism are really just two ways of looking at the same class relationship. Inheritance is looking at the class hierarchy from the bottom up. A subclass inherits behaviors and attributes from its superclass. A subclass automatically possesses certain behaviors and/or attributes simply because it is classified as being a subclass of an entity that possesses those behaviors and/or attributes.

Inheritance is useful from a code reuse perspective. Any (non-private) code in the superclass does not have to be replicated in any of the subclasses because they will automatically inherit those behaviors and attributes. However, one must be very careful when transferring common code from the subclasses to the superclass, as the proper abstraction represented by the superclass may be broken.

Polymorphism, on the other hand, is looking at the class hierarchy from the top down. Any subclass can be used anywhere the superclass is needed because the subclasses are all abstractly equivalent to the superclass. Different behaviors may arise because the subclasses may all have different implementations of the abstract behaviors defined in the superclass.

Polymorphism is arguably the more useful perspective in an object-oriented programming paradigm. Polymorphism describes how an entity of a lower abstraction level can be substituted for an entity of a higher abstraction level and in the process, change the overall behavior of the original system. This will be the cornerstone that enables us to build OO systems that are flexible, extensible, robust and correct.

Friday, September 3, 2010

What is J2EE, J2EE Platform and benefits

In the world of software, a platform is a combination of hardware and software necessary to run applications. J2EE is a platform for delivering enterprise applications. But what does it mean to say that J2EE is a platform? J2EE isn't hardware, although it can run on any hardware with an appropriate JVM. And J2EE isn't software exactly, since many vendors provide J2EE-compatible systems, and even provide their own JVMs.

J2EE is a platform-independent, Java-centric environment from Sun for developing, building and deploying Web-based enterprise applications
online.

The J2EE platform is a collection of related technology specifications that describe required APIs and policies. The content of the specifications is controlled by the Java Community Process (JCP). Interested vendors come to consensus on the specifications' contents, and then compete on implementations of those specifications. The J2EE platform consists of a set of services, APIs, and protocols that provide the functionality for developing multitiered, Web-based applications.

Some benefits of deploying to a J2EE-compliant architecture include:

1. A simplified architecture that is based on standard components, services, and clients. The architecture maximizes the write-once, run-anywhere Java technology.

2. Services providing integration with existing systems, including Java DataBase Connectivity (JDBC); Java Message Service (JMS); Java Connector Architecture (JCA); Java Interface Definition Language (Java IDL); the JavaMail API; and Java Transaction API (JTA and JTS) for reliable business transactions.

3. Scalability to meet demand, by distributing containers across multiple systems and using database connection pooling, for example.

4. A better choice of application development tools and components from vendors providing standard solutions.

5. A flexible security model that provides single sign-on support, integration with legacy security schemes, and a unified approach to securing application components.

Hope this is useful!

What is Software Framework

A software framework is an abstraction in which common code providing generic functionality. Frameworks are a special case of software libraries in that they are reusable abstractions of code wrapped in a well-defined Application programming interface (API).

Software frameworks have these distinguishing features.
1. The overall program's flow of control is not dictated by the caller, but by the framework itself.
2. A framework has a default behavior.
3. A framework can be extended by the user usually by selective overriding or specialized by user code providing specific functionality.
4. In general, the framework code is not allowed to be modified. Users can extend the framework, but can not modify its code.
5. It makes it easier to work with complex technologies

A software framework may include support programs, code libraries, a scripting language, or other software to help develop and glue together the different components of a software project. Various parts of the framework may be exposed through an API.

The purpose of a framework is to improve the efficiency of creating new software. Frameworks can improve developer productivity and improve the quality, reliability and robustness of new software. Developer productivity is improved by allowing developers to focus on the unique requirements of their application instead of spending time on application infrastructure. It also helps in modularity, easier maintenance, and shorter development times.

The main idea on frameworks is, that there is an almost ready to go application, which you can use and expand for your own demands.
There are several frameworks. To name a few like - Struts, JSF, Toplink, Spring, Log4J, J2EE, -

Hope this is useful!

What is Software Architecture

The software architecture of a program or computing system is the structure or structures of the system, which comprise software components, the externally visible properties of those components, and the relationships between them.

Architecture serves as the blueprint for both the system and the project developing it, defining the work assignments that must be carried out by design and implementation teams. The architecture is the primary carrier of system qualities, such as performance, modifiability, and security, none of which can be achieved without a unifying architectural vision. Architecture is an artifact for early analysis to make sure that the design approach will yield an acceptable system. Architecture holds the key to post-deployment system understanding, maintenance, and mining efforts. In short, architecture is the conceptual glue that holds every phase of the project together for all its many stakeholders.

Benefits
When you take the time to properly design, implement, document, and evaluate a software architecture, you can

* predict, achieve, and control quality attribute behavior and make practical tradeoffs early
* greatly reduce the failure rates of software projects
* produce a rationale for certain architectural decisions made or not made
* communicate with your stakeholders
* reason about and manage change
* enable more accurate cost and schedule estimates
* create evolutionary prototypes
* predict and mitigate risks
* understand the tradeoffs inherent in the architectures of software-intensive systems
* provides insight into how quality goals interact—that is, how they trade off
* plan your staffing needs

Hope this is useful!

Business Object/Domain Object

A business object is a an entity. That is an actor inside the business layer in a multi-tiered system of object-oriented computer programs. A business object, itself usually does nothing but holds a set of instance variables or properties, known as attributes and associations with other business objects, a map of objects representing the business relationships. It communicates across the tiers in a multi-tiered system.

Business objects are sometimes called domain objects (where the word domain means the business).

Good business objects will encapsulate all of the data and behavior associated with the entity that it represents.
For example, an order object will have the sole responsibility for loading an order from a database, exposing or modifying any data associated with that order (i.e. order number, the order's customer account), and saving the order back to the database.

A domain object is an object from a domain model. It encapsulates only business rules and logic. Domain objects are Java classes that perform operations on data objects and provide data for presentation.

Domain objects contain logic particular to a business domain, such as managing users or credit cards. This logic operates over a persistent data object that contains the state necessary to implement the domain specific logic. Domain objects contain the application logic specific to the domain that require representing persistent state.

The purpose of the DomainObject class is to encapsulate access to one or more types of data objects. A number of methods, such as the save and delete methods, are delegated to the data object. The domain object, part of the application logic layer, is acting as a facade for an operation of the data object, part of the persistence layer. This is an interface between the persistence and application logic layers and one point where the two layers connect.

Domain objects are responsible for providing an interface to create, retrieve, update, and delete (the CRUD methods).

Hope this is useful!

Data Object

Data objects are useful for storing and retrieving data. However, in order to support other behavioral methods, the data object is used within domain objects. A data object does not need to be used within a domain object, and a data object may be used by multiple domain objects.

Java One Liner...

Blog on First Java One Liner
6. Architectural patterns that are larger in scope, usually describing an overall pattern followed by an entire system.
7. In software engineering, a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.
8. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved.
9. The amount of data transferred from one place to another or processed in a specified amount of time. Data transfer rates for disk drives and networks are measured in terms of throughput. Typically, throughputs are measured in Kbps, Mbps and Gbps.
10. Java Virtual Machine. A software "execution engine" in a browser, application or Oracle database that runs compiled java byte code (in class files).
11. Java Virtual Machine - Also called a "Java Interpreter", "Java Runtime" - Converts bytecode into OS specific commands.
12. A JVM is a piece of software that is responsible for running Java programs.
13. A domain model can be thought of as a conceptual model of a system which describes the various entities involved in that system and their relationships.
14. A use case is a description of a system's behaviour as it responds to a request that originates from outside of that system.
15. Domain objects are Java classes that perform operations on data objects and provide data for presentation.
16. A business object is a an entity. That is an actor inside the business layer in a multi-tiered system of object-oriented computer programs.
17. The delegation pattern means that a method of one object is implemented by relying completely on a method of another object.
18. In the world of software, a platform is a combination of hardware and software necessary to run applications.
19. The use case technique is used in software and systems engineering to capture the functional requirements of a system.
20. Use cases describe the interaction between a primary actor-the initiator of the interaction-and the system itself, represented as a sequence of simple steps.
21. Actors are something or someone which exist outside the system under study, and that take part in a sequence of activities in a dialogue with the system, to achieve some goal: they may be end users, other systems, or hardware devices.
22. The Document Object Model (DOM) is a platform- and language-independent standard object model for representing HTML or XML and related formats.
23. The DOM is required by JavaScript scripts that wish to inspect or modify a web page dynamically. In other words, the Document Object Model is the way JavaScript sees its containing HTML page and browser state.
24. A subset of the Java Development Kit (JDK) that contains the core executables and files that constitutes the standard Java platform. It includes the Java Virtual Machine (JVM), core classes, and supporting files. - Java Runtime Environment
25. A software package that can be used to write, compile, debug, and run Java applets and applications. - JDK
26. a JRE is a specific implementation of the the JVM, including the core libaries.
27. JVM is used for running the java software with the availablity of JRE which is different in a given environment.
28. Framework is a set of well designed components with the help of which applications can be built upon.
29. The main difference being that a framework is a physical and usable piece of code while a pattern is a logical design solution to a given kind of problem.
30. "A design pattern is a proven solution for a recurring design problem that occurs within a context." - Design Pattern
31. A web application framework is a software framework that is designed to support the development of dynamic websites, Web applications and Web services.
32. A software framework may include support programs, code libraries, a scripting language, or other software to help develop and glue together the different components of a software project. Various parts of the framework may be exposed through an API.
33. The software architecture of a program or computing system is the structure or structures of the system, which comprise software components, the externally visible properties of those components, and the relationships between them.
34. A system of principles, practices, and procedures applied to a specific branch of knowledge. - Methodology
35. The methodology includes the methods, procedures, and techniques used to collect and analyze information.
36. Software testing is the process used to assess the quality of computer software with respect to the context in which it is intended to operate.
37. SQA is a means of monitoring the software engineering processes and methods used to ensure quality.
38. This type of testing is also called sanity testing and is done in order to check if the application is ready for further major testing and is working properly without failing up to least expected level. - Smoke Testing
39. The application is tested against heavy load such as complex numerical values, large number of inputs, large number of queries etc. which checks for the stress/load the applications can withstand. - Stress Testing
40. the software is tested for the functional requirements. The tests are written in order to check if the application behaves as expected. - Functional Testing
41. The software is handed over to the user in order to find out if the software meets the user expectations and works as it is expected to. - User Acceptance Testing
42. The users are invited at the development center where they use the application and the developers note every particular input or action carried out by the user. Any type of abnormal behavior of the system is noted and rectified by the developers. - Alpha Testing
43. The software is distributed as a beta version to the users and users test the application at their sites. As the users explore the software, in case if any exception/defect occurs that is reported to the developers. - Beta Testing
44. White box testing strategy deals with the internal logic and structure of the code. White box testing is also called as glass, structural, open box or clear box testing.
45. Regression testing is any type of software testing which seeks to uncover regression bugs. Regression bugs occur whenever software functionality that previously worked as desired, stops working or no longer works in the same way that was previously planned.
46. Validation refers to meeting the needs of the intended end-user or customer.
47. Verification is the act of reviewing, inspecting, testing, etc. to establish and document that a product, service, or system meets the regulatory, standard, or specification requirements.
48. The tester only knows the inputs and what the expected outcomes should be and not how the program arrives at those outputs. - Black Box Testing
49. A method of testing software that tests the functionality of an application as opposed to its internal structures or workings. - Black Box
50. In Black Box, test cases are built around specifications and requirements (what the application is supposed to do). It uses external descriptions of the software, including specifications, requirements, and design to derive test cases.
51. Black Box can be applied to all levels of software testing; such as unit, integration, functional, system and acceptance.
52. White/Glass Box Testing Strategy can be applied to Unit Testing, Static and dynamic Analysis, Statement Coverage, Branch Coverage, Security Testing and Mutation Testing.
53. White-box test design techniques include Control flow testing, Data flow testing, Branch testing and Path testing.
54. Black-box test design techniques include Decision table testing, All-pairs testing, State transition tables, Equivalence partitioning, Boundary value analysis
55. A framework is usually made of several patterns implementation.
56. Every framework provides the basic building blocks for building your own systems according to your needs.
57. In software development, a Framework is a defined support structure in which another software project can be organized and developed.
58. A software framework is a re-usable design for a software system (or subsystem).

Thursday, August 5, 2010

Java One Liner...

1. Static methods can not be overwritten. A call to a static method is dependent on the type of the identifier and not on the object's class.

2. String fileContent = new Scanner(new File("test.txt" )).useDelimiter("\\z").next(); it reads in the entire file at once.

3. A Monostate object has static member variables only. So all instances of a Monostate class share the same state. This is a rare pattern and it is used less.

4. Antipatterns -- "a commonly occurring solution to a problem that generates decidedly negative consequences".

5. Use “==” operator while performing value comparison, with Value Type and use “Equals()” method while performing value comparison with Reference Type.