Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5985499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:32:19+00:00 2026-05-22T22:32:19+00:00

This problem is for a piece of software that is use by companies that

  • 0

This problem is for a piece of software that is use by companies that organise activities. When an activity is changed (status, starting time, number of persons), some people need to be notified of this (by e-mail). The code that is responsible for this started out very simple: the body of the e-mail contained all the old values and new values of the information that was changed.

Over the years, many small rules were introduced. For example: if the new status is ‘cancelled’, the subject of the mail should be: “Activity cancelled” instead of “Activity changed”. If there is no previous status (so the activity is new), and the current status is “final”, then the subject should be “New Activity on [date]” and the body should contain a full overview (so no changes).

These rules above just serve to illustrate the problem. There are quite a few more of them (concerning combinations of status/date/time/etc.), totalling up to about 500 lines of code.

The problem that occurs is that this code is currently quite hard to understand and maintain. New rules are introduced every now and then, and adding them without breaking other rules can be a pain. What would be the best way to rewrite code like this into more understandable and maintainable code? Currently, the order of the if-else branches is also really important. The first if statement is the most important, the next else-if statement is bit less important, until the final else clause for the most general case.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:32:19+00:00Added an answer on May 22, 2026 at 10:32 pm

    Sounds like something a rules engine could help with. Drools is one option, but it’s almost certainly complete overkill!

    Do you have an interface representing a rule? Something like

    public class Activity {}
    
    public interface Rule {
         boolean applies(Activity);
    
         Activity applyRule(Activity x);
    }
    

    Given this, you could implement a reduce function to apply the rules in order until you reach the end of the list.

    Activity applyRules(List<Rule> rules, Activity);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing a piece of software that works like this: I have a
I am having problem getting this piece of code to run. The class is
I've wrote this simple piece of code. And I have a slight problem with
This problem has been bugging me for a long time. For example, the code
I have a project that is for a piece of software. So I reference
I have a piece of software that just entered beta. A Japanese version of
I need to profile a piece of software written in C. Now the problem
I am writing a software in C. For that purpose I use lex. I
As part of this php login and redirect software I have a piece of
My office uses a piece of software that generates XML based reports. These reports

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.