If you're like me, you spend a lot of time dealing with legacy code that, for whatever reason, does not take advantage of modern methodologies and libraries. I've taken over Java projects that contain hundreds of thousands of lines of code and not a single third-party jar other than a JDBC driver! One of the most common examples of this is the implementation of the data access layer. These days, the de facto methodology involves Hibernate and DAOs, usually managed by Spring.This article will detail the steps I recently took to covert a large application from custom-written data access to Hibernate and Spring using the refactoring facilities in Eclipse. The key with this refactorization is to get the existing business logic code (Struts Actions, JSPs, Delegate classes, Business Service classes, etc.) to access the datastore using Hibernate, managed by Spring, without manually changing any of that code directly. Part 1 will include creating the Hibernate data object classes, DAOs, and refactoring the existing code to work with these newly created types. Part 2 will conclude the project with integration of the Hibernate DAOs and wiring everything up with Spring.First of all, we need to create our Hibernate model and DAO classes. Obviously, since we're dealing with a legacy application and data structure, we will want to use a bottom-up approach to building our data access layer. This just means that we're going to generate the Java code and appropriate Hibernate config files from the existing database. There are many tools freely available to make this process very painless. I recommend an Eclipse Plugin for creating and maintaining the Hibernate artifacts (Google Hibernate Eclipse Plugin to get started). The structure and requirements for creating Hibernate classes and config files are well documented elsewhere, so I won't go into detail here. However, in this particular project, the Hibernate DAO lifecycles are managed by Spring, so the DAO classes should all extend HibernateDAOSupport.Now we have java classes (POJOs) which map to our database tables, but none of the existing code uses these new data object classes. This is where the refactoring tools of Eclipse comes in really handy. For example, say we have a legacy class called AccountInfo which corresponds to the ACCOUNT database table. Right-click the class and select Refactor -> Extract Interface. On the dialogue box, call the new interface IAccount and make sure you select Use the extracted interface type where possible. Choose the other options according to your preferences. Click OK and kick back while Eclipse changes every occurence of AccountInfo references to IAccount references and recompiles. Of course, do this with each object model class.If you never realized why OOP languages are so great, you're about to. Now we're going to refactor the code so that all of the existing legacy can be hooked into the new Hibernate model classes instead of the legacy ones. Continuing with the AccountInfo example, create a new class you'll probably want to create a new package for this step called Account that extends the Hibernate POJO for Account and implements the new IAccount interface.This next part is the most time-consuming, but really isn't that bad. At this point, the newly created class will probably contain a bunch of empty methods containing only TODO comments. This is because the IAccount interface most likely defies a bunch of methods that are not implemented in the Hibernate Account POJO. To deal with these, we basically want the new Account class to delegate to its generated superclass whenever necessary to satisfy its contract as an IAccount type. As a real world example from the application I was working on, the legacy AccountInfo class defined a getter/setter pair for a property called username, whereas the corresponding column in the ACCOUNT table was actually LOGIN_NAME. To deal with this, you would simply implement the get/setUsername methods in Account to delegate to get/setLoginName (from its superclass). I also had to translate between various data types quite a bit. For example, the legacy code would define many properties as Strings even though the corresponding piece of data in the database was defined as an INT or TIMESTAMP. Again, do this with each object model class.To finish up the data model layer, edit the appropriate Hibernate and Spring configuration files to refer to these new object model classes. The application now has the ability to map database records to Java objects via Hibernate, and the legacy code which refers to these classes has not required any editing by hand. To finish up this refactorization project, we need to hook in the Spring-supported Hibernate DAOs in a similar way. In Part 2 of this article, I will discuss refactoring the legacy code to read, write, and update data using Hibernate and Spring.
It is easy to lose track of what your kids are doing online without being overly snoopy about their growing independence. Independence is a good thing when the child has demonstrated that they can make responsible decisions and good choices. Part of your responsibility as a parent is to provide the tools which will help them along this pathway. A good way to open communications with your child is to discuss the MySpace internet area with them. MySpace is a web site where teens and preteens can journal thoughts, add pictures, chat with others about their interest, and discuss events and problems which affect their daily lives. A great deal of controversy lately has surfaced around the site, because of the potential for unwelcome elements of discussion, pedophiles who may use the site as a springboard for meeting youngsters face to face or other unhealthy aspects. By understanding the mechanics of how MySpace works, parents are enabled to sit down with a preteen child and dialogue about the positive aspects of the web site as well as opening discussion about the dangers which can be found. Obviously, no parent is going to be able to totally block off any areas of the internet which might be perceived as unhealthy for the child. Often such actions will either be resented as overly controlling, or will create an interest where none existed previously. Some important tips to use with your youngster is how to set privacy and profile options for security online. You can also explain to your child the importance of not lying about your age, or giving out the real name of your school or other identifying information. The important part of this exercise is that it is done jointly with the child, so they learn not only how to use guidelines in making decisions, but that there are good reasons for the guidelines.
In the vast competition on the internet money-making industry, keeping your website with a membership site running is the most popular way to keep you alive in the business. A membership site will somehow increase your chances on the web to make it big, and if by luck, will continue being so for the coming, long years. However, a membership site will not stay long in the industry if you don't have the membership site software to run the organization properly. The membership site software is a way to keep your members glued on their commitments with your organization, so it is essential that you largely consider it as your primary tool in keeping your website. If you are just staring with your membership site and you are hoping to make it really big in the industry, make sure you choose the most appropriate membership software that can manage well your organization in tracking your members. The following should be considered in selecting your own membership website software:1.Reliability this tackles about how the software is going to be effective with your website. It should not only focus on the reliability of the software alone but on the company that supplied the membership website software as well. You have to look for a company which will offer the best services such as being available 24 hours a day and will always provide you solutions.2.Actual features you have to learn of these things before picking the software. There are many software programs you can choose on the web but they are not the same. A "membership software" website may have features that are unnecessary with your website while the other may lack some that you need. Check them all and get one with features that will largely compensate on your needs. 3.Compatibility some membership software runs on PHP on the server, while others run on ASP. In this aspect, check one that would be compatible with the web host account that you have. 4.Price of course, this is the most indispensable factor that you must take into consideration. Membership site software programs can be quite expensive. If you do not want to waste even a cent, do not spend on an overly expensive software which features a lot of things but you have no need for in the end. On the other hand, you do not have to spend on cheap software if it lacks the necessary features you need for your organization. If you have analyzed these factors, you will find a membership software program that will surprisingly meet your needs but without spending exaggeratingly. For a starter, you will find a program which costs at a very reasonable rate. If you have stepped further in the business, then you can upgrade the software so you will be able to manage the membership you have collected. Membership management software is the most ideal program which most organizations and associations employ. It allows you to keep track of your members even without you supervising it on hand. Most membership management software applications are available with features that will keep track of the details and information of your members by sending them regular emails to the account they have provided. Membership management software is very accurate in the sense that it can keep the status of your members updated. It will help you keep your members; thus a steady flow of the traffic.