How to manage client configuration

For a product that is used by several clients, where different clients request different settings both with a user interface and with functionality, how to take into account these changes without getting code cluttered with client code?

Are there any frameworks (for any programming language) that help with this?

To add more details, the user interface is web-based and written using JSP.

+4
source share
5 answers

This is one of the most complex business requirements for managing different versions of the same application, so do not expect open frameworks for this case, however, each participating company develops its own system for this.

As for business logic modifications, you would benefit from strong interaction and IoC (e.g. Spring ). You will redefine the services for your specific case and change the necessary methods, and then introduce the modified version of the service in IoC.

As for the UI, this is more complicated because you chose a JSP that has little flexibility. When you program in Swing or GWT, how could you modify the interface in the same way - redefine the necessary classes of the user interface, change them, make modified versions. With JSP - there may be many changes to .jsp files in your custom version.

Now change changes / bug fixes - version control system is fully used. Of course, your client versions are branches, and the main standard version is the trunk. Bugs associated with trunks are fixed, then merged with client-specific branches. With an interface / overriding implementations, most merges would be an easy way, however, with JSPs, I would expect conflicts to happen often ...

As a rule, code changes are easier than XML-based.

+3
source

How about a simple OOP ? Set up a realistic interface / base class and, depending on your configuration, create an instance of a child class A or B, depending on the client. It is difficult to provide more detailed information on a linguistic agnostic issue like this, but I think it is very realistic.

+2
source

One solution to this problem, common in the Win32 / .NET world, is to migrate client "code" to resource files. Many .NET projects (.NET has built-in support for this template through System.Resources ) use this template for internationalization, placing the UI builds in one file for each language, and then loads the user interface lines from the corresponding file at run time.

How does this template apply to a JSP application? So, here you can store one resource file on one client (or use a database instead of files) and load user settings from the resource file whenever you serve the page.

For example, say that your biggest customer wants their logo to overlap on some part of every web page on your site. Your page can load the CustomerLogo property and use it as the src attribute for the HTML image in this part of the page. If you serve an important customer’s page, you download the URL β€œ/static/images/importantCustomerLogo.png”, otherwise you return to the default resource file, which indicates the URL β€œ/static/images/logo.png. "

Thus, you can abstract from the code to load properties into one or two Java files and simply use these properties on the website. The only part of your codebase that depends on the client will be a set of resource files, and they can be in pure XML format that is easy to read and modify. As a result, people who did not develop the application in the first place can modify XML without having to read the code first, so you will not need to support resource files - the sales department can do the job for you.

+2
source

GWT does this out of the box using the delayed snap function

When compiling a GWT application, the compiler actually generates different versions of the code for different browsers. this is done automatically out of the box with GWT components that take care of different browser details.

This feature can be extended to arbitrary compilation of the product based on user properties. here's a simplified example: suppose you have different definitions of definitions for a regular and a detailed view

 public abstract class AbstractView { ....} public abstract class NormalView extends AbstractView { ... } public abstract class DetailedView extends AbstractView { ....} 

you can create a module definition that will generate two different versions: one with the NormalView class NormalView other using DetailedView (in your gwt.xml file)

 <define-property name="customMode" values="normal,detailed" /> <replace-with class="com.example.NormalView"> <when-type-is class="com.example.AbstractView" /> <when-property-is name="customMode" value="normal" /> </replace-with> <replace-with class="com.example.DetailedView"> <when-type-is class="com.example.AbstractView" /> <when-property-is name="customMode" value="detailed" /> </replace-with> 

using

 AbstractView view = GWT.create(AbstractView.class); 

will provide the appropriate instance at runtime.

It is for you to encapsulate your client code in specific classes and expose common interfaces for different implementations.

You will also need to select the appropriate compiled version according to viewing the current client (for this you can use jsp.)


please do not accept the above code samples as tested, there may be problems with the syntax, it is just intended to convey a general idea


The JSP server is an ideal environment for hosting a GWT application, you can use the requestfactory mechanism for easy communication between the client and the server.

obviously there is a learning curve here, IMO's official documentation is a good place to start.

+1
source

I guess you can try reading OSGi related articles (or books) ... This platform will give you a very pragmatic answer to your modularity problems. It is specifically designed to be able to handle various modules living all together with dependencies and version control. As mentioned at the beginning of the answer, nesting dependencies through OSGi declarative services is a very valuable alternative to Spring, with dynamic capabilities. Deploying the service package and your links will automatically update, dropping them, and they will update too ... Take a look at this technology and ask a few questions after? Regards jerome

0
source

Source: https://habr.com/ru/post/1390162/


All Articles