Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I agree, I do not see a natural object relationship between the types of numbers.

'Natural' (unsigned int) numbers might be a building block of signed integers, fractional pairs, and composed floating point types; but they seem like three distinct use cases, with perhaps a way of converting a whole fraction or positive signed number into another type either if it fits, or with an accepted loss of information.

When OOP was covered in classes years ago the typical example was something like...

Class Animal

Class Pet extends Animal

Class Dog extends Pet

Class Cat extends Pet

etc

Edit: These days I prefer golang's example of Interfaces which specify what methods and members must exist for something to be 'used as an X'; very useful IOReader IOWriter and https://pkg.go.dev/io#ReadWriter which naturally is an Interface containing only a Reader and Writer



Yeah,Pet extends Animal is just sad...




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

Search: