lvkaiyang / CitySim9002

0 stars 0 forks source link

Dependency injection and code organization #1

Open asphaltpanthers opened 8 years ago

asphaltpanthers commented 8 years ago

Hello @lvkaiyang,

Your program is coming along well. Some things I noticed.

Your going to need to practice some dependency injection. Currently, your random number generators are hard coded. This is going to make it difficult to build repeatable unit tests.

It's also going to be difficult to test the ShowMessages method. There are several things you could segment out of this method. For example, the code within the nested while loops could be segmented into their own method that returns a list of strings. Then the ShowMessages method could simply print that list of strings. Then you would be able to build tests that asserts that the list of strings is correct.

I recommend organizing your application code into folders. For examples, all your visitor related classes (Student, Blogger, etc.) could be placed in a folder named Visitors. This would make your code more organized and easier to find specific files.

Make sure to add more comments.

asphaltpanthers commented 8 years ago

Hello @lvkaiyang,

Your program looks good. I really liked the polymorphism you used with your visitor classes. Here are the rest of my notes. Check CourseWeb for your grade.

Issues with messages:

Missing tests for visitor preferences.

There could have been more dependency injection. Instead of passing the seed as a parameter into methods, the random number generator should have been passed.