Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Introduction
  • General Concepts
  • Data Layer
  • Logic Layer
  • Presentation Layer
  • Before Starting - Methodology Recommendations
  • Managing Your Source Differences

Introduction

This documents presents best-practices for development and architecture related to The Open For Business Project.

...

Note that this document assumes some knowledge of the OFBiz Core Framework. With some basic knowledge it can answer a lot of questions about how certain things should be used. If you are not familiar with the OFBiz Core Framework this will give you an introduction to it, but some things may not make a lot of sense to you.

General Concepts

Reduce Code Complexity, Redundancy

...

and Size

There are various techniques that can be applied to this problem that produce good results. The most common, but least effective, practice is code generation. Because it is not something that I consider to be a best practice, I won't discuss it further here.

...

When using FreeMarker is not possible or practical we recommend using another dynamic templating language such as Velocity. When that is also not possible or practical we recommend using JSPs. But, note that when using JSPs you cannot take advantage of the actions or decoration templates because you cannot run it through JPublish. This is thanks to limitations in the JSP specification. Even through you cannot use the decorator patter, you can use the composite view pattern with the OFBiz Regions framework. Regions are specified in the regions.xml file. Note that these are not as easy to use as Screen Widget composite views, and they do not support actions. But the Regions framework does offer a lot of flexibility and is very useful in many cases.

Before Starting - Methodology Recommendations 

Before you can build something that something has to be defined. Every detail has to be decided at some point. Because of the difficulty of communication between individuals and the difficulties that are inherently involved in complex systems we recommend various practices.

While these techniques are used for some components in the core Open For Business functionality they are primarily meant for those who are creating derivative works based on OFBiz. The reason for this is that OFBiz is a generic framework, set of application components and suite of applications. In many cases these applications can be used as is but they are not meant to be everything to everyone. Because of this work will likely be needed for derivative works that are targeted at a specific industry, type of business, or specific end user.

Methodology: Keep it simple, but not too simple

There are dozens of different software development methodologies, and more are being introducted all the time. There are lots of good ideas presented in the hundreds, or even thousands, of documents available about different methodologies. In general we recommend the "agile" approach, but that needs to be qualified given the different perspectives that have been attached to that name. In general we recommend keeping it as simple as possible, but not too simple. For more specifics on agile software development see the Agile Alliance web site.

So the big question is generally: what is the minimum that we need to handle this project? The more methodology you have the more time and money you will spend on it. The less methodology you have the greater the chance that the requirements of the project will not be satisfied.

Minimal Roles

There are really only two roles necessary for any project: a buyer and a seller. In the case of software projects, and other service offerings, the more common terms are customer and developer. Those are the terms that will be used in this document. The term developer is used loosely here and refers to anyone that produces actual deliverables. The term customer is also used loosely here and refers to anyone that specifies what will be done and pays for it to be done. In some cases the customer and developer will be the same person, or the same group of people.

It should be noted here that an important part of the "customer" role is the actual target user(s) of the software. If possible reviewing stories and use cases (as described below) with users should be done. Interviewing those who are currently performing tasks that will in the future involve interaction with the new system can make it much easier to acheive complete and effective results. This is true on many levels. For instance, the best usability can be acheived by reviewing screen/page prototypes with real users and then validating final deliverables with real users. If the user group is large this may require a lot of work to get a good sampling of the different users of the system.

In many projects the two roles, customer and developer, will consist of groups of people and other roles will be introduced within the groups to clarify responsibilities. In these cases the methodology may also have to be more significant to keep things from deteriorating into chaos.

One practice that can reduce the need for a complicated and detailed methodology is to have one person from each group act as the agent for the entire group. Of course, that agent should discuss things with the rest of the group, but if the number of voices for interaction between the groups can be consolidated to one then communication and management of details will be much easier.

Note that for large projects having one agent for each side will not be practical. In those cases dividing the scope of the project and likewise dividing the customer and developer groups will be necessary.

Another variation on this is where a group creates a product targeted at hundreds or thousands of customers. In this case the "customer" that defines the product will be part of the same organization that produces the product. Given the definition of customer above the sales, marketing, and testing groups should be in the customer group, and an agent from that combined group should coordinate with the development group.

Minimal Communication

The biggest trick with communication is to find the balance between to much and too little communication. The burden for this is generally on the customer because it is customer that specifies what will be build. Like I said at the beginning of this section everything that will be built MUST be defined sooner or later. Anything that is not specified by the customer can be handled in one of two ways. The developer can decide what will fit into the gaps or the developer can request clarification and details from the customer.

To facilitate communication and make sure that the final result satisfies the needs requested by the customer the following process is recommended.

Minimal Process

One important aspect of this process is that it should be repeated frequently and the scope for each pass should be kept small so that when miscommunications occur they can be identified and resolved quickly.

While this process is simple and involves simple roles and artifacts it can be used as a skeleton for a much larger and more detailed process. Each step can be divided into many steps and extra steps to compensate for the needs of a specific project can be added.

Also note that this general process is the basis of the Work Effort components that are part of OFBiz and those tools, as well as many other available tools, can be used to make artifacts and other information easier to manage.

  1. The customer requests features by telling a "story" about each feature desired.
  2. The developer creates one or more requirements for each story by writing a more formal "use case" describing in detail how the resulting component(s) will be used.
  3. The customer reviews the use case(s) and provides feedback to the developer if necessary. If feedback is returned the developer adjusts the use case(s) and resubmits them to the customer. When the customer is satisfied the requirement is approved for implementation.
  4. The developer defines tasks that must be done to create or modify components in order to satisfy the approved requirements. At this point, if desired, time and/or cost estimates should be associated with the tasks.
  5. The customer can specify priorities on the request, requirement or task level. Given that tasks may have dependencies the actual order may be changed by the developer such that prerequisites are satisfied first.
  6. The developer does the work described in each and demonstrates the result to the customer. To improve developer productivity interruptions during this time should be minimized, except of course interruptions related to changes in what is to be done for that component. The actual time and/or cost should be recorded at this point if desired.
  7. The customer reviews the deliverable and either approves the work or requests adjustments as needed in the story, use case, and/or tasks. Making adjustments at this point involves going back to previous steps and then the same subsequent steps should be followed to complete the process.

You will notice that this process involves a great deal of customer interaction. If done right the customer and developer will interact on nearly a daily basis. For coordination and management periodic meetings should be held to review new requests or changes to existing requests and to adjust priorities as necessary. These meeting should be held once every one or two weeks for most projects.

After looking at this list you may have questions about what constitutes a story, use case, and task.

A story is essentially an informal free form document from the customer that describes what is desired in complete sentences or as an outline. Precise details are not needed at this stage. Note that this document may change to be more precise or to include additional aspects. This document will be used to create more formal use case(s).

A use case is a document that contains detailed information in a more formal structure and represents the complete specification corresponding to one or more stories. A use case should include the following:

  • The primary and other actors, defined by the roles of the the users or systems that will be interacting with the functionality
  • The goal(s) of each actor and/or the overall interaction
  • Usage scenario(s)
    • The primary actor
    • The goal of the scenario
    • Conditions that trigger the scenario
    • The result(s), includes both success and failure results
    • Scenario variations
    • Errors, exceptions, and resulting actions

Note that for simplicity scenarios should be kept small and include only the minimal basic process. Variations on process should be defined separately. Exceptions and errors in the process should be defined separately along with their results.

Defining tasks is generally fairly simple and should be done by the developer in a form and using terms that the developer will understand. There is a lot of meta-data that is generally associated with such a task. Examples include esimated and actual time and cost, start and end dates, all parties performing or otherwise involved with the task, and so on.

Conclusion

Some basic preparations should always be done before getting into the implementation. Some basic principles and a basic process has been presented. Because of the nature of how most projects work all of the steps in the process will be done in one way or another. Following this process does not require the creation of any written documents, although in many cases that will help quite a lot. It can be done through verbal conversation, or even a series of thoughts inside one's head.

The process described is meant to be customized to your needs. Following it as is should do for most medium sized projects. When there is only one or two individuals involved, or tens or hundreds of individuals, changes will obviously be desired. When modifying the process keep in mind the basic principles presented and be especially careful about leaving out communication steps, espcially the communication verification steps.

Managing Your Source Differences

When customizing OFBiz components for your specific business requirements you will most likely come across situations where small changes to files are needed and it doesn't make sense to replace a component completely or attach logic to it through Service ECA rules or other means. So, how should you manage the differences between your code and the OFBiz baseline code so that updating from the OFBiz baseline will be as painless as possible?

The first thing you should always do is isolate your chagnes and comment them so that it is easy to distringuish what you changed from the OFBiz baseline code. The final goal is to make it easy to merge your changes with future changes in the OFBiz baseline.

There are various ways to structure your internal CVS or other code repository. One very flexible, but laborious, way is to create a complete copy of the OFBiz CVS tree in a module in your own CVS repository. This could perhaps be called "ofbizbase". This should contain the revisions of the code that you are currently working with and allows you to selectively incorporate specific changes from the OFBiz baseline. These files should be direct copies from a revision in the OFBiz CVS repository. If you make changes in this module that are not part from the OFBiz baseline they should be temporary changes that are meant to be overwritten and replaced with future versions from the OFBiz baseline.

Once your ofbizbase snapshot module as described above is in place you should create another module, maybe called "ofbizdiff". This will contain ONLY the files that you have changed relative to your ofbizbase module. When updating the version of a file in your ofbizbase repository from the OFBiz baseline you should do a three way diff/merge to make sure the changes in the OFBiz baseline make it into the version of the file in your ofbizdiff module as well as the file in your ofbizbase module.

The three way diff/merge will be done with the following three files: the old file from your ofbizbase module as the base, your changed file in your ofbizdiff module as the merge target, and the new file from the OFBiz baseline as the merge source.

The build process for this sort of a structure is very simple. Create a temporary build directory. Copy the entire ofbizbase tree into the directory. Copy the entire ofbizdiff tree into that directory, replacing files as needed. In the root of the temporary build directory run the Ant build file. What could be more simple?

When editing files in your ofbizdiff module you should ALWAYS edit them in place in the ofbizdiff directory tree and copy them to the temporary build directory for testing. Doing this you will always be able to do a CVS update to see which files you have modified as you are working.

Many variations on this technique can be effectively used. If you don't plan to make temporary changes to ofbizbase files or update individual ofbizbase files selectively, you may do just fine with an archive (like a zip or tar.gz file) instead of a CVS module for your ofbizbase tree. You could keep the current version of this archive in your ofbizdiff CVS module.

We have heard a lot of questions about using simple merge scripts to apply differences to source in the ofbizdiff tree so that full files do not have to be stored ant maintained there. This is fine, but it is a LOT harder to perform the diff/merge or other code synchronization when you don't have the complete files to do a three way diff/merge. So, we don't recommend using minimal diff files that can be applied as part of preparation for the build process. Just copy the file from ofbizbase to ofbizdiff and make the changes you need as recommended above.

For Those Comfortable With CVS Branching/Merging

If you are comfortable with the branching and merging features in CVS you can use those very effectively to easily maintain you differences from the OFBiz base source tree, and still keep up-to-date with the latest from OFBiz without too much trouble. CVS does three-way diff/merge operations all the time when doing updates, and this same feature can be used to do the three-way diff/merge described above, but in an automatic way that only requires your involvement for merge collisions.
To get started do a fresh checkout from the OFBiz CVS repository, then remove all CVS directories and import the tree into a new module in your local CVS repository. Tag this set of files with a name like OFBIZ_20030612 (adjust for the current date) using a command like "cvs tag -b OFBIZ_20030612". Now just change/add things as you please. Note that you are not working on that branch, you are working on the HEAD branch unless you do something like "cvs update -rOFBIZ_20030612".

So, now you have a bona-fide branch of OFBiz with your own code mixed in, but there are a ton of cool new things in the latest OFBiz base code that you would LOVE to have. What do you do? The easiest way to do this is to use the "cvs import" command, and you can do this multiple times to get a new vendor branch for the latest OFBiz code. For example, checkout the latest OFBiz code (with an export or a checkout) and from the root directory of that import run something like 'cvs import myofbiz OFBIZ_BASE REL_3_0_0 -m "More cool stuff from OFBiz"', where myofbiz is the name of your local CVS repository module, and OFBIZ_BASE string you use to identify this vendor branch, and REL_3_0_0 is a string you use to identify the current set of code from OFBiz. This could also be date based if it isn't from an official OFBiz release or tag.

Wiki Markup
Go back to the place on your machine where you have HEAD checked out and merge the branch you just created with the HEAD, or the current set of files you have checked out. To do this run something like  "cvs update \-dP \-j\[the-ofbiz-tag\]".

At any time to get a list of all files changed from the base, get a list of all tags on the module and compare the HEAD revisions with the revisions tagged using the most recent OFBiz tag.