Giter VIP home page Giter VIP logo

Comments (5)

datanel avatar datanel commented on August 22, 2024

What we note is that with unit tests we cannot cover every cases.
And it's easier to create fixtures than create model.
But if a piece of code need to be unit tested and has a value, we "unit test" it.

from transit_model.

antoine-de avatar antoine-de commented on August 22, 2024

Edit: sorry @datanel didn't saw your reply before posting πŸ˜›
I think a model creation is way easier to understand than fixture (but fixture are really useful too!).
Unit tests are not really great for parsing NTFS/GTFS/Netex, but I think they could be a great asset business logic like transfer creation, merging (and real time applying πŸ˜† )

I'll try to make a proposal.

What do you think of:

 let model = ModelBuilder::default()
    .vj("toto", |vj_builder| {
        vj_builder
            .st("A", "10:00:00".into(), "10:01:00".into())
            .make_st("B", "11:00:00".into(), "11:01:00".into(), |mut st| { // <-- could a stop creation with total access to the object be useful for complex initialization ?
                st.boarding_duration = 12;
            })
    })
    // .vj(...)
    .build();

We could also go for something with less lambda (but then it cannot be chained):

let mut builder = ModelBuilder::default();

builder
    .vj("toto")
    .st("A", "10:00:00".into(), "10:01:00".into())
    .make_st("B", "11:00:00".into(), "11:01:00".into(), |mut st| {
        ...
    });
    // builder.vj(...);
let model = builder.build();

what do you think ? do you see better/simplier api ?

from transit_model.

datanel avatar datanel commented on August 22, 2024

why you cannot chain in the 2nd proposition if you always return a builder?

from transit_model.

antoine-de avatar antoine-de commented on August 22, 2024

because .vj(..) will return a VJBuilder and not a builder (to mutate the current vj)

we could return a Builder and make .sa(...) work on the last vj but I'm not a fan of such implicit stuff

from transit_model.

antoine-de avatar antoine-de commented on August 22, 2024

Some work still need to be done, but it's usable for the moment, I think we can close this

from transit_model.

Related Issues (20)

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.