Click here to Skip to main content
13,768,884 members
Click here to Skip to main content
Add your own
alternative version

Tagged as



16 bookmarked
Posted 12 Apr 2004

Behavior Modeling Lesson

, 12 Apr 2004
Rate this:
Please Sign up or sign in to vote.
Behavior modeling is the minimal form of logical abstraction that fits nicely into how the human mind thinks and allows for one to understand complex systems and increases one's own ability to solve difficult puzzles.


This generic behavior modeling exercise was brought to you by Chat bot.

Behavior modeling

So you are about to design the next hit .com like Google, Yahoo, Hexbot, Ebay. One of the keys to implementing a robust multi-user application is to fully understand it from a behavior modeling perspective. Moreover, you must decide how the system should behave.

What is behavior modeling?

Behavior modeling is when you think of your ideas in terms of states and transitions. This requires both identifying all of the interesting states of being that your software or its components are likely to be in. And also, at a high level, abstracting what events are likely to cause your software or its components to change between states of being. Confused yet? After you do a few examples you will quickly get the hang of this mental exercise.

Behavior modeling is also referred to as State modeling, State machines and State transition matrix.

Why model behavior?

"Behavior modeling is the minimal form of logical abstraction that fits nicely into how the human mind thinks and allows for one to understand complex systems and essentially increasing one’s own ability to solve difficult puzzles"

– Daniel Stephen Rule

Mentally modeling the behavior of your idea helps you to better understand how your system or its components will react to events.

Here are some reasons to master behavior modeling

  • Prevent race conditions in your software.
  • Avoid nebulous areas in your software development.
  • Help you ask the right questions to your clients.
  • It is a critical skill designing large-scale multi-user solutions.

Drawing behavior models

Although you should generally just do behavior modeling or any software design in your head, some times while learning how to behavior model, it helps to draw out the models in a diagram.

Components of drawn behavior models


For the state you simply draw a box with the name of the state inside of it. The name of the state should remind you of what state action occurs when that state is encountered.


Represent a transition by drawing an arrow from the start state to the destination state and note what event causes the state to change.


Here are some examples that demonstrate how to draw your behavior model. The objective here is to master behavior modeling in your head, but drawing them out first will help you get there.

Bullet example


Once the bullet is created it is out of the rifle. If the bullet has not been fired it can be put into the rifle. Once in the rifle it can be either taken back out by hand or fired.


Rifle example


Once the rifle is created its safety is off and it is unloaded. As long as the rifle is not being fired the safety can be pushed on and off freely. The rifle can also be loaded and unloaded freely as long as it is not firing. The rifle can only be fired when the safety is off and it is loaded. Once the rifle is fired it looses its bullet and becomes unloaded and the safety remains off until it is pushed on.


Scenario to try modeling yourself

Here is a simple scenario to try modeling yourself. First roughly identify the states and transitions. Then reread it and check your behavior model for correctness:

Jack wants you to design him a chat bot. He wants the chat bot to ignore people unless they either say “hello” or “what is this”, if they say “hello” the chat bot should say “hi I am a bot” back to them and then wait to see if they say “hello” again or if they say “what is this”. If they say “what is this” then the chat bot should say “I am a chat bot, do you know what that is?” and then after that ignore everything they say unless they say “yes” or “no”. If they say “yes” at that point then the chat bot should say “good I am glad you know” and then go back to waiting to see if they say “hello” or “what is this”, if they say “no” at that point then the chat bot should say “that is too bad” and go back to waiting for the chat bot to say “hello” or “what is this”.

Practice behavior modeling

You can practice behavior modeling on a chatbot at create hexbot and then adding states and transitions at train hexbot. Once you create your chat bot you can test out the state model with Chatbot! by chatting with your state model at chat hexbot.

Mastering behavior modeling

One exercise to master behavior modeling is to read your favorite novel and constantly break the information up into states and transitions in your head as you read.

How does behavior-modeling compare to OOP?

Behavior modeling is a way to think more clearly about problems. OOP is a collection of constructs commonly found in computer programming languages that are considered to be useful and called OOP. There are various formalized software analysis diagrams, which are considered to be useful when coding OOP; these include UML, xUML and Shlaer Mellor. Mastering behavior modeling is a prerequisite to using any of these methodologies. However, having behavior modeling under your belt alone is often sufficient to engineer most large-scale projects.

How do design patterns compare to behavior modeling?

Design patterns are commonly used data models with intended behavior. Often, design patterns will share very similar behavior models but have much different usage. Like behavior modeling, design patterns help computer programmers communicate architecture at a higher level. In contrast, behavior-modeling focuses on generically breaking up the software design into states and transitions whereas design patterns are data models that are reused across many different applications within the same manor. Hence the “pattern” in “design pattern". If you were to look at behavior modeling from a design patterns perspective you would have a fairly simple data model and some rules about state transitions. Here is what a coding implementation of behavior modeling would look like from a design patterns perspective:

State machine design pattern



The state machine design pattern consists of an object that maintains both a state transition matrix and a current state pointer. The state transition matrix is dimensioned with all possible events by all possible states. The state transition matrix holds a pointer to the next state for each possible state and event pair. When the object gets an event, it determines what the next state is given its current state and the logic imposed by the state transition matrix. It then re-points the current state pointer to the new state in the state transition matrix hence completing a transition.

This is one implementation. You could opt to not use a state transition matrix and just use if-then logic in your code to maintain the state machine. The behavior modeling and how you code it are two very different things. Behavior modeling is when you mentally break your problem up into states and transitions, how you code your state logic is entirely up to you. There were a number of tools in the 90’s and early 2000’s that converted high-level behavior model diagrams into the coded design patterns and generated code. There is now a state transition mechanism that you can use to design state machines concurrently while they are being tested with events, without any sort of boot time configuration or code generation (patent pending: Daniel Stephen Rule). It works a lot like an RDBMS however, instead of creating tables while users send SQL against them, it lets you create states and transitions concurrently while users send events against your behavior models causing transitions. An example of this technology is Thousands of users are creating behavior models for’s mind data concurrently while users are sending events (chatting) to invoking state transitions.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
Keep on coding!

You may also be interested in...

Comments and Discussions

GeneralNeed Some more help Pin
ciacia9-Aug-08 11:06
memberciacia9-Aug-08 11:06 Pin
marc.thom8-Jun-06 5:54
membermarc.thom8-Jun-06 5:54 
GeneralOOA class Pin
Anonymous8-Jun-04 22:00
memberAnonymous8-Jun-04 22:00 
Anonymous2-Jun-04 7:30
memberAnonymous2-Jun-04 7:30 
eggie52-Jun-04 8:38
membereggie52-Jun-04 8:38 
abhadresh4-Jun-04 6:53
memberabhadresh4-Jun-04 6:53 
Generalgreat post Pin
Anonymous7-May-04 9:28
memberAnonymous7-May-04 9:28 
GeneralWOW - This is the best Pin
Anonymous20-Apr-04 11:45
memberAnonymous20-Apr-04 11:45 
General-- Very Informative -- Pin
Anonymous20-Apr-04 11:30
memberAnonymous20-Apr-04 11:30 
Generalimage at top Pin
Anonymous20-Apr-04 6:56
memberAnonymous20-Apr-04 6:56 
Generaldesign pattern Pin
Anonymous16-Apr-04 8:10
memberAnonymous16-Apr-04 8:10 
GeneralThis article is at least intelligible... Pin
Jeff Varszegi16-Apr-04 6:34
professionalJeff Varszegi16-Apr-04 6:34 
GeneralRe: This article is at least intelligible... Pin
sandeman17-Apr-04 14:54
membersandeman17-Apr-04 14:54 
GeneralRe: This article is at least intelligible... Pin
sandeman17-Apr-04 15:37
membersandeman17-Apr-04 15:37 
GeneralBehavior modeling and OOD Pin
mav.northwind13-Apr-04 20:46
membermav.northwind13-Apr-04 20:46 
GeneralRe: Behavior modeling and OOD Pin
dzzxyz14-Apr-04 9:30
memberdzzxyz14-Apr-04 9:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.181117.1 | Last Updated 13 Apr 2004
Article Copyright 2004 by dzzxyz
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid