Hacker News new | past | comments | ask | show | jobs | submit login

What bothers me just a wee bit in section 1 of his example is that Date is more or less a simple container class for data - one that could be implemented as a HashMap.

It is easy to make classes like Date immutable, but that does not help with a lot of problems. Date is super-easy to test, only state, no logic. Similarly, static methods are easy to test.

The real pain in Java is when a class has both state and logic - and those are precisely the classes you cannot easily make immutable.




Not necessarily - take joda-time's DateTime class as an example, which contains plenty of methods for changing fields in the date, but all of which return new DateTime instances to caller. DateTime itself is immutable.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: