Code Monkey home page Code Monkey logo

Comments (4)

viktorvan avatar viktorvan commented on June 19, 2024

Let me elaborate on the issue.

I find this part of the api confusing, that is why I created the issue.
Most users are probably not aware of why this matters, or do not need the feature.

The usecase for providing a date when parsing an identity number I can think of is that you are parsing old data: The user entered the data with a hyphen when they were 99 years old and have since turned 100 which means the parsing will fail when performed at a later date. An edge case, but I can understand that we want to support this for completeness.

But the usecase for providing a date when calling ToString/ToShortString I do not really see. What is it I want to do at that point? β€œWhat would the string representation of this identity number be if I asked for it before this person turned 100”? Who wants to do that?

So I guess what I would like to propose is that if we consider the Parsing usecase to be important than we remove the overload without date and force the users of the api to always call it with a date. That way we make the users aware of the potential issue with people turning 100 after the string has been entered.
I think I prefer this solution the most actually. Let the users of the api create their own convenience method for calling our api with date = DateTime.UtcNow, so we don't hide the issue.

An alternative solution would be to not have this as an overloaded method, instead we name the method something else: ParseWithCustomDelimiterCutOffDate, or something shorter πŸ˜‰

In any case we need to add some tests for this usecase.

For ToString/ToShortString I think we could do the same thing but since I think that usecase is weird, right now I would propose instead simply removing the overload that takes a date.

from activelogin.identity.

PeterOrneholm avatar PeterOrneholm commented on June 19, 2024

After some offline discussions we have decided to:

  • Keep the data parameter both for .To10DigitString() and .Parse()
  • Rename the parameter to make it more clear what it does, not it's only named date

Suggestions of possible names?

from activelogin.identity.

viktorvan avatar viktorvan commented on June 19, 2024

Since only the year part matters maybe it makes sense to call the parameter

  • currentYear

That's sort of what it is, right? CurrentYear for the execution of the method call, so to speak.

Otherwise

  • decisionDate
  • delimiterDecisionDate

from activelogin.identity.

PeterOrneholm avatar PeterOrneholm commented on June 19, 2024

Since only the year part matters maybe it makes sense to call the parameter

  • currentYear

I like this! I've just created a PR.

from activelogin.identity.

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.