nus-cs2030 / 2122-s2

CS2030 repository and wiki for AY 2021/2022 Sem 2
MIT License
0 stars 0 forks source link

How do you know when you need to define additional classes in your code? #49

Open jkjliang opened 2 years ago

gracelimshiern commented 2 years ago

when you have an additional set of data with a specific structure and you want to perform specific methods on it that the other current classes do not have

shotnothing commented 2 years ago

I think additional classes are appropriate when it makes physical/logical sense to do so. For example, not all loaders are recycled loaders, so it doesn't make sense for normal loaders to have recycled loader specific code inside. From a physical perspective, a normal loader would not know what a recycled loader is, nor how much time it would take for maintenance.

Another reason would be if it makes your life easier when programming, e.g. if you were making a utility library or implementing a comparator class.