Skip to content

Immutable DateTime [WIP]#133

Open
dg wants to merge 6 commits into
nette:masterfrom
dg:datetime
Open

Immutable DateTime [WIP]#133
dg wants to merge 6 commits into
nette:masterfrom
dg:datetime

Conversation

@dg

@dg dg commented Feb 1, 2017

Copy link
Copy Markdown
Member
  • new feature? no
  • BC break? yes

I am looking for way how move from mutable to immutable DateTime.

From my point of view, mutable DateTime is something you never want (of couse I may be wrong). And switch from mutable to immutable is big BC break. On the other hand, I found way how to discover bottlenecks (like this one) where mutable and immutable behave differently and I can trigger error. So maybe the transition from one model to another would be possible.

@Majkl578

Majkl578 commented Feb 1, 2017

Copy link
Copy Markdown
Contributor

+1 for immutable version, but I don't think changing parent class is a good idea due to BC constraints, mostly because of typehints in userland and entirely different behavior... Rather properly deprecate DateTime in favor of new variant.

@dg

dg commented Feb 1, 2017

Copy link
Copy Markdown
Member Author

Deprecate for new variant seems better to me. The point is that a lot of people just will change class name, so functionality that traces bottlenecks should be useful in new class.

I am not sure about name, because Nette\Utils\DateTimeImmutable sounds terrible to me.

@TomasVotruba

Copy link
Copy Markdown

I am not sure about name, because Nette\Utils\DateTimeImmutable sounds terrible.

Why? It sounds explicit and logic.

  • DateTime => Nette\Utils\DateTime
  • DateTimeImmutable => Nette\Utils\DateTimeImmutable

@dg

dg commented Feb 1, 2017

Copy link
Copy Markdown
Member Author

\DateTimeImmutable sound terrible too :)

@TomasVotruba

Copy link
Copy Markdown

Well, that's issue for another repository :)

@michalhlavka

michalhlavka commented Feb 1, 2017

Copy link
Copy Markdown

What about something like that Nette\Utils\Immutable\DateTime, that also wrong, but something like this principle

@Majkl578

Majkl578 commented Feb 1, 2017

Copy link
Copy Markdown
Contributor

There is still #82 though - kill DateTime entirely. 😊

@dg

dg commented Feb 1, 2017

Copy link
Copy Markdown
Member Author

To kill DateTime is colossal BC break.

@Majkl578

Majkl578 commented Feb 1, 2017

Copy link
Copy Markdown
Contributor

Migration to different class is as well and helper methods would be kept in new helper class.
And honestly, what is the added value of extending (inheriting) PHP's DateTime(Immutable)? Adding some helper methods and making code less portable?

@dg

dg commented Feb 1, 2017

Copy link
Copy Markdown
Member Author

__toString and jsonEncode is added value.

(I dont need them, but BC…)

@dg

dg commented Feb 1, 2017

Copy link
Copy Markdown
Member Author

Helper class for immutable DateTime factories can have name DateTimes, for cosistency with Arrays and Strings ;)

@dg dg force-pushed the master branch 2 times, most recently from 8a9b344 to a7f9308 Compare February 1, 2017 23:53
@milo

milo commented Feb 2, 2017

Copy link
Copy Markdown
Member

What about name Timestamp?

@dg dg force-pushed the master branch 4 times, most recently from ba38669 to bba41ff Compare February 10, 2017 12:52
@pavelkouril

Copy link
Copy Markdown
Contributor

The helper class for the added functionality (working with DateTimeInterface) and just deprecating Nette DateTime is IMHO the best option.

The loss of __toString kinda sucks, but other aspects outweight the loss of it.

@dg dg force-pushed the master branch 3 times, most recently from c4dc559 to f6984a9 Compare July 21, 2017 18:48
@dg dg force-pushed the master branch 8 times, most recently from 5c076fd to 0b71017 Compare March 17, 2019 13:59
@dg dg force-pushed the master branch 2 times, most recently from 3ad8f46 to c133e18 Compare October 21, 2019 20:42
@dg dg force-pushed the master branch 6 times, most recently from 7331c07 to e024393 Compare November 19, 2019 21:13
@dg dg force-pushed the master branch 3 times, most recently from aa00974 to 6339ca2 Compare December 3, 2019 20:49
@dg dg force-pushed the master branch 6 times, most recently from 69c5192 to e4e1361 Compare December 28, 2019 00:33
@dg dg force-pushed the master branch 2 times, most recently from 5716775 to 88187c7 Compare January 3, 2020 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants