avatarMartin Schimak ☕

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2588

Abstract

obably up to three days.”</p><figure id="071d"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*gmzGwUXlcC3XBATHmci45Q.jpeg"><figcaption></figcaption></figure><p id="86ca">Seconds later, Max, who already happens to be in the 5b classroom and is busy to finish his math homework, looks at his phone and sees a message saying that Mr. Schlesinger will teach English at 08:30. And mathematics? It was canceled! Max is relieved and heads for the soda machine. The electronic time table next to the entrance of 5b already shows the change, too. English at 8:30, it’s Mr. Schlesinger who will teach the class until 09:15. There are a few other changes instead of mathematics for tuesday already visible. And for wednesday, the last lesson, which is a mathematics lesson, is canceled, too. Max is thrilled! This week starts like every week could start, actually. But he also knows that sometimes the “long-term” cancellations are reversed again. Max hopes for the best and moves on to the soda machine.</p><p id="b16e">Seconds after the teacher reported to be sick, the chatbot system already arranged for all changes for all three days. Mr. Schlesinger, just on his way to school, of course got the message, too, and was quite happy about it. Max’ mother, looking at her phone, smiled, because she knows why Max left in a rush today. And while she respected that decision she also suspected that Max couldn’t finish his math homework anyway anymore. While all this happened, the director went through an architect’s proposals for the new school kitchen. She didn’t even need to know. Sometimes, the chatbot would involve her, but just in case it can’t sort out a solution with directly affected stakeholders.</p><h1 id="3482">Scenario: Determine solution for abandoned lesson</h1><p id="b51c">Let’s dig into an example with which the chatbot enabled system determines a substitution teacher for the first lesson on monday morning and assigns this selected teacher to teach a lesson for this class. I am using EventStorming to illustrate the scenario (a <a href="https://readmedium.com/business-rules-367e430ee168">personal variant</a> using large, yellow stickies to describe business rules):</p><figure id="63ae"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*apI839LhNCsl5ylnJJspFw.png"><figcaption></figcaption></figure><p id="37de">It starts with a domain event “Teacher absence reported”. Based on this new fact in the system a component triggered by an event listener might now apply some rules to determine a strategy for the lesson we need to take ca

Options

re of. It might e.g. be a valid strategy to cancel the very first and the very last lessons on a specific day, but in our case it might also be too late to apply this strategy for the very first lesson on monday morning. Therefore, as a second step we might have more rules to determine and select a specific teacher as a substitute for the absent teacher for that specific lesson. As we now want to automate most of the stuff we of course needed to get a bit more specific about applicable rules and decided that a teacher already teaching a class in another subject should actually be preferred over a teacher who is teaching the original lesson’s subject but does not know the class.</p><p id="e744">As a result of all these considerations we have now specified intent, a command “Assign substitute to lesson”. This intent can now be executed and we can finish the execution with a domain event “Substitute assigned to lesson”. Note, that the execution could also finish with “Substitution for lesson rejected”! Imagine e.g. it could sometimes happen that we want to assign a substitute to a lesson, but while executing that intent we find out that this is not possible: the selected teacher is e.g. absent himself or was just assigned to substitute for another lesson. We would then have a new fact in our system and needed to come up with new commands to act upon those facts.</p><h1 id="33aa">My fact-driven journey</h1><p id="8711">This scenario and example will be used to illustrate some stuff on <a href="https://readmedium.com/my-fact-driven-journey-79ce955d40a">my fact-driven journey</a>. As I need to link to it several times I decided to put it into a separate article. The example here might evolve over time so that it always fits to the other articles collected in the journey!</p><p id="1499">A small, but important thing … even when I sound assertive sometimes, it’s a subconcious technique I use to provoke <b>your</b> associations and counter arguments. I never claim to understand, but always try to understand better than before. I share <b>thoughts and feelings</b>, and even when I attempt to “define” things, it’s an invitation: please help me, as a software community, to <b>eventually </b>get this stuff<b> consistent</b>! :-) If you want to keep in touch, you can <a href="https://twitter.com/martinschimak">follow me on Twitter</a>. It’s also the simplest way in case you need to exchange a direct message with me. Thank you for reading and spending some of your precious time with me. For me it’s the most precious thing you can share.</p></article></body>

A Little Chatbot for Schools

Scenarios for my fact-driven journey.

It’s Monday 8:00 in the morning and Cloe Wood’s mobile phone rings. Paul Myers, one of her teachers, reports to be “knocked out” and sick for “up to three days”. The school principal looks at Paul’s time table in order to arrange for his very first lesson. It’s a mathematics lesson in the 5b class and already starts 8:30. This of course needs to be taken care of immediately …

Arranging for the first affected lesson

Everything else Mrs. Wood’s assistant will arrange for a bit later. But Mrs Wood knows that according to the substitution arrangements, there are two colleagues who are supposed to be available from 8:30 until 9:15, when the first lesson finishes. The first one is Emilia Peterson, a mathematics teacher, but she doesn’t know 5b. The second one is an english teacher, Kurt Schlesinger, who happens to teach in 5b. Mrs. Wood goes for Emilia first and gives her a call. Emilia hesitates for a moment, then says: “I believe I’m already assigned to substitute in 3a. But I will know for sure when I arrive at school.” So Mrs. Wood decides to give Kurt a call. He tells her to already be on his way and that he will be in the 5b on time. “It’s a fortunate coincidence, we can use the time for another english lesson really well!” Mrs. Wood sighs. Some things can go rather smooth, too. Sometimes.

A conversation with Cindy

She leaves her office and realises that Cindy, her assistant, is actually already at her desk, too. “Good morning, Cindy! Cindy … by the way … what about the substitution in 3a … is it taken care off?” “Oh, sure”, Cindy answers, “actually I just informed Emilia she doesn’t need to substitute, the other colleague is already well again.” Mrs. Wood nods slightly and is already about to leave the room. But then she turns around and asks: “Cindy, when exactly did you tell Emilia?” “Well, I don’t know exactly. Maybe fifteen minutes ago. Why?”. “Oh nothing… it doesn’t really matter.” Mrs. Wood, slightly raising an eyebrow, returns to her office.

A chatbot for schools

Let’s suppose, we build a chatbot for this school. All teachers, parents, pupils and other stakeholders can communicate with this bot: Paul Myers, the sick mathematics teacher just types: “I am sick. Probably up to three days.”

Seconds later, Max, who already happens to be in the 5b classroom and is busy to finish his math homework, looks at his phone and sees a message saying that Mr. Schlesinger will teach English at 08:30. And mathematics? It was canceled! Max is relieved and heads for the soda machine. The electronic time table next to the entrance of 5b already shows the change, too. English at 8:30, it’s Mr. Schlesinger who will teach the class until 09:15. There are a few other changes instead of mathematics for tuesday already visible. And for wednesday, the last lesson, which is a mathematics lesson, is canceled, too. Max is thrilled! This week starts like every week could start, actually. But he also knows that sometimes the “long-term” cancellations are reversed again. Max hopes for the best and moves on to the soda machine.

Seconds after the teacher reported to be sick, the chatbot system already arranged for all changes for all three days. Mr. Schlesinger, just on his way to school, of course got the message, too, and was quite happy about it. Max’ mother, looking at her phone, smiled, because she knows why Max left in a rush today. And while she respected that decision she also suspected that Max couldn’t finish his math homework anyway anymore. While all this happened, the director went through an architect’s proposals for the new school kitchen. She didn’t even need to know. Sometimes, the chatbot would involve her, but just in case it can’t sort out a solution with directly affected stakeholders.

Scenario: Determine solution for abandoned lesson

Let’s dig into an example with which the chatbot enabled system determines a substitution teacher for the first lesson on monday morning and assigns this selected teacher to teach a lesson for this class. I am using EventStorming to illustrate the scenario (a personal variant using large, yellow stickies to describe business rules):

It starts with a domain event “Teacher absence reported”. Based on this new fact in the system a component triggered by an event listener might now apply some rules to determine a strategy for the lesson we need to take care of. It might e.g. be a valid strategy to cancel the very first and the very last lessons on a specific day, but in our case it might also be too late to apply this strategy for the very first lesson on monday morning. Therefore, as a second step we might have more rules to determine and select a specific teacher as a substitute for the absent teacher for that specific lesson. As we now want to automate most of the stuff we of course needed to get a bit more specific about applicable rules and decided that a teacher already teaching a class in another subject should actually be preferred over a teacher who is teaching the original lesson’s subject but does not know the class.

As a result of all these considerations we have now specified intent, a command “Assign substitute to lesson”. This intent can now be executed and we can finish the execution with a domain event “Substitute assigned to lesson”. Note, that the execution could also finish with “Substitution for lesson rejected”! Imagine e.g. it could sometimes happen that we want to assign a substitute to a lesson, but while executing that intent we find out that this is not possible: the selected teacher is e.g. absent himself or was just assigned to substitute for another lesson. We would then have a new fact in our system and needed to come up with new commands to act upon those facts.

My fact-driven journey

This scenario and example will be used to illustrate some stuff on my fact-driven journey. As I need to link to it several times I decided to put it into a separate article. The example here might evolve over time so that it always fits to the other articles collected in the journey!

A small, but important thing … even when I sound assertive sometimes, it’s a subconcious technique I use to provoke your associations and counter arguments. I never claim to understand, but always try to understand better than before. I share thoughts and feelings, and even when I attempt to “define” things, it’s an invitation: please help me, as a software community, to eventually get this stuff consistent! :-) If you want to keep in touch, you can follow me on Twitter. It’s also the simplest way in case you need to exchange a direct message with me. Thank you for reading and spending some of your precious time with me. For me it’s the most precious thing you can share.

Software Design
Software Architecture
Software Development
Ddd
Event Driven Architecture
Recommended from ReadMedium