Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 1 year has passed since last update.

マルチスケールモデリング特論 :: 狙いはRuby修得

Last updated at Posted at 2022-08-02

動画リンク切れ

DONE 4, 6

Introduction

目的と最終課題

この講義では,Rubyを修得することを目的とします.その目的が達成されたかを評価するため,

  • なんかのCLA(command line application)をRubyで作成してgithubで公開する,
  • あるいはgemで公開する,
  • あるいは,その紹介記事をqiitaに投稿する

を最終課題とし,成績評価します.それぞれのリンク先を年内をめどにmailで西谷に送ってください.

links

Schedule

past

d11_qiita 12/14

d12_members_CLIs 12/21

(Rubyで)ソフト開発必読書

  • pragmatic programmer
    • "The Pragmatic Programmer, Your journey to mastery, 20th Anniversary Edition", 2nd ed.,David Thomas and Andrew Hunt, (Addison-Wesley Professional,2019) or (Pragmatic Bookshelf).
    • "達人プログラマー -熟達に向けたあなたの旅-" 第2版, David Thomas and Andrew Hunt (著), 村上雅章 (訳) ,(オーム社,2020).
  • TDD, RSpec3
    • "Effective Testing with RSpec 3, Build Ruby Apps with Confidence", by Myron Marston and Erin Dees, (The Pragmatic Bookshelf, 2017).
  • Refactoring
    • "Refactoring : Ruby Edition: Ruby Edition", by Jay Fields, Martin Fowler, e-book, (https://martinfowler.com/books/refactoringRubyEd.html).
    • "リファクタリング: Rubyエディション", ジェイフィールド,シェーンハービー,マーティンファウラー,Kent Beck【著】,長尾高弘【訳】, (アスキー・メディアワークス, 2010).
  • Design Pattern
    • "Rubyによるデザインパターン", ラス・オルセン (著), 小林 健一他 (翻訳), (ピアソン桐原, 2009).

Schedule_preparing

Error_translator

translator

DeepL API + GAS(google apps script)

shell

other language

日本語化が当たり前...

qiita_org

Design pattern(DSL, CoC)

contents_memo

rsync

  • rsyncで同期
    • rake rsync
    • –dry-run
    • exlcudeで.gitとか指定すればgitとの併用になんの問題もなし
    • ただし,失敗するとrepositoryが乗っ取られるので,両方をgithubに載せて作業すべし.
  • ruby bin/auto_sync.rb
    • 一致の検査,
    • array比較の好例

open on wsl

rspec

-t, task-o, output_format-m, matcher-c, check_stderr-K, KeyError-s, shared_context-u, using_temp_dir , shared_context_II-a, aruba_setup , thor_aruba_loop , thor_aruba_-r, raise_error-i, interactive_aruba

for new class

  • name the behavior (The Org2Hash: get org and trans it to hash by FSM)
  • cp some spec for rspec
  • start coding in main loop
  • test
  • TDD…
  • after that the new class should go appropriate position(name).
> cat spec/unit/org2hash_spec.rb 
module MyHelp
  describe "Org2Hash" do
    it "return input" do
      input = "hoge"
      expect(Org2Hash.new(input).contents).to be_include(input)
    end
  end
end

> cat lib/my_help.rb 
# frozen_string_literal: true
...
module MyHelp
...

  # Your code goes here...
  class Org2Hash
    attr_accessor :contents

    def initialize(input)
      @contents = input
    end
  end
end

> rspec spec/unit/org2hash_spec.rb

Org2Hash
  return input

Finished in 0.00184 seconds (files took 0.23943 seconds to load)
1 example, 0 failures

fsm(finite state machine)

  • make sample #=> org text
  • name state
  • guess final results #=> Hash
  • make TRANSITIONS
  • make case-when and action
  • make def-method if large

Discussions

bashly

Compare to Rust ( => Ruby )

Guessing number game

  • install, compile, run
  • cargo => packaging
  • library, install, => bundle install, exec
  • use rand::Rng; => install library
  • Cargo.toml => **.gemspec
  • . trains
  • type => nil

Common Language Concepts

  • variables and Mutability, Constants, Shadowing,
  • Data Types
    • Scalar, Integer(u32, unsigned), Floating-Point(f32), Numeric Op.,Boolean, Character,
    • Compound Types
      • Tuple, Array,
  • Functions, Parameters(arguement), Functions with Return Values,
  • Comments
  • Control Flow
    • if(if in let), loop, for, while,

Ownership

  • manage memory, without garbage collector

  • the Stack and the Heap

  • Variable scope, String

  • borrowing(clone), slice

  • Structs

  • Enum and Pattern Matching

  • Packages, Crates, and Modules

= Common Collections

  • Error Handling,
  • Generic Types, Traits, and Lifetimes
  • Automated Tests

Building a command line program

  1. Reading the Argument Values
    • main, dbg!, args
  2. Reading a File
  3. Refactoring
    • methods, Grouping Conf. Vals.,
    • Constructor for Config
    • Error handling
    • move to lib.rs
  4. Test Driven Dev.
    • test, case_insensitive, ignore_case
  5. error output

Iterators and Closures

etc

  • Cargo, Crates.io, Pointers, Concurrency, OOP,

OOP

  • object, encapsulation, inheritance,
  • To many people, polymorphism is synonymous with inheritance.

Inheritance has recently fallen out of favor as a programming design solution in many programming languages because it’s often at risk of sharing more code than necessary. Subclasses shouldn’t always share all characteristics of their parent class but will do so with inheritance. This can make a program’s design less flexible. It also introduces the possibility of calling methods on subclasses that don’t make sense or that cause errors because the methods don’t apply to the subclass. In addition, some languages will only allow single inheritance (meaning a subclass can only inherit from one class), further restricting the flexibility of a program’s design.

For these reasons, Rust takes the different approach of using trait objects instead of inheritance. Let’s look at how trait objects enable polymorphism in Rust.

Go, Elixir, Clojure


  • source ~/git_hub/ruby_docs/multi_scale_22_text/README.org
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?