@jgrenat@bsky.social
Slides : bit.ly/metier-types
True
False
1
12347
2
0.5664908
Infinity
"1"
"Devoxx"
""
"Elm"
"笑う門 には 福来たる"
"🐣"
True
False
2 valeurs
L’ensemble des connaissances, règles, processus et concepts spécifiques liés à l’activité
La gestion de réservations de salles et de services pour des réunions
type Booking = {
items: {
product: Product,
discount?: Discount
}[];
customer: Customer;
status: string;
paymentDate?: DateTime;
}
export type Product = {
id: string;
name: string;
type: string;
unitPrice: number;
details: any;
}
export type Discount = {
type: string;
value: number;
}
export type Customer = {
id: string;
email: string;
address: string;
}
Modélisation
Métier
2
∞
2
Card(modelisation) == Card(business)
export type Discount = {
type: 'percentage' | 'fixed';
value: number;
}
export type Discount = {
isPercentage: boolean;
value: number;
}
Value Objects
Types algébriques
export type Customer = {
id: CustomerId;
email: Email;
address: string;
};
export type Discount = {
type: "percentage" | "fixed" | "free";
value: number;
};
export type Product = RoomProduct | ServiceProduct;
type RoomProduct = {
id: ProductId;
name: string;
type: "room";
unitPrice: number;
details: { from: BookingTime; to: BookingTime; roomId: RoomId };
};
type ServiceProduct = {
id: ProductId;
name: string;
type: "service";
unitPrice: number;
details: { serviceId: ServiceId; count: number };
};
export type Booking = DraftBooking | ValidatedBooking | PaidBooking;
type DraftBooking = {
items: BookingItem[];
customer?: {
email?: string;
address?: string;
};
status: "draft";
};
type ValidatedBooking = {
items: NonEmptyArray<BookingItem>;
customer: Customer;
status: "validated";
};
type PaidBooking = {
// ...
paymentDate: DateTime;
};
@jgrenat@bsky.social
Slides : bit.ly/metier-types
Slides : bit.ly/metier-types
@jgrenat@bsky.social
Slides : bit.ly/metier-types
@jgrenat@bsky.social