## Tutorial: Birthdays - Maintaining UI / Data Separation

This example shows how to use the Carbide.c++ UI Designer for S60 to define the UI of an application and to implement the "real work" in the generated code.

The goals of the application are to:

- Maintain data and UI separation

- Use the S60 UI Designer to create the UI

- Editing generated source to provide application logic

- Save and restore birthdays from persistent storage

- Summary

### Maintaining UI / Data Separation

We want to define a record for a birthday and a list of birthdays, but not tie this to the UI that displays or edits it. The UI, of course, must be able to read and write birthdays, so the term "separation" really refers to separation of ownership. So in this application, birthday information is owned by the application, and the UI derives its content from and contributes to this information.

The TBirthday.cpp and .h files define the model for one birthday, containing setters and getters for the name, date, and todo fields. For ease of programming these are fixed-size TBuf objects and copied in and out without checking sizes. Since it contains no heap-allocated storage, this is a "T" class. The constraints on the editors in the UI ensure (hopefully) that these buffer limits will never be exceeded. More error-checking would be expected from a real application.

We don't provide a custom class for the list of birthdays, instead storing these inside the CBirthdaysDocument class. The "document" is a standard S60 application class, used in Symbian OS to manage the data for an application. We maintain an array of birthdays and provide accessors for adding, removing, and accessing a TBirthday by index.