Learning Library

← Back to Library

Designing Business Rules for Scalable Apps

Key Points

  • Jam Spain, an IBM Cloud Developer Advocate, recounts his early experience building a large‑scale online admissions system nearly 14 years ago, which forced him to embed extensive business logic directly into application code.
  • He defines **business rules** as the everyday logic programmed into applications, distinct from **business requirements**, which describe the desired outcomes or success criteria of a system.
  • Initially, his code scattered decision‑making across many functions and workflows, leading to duplicated logic, “band‑aid” fixes, and difficulty maintaining the system as requirements evolved.
  • Centralizing this logic into a dedicated **business‑rules engine** (or separate rule classes/interfaces) provides a cleaner, more maintainable architecture that isolates business logic from core application code.

Full Transcript

# Designing Business Rules for Scalable Apps **Source:** [https://www.youtube.com/watch?v=O0xcKqnBPx8](https://www.youtube.com/watch?v=O0xcKqnBPx8) **Duration:** 00:14:00 ## Summary - Jam Spain, an IBM Cloud Developer Advocate, recounts his early experience building a large‑scale online admissions system nearly 14 years ago, which forced him to embed extensive business logic directly into application code. - He defines **business rules** as the everyday logic programmed into applications, distinct from **business requirements**, which describe the desired outcomes or success criteria of a system. - Initially, his code scattered decision‑making across many functions and workflows, leading to duplicated logic, “band‑aid” fixes, and difficulty maintaining the system as requirements evolved. - Centralizing this logic into a dedicated **business‑rules engine** (or separate rule classes/interfaces) provides a cleaner, more maintainable architecture that isolates business logic from core application code. ## Sections - [00:00:00](https://www.youtube.com/watch?v=O0xcKqnBPx8&t=0s) **Untitled Section** - ## Full Transcript
0:00hello my name is Jam Spain developer 0:03Advocate with the IBM Cloud as a 0:06technologist everyone has that 0:07opportunity to build that first large 0:10scale application for me that's been 0:13almost 14 years ago the first challenge 0:17that I encountered where I had to do 0:19this task all by myself a single coder 0:22of one was actually an online admissions 0:25application now doing that process which 0:28is Way Way Beyond any hello world I had 0:32to actually have the opportunity to put 0:34in business logic into the application 0:36as I was developing it well there's 0:39actually a term for that and it's my 0:42topic for today business rules so what 0:45exactly are business rules if I had to 0:48simplify this for you let's just say 0:51that it is the 0:54everyday 0:56logic that gets programmed into actual 1:01applications um not to be confused with 1:03business requirements which really 1:05that's the output of what you're 1:06developing the application for we can 1:08call it kind of the success criteria so 1:11the business rules are really the way 1:13you formulate that business logic in and 1:16and it's usually done in many different 1:18circumstances but let me pose a 1:21situation for how it came to be that you 1:24kind of kind of work through now now 1:26when you think about it in your existing 1:28applications or as when I approached 1:29that this is generally how that design 1:32actually occurred I started with 1:34application 1:36code and at some point my immediate goal 1:39was to get me over to the actual data 1:42store of 1:46course now at some point I am building 1:49workflows algorithms as you may call it 1:51um particular patterns that I must 1:54follow what happens when someone signs 1:55up what 1:57happens um when they want to register 1:59for a class you know all these type of 2:01things in my mind I was trying to 2:03picture how do you symbolize those and 2:05how does it work so I'll just take two 2:06arrows here but I wanted to kind of 2:08formulate that there are many many 2:10decisions and functions and methods that 2:13must be programmed to work 2:15clearly all my data is is inside my 2:18database so I'm doing a back and forth 2:20this can actually be a two-way street 2:23here but what I noticed and when I think 2:25about when I first started development I 2:27really attached my logic into these 2:31individual flows so here I may have 2:33other 2:35functions that actually ran different 2:37logic and they were just kind of all 2:39over the place functions here functions 2:41there kind of as I started to approach 2:43them or another business requirement 2:45came up or something I had to do that 2:47had to be a part of this workflow I just 2:49kept piggybacking and banding on to 2:52processes all right and it kept on going 2:54kept on going and naturally when I had 2:57to make changes or update or or 3:00something evolved I had to try to go 3:01back in and band-aid and let's hope that 3:04there weren't two types of similar 3:07operations that had to occur in both of 3:09these workflows I had two or more places 3:12to kind of go here so this is where 3:14exactly where it comes in the context of 3:16where I'm talking to you today is 3:19formulate that into business rules so 3:22you'll have a secondary engine code 3:25classes some type of interface that you 3:27want to kind of code into where now 3:29actually a lot of your data flows in 3:31through here and then flows 3:37out maybe to your database has that 3:39process here and this gives you that one 3:41place where you can start to formulate 3:43things to have one particular area that 3:47data has to flow through um and then 3:49this gets me back to why business rules 3:52are really important so we said it's the 3:54everyday logic and you can naturally 3:56know that that's symbolized by your your 4:00your your syntax that we usually do for 4:02a lot of decision trees so you have your 4:04what I like to call the ifs all right uh 4:07so this would be expressing 4:11logic and we said the ifs so that's the 4:16ifs of the 4:18then 4:21only uh if 4:24else and naturally I have other 4:26conditions when something happens this 4:28should happen and maybe maybe um um only 4:32do this particular piece of logic if and 4:35only if uh so you can tell it gets 4:37really it's kind of your basic 4:39structures but gives you a big formal 4:41way of of kind of working with that now 4:44you may say why as I like to do with any 4:46technology or as a technology anything I 4:48want to implement I have to ask myself 4:51that question why do I actually want to 4:53do this there are obvious benefits that 4:55I want to spend my time in re 4:57architecting the application and as I 5:00started to work through this video 5:02concept here I actually thought about 5:04ways I could improved my original design 5:07if I actually went with this kind of 5:08architecture way back then but let's 5:11talk through those and they're very very 5:13important to cover here uh the first is 5:20efficiency a definitely added point 5:23there because naturally you can always 5:26see there's only one place I have to 5:28make changes all right um and that 5:31really helps uh uh with anything that I 5:34want to kind of assimilate and do I have 5:36one place to make the code changes I 5:39also say for 5:43consistency there're definitely going to 5:44be a plus in that area as well um 5:48naturally now with all these different 5:50workflows you think about the context of 5:52an application for an admissions from 5:54maybe um any type of institution that 5:57has to require an application for ad 5:59missions 6:00is you have many different departments I 6:01have one consistent way to represent my 6:03workflows uh and I may have you know 6:06maybe for the admission criteria I may 6:10have better ways to give to the 6:12scholarship committee to understand how 6:14we make decisions on admission so it 6:16gives you kind of a consistent process 6:18that you can use to really help 6:20formulate uh uh a particular workflows 6:24um there as well and then the last we 6:27have efficiency we're going to be 6:29consistent 6:30the 6:33complexity so not increasing complexity 6:36but we have a way 6:37to uh definitely uh decrease uh uh 6:41complexity because now we have um a easy 6:45way to represent how we can take a part 6:47of business workflow and break it up 6:50into constraints and parts that you know 6:52we can simulate it for how it should 6:54work here and now we have a template 6:57that can actually be used for the next 6:59business pro process and the next 7:00business process and quietly this is 7:03really the foundation of entering into 7:06um actual Automation and we'll get a lot 7:09about that please check out the process 7:10mining video we'll talk about how this 7:13this a lot of these activities really 7:15parlay you into that particular context 7:18here but yeah definitely obvious ways 7:21that you can kind of get direct benefits 7:23out let's go back to the logic here 7:26though we mentioned some of the basic 7:28control structures that works but this 7:31also goes by there's there's even a 7:33discipline for classifying how these 7:36rules apply now they can be 7:40constraints and think of constraints as 7:43things that immediately happen I already 7:45know a condition uh that's there so I 7:48know things that I want to do so we'll 7:50call that of a uh a yes criteria I met 7:54something so I can immediately jump here 7:56um uh so for admissions do you have a 7:59certain G PA yes we can go um there's 8:02you can also do pre and 8:04post conditions the what must happen 8:07when the data comes in and out just to 8:09make sure uh two conditions are set um 8:13uh and things that flow from there um 8:15and then uh there's other types of 8:17inference we'll 8:21say all right scribbled on in there we 8:23at least got it in the word is inference 8:25here and that's really uh uh based upon 8:28two particular cont text here I can also 8:31say whenever I have some facts that I 8:34know that I can make decisions on for 8:37instance um um you may I mentioned like 8:41a particular GPA or certain SAT scores I 8:45can make different factors there and 8:47then we have the things that we can 8:49calculate these type of numerical facts 8:51or conditions 8:52here I'll just do calc um and then those 8:56computational things can actually allow 8:58to me to get to to certain facts um here 9:01as well I remember at one point we were 9:03evaluating the applications I had to 9:05build a workflow that helped with 9:07evaluation if you did this on your if 9:10you inputed this from your scoring your 9:13essay you got this many points for a 9:15number of activities GPA all those 9:17things so I have certain facts that I 9:19can then make decisions over to know 9:21you're in a final group off from there 9:23just theorizing here as well so we've 9:25kind of moved through on how you kind of 9:27start out um and how you should have an 9:29architecture to take proper 9:31implementation of business rules we know 9:33the logic that's applied in different 9:36really different situations that you can 9:37build a lot of the workflows to gain 9:39these obvious benefits just to bring it 9:42on home here let's talk through a couple 9:44of use cases that really I can kind of 9:46see besides this that um can really be 9:49useful uh for you to use now the first I 9:52did mention here I kind of gave that one 9:55away but we said the first was 9:57definitely applications 10:02now I'm not saying that every actual web 10:05application project requires business 10:07rules but we are talking some of the 10:09large scale applications that you want 10:11to build definitely anything that 10:13requires an application you have ways 10:15that you can apply definite criteria to 10:18work and also a lot of these situations 10:20let's say in that situation where we had 10:22the application I was building I also 10:24had to prove how applications were 10:27evaluated so for regulations and in 10:29compliance you also can have a track 10:31record on how you went through and made 10:33a decision you know it wasn't just um if 10:36these were just loose rules like here it 10:39has an opportunity that it could not 10:41have gotten picked up or one particular 10:43piece of code could not have done um the 10:46the particular constraint that we wanted 10:48to apply but since everything rinses 10:49through we have a great opportunity to 10:52show how it was evaluated and show that 10:54kind of check and balance uh here let's 10:57say also for e-commerce 11:03so in Ecom let's think about the uh 11:06opportunity when you do purchases and 11:09returns and throughout the pandemic we 11:12know that we've bought a lot of things 11:13online there been numerous products that 11:15have been ordered we definitely always 11:17want to make sure before we go back and 11:19return has it been the 30 days has it 11:21been the 14 days and most a lot of 11:24applications I've G through and and use 11:26and return products you have to request 11:28the return authorization it's Meed going 11:30to ask you when did you purchase this 11:33and so at that first iteration I have an 11:35opportunity to say it's been uh plus or 11:39minus 30 days or 11:4314 and if I would like to that's a great 11:46opportunity for me to go ahead and send 11:47back a rejection sorry it's been past 11:49that time here but definitely give you a 11:52way to help evaluate different pieces 11:54there um and also uh think about 11:57purchasing there's a great opportunity 11:59to interact with other systems of 12:01inventory moving inventory around we all 12:04know that there's been a lot of 12:06inventory issues uh as of yet that we've 12:08come through and last but not least one 12:11that I love I want you to definitely pay 12:13attention to and I think this is great 12:15in today's many of today's architectures 12:19here and it's um 12:25the all right scribble that out 12:27personalization so lot of these engines 12:30everything is personal to you and I love 12:33it when I actually go to I get to browse 12:36a site I may be able to come come back 12:39so let's say you have the opportunity of 12:41new visitors and 12:45returning so if I'm a new visitor I have 12:47a great opportunity to put you into my 12:50new visitor workflow here are my 12:52featured products that I want you to pay 12:54attention to here are my deals the 12:56specials that I have but let's say I'm a 12:58returning user I'm just coming back to a 13:01website this can be an opportunity to 13:03show me what I've been looking at or to 13:05correlate I actually personally love the 13:08engine where I'm able to say other 13:10people who are looking at this they 13:12bought this maybe you should look at 13:14these options as well because it's all 13:16about diving deep into the 13:17specifications and understanding what's 13:20the option of why should I buy this over 13:22that especially when it comes to uh all 13:25the gadgets uh that I love here so we've 13:29done a lot today we talked about 13:31business rules the logic the rules that 13:33are required the obvious benefits that 13:35you can use to really implement this 13:37type of architecture and some use cases 13:40that you can kind of immediately jump 13:42out to you've always wanted to do this 13:44but this is a formal sturdy way of 13:47actually implementing this type of uh 13:49logic in your application if you have 13:51any questions please drop us a line 13:52below and if you want to see more videos 13:55like this in the future please like And 13:58subscribe