Pages

A note on anemic antipattern

In the object oriented principles POJOs or java objects represent data.Some people do write business logic along with the data objects.The objects do represent the real world object as it is named according to business nouns.The anemic anti-pattern describe the use of a domain model where the business logic is implemented outside the domain objects. The antipatterns help us to understand what are bad practices.These pitfalls are to be avoided.There is a fundamental mismatch with the OOP concepts explained by Martin Fowler in his article . With this pattern, logic is typically implemented in separate classes which transform the state of the domain objects. Fowler calls such external classes transaction scripts.It decouples the binding using a separate business layer to contain the logic.When we use hibernate-like persistance layer, most of the objects are basically attribute beans.The businesss logic will reside in a layer in which the process is spread between these objects.A service layer on top of domain layer or models is used when domain model impelementing multiple interfaces for data storage and logic.The service layer is not supposed to serve as a business logic provider/container, but rather as an access / synchronization layer, to allow for radically different interfaces access to your domain model.Ideally, the domain object would contain behavior to handle its own persistence. If domain objects offered such behavior, then the service object could deal directly with the domain object in a very object-oriented way. Instead of telling a DAO to persist a customer, the service would tell the customer to persist itself. There will still be a DAO, but the domain object will do its own dealing with the DAO, unbeknownst to the service object. In effect, the domain object and the DAO swap positions with relation to the service object.The attributes are provided by POJOs and the behaviours are provided by service layer. These forms the basis of domain driven design.I believe that in Anemic Domain Model the behavior is implemented in separate classes increasing the lines-of-code in the application layer and it also makes the application code less maintainable since the use of domain objects is no more logical.But the loosely coupled nature could provide more benefits of relationsgips,encapsulation,simplicity,readable,more functional support and so on.These are mere analysis in my perspective, hope I could add much more knowledge about this in future.

Object Relational Mapping Tools – An overview

Data is critical part of any application.Engineers need to get involved in the tedious work dealing with data.And we all know that the most flexible paradigm way of programming is based on OOPs.We have to simplify by the creation of data access layers, automate data access, or generate data access code.Various design patterns are applied in developing these.There are various OOP languages and an array of relational databases. Any applicaton will need enhancements and refactoring.The databases may change due to requirements.So a technique is need for a flexible architecture.ORM/Object Relational Mapping is therefore a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages.This is like a virtual database used within programming language.Most data manipulation is done through Value Objects .These objects can be persisted in database tables.The data types in the database and programming language can be different.The ORM layer could do the possible type mapping.It generates mapped queries for manipulating data in database.The data us represented as objects in application and its stored in RDBMS in accoradance with relational theory.Mapping determines how objects and their relationships are persisted in permanent data storage. In object-relational mapping products, the ability to directly manipulate data stored in a relational database using an object programming language is called transparent persistence. With transparent persistence, the manipulation and traversal of persistent objects is performed directly by the object programming language in the same manner as in-memory, non-persistent objects. This is achieved through the use of intelligent caching mechanisms.Thus a one-to-one object relationship maps to a one-to-one data relationship, a one-to-many maps to a one-to-many, and a many-to-many maps to a many-to-many.

A list of ORM vendors and products
ActiveRecord
Apache DB Project
(ObJectRelationalBridge)
Applied Information Technologies, Inc. (<SQLTags:>)
AlachiSoft (TierDeveloper)
Art Technology Group (ATG Repository)
ARTech (DeKlarit)
The BBA Data Objects Project (BBA Data Objects)
The Castor Project (Castor)
CodeFutures (FireStorm/DAO)
DADO Solution (DADO Database Mapper)
D2O Pty Ltd. (GURA)
Developer Express, Inc. (eXpress Persistent Objects for .NET)
EntitySpaces, LLC (EntitySpaces Architecture for .NET 2.0)
elephant
SQLAlchemy open source
SQLObject , open source
Evaluant RC, S.A. (Data Tier Modeler for .Net)
FireStar Software, Inc. (ObjectSpark)

JPOX
CoughPHP
Open Source ORM for PHP 5 featuring code generation (FreeBSD license)
Doctrine
Open Source ORM for PHP 5.2, free software (GNU LGPL)
ezPDO A Simple Solution for PHP Object Relational Mapping and Data Persistence
Junction
Open-source, object persistence layer (MIT)
ORMer
Open Source, foreign key based ORM for PHP 5, free software (MIT License)
Propel
ORM and Query-Toolkit for PHP 5, inspired by Apache Torque, free software (GNU LGPL)
SilverStripe

The GLORP Project (Object-relational persistence for Smalltalk)
The Hibernate Project (Hibernate)
The Hydrate Project (Hydrate)
The iBATIS Project (iBATIS Data Mapper for Java and .NET)
IdeaBlade (IdeaBlade)
The JC Framework Project (JC Framework)
The Last Component (Persistent Datasets for .NET)
Kodo
Linq
Lattice Business Software International, Inc.
(Lattice.DataMapper for .NET)
LightSpeed
MetaMatrix, Inc.
(MetaBase and MetaMatrix Server)
Metastorage (Metastorage - PHP object-relational mapping code generator)
Michael Campbell Associates, Ltd. (JCodeBox)
MicroDoc Computersysteme, GmbH (MicroDoc Persistence Frameworks for Java)
MyGeneration Software (MyGeneration)
.NET Data Objects (NDO)
The .NET Entity Objects Project (.NET Entity Objects - NEO)
NHibernate
NConstruct
Neo
ObjectMapper .NET Project
(ObjectMapper .NET)
Object Persistent Framework for .Net 2.0 (Opf3)
ObjectFrontier, Inc. (FrontierSuite and FrontierSuite for JDO)
Objectmatter, Inc. (Visual BSF)
ObjectStyle Group (Cayenne Project)
Olero Software, Inc. (ORM.NET)
OmniSphere Information Systems Corp. (OmniBuilder)
OpenJPA
Oracle Corporation
(OracleAS TopLink)
OOmega.net (OOmega JAVA Connector, XML Connector, and DBMS Connector)
The PerlORM Project (PerlORM - Object relational mapping for Perl)
PHP Object Generator (POG)
Premisa d.o.o. (PADO)
postmodern
Persistor.NET
POTIS Software Development Tools
(POTIS Object-Relational Toolkit - PORT)
The Propel Project (Propel: PHP Object Persistence)
PrismTech (OpenFusion Java Data Objects)
Progress Software Corporation (DataXtend CE)
RogueWave Software, Inc. (SourcePro DB)
SharpPower Corporation (RapTier)
SimpleORM (SimpleORM)
Software Tree, Inc. (JDX for Java and NJDX for .NET)
SolarMetric, Inc. (Kodo JDO)
Solutions Design (LLBLGen Pro)
Sooda
submarine
Sun Microsystems, Inc.
(Java Studio Standard 5)
Sybase, Inc. (PowerDesigner)
TechTalk, Ltd. (Genome)
Thought, Inc. (CocoBase)
Vanatec, GmbH (Vanatec OpenAccess for .NET)
Visual Paradigm International Ltd. (DB Visual Architect)
WebObjects
WilsonDotNet.com
(OR Mapper)
X-tensive.com Software Development Company (DataObjects.NET)
Xcalia (LiDO)
YTZ Systems, Inc. (SavePoint for Java)

An Introduction to Ruby - part 1

Ruby is red hot today.Rails based applications sprung up as most hosts began to support the framework.What makes interesting the object oriented concepts getting implemented in Ruby.Ruby is being used world-wide for text processing, XML and web applications, GUI building, in middle-tier servers, and general system administration. Ruby is used in artificial intelligence and machine-learning research, and as an engine for exploratory mathematics.Its becoming powerful in its infancy..

Ruby is a dynamically typed language ie the programmer neednot define the type of variable.A programming language is said to use dynamic typing when type checking is performed during run-time (also known as "late-binding") as opposed to compile-time.The interpreter takes care of the storage class at run-time based onthe value held by variable.Yukihiro Matsumoto is the creator of the Ruby programming language began work on Ruby back in 1993, because he wanted a language that made him productive while being fun to use. Initially popular in Japan, Ruby has been finding its way into the hearts of programmers all over the world.

The conventional Hello world:
print 'hello world'

Cool.No main method.No class definitions... to run a simple program ! Lesser code less time for debug mode.
No semicolons at the end of line unless multiple statements in a line.
Calling a method is simple a like method(args) or method arg1,arg2.
Everything you manipulate in Ruby is an object (even the numerals), and all methods are invoked in the context of an object.

To print 'hello world' ten times:
10.times{"hello world" }

What about null object ? Its 'nil' in Ruby. It is also an object. So we can call methods of nil object like nil.methods.

Ruby class definitions are remarkably simple: the keyword "class" followed by a class name, the class body, and the keyword "end" to finish it all off. Ruby features single inheritance: every class has exactly one superclass. A class with no explicit parent is made a child of class Object–the root of the class hierarchy, and is the only class with no super-class.In Java the Object class is the super class of all classes by default.

Names that start with single “at” signs (@) are instance variables.Unlike languages such as Java and C++, you don’t have to declare your instance variables in Ruby; they spring into existence the first time to reference them.

Instead of constructor it uses initialize method to initialize its values.

class.new(params)

This new message allocates an empty, uninitialized object, and then sends the message initialize to that object,passing along any parameters that were originally given to new.

Although a class may have only one parent class (the single inheritance model), it may mix in any number of modules. This effectively gives Ruby the power of multiple inheritance without some of the ambiguities that can arise.

eg:

class Animal
def initialize( speciesname )
@speciesname = speciesname
end
end

man = Animal.new( "Homo Sapiens" )

class Omnivores<> def initialize( speciesname,food )
super(speciesname)#initialize super class
@food = food
end
end

manall=Omnivores.new("Homo Sapiens","All")

Defining a method is simple:

def method(arg1,arg2)
#statements
end

The methods return a value.If no return is specified the value of last statement is the returned.More than one value can be returned as it bundled as an array.

Modules provide a way to indirectly support multiple inheritance in ruby.A module included in a class is called a mixin.
With a mixin you can extend from a module instead of a class.A module can’t be instantiated and no class can directly extend it but a module can fully implement methods like an abstract class does.

module Math
def add(a, b)
BigInteger.new(a+ b)
end
end

Ruby has its powerul unique expressions.expressions in the right hand side of the assignment operator are evaluated in the order in which they appear beore the statement is made to the variables in the left.

To swap two variables:
a,b = b,a

ImagePrvR - A sample AIR project


ImagePrvr is my first attempt in developing an AIR application which was done within some minutes.It is a simple image browser.
More news were coming from Adobe world.They are going to have an up hand on creating future web user interfaces and multimedia.They have announced the Open Screen Project which remove restrictions on use of the SWF and FLV/F4V specifications.Adobe recently launched a beta version of Adobe Flash Player 10, codenamed "Astro", which is claimed to include better 3D animation support helping create better special effects and Web experiences. "Astro" boasts Adobe's free pixel bender tools that support custom visual effects.I have installed that and the air application was running fine.

This is an experiment.Just try it.In future the interface may change and more features will be added.

Download

Content Delivery Network

For the better performance of a website, the use of Content Delivery network as a backbone provides internet bandwidth efficiently.

What are CDNs ?

A content delivery network (CDN) is a collection of web servers distributed across multiple locations to deliver content more efficiently to users. The server selected for delivering content to a specific user is typically based on a measure of network proximity. For example, the server with the fewest network hops or the server with the quickest response time is chosen.

When we request a page, the browser requests to particular domain only. If any other hypermedia contents are embedded they are loaded by the browser by requesting to the resource from the location domain.These assets are originally located in a server. Most browsers support only a few persistent requests to the same domain. It is possible to direct the clients' requests to a surrogate server or a network is commonly called Request routing or Content routing or Content Redirection. It is used in the Content Delivery Networks (CDNs).Content Networks deal with the routing and forwarding of requests and responses for content. Replication is a well-known technique to improve the accessibility of Web sites. But replicating resources may not be an ideal solution.Which objects are selecting the objects to replicate? Object selection is directly related to the granularity of replication. In practice, whole Web sites are taken as the unit for replication, coz its been observed that grouping Web documents can considerably improve the performance of replication schemes at relatively low costs. These CDNs provide replication for digital content providers. These web replica hosting systems host the documents of a Web site and manage replication automatically.Nowadays the web gives more relevance to content as more and more users seek the web for data. The burst of video streaming and social networks made web to imbibe more data than ever. It grows exponentially as the web provides a potential market for the new gen business. These content networks can be seen as a new virtual overlay to the OSI stack: a "content layer", to enable richer services that rely on underlying elements from all 7 layers of the stack. The CDNs are an upgraded idea of caching proxies. They were used by ISPs for the benefit of customers using dial up or cable modem. Server farms are also used to improve performance of a website which is a form of content network. They worked as if the groups of servers as a single server through a load balancing mechanisms. The requests are rooted to the resource for a failure situation. They have an important role is maintaining state management. By placing static files (css/js/images) to a cdn sub domain, visitors can load content with twice the allowed amount of persistent requests. CDN nodes are deployed in multiple locations, often over multiple backbones. These nodes cooperate with each other to satisfy requests for content by end users, transparently moving content behind the scenes to optimize the delivery process. Optimization can take the form of reducing bandwidth costs, improving end-user performance, or both.The number of nodes and servers making up a CDN varies, depending on the architecture, some reaching thousands of nodes with tens of thousands of servers.Requests for content are intelligently directed to nodes that are optimal in some way. When optimizing for performance, locations that can serve content quickly to the user may be chosen. This may be measured by choosing locations that are the fewest hops or fewest number of network seconds away from the requestor, so as to optimize delivery across local networks. When optimizing for cost, locations that are less expensive to serve from may be chosen instead. Often these two goals tend to align, as servers that are close to the end user sometimes have an advantage in serving costs, perhaps because they are located within the same network as the end user.

Remember that 80-90% of the end-user response time is spent downloading all the components in the page: images, stylesheets, scripts, Flash, etc. This is the Performance Golden Rule. Rather than starting with the difficult task of redesigning your application architecture, it's better to first disperse your static content. This not only achieves a bigger reduction in response times, but it's easier thanks to content delivery networks.

Akamai is one of the largest CDNs currently deployed, with tens of thousands of replica servers placed all over the Internet. To a large extent, Akamai uses well-known technology to replicate content, notably a combination of DNS-based redirection and proxy-caching techniques.Akamai transparently mirrors content (usually media objects such as audio, graphics, animation, video) stored on customer servers. Though the domain name is the same, the IP address points to an Akamai server rather than the customer's server. The Akamai server is automatically picked depending on the type of content and the user's network location.In addition to image caching, Akamai provides services which accelerate dynamic and personalized content, J2EE-compliant applications, and streaming media to the extent that such services frame a localized perspective.

More:

RFC 3568

ACM Article

Akamai

The REST - part1

Representational State Transfer is the basic architecture of Web.
"Representation State Transfer is intended to evoke an image of how a well-designed Web application behaves: a network of web pages (a virtual state-machine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use.",
as quoted by Roy Fielding who coined REST in his Ph.D dissertation to describe an architecture style of networked systems.
The resources scattered all around the web are identified by its URI.These URIs are the equivalent of a noun.Think how many nouns !! From "flick"ring pixels to "twitter"ing fingers.All the thoughts congregate to the web.Verbs describe the actions.We use verbs for funcion names in programming.GET is the action to fetch a web page , the representation of the resource identified by URI.It is the undamental action of a browser.Other verbs are : POST to add information, PUT to update information, DELETE removes information.They make the CRUD verbs for web as a database.REST is like modelling the web services as URI addressable resources. These REST type URIs are logical ones than physical.The URLs are parsed and the required data ie the represenatio is sent back to client. So the state of client changes as per the recievables.If we look in a hypertext document we see hyperlinks to other resources.
Each resource representation contains hyper-links. Following a hyper-link takes the client to the next state. Thus, within the resource representations themselves are pointers to the next states.
If we consider this concept in regard to OOP , it is like a "HTTP Object Model", as it was originally referred.
The REST-RPC style in flickr API looks like :-
GET services/rest?api_key=xx&method=flickr.photos.search&tags=sunflower
It gets the images with tag sunflower using the search method.
The Web uses embedded identifiers rather than link servers.So the authors need an identifier that closely matches the semantics they intend by a hypermedia reference, allowing the reference to remain static even though the result of accessing that reference may change over time. REST accomplishes this by defining a resource to be the semantics of what the author intends to identify, rather than the value correspondingto those semantics at the time the reference is created. It thus integrates with "tagging" on web .So the REST becomes the fundamental principle for a semantic web.

Run Linux in your browser

Eh? Yeah.Virtualization has become a prominent technology for computing multiple operating systems in a single host environment.Emulators are resource hungry.Java is slow as it got its own VM.But wat will happen if an emulator is developed using Java? What if an x86 emulator?I thought I was reading "Mythago Wood" when I have gone through JPC project done by Oxford Physics students.A new step in grid computing.You can run an x86 PC on top of JVM!!.Interesting thing is that they don't use native codes for the the coding ie no JNI and even then they were able to get a decent performance.See the linux demo here.It supports DOS programs too,so that we can have a decent DOS emulator to play some old games or run applications.So a chance to run a dos game in java supported handhelds.JPC creates a virtual computer upon which you can install your favorite operating system in a safe, flexible and powerful way. It aims to give you complete control over your favorite PC software's execution environment, whatever your real hardware or operating system, and JPC's multi-layered security makes it the safest solution for running the most dangerous software in quarantine - ideal for archiving viruses, hosting honey pots, and protecting your machine from malicious or unstable software.They ran DOS in N95...


The scientific computing for eg Particle physics or Genome projects where millions of computers are needed will get the advantage of this project.Users can use their own trusted JVM implementation and then use pure Java code to run the potentially dangerous x86 code.Multiple computers connected by this technology can have operating systems with particular security level without affecting the host machine.The JPC helps to run the x86 operating systems on any other platforms.I think people who made this did work very hard.These x86 CPU instruction set is large and complex with opcode lengths vary from 1 to 15 bytes and the complex graphics card implementation with various resolutions will be cumbersome.They have developed their own byte-code compiler with optimized to reduce object churn and make it faster.It has real mode and protected mode for various memory access levels.Thus we can have the quarantines and honey-pots for security experiments.
JPC Project home

A simple RSS parser

Various XML parsing technologies made the content delivery on web very flexible.I am experimenting with various rss parsing methods.One of the straight forward parsing technology is XML Pull Parsing.Xml Pull Parser (in short XPP) is a streaming pull XML parser and should be used when there is a need to process quickly and efficiently all input elements.The method is very flexible and there is no need for xml validation.I think this form is very useful for parsing simple xml documents.The parsing is designed by programmer itself requesting the parsing for each elements.He can omit elements and its subtree which are not needed.RSS are syndications through xml data.So a simple RSS parsing can be done by XPP method.The limitation that restricts XPP to a subset of XML documents is that it does not support entities, comments, or processing instructions in the document. XPP creates a document structure consisting only of elements, attributes (including Namespaces), and content text. This is a serious limitation for some types of applications.Anyway I try here to make a sample code.In this code an rss feed is read and create a string as a content inside div tag , so that the string can attach as innerhtml data for a dynamic page.I want to make it as a webservice, so that the content delivery can happen as a service.

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
using System.IO;
using System.Xml;

namespace SampleWebService
{
public class Parser
{
StringBuilder sbString = new StringBuilder();
StringBuilder sbTempString = null;

public string GetXMLData()
{

XmlTextReader xtrReader = new XmlTextReader("http://rss.cnn.com/rss/cnn_world.rss");
xtrReader.WhitespaceHandling = WhitespaceHandling.None;
xtrReader.MoveToContent();


while (xtrReader.Read())
{
switch (xtrReader.NodeType)
{

case XmlNodeType.Element:
BuildElements(xtrReader);
break;

case XmlNodeType.EndElement:
BuildEndElements(xtrReader);
break;
}

}

return sbString.ToString();

}

private void BuildElements(XmlTextReader xtrReader)
{
switch (xtrReader.Name.ToLower())
{

case "item":
sbTempString = new StringBuilder();
sbTempString.Append("<div>");
break;

case "title":
if (sbTempString != null && sbTempString.Length > 0)
{
xtrReader.Read();
sbTempString.Append("<a>").Append(xtrReader.Value).Append( "</a><br />");
}
break;

case "link":
if (sbTempString != null && sbTempString.Length > 0)
{
xtrReader.Read();
sbTempString.Insert(sbTempString.ToString().LastIndexOf("<a") + 2, " href=\"" + xtrReader.Value +"\"");
}
break;

case "description":
if (sbTempString != null && sbTempString.Length > 0)
{
xtrReader.Read();
sbTempString.Append("<p>").Append(xtrReader.Value);
}
break;

}
}


private void BuildEndElements(XmlTextReader xtrReader)
{
switch (xtrReader.Name.ToLower())
{

case "item":
if (sbTempString != null && sbTempString.Length > 0)
{
sbTempString.Append("</div>");
sbString.Append(sbTempString);
}
break;

case "title":

break;

case "link":
break;

case "description":
if (sbTempString != null && sbTempString.Length > 0)
{
sbTempString.Append("</p>");
}
break;

}
}


}
}



Gravatar - Universal Avatar

Gravatar -is the globally recognized avatar.Avatars are the virtual persona in the cyber world.They are your pixelized existence in two dimensions.Gravatar, is invented by Tom Werner an american web developer, is a service to have a single image identity on web.It will show your picture on content delivery platforms.The encrypted url helps to identity the avatar image.When a comment is posted on web forum or a blog using your mailid, the gravatar will be shown along the post.Comment platforms like Disqus support gravatar. The avatar is stored in one place and it will appear on several websites, blogs, forums.Once the image is changed and its reflected in all the web pages.This is web as a service.Adding avatar to your website is simple - add the url provided by gravtar API inside the img tag.

<img src="http://en.gravatar.com/avatar/2f89787e504e558c1efbe55e73a95df3" />


The hashing algorithm is used on the email id which is unique.Suppose we have a site and if we want to create a gravatar ..hash("ur@mail.com") => results the string which is encrypted by MD5 hashing algorithm.
Append that string to rest of cleaner URL API "http://en.gravatar.com/avatar/".
"http://en.gravatar.com/avatar/"+hash("ur@mail.com")+[.jpg -optional] .
These gravatars can be integrated with microformats,xfn,mails,forums,blogs,
Grab a gravatar

Introduction to Session Management

In most of the works done by a web application developers, managing sessions is strategically important for business needs.The session management keep track of a user's activity across sessions of interaction with the computer system.The application can be a desktop client in a distributed environment or most commonly web applications.As I had an experience in developing session management for J2ee and ASP. Net, the Microsoft technology provides the provisioning of scaling the ASP .Net applications.The session has a very critical importance in maintaining data between user and application.So it has become a play toy for vulnerability hackers.I made a technical document for Session management in ASP .Net- an overview.Read here

session management in asp

Creating a Java WebService using Axis 2

The web has become more ubiquitous than it was a decade ago.Years before SOA and webservices were buzzwords.But today they have become the building blocks of enterprise business applications as well as any other web applications.Future i said to be semantic webservices.The web itself is an aplication to application communication.These webservices are those programmatic interfaces available to be used by any application that connect to web.Java clients are efficient to communicate through web.Java web services has shown its impact in industry.I tried to make a documentation on developing a simple Java Webservice using Eclipse WTP tool and Axis 2.You are able to view the document here

Scrolling Bytes

The change is inevitable in the course of cosmic voyage.Expanding universes and interjecting parallel worlds.DarkMatters and micro-cosmos.The human intelligentsia and artificial cognitive minds.Future seems dimly bright.None knows.Laws befall.Economies cripple and boom.Hunger and plenitude.Odds and ends.The unending strides to pleasure.Seeking happiness being the ultimate aim for human society.Sadly the pursuit is unending.What if we are the ones and zeros of scrolling bytes filling the computing brains of the ultimate being? Fantasies are the companion for mere human beings throughout his existence.Hope for the day when the mystery solves to answer all the inquisitions of mankind.