
“Free” documentation that cannot become obsolete for your UseCases.Let’s see what other advantages we get with this approach:


It’s definitely a little bit weird at first, but the more I get used to the idea, the more I see how it all makes sense. We start with one of the hierarchies above in a way we are used to writing sealed hierarchies:Īhh, things are making sense… Now if we have other “UseCaseErrors” that should contain ApiCallError as their entries, we need to make ApiCallError implement those “UseCaseErrors” sealed interface.

Let’s take it step by step and maybe it will click for us. In fact, I asked two great developers of our dear community to take a look at this article after I finished the first draft, and they too felt the exact same way! (Thank you so much Adam McNeilly and Adam Bennett ❤️)īut this is in fact how we can achieve what we want. Instinctively, I almost wanted to do it the other way around. When I arrived at this solution, it felt weird for some reason. Maybe we’ll even have some Use Cases that can use ApiCallError as the return error type (if they don’t have any other unhappy path).īut, wait a second… Is this really right? Should ApiCallError really implement each UseCaseError and not the other way around? 🤔 This is not only for semantic reasons, we can now have our own wrapper for API calls that always returns ApiCallError in case of error. Once your layout has created, you can load the layout resource from your application code, in your Activity.With this change, we don’t have to repeat any error class ever again, and we even added a new error hierarchy for ApiCallError. Following is a simple example of XML file having LinearLayout − A layout may contain any type of widgets such as buttons, labels, textboxes, and so on. This tutorial is more about creating your GUI based on layouts defined in XML file.

The ViewGroup is a subclass of View and provides invisible container that hold other Views or other ViewGroups and define their layout properties.Īt third level we have different layouts which are subclasses of ViewGroup class and a typical layout defines the visual structure for an Android user interface and can be created either at run time using View/ViewGroup objects or you can declare your layout using simple XML file main_layout.xml which is located in the res/layout folder of your project. View is the base class for widgets, which are used to create interactive UI components like buttons, text fields, etc. The basic building block for user interface is a View object which is created from the View class and occupies a rectangular area on the screen and is responsible for drawing and event handling.
