Timeline for Python OOP - creating library
Current License: CC BY-SA 3.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| S Nov 26, 2017 at 7:41 | history | suggested | Elias Zamaria | CC BY-SA 3.0 |
Minor fixes
|
| Nov 26, 2017 at 6:12 | review | Suggested edits | |||
| S Nov 26, 2017 at 7:41 | |||||
| Nov 25, 2017 at 4:38 | review | Suggested edits | |||
| Nov 25, 2017 at 6:45 | |||||
| Nov 24, 2017 at 15:32 | comment | added | Peilonrayz♦ |
@BrandonIbbotson I never use self.__variable. Mentioning 'protected', self._variable, variables could be a good addition to my answer however, thanks.
|
|
| Nov 24, 2017 at 15:24 | comment | added | byxor |
Is it useful to mention encapsulation? For example... using self.__books instead of self.books to prevent users from accessing the books directly out of the object? (In the spirit of OOP and hiding internal stuff)
|
|
| Nov 24, 2017 at 14:36 | comment | added | Peilonrayz♦ | @RichardNeumann You could. I just didn't want to give too many 'you can do's, :) Feel free to make that another answer, :) | |
| Nov 24, 2017 at 14:29 | comment | added | Richard Neumann |
You could also make books_by_author and books_under_price generator functions or return a filter().
|
|
| Nov 24, 2017 at 14:18 | comment | added | Peilonrayz♦ | @Graipher I would too, however this reads like a homework question. Which only has like four books. So IMO the maintenance cost here would outweigh the speed benefit. Otherwise I'd fully agree, +1 to your answer too. | |
| Nov 24, 2017 at 13:55 | comment | added | Graipher | Done. And I agree about premature optimizations, but in general I would expect a library to have more than three books :) | |
| Nov 24, 2017 at 13:21 | comment | added | Peilonrayz♦ | @Graipher yes you could, feel free to make that an answer. 🙂 I feel that as we don't know how the code is used that premature optimisations could be a bad idea | |
| Nov 24, 2017 at 13:11 | comment | added | Graipher | Having O(1) lookup by keeping dictionaries around to search by ISBN or author might also be handy. | |
| Nov 24, 2017 at 11:19 | history | answered | Peilonrayz♦ | CC BY-SA 3.0 |