Khangharoth

May 17, 2009

Homegrown Persistence Framework

Filed under: Uncategorized — khangharoth @ 3:21 pm

I now moved to new team in my company and task is to set a team in India which  works with london based team on round the clock model.

In process of this migration we inherited existing java code. Functionally this code is in production and is performing quite well.And this project started as small and then grown into a important big project.

Couple of points worth mentioning about this code.

  • Extensive use of Static  : Or Over use of static .Writing Unit tests is big nightmare and now i can fully appreciate how dependency injection is so useful in writing Unit testing.
  • Extensive use of nested classes : Not sure exact need for this kind of architecture.
  • Home Grown Persistence framework.

After working with Hibernate and JDBC ,this is first time i am working a piece of code which can be dubbed as Home grown Persistence framework.Its really nice from personnel prespective after reading all sorts of problem self written Persistence framework could pose.

So am looking forward to get as much prespective on any design approach and  what prompted to be that way.

Also to compare that with hibernate .

Advertisements

May 12, 2009

Manage your Eclipse Plugin Dependencies

Filed under: Uncategorized — khangharoth @ 3:20 pm

For a Java developer who primarliy uses Eclipse as IDE,managing all the dependecies can be nightmare.It took me quite a while to get euml2 plugin installed and working.

More often downloading a new plugin can leave your eclipse installation in inconsistent state and you are now worse than when you started.

I try new plugins just to get feel of what’s on table from eclipseplugincentral,but am always worried about the dependencies i need to sort between eclipse versions and then plugin’s version.

And then i came across Yoxos ,it just what every eclipse user needs.You select the plugins and it sorts out the dependencies for you.And you get a customised eclipse installtion for you.Really sleak….

It’s really worth giving a try…

http://eclipsesource.com/en/yoxos/yoxos-ondemand/

Note: Would be a good idea to start building from base Java IDE

November 1, 2007

Learning the Art of Databases.

Filed under: Uncategorized — khangharoth @ 8:41 am

Relational databases are their for long time and going forward nothing seems to change that trend.

Object oriented database are now history and it seems that the idea was great but execution wasn’t. So we are pretty much goona live our life with RDBMS.

I was working in Computer graphics and we used to have 3D file formats like DWG ,DXN ,IGES etc and for couple of years i had absolutely no contact with databases.But as i am again working in JEE world and in this world DB’s are backbone of any application.

So how to be with current with this aspect of your programming world , well I’ll suggest http://www.databasecolumn.com/

And if you just want to hone up your Db skill’s than you can try these

October 31, 2007

High Performance Web Sites

Filed under: Software Design — khangharoth @ 1:24 pm

This is the name of Book written by Steve Souders, Chief Performance Yahoo.

Well it does give another view to the problem , what is seems as most of the time we only for known culprits like Database queries etc whenever we are on any Performance drive. And invariably the responsibility is of back-end developer to increase the performance.

Most of the Stuff was  new to me , as how diverse the problems can be .

Haven’t got the Book Copy : Need to find out ,Its tough to get these kind of books in India!

But to get  Gist , you can go through  this review : http://www.theserverside.com/news/thread.tss?thread_id=47378

Also this http://developer.yahoo.net/blog/archives/2007/03/high_performanc.html 

Now i am curious as what sort of Architecture these Top sites have : Also Do Java has any role into it ?

October 26, 2007

Software : Finding Right person for the Job .

Filed under: Software Management — khangharoth @ 2:02 pm

This is a hypothetical case study based on my experience in software industry.

Disclamor : Whatever i am discussing below is based on my experience which i admit is very limited ,but intention here to make you think about this aspect of Software Life Cycle.

BackGround : Any Software Work which we do has these inherent factors associated with it.

  • Complexity : How complex the piece of Work.
  • Resource Competence : how competent are the people who will work on this.Compensation for the resource depends upon competence level.
  • Time: What are the time lines.
  • Cost:Total cost which incur to company for this piece of Work.

We will rate all the above parameters on the scale of 10, ten being highest.

Requirement : We have a piece of Work , which say has complexity of level 3.

Resource and Time Planning :

Scenario 1:

We take a Developer with competence level of 3.Now let’s assume he will take 3 unit of time.This means for the work we have to wait for 3 unit of time and it will cost :

Developer Compensation * Unit Of time = Cost To Company.

In our example as compensation is proportional to competence so ,

3*3=9 this is the Cost .

Scenario 2:

Now say Manager wants to hire a person with higher competence so that quality should be higher and work can be finished before time.

So he hires a Developer of Competency level 8.Now to have same cost this guy needs to finish the work in

Cost/Competency=Time 9/8= 1.125 unit of Time.

Everything is fine but this generally don’t happen in real world.

What actually happens is this Developer is not Sufficiently challenged by the work he is doing and so he invariably thinks of more than necessary aspects of the given Problem and would now make given task of higher complexity ,say of level 8.

As now the task is of more or less same level of complexity as developer competence so time will again be of similar magnitude , say 3.

Now let’s calculate the cost 8*3=24.

More than double the cost of original cost.

So if you are Project Manger and you feel that your resources are over competent for the given work , than keep close eye on Scope of the Project.

October 18, 2007

Software : Time and budget estimation.

Filed under: Architecture,Software Design — khangharoth @ 3:30 am

In continuation of my previous blog about “Failure of Software Project” .

This one topic has really amazed me as people are able to estimates such huge building with such good accuracy.How many times you have heard in News that this Stadium will be ready by this date with these functionalities and they do deliver.Also in these situation maximum worst that happen is delay,but vary rarely whole thing gets scrapped,but this happens in Software Industry all the time!

Is it to do with Team-Work as this industry very much reward individualism  and so you will see lot’s of Talented guys who can single handedly deliver a small to Mid Size project.But a team of 5-6 of them fails to deliver some what bigger application.So is this why Failure rate of Software is directly proportional to its size.

And if this is one of the reason why people in other industry can work so well in Teams?                                                             One of the answer i have in mind is  as this Industry pays a lot and this could be a simulator for  Huge Ego and individualism.

Well these are all guesses and it may be that  inherent process of Software development is difficult and hence  this gap’s in estimation’s.

So why estimation of Software is so hard,well the point is “Software is Hard”.In Maths we know that in any equation as we have more and more variables,prediction is less and less accurate from couple of variable values in hand.

To read more on this subject , i regularly search internet and  today stumbles upon this.I think its quite a bold statement and also very close to reality.

It is impossible, by examining any significant piece of completed code, to determine within a factor of two how many man-hours it took to produce that code.

And the corollary:

If you can’t tell how long a piece of code would take when you have the finished product available, what chance do you think you have before the first line of code is written?

My first response to this : am reading the above line’s again and again,Isn’t it true?

October 13, 2007

AspectJ aspect configured by Spring

Filed under: Java,JEE — khangharoth @ 9:34 am

Today i came across a peculiar problem and more importantly it hit me in my face ,the integration tests were breaking and result of this were mail’s flying all across.

We are having a Web-Service which web-client calls and in the server side we are using spring as application framework.We were using aspect of AspectJ for some purpose and it needed certain properties which were available in spring.xml,so we thought to configure the aspect from spring.

Now just to quote a citation

http://www.ibm.com/developerworks/java/library/j-aopwork13.html

Now I’d like to configure my aspect with a particular exception handling strategy using dependency injection. For this, I can use the standard Spring approach, but with one caveat. Normally Spring is responsible for both creating and configuring beans. AspectJ aspects, however, are created by the AspectJ runtime. I need Spring to configure the aspect that AspectJ has created. For the most common case of singleton aspects such as the RemoteExceptionHandling aspect above, AspectJ defines an aspectOf() method that returns the aspect instance. I can tell Spring to use the aspectOf() method as a factory method for obtaining the aspect instance. Listing 2 shows the Spring configuration for the aspect:

Now what i mistakenly did was put this line of code in my spring.xml.

And everything was fine in Unit-testing and functional level testing.But as soon as client tried to generate the proxies from WSDL,their were number of proxies getting generated which were not even part of our WS interface.

After debugging , i got the cause of  those extra classes in WS interface.As sprin AOP is proxy based framework and it was this that was creating those extra proxy classes.

Need to get more into Spring AOP and how it is different from AspectJ.

October 9, 2007

Overview Of ORM : Hibernate

Filed under: Java — khangharoth @ 8:38 am

I have to give a presentation on ORM and then coming down the days more light on Hibernate.

So the theme across my series of presentation would be first addressing some basic questions about ORM .

q1) What is the problem that ORM solves?

q2) Magnitude of Object-Relational paradigm mismatch.

q3) How people survived before ORM concepts.

q4) How those efforts of traslated to many home-grown ORM frameworks.

q5) Industry wide available ORM solutions.

q6) Why to choose hibernate among all these.

And subsequently moving into internals of Hibernate .

Note:Presentation don’t have much text,if you need full transcript then do contact me.

ORM OverView :Hibernate

September 26, 2007

Tutorial: Profiling With AspectJ

Filed under: Java,JEE — khangharoth @ 8:00 am

Just to have background about what is Aspect Oriented Programming :Well we are in Object Oriented programming world.

Everything is object and concepts of OOP’s can applied very easily.Things are easy to maintain as things are very well encapsulated under objects and hence code changes are easy to implement and maintain.

This happens because each Object has a specific task ,and in well written OOP’s code change in some functionality involves changes at few places or to say only concerned objects change.

This is generally applicable for Business requirements which can be easily modularized,but what about the cross-cutting concerns.

Cross-Cutting Concerns: The concerns which are to be taken care of ,in almost every part of code or in other words,code for these concerns is scattered all around the code base.In short these requirement cross-cut at many places and hence regular concepts of OOP’s are not very useful in handling them.

These are generally requirements not specified by the user , but are needed for over-all well being of the projects.

So what are these kinds of requirements:

  • Security: Security checks may be need at each and every class.
  • Logging: Logging is a typical example of cross-cutting concerns.
  • Profiling:Need to know bottleneck in the system,so typically present at everywhere.

Now as this type of code will scattered everywhere in the main code.Other then reason’s like maintenance etc ,it also reduces the code readability and make code ugly.

We imagine if you have to change something ,then we need to go and change thousand’s of classes,ex:If we decide to change the way logging has been implemented,then probably we will need to open each and every file in the project and do the change.And we all know changes are the main cause of getting infected with new bugs.So again the goal is to minimize the effect or localize the effect of change.

Q)So how these cross-cutting features come’s into play?

A) We define pointCuts:These are basically some conditions which when fulfilled starts the magic.

so a pointcut in annotation will be defined as @Pointcut(“execution(* com.model.service.EmployeeService.*(..))”)
public void employeeService()
{}

This means employeeService pointcut is applicable to all methods of com.model.service.EmployeeService implementations.

for specific methods we write like

@Pointcut(“execution(* com.model.service.EmployeeService.doSomeStuff(..))”)
public void doSomeStuff()
{
}

This pointcut will pick only this specific method.

And then you define advice where you define actual code about what you want to do,advice is then linked to a pointcut.

   @SuppressWarnings(“unchecked”)
@Before(“employeeService()”)
public void methodEnter(JoinPoint pjp )
{
Object obj = pjp.getTarget();
LOG.debug( “[” + obj .toString + “] ” );

}

So suppose we need to introduce logging into our existing code-base.What are the steps needed?

  • Define  pointcut’s  specifying where these should be invoked. You can use wild-cards and this make pointcut definition very powerful.
  • Define an advice as what needs to be done when program flow reaches these pointcuts,i.e our logging code. Now it should be very clear as how we have modularize the cross-cutting concerns.No more we have code like Log.Debug all across out code-base.
  • We also has to define as which kind of advice it is.It means when this advice code will get executed.                                                 1) @Before :Runs before the actual method starts running,just after the arguments to the method call are evaluated.                                                                                                                                                                                                             2) After: similarly we have @AfterRetruning,@AfterThrowing and simply @After which is like finally i.e no matter how the method returns ,it will run.

In the example ,the goal is to try and have profiling enabled in the project.Its a very crude profiling which just logs how much time a method takes.

To run this example just create a new AspectJ project in Eclipse,and paste the code in corresponding java files.

TestClass.java is the one which have main method,also if eclipse you can see a nice Cross-Refrence view as which aspect is advising whom or other way round.

Note:Looking out for your comment’s!

TimerClass.java

TestClass.java

Profile.java

Profiler.java

ProfilerAspect.java

September 6, 2007

Difference Between JPA and Hibernate

Filed under: JEE — khangharoth @ 3:44 pm

My colleague just asked me this question and i thought its quite a common question in, lot of developers mind.

Well as you might aware of now we have a much leaner and easy to use Ejb 3 specifications.

The EJB 3.0 specififcation is divided into two parts the first which deals with session and MDBs and the second which deals with persistence and entity beans.

This later part is know as JPA.And as i say latter part so this is independent of session and other concepts.This means that this can be used outside of any Server or managed Container .You can use JPA in SDK just like you write “Hello World”,no need of any Server or container.

JPA works with normal java beans so your code can be just Java beans ,some XML/annotatons about how Object’s are mapped with tables and you are good to go,very easy to write test cases as well.

And hibernate 3.0 implements the JPA specification so  TopLink and other O/R mapping framework.So your code depends upon JPA Api and its implementation is supplied by any JPA impl vendor framework.

So in effect if you use JPA , you are using a standard Java Api and not some orthogonal Api and hence you have flexibility in your system.

Say initially you have used Hibernate but now want to shift to Other framework.That means JPA supports pluggable persistence providers.

JPA specification is heavily influenced by current O/R mapping frameworks like Hibernate and Top-Link .

So if i need to put in Concise words:

a) JPA is Persistence Api which your code should use.

b) JPA Api will pass on the call to actual peristence provider (ex:Hibernate/TopLink) to do the actual work.

c) If you are looking from Performance prespective ,it will be dependent on actual peristence provider (Hibernate/TopLink) and not on JPA as its just a wrapper layer.

d) If you are looking from code dependency prespective ,JPA makes more sense as your code is dependent on standard Java Api.

e) If you have used Hibernate then you will find that certain features are missing in JPA like criteria queries etc.This does not mean that you can’t write criteria query in your application, you need to get Session object from JPA Entity manager and now you are as good as in hibernate project.

But now your code is dependent on Specific impl (Hibernate),going forward you can see more things getting added in JPA (2.0)

f) Should you use JPA: My take is you should ,API is clean and although not everthing you need is their but is a good step forward.

Hopefully this give better picture as where all these pieces fits into an Java based Enterprise Application .

« Previous PageNext Page »

Create a free website or blog at WordPress.com.