0% found this document useful (0 votes)
8 views

Lecture 2

The document provides an introduction to the Dart programming language including details about main functions, comments, variables, data types, collections, null safety, and functions. It explains key Dart concepts like optional and named parameters and using final and const with variables.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lecture 2

The document provides an introduction to the Dart programming language including details about main functions, comments, variables, data types, collections, null safety, and functions. It explains key Dart concepts like optional and named parameters and using final and const with variables.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Software Engineering

2023 2024
Lecture 2

10 October 2023 1
‫ساليدات‬BPMN
‫من المرجع‬

‫ومن الرابط‬

http://fundamentals-of-bpm.org/supplementary-material/lectures/

10 October 2023 2
Modeling an order to-cash process in BPMN.
• This process starts whenever a purchase order has been received
from a customer.
• The first activity that is carried out is confirming the order.
• Next, the shipment address is received so that the product can be
shipped to the customer.
• Afterwards, the invoice is emitted and once the payment is received
the order is archived, thus completing the process

10 October 2023 3
The model of a simple order-to-cash process
Figure 3.1

10 October 2023 4
Start event, end event, tokens
• the start event indicates when instances of the process start
• The end event indicates when instances complete,
• For example, a new instance of the order-to-cash process is triggered
whenever a purchase order is received, and completes when the
order is fulfilled.
• we use the notion of token to identify the progress (or state) of that
instance. Tokens are created at the start event and flow throughout
the process model until they are destroyed in an end event

10 October 2023 5
Tokens
• We depict tokens as colored dots on top of a process model. For
example Figure 3.2 shows the state of three instances of the order-to-
cash process: one instance has just started (black token on the start
event),an other is at the stage of shipping the product (red token on
activity “Ship product”), and the third one has received the payment
and is about to start archiving the order (green token in the sequence
flow between “Receive payment” and “Archive order”).

10 October 2023 6
Exclusive Decisions
example
invoice checking process
As soon as an invoice is received from a customer, it needs to be
checked for mismatches. The check may result in any of the following
three options: (i) there are no mismatches, in which case the invoice is
posted; (ii) there are mismatches but these can be corrected, in which
case the invoice is resent to the customer; and (iii) there are
mismatches but these cannot be corrected, in which case the invoice is
blocked. Once one of these three activities is performed the invoice is
parked and the process completes

10/10/2023
An example of the use of XOR gateways

10/10/2023
From a token perspective, an XOR-split routes the token coming from
its incoming branch towards one of its outgoing branches, i.e.only one
outgoing branch can be taken

10/10/2023
Repetition

10 October 2023 10
10 October 2023 11
‫‪introduction to Dart‬‬

‫جميع المعلومات الواردة في الساليدات من المرجع األول •‬


‫‪• Dart documentation‬‬

‫‪10 October 2023‬‬ ‫‪12‬‬


main() function
• Every app requires the top-level main() function, where execution
starts.
• Functions that don’t explicitly return a value have the void return
type.
• To display text on the console, you can use the top-level print()
function:

10 October 2023 13
Single-line comments
A single-line comment begins with //.
Everything between // and the end of line is ignored by the Dart compiler.

10 October 2023 14
Multi-line comments
• A multi-line comment begins with /* and ends with */.

10 October 2023 15
Variables

• Variables store references. The variable called courseName contains a


reference to a String object with a value of “Software Engineering 2”.
• The type of the courseName variable is inferred to be String,
• Another option is to explicitly declare the type that would be inferred:

10 October 2023 16
Built-in types
• Numbers (int, double)
• Strings (String)
• Booleans (bool)
• Lists (List, also known as arrays)
• Sets (Set)
• Maps (Map)

10 October 2023 17
Strings

• You can use either single or double quotes to create a string:


• To create a multi-line string, use a triple quote with either single or
double quotation marks:

10 October 2023 18
Strings
• You can put the value of an expression inside a string by using
${expression}.
• If the expression is an identifier, you can skip the {}.

10 October 2023 19
Boolean
• To represent boolean values, Dart has a type named bool. Only two
objects have type bool: the boolean literals true and false, which are
both compile-time constants.

10 October 2023 20
Numbers
• Dart numbers come in two flavors: int, double

10 October 2023 21
int.parse()

10 October 2023 22
Collections
Dart has built-in support for list, set, and map collections

10 October 2023 23
Lists
• Perhaps the most common collection in nearly every programming
language is the array, or ordered group of objects. In Dart, arrays are
List objects, so most people just call them lists

• Note: Dart infers that


listOfNumbers
has type List<int>

10 October 2023 24
Sets
• A set in Dart is an unordered collection of unique items

10 October 2023 25
Sets
• To create an empty set, use {} preceded by a type argument, or assign {} to
a variable of type Set:

• Note: var names = {}; // Creates a map, not a set.


10 October 2023 26
Maps
• In general, a map is an object that associates keys and values. Both
keys and values can be any type of object. Each key occurs only once,
but you can use the same value multiple time

Note: referenceSE2 has the


type Map<int, String>

10 October 2023 27
Null safety
• When you specify a type for a variable, parameter, you can control
whether the type allows null. To enable nullability, you add a ? to the
end of the type declaration.
String? name // Nullable type. Can be `null` or string.
• You must initialize variables before using them. Nullable variables
default to null, so they are initialized by default. Dart doesn’t set
initial values to non-nullable types. It forces you to set an initial value.

10 October 2023 28
Default value
• Uninitialized variables that have a nullable type have an initial value
of null. Even variables with numeric types are initially null, because
numbers—like everything else in Dart—are objects.
int? lineCount;

10 October 2023 29
Final and const

• If you never intend to change a variable, use final or const, either


instead of var or in addition to a type. A final variable can be set only
once; a const variable is a compile-time constant. (Const variables are
implicitly final.)

10 October 2023 30
loops

10 October 2023 31
for-in loop

10 October 2023 32
For each

10 October 2023 33
if statements

10 October 2023 34
functions
• For functions that contain just one expression, you can do the
following
• The => expr syntax is a shorthand for { return expr; }
• Note: Only an expression—not a statement—can appear between the
arrow (=>) and the semicolon (;). For example, you can’t put an if
statement there,

10 October 2023 35
functions
• the function still works if you omit the types:

10 October 2023 36
Named parameters
• Named parameters are optional unless they’re explicitly marked as
required.
• When defining a function, use {param1, param2, …} to specify named
parameters. If you don’t provide a default value or mark a named
parameter as required, their types must be nullable as their default
value will be null

10 October 2023 37
default value
• use = to specify a default value. The specified value must be a
compile-time constant.

10 October 2023 38
required
• If you instead want a named parameter to be mandatory, requiring
callers to provide a value for the parameter, annotate them with
required

10 October 2023 39
Optional positional parameters
• Wrapping a set of function parameters in [] marks them as optional
positional parameters. If you don’t provide a default value, their types
must be nullable as their default value will be null

10 October 2023 40
Optional positional parameters
• use = to specify a default value. The specified value must be a
compile-time constant.

10 October 2023 41
readLineSync();
• First: import 'dart:io';

10 October 2023 42
Conditional expression
• condition ? expr1 : expr2
• If condition is true, evaluates expr1 (and returns its value); otherwise,
evaluates and returns the value of expr2.

10 October 2023 43
10 October 2023 44
10 October 2023 45
10 October 2023 46
10 October 2023 47

You might also like