Web Development

General discussion


Can you put business logic in the properties files ?

By rushabh_subscriptions ·
Properties files were initially introduced to store configuration. Then, they got extended to include localisation information.

Now, how about storing business logic in properties files ?

We are doing a project that involves supporting several mobile handsets. Keeping this criteria in mind, we evolved a design whereby the core functionality remains as is, and to support a new handset, we only have to write the handset specific logic in an abstract class implementation, and accomodate this class in the Handset factory.

All's going well until the Project Manager thought that I should be able to support more handsets without any source code change !!! There certainly is some logic which is different between the handsets; so how do you take care of that ? eg: Handsets sort phone book contacts differently, based on case and length of the strings.

So now, the big plan is that we make a super set of all possible logics we can think of at this stage, and then by configuring the properties file, add a new handset with some settings.

However if, the new handset still has some new logic, I still have to do a "server-drop"; and test; and clear the QA criteria ....

At the end of the day, it does look like a challenging task. But I have a different question in my mind.

Is the properties file (or a config file in .Net) not a part of the source code ? Why is changing the properties file not that big an issue like changing some source code ? Just because it is outside the binary ?

And for the kind of logic that we are trying to accomodate within the properties file, shouldn't it be considered unsafe that business logic can be altered so easily ?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Handset OS will determine what....

by dawgit In reply to Can you put business logi ...

The OS of the handsets will determine just what and where you can put the config. files. I personally would want a little seperation, for many reasons. (Mine, are in a seperate file for a)security,b)the Phones use Java, my computer uses windows, and c)there's less danger of cross file contamination) Also, in the other part of your discussion, you mentioned a sort of 1 size fits all program. You are correct in not wanting to do that, you will have a some units working, but most becoming rocks.

Collapse -

Why not

by sudhindrashamanna In reply to Can you put business logi ...

Your first question:why changing properties file is not a big issue. It is probably because the changes are done at one central location which is very loosely coupled (hopefully) with other components. You just make amendments to one section of the properties file and don't worry about the effects on other components.
Second question: You would put only that part of your business logic which you feel is 'safe' in the properties file. It is your discretion ultimately.

Collapse -

Not happening in a compiled language, at least not easily

Welcome to the Stark Fist of Justice known as "a compiled language".

Reading values such as localization and configuration values isn't a problem, because it's putting the data into variables. But compiled languages lack an eval() ability. That means that you won't be able to read information into a variable and then run it.

One option is to put the buiness logic into a separate DLL (or whatever your compiled system is using) and then have the configuration file tell it what DLL to call up.

Your best option is to use an interpreted language, like Perl to perform that portion of the processing, and use that to load business logic dynamically.

Putting the business logic in a seprate file is not a problem, if (big if) you have your security set up right. If it is set up right, only authorized people will be able to alter it.


Collapse -

On track with the first solution, however...

by jslarochelle In reply to Can you put business logi ...

If you are programming in Java you can write a separate .jar file for each device and load that dynamically. You could define a set of interface that the classes in the .jar would implement. The class would infact implement a "strategy" for each device.

In C++ or other compiled language you could probably do something similar using DLL loaded explicitly. However you will have to do without the added flexibility of the reflection API of Java.

Related Discussions

Related Forums