UML model and code examples of design patterns for Kotlin/Native. The model is created with Astah.

Overview

Design Pattern Examples in Kotlin/Native

Model and code examples of GoF Design Patterns for Kotlin/Native.
This project is available for the following objectives:

  • To understand GoF Design Pattern examples in Kotlin/Native.
  • To understand the mapping between UML model and Kotlin/Native code.
  • To try Model-Driven Development (MDD) using Astah and M PLUS plug-in.

NOTE: The code examples use GTK4 and work on Ubuntu 22 (x86_64) and Fedora 36 (x86_64).

UML model example:

Kotlin/Native code example:

package structuralPatterns.composite
// ˅
// ˄

abstract class FileSystemElement {
    // ˅
    // ˄

    abstract val name: String
        // ˅
        
        // ˄

    abstract val size: Int
        // ˅
        
        // ˄

    // Print this element with the "upperPath".
    abstract fun print(upperPath: String)

    override fun toString(): String {
        // ˅
        return "$name ($size)"
        // ˄
    }

    // ˅
    
    // ˄
}

// ˅

// ˄

Installation on Ubuntu/Fedora

NOTE: The code examples work on Ubuntu 22 (x86_64) and Fedora 36 (x86_64).

UML Modeling Tool

Kotlin/Native Development Environment

  • Download and install IntelliJ.
  • Run the following command to install GTK4 development libraries.
    Ubuntu 22
    sudo apt install libgtk-4-dev libncurses5 gcc-multilib
    Fedora 36
    sudo dnf install gtk4-devel ncurses-compat-libs

Usage on Ubuntu/Fedora

NOTE: The code examples work on Ubuntu 22 (x86_64) and Fedora 36 (x86_64).

Code Generation from UML

  1. Open the Astah file (model/DesignPatternExamplesInKotlinNative.asta).
  2. Select model elements on the model browser of Astah.
  3. Click the Generate Code button.

    The generated code has User Code Area. The User Code Area is the area enclosed by "˅" and "˄". Handwritten code written in the User Code Area remains after a re-generation. View code example.
    For detailed usage of the tools, please see Astah Manual and M PLUS plug-in Tips.

Build and Run

  1. Open the project root directory (design-pattern-examples-in-kotlin-native) in IntelliJ.
  2. Open Main.kt for the pattern you want to run, and click Run icon in the left gutter.

References

  • Gamma, E. et al. Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, 1994
  • Hiroshi Yuki. Learning Design Patterns in Java [In Japanese Language], Softbank publishing, 2004

Licence

This project is licensed under the Creative Commons Zero (CC0) license. The model and code are completely free to use.

CC0

Other Language Examples

C++, C#, Crystal, Go, Java, JavaScript, Python, Kotlin/JVM, Ruby, Scala, Swift, TypeScript

You might also like...
React-native-user-interface - Change React Native userinterface at runtime

react-native-user-interface change RN userinterface at runtime. Installation npm

Examples of Android applications

Android Demos This is a collection of basic android examples created by Novoda. CarouselFragment CompassExample ContactSelector CustomActivityTransiti

Examples for my Android GraphView library

Chart and Graph Library for Android GraphView - open source graph plotting library for Android GraphView is a library for Android to programmatically

Examples of using Torus CustomAuth Android SDK

Torus CustomAuth Android Samples Examples of using Torus CustomAuth Android SDK. Usage Clone the repository and open with Android Studio Run the app,

A repository that contains various examples of how to use the telegram-bot library.

Telegram-bot templates This repository contains simple different examples of how to use the telegram-bot library. How to use All the examples are conv

Smart-flight - This app was created to learn and practice Kotlin language
Smart-flight - This app was created to learn and practice Kotlin language

Smart Flight This app was created to learn and practice Kotlin language. Works o

KVMapper: A Key-Value Mapper app for MacOS, created with Kotlin and Compose Desktop
KVMapper: A Key-Value Mapper app for MacOS, created with Kotlin and Compose Desktop

KVMapper is an application to convert key-value pairs from one format to another. About This app was purely written in Kotlin and compiled fo

A pet project created to practise Android Development skills in Kotlin after finishing multiple courses online.

A pet project created to practise Android Development skills in Kotlin after finishing multiple courses online. The app displays a list of hundreds of characters provided by The Rick and Morty API https://rickandmortyapi.com/. In other screens user can access detailed information about a particular character, such as status, location and episodes. Libraries used in a project: - Kotlin - Jetpack libraries (Navigation, Room, Hilt, Palette) - other: Glide, Retrofit

KotlinRoom - What is Android Room? (Use in Kotlin) is a sample project I created for my article
KotlinRoom - What is Android Room? (Use in Kotlin) is a sample project I created for my article

KotlinRoom Android Room Nedir? (Kotlin'de kullanımı) adlı yazım için oluşturduğu

Owner
Takaaki Teshima
I am a software engineer interested in Model-Driven Engineering (MDE) and Model-Based Systems Engineering (MBSE).
Takaaki Teshima
Design patterns are typical solutions to common problems in software design

Design patterns are typical solutions to common problems in software design. Each pattern is like a blueprint that you can customize to solve a particular design problem in your code.

hamid 4 Aug 30, 2022
ZeAppp v3, created by Android enthusiasts joining the Droidcon 2021 in Berlin, coming to the GDG Booth and writing code, 15 minutes at a time

ZeThree App build at the GDG Community booth at Droidcon Berlin 2021. Come join the fun™. ZeWhat? Based on the previous success of the ZeAppp-app, thi

GDG Berlin Android 8 Sep 16, 2022
An app created for Code Lousiville in order to learn the in-and-outs of basic Android development

Tea House is an app created for Code Lousiville in order to learn the in-and-outs of basic Android development.

Chauncey Harlan 0 Nov 19, 2021
A Python native extension written in Kotlin Native

Kotlin Python Ext This is a proof of concept for a Python extension in Kotlin. It is recommended to read the Official Python C API Documentation befor

Martmists 20 Jun 22, 2022
It is a project that contains lessons and examples about Kotlin programming language. 🇰

Kotlin Tutorials What is Kotlin? I added the platforms it supports and great resources. You can access the article from the link below: https://medium

Halil Özel 94 Dec 22, 2022
📲💬 react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in android and iOS devices.

React Native Fontext react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in androi

mroads 9 Dec 3, 2021
Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in the official package.

@mccsoft/react-native-matomo Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in th

MCC Soft 4 Dec 29, 2022
CMPLR Technologies 8 Apr 5, 2022
Native-loader - Safely load native libraries in Java

Native Loader ??️ Safe native loading in Java based off of the native-loader use

Mixtape 1 Oct 19, 2022