Coder Social home page Coder Social logo

takaakit / design-pattern-examples-in-kotlin-native Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 10.2 MB

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

License: Creative Commons Zero v1.0 Universal

Kotlin 100.00%
astah design-patterns gof kotlin-native m-plus-plugin uml

design-pattern-examples-in-kotlin-native's Introduction

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

design-pattern-examples-in-kotlin-native's People

Contributors

takaakit avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.