Skip to content

Kokodemy/taschenrechner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deploy Go Report Card Maintainability Go Reference Go version


taschenrechner

This is an example project to showcase how to organize application code, implement unit tests and define integrity tests using a BDT framework. The app is available under taschenrechner.sarumaj.com.

Application screenshot

Features

  • handle invalid input
    • complete open brackets
    • abort incomplete arithmetic operations
    • prevent invalid input (partially tested)
    • in case of unforeseen exception, display NaN
  • memory cell
    • store result in a memory cell
    • retrieve and reuse last result

Setup

To setup similar project follow following steps:

  1. Create GitHub repository.
  2. Install git CLI and authenticate it.
  3. Clone your repository:
    git clone https://github.com/[username]/[repository name]
    cd [repository name]
    
  4. Initialize new Go module: go mod init github.com/[username]/[repository name], where github.com/[username]/[repository name] will be your module name.
  5. Start coding. Additional libraries can ben added using go get [module name]. Use go mod tidy if necessary.
  6. Define unit tests and execute: go test -v ./...
  7. Execute: go run [program entrypoint file]
  8. Build: go build [program entrypoint file]
  9. Utilize version control:
    1. Status check: git status
    2. Pull: git pull
    3. Stage and commit:
      git add .
      git commit -m "[your commit message goes here]"
      
    4. Push: git push
    5. Advanced usage:
      1. Create a temporary branch: git checkout -b [branch name]
      2. Pull, stage, commit
      3. Push: git push --set-upstream origin [branch name]
      4. Create pull request and merge it through the web interface (github.com)

Application structure

The application entrypoint makes use of the package ui. The import path is always the module name followed by the package path, e.g.

Property Value
Module name github.com/sarumaj/taschenrechner
Package pkg/ui
Import path github.com/sarumaj/taschenrechner/pkg/ui

The app utilizes following frameworks:

  • Fyne for frontend development
  • Goval to parse and evaluate arithmetic expressions in the backend

As for the BDT testing the Cucumber framework and its Go implementation (Godog) are being used.

The unit test file sequence_test.go provides an example on how to write context-aware and well documented unit tests.

The unit test file cursor_test.go, unit test file parse_test.go, or unit test file tokens_test.go provide examples on how to write context-aware and compact unit tests (reduced number of lines).

The test suite for entrypoint main_test.go defines the feature steps parsed by the test engine:

  • ^I press following buttons: "([^"]*)"$
  • ^I get following result: "([^"]*)"$

The BDT feature file example.feature defines few test scenarios making use of the aforementioned feature steps.

Questionary

Analyze this project and answer following questions:

  1. Testing
    1. How do the unit tests work?
    2. What advantages does BDT bring about? How is BDT set up for this project?
    3. How to increase test coverage, without increasing maintenance effort and code complexity?
  2. Data Models
    1. What are linked lists or trees? How is a linked tree used for parsing in this project?
    2. What are interfaces and what are they good for? How are they used in this project?
    3. Where do we use generics?
  3. Design Patterns and Coding Style
    1. Find and explain: Return Early Pattern.
    2. Find and explain: Method Chaining.
    3. Find and explain: Object Abstraction and Object Oriented Programming (OOP).
    4. Find and explain: Dependency/Configuration Injection.
  4. Logic
    1. How does the lexical parser work? What does a tokenizer do?
    2. What does the cursor do? How does it work?
    3. What is the memory cell for? How does it work?
  5. UI and Deployment
    1. Hos is the UI set up?
    2. How to compile the project?
  6. Documentation
    1. How to document a function? A custom type?
    2. How to publish code documentation?

About

Example project using fyne for GUI development

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages