Coding complex
app logic, visually
David Khourshid
Render ATL 2022
@davidkpiano
David Khourshid
David K Piano
isLoading === true;
isLoading === false;
isSuccess === true;
isError === true;
<form onSubmit={event => {
// ๐ฅ side-effect!
submitData(event);
}}>
{/* ... */}
</form>
<form onSubmit={event => {
submitData(event);
}}>
{/* ... */}
</form>
const [isLoading, setIsLoading] = useState(false);
<form onSubmit={event => {
if (isLoading) { return; }
submitData(event);
setIsLoading(true);
}}>
{/* ... */}
</form>
const [isLoading, setIsLoading] = useState(false);
<form onSubmit={event => {
if (isLoading) { return; }
submitData(event)
.then(() => { setIsLoading(false) })
setIsLoading(true);
}}>
{/* ... */}
</form>
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(null);
<form onSubmit={event => {
if (isLoading) { return; }
submitData(event)
.then(() => { setIsLoading(false) })
.catch(err => {
setIsLoading(false);
setError(err);
});
setIsLoading(true);
}}>
{/* ... */}
</form>
const [isLoading, setIsLoading] = useState(false);
const [isCanceled, setIsCanceled] = useState(false);
const [error, setError] = useState(null);
<form onSubmit={event => {
if (isLoading ) { return; }
submitData(event)
.then(() => {
if (isCanceled) { return; }
setIsLoading(false)
})
.catch(err => {
if (isCanceled) { return; }
setIsLoading(false);
setError(err);
});
setIsLoading(true);
}}>
{/* ... */}
<button
type="button"
onClick={() => { setIsCanceled(true) }}
>
Cancel
</button>
{/* ... */}
</form>
Low-code
No-thanks?
๐
index.html
๐
scripts.js
๐
styles.css
โจ
What low-code
tools can do
โ๏ธ
What you
need to do
๐ป
What code can do
Abstraction
Complexity
Abstraction
Complexity
Libraries, frameworks
Functions, classes
APIs, SDKs
Abstraction
Complexity
Libraries, frameworks
Functions, classes
APIs, SDKs
Varied tools, stacks
Multiple languages, runtimes
Dynamic, changing
Abstraction
Complexity
Libraries, frameworks
Functions, classes
APIs, SDKs
Varied tools, stacks
Multiple languages, runtimes
Dynamic, changing
Abstraction
Complexity
How can visual tools balance
?
Graphics design
Games & CAD
Websites & Apps
๐
User stories
๐ผ
Mockups
๐
User flows
๐ป
Code
๐งช
Tests
๐ฉโ๐ซ
Tutorials
๐ฅ
๐
User stories
๐ผ
Mockups
๐
User flows
๐ป
Code
๐งช
Tests
๐ฉโ๐ซ
Tutorials
Designers
Stakeholders
Developers
Executable models
BPMN
Statecharts
UML
Umm...
not exactly!
Logged out
Logged in
LOG IN
[correct credentials]
- Make API call to Supabase
- Initiate OAuth flow
- Ensure token is valid
- Persist token as cookie
- Redirect to logged in view
Given a user is logged out,
When the user logs in with correct credentials
Then the user should be logged in
๐จโ๐จ
Designers
๐ฉโ๐ผ
Stakeholders
๐ฉโ๐ป
Developers
๐ค
Common visual language
import { createMachine, assign } from 'xstate';
const machine = createMachine({
id: 'Dog API',
initial: 'idle',
context: {
dog: null
},
states: {
idle: {
on: {
FETCH: 'loading'
}
},
loading: {
invoke: {
id: 'fetchDog',
src: (context, event) => fetch('https://dog.ceo/api/breeds/image/random')
.then(data => data.json()),
onDone: {
target: 'resolved',
actions: assign({
dog: (_, event) => event.data
})
},
onError: 'rejected'
},
on: {
CANCEL: 'idle'
}
},
resolved: {
type: 'final'
},
rejected: {
on: {
FETCH: 'loading'
}
}
}
});
๐ป
Code
โคต๏ธ
Diagrams
?
๐ป
State
management
๐ผ
State
orchestration
๐งช
Model-based
testing
๐ค
Automated
workflows
โฏ
Simulation
โ๏ธ
Multi-step
forms
๐
Routers
๐
Documentation
generation
๐ผ
Executable
diagrams
Low-code
Abstraction
Complexity
Pro-code
Thank you Render ATL ๐
David Khourshid
Coding Complex App Logic, Visually
By David Khourshid
Coding Complex App Logic, Visually
- 1,322