Several Thoughts after Coding - MoriSupa/lab1 GitHub Wiki
####When we got this repository, we have the following observations
-
Magic Number Infests nearly everywhere.
-
Redundant Classes.(Why should we have so many classes with only similar structure and of little usage?)
-
Main.java is disgusting(with no offense, but it is in virtue.)
According these observations, we re-structured the whole project in such a way(^^feel free to refer to the code^^)
####Our initial motivation is concisely related as follows
We are not embarassed to confirm that we have adopted a procedure-based view to reform the original code structure, for data plays an important role in it. Those wretched magic numbers are actually data but not some property of a class. It should not be represented as some constants fixed in class, which doesn't make sense, especially under such a condition that kinds of beverages are of large count.
####Thus, we claim our main opinion
In a data-intensive project, a procedure-based programming paradigm with a database is much better than an accumulation of numberless classes.
In our view, each handler class serves for data and such an architecture can be classified into 'Data-Driven Coding', but not a conventional procedure-based coding, since we have hierarchy and modules in our projects with adpotion of some MVC-like design pattern.
####The last thing we want to emphasize about our project is its extensibility
Thanks to JSON, we have removed the magic numbers and store data as a json file. If considering OOP in a more general way, you'll have the feeling that JSON actually is a perfect implementation of OOP. That's why we choose json as our 'database'. Also because of introducing JSON into our project, we can remove most of the 'if-else' to be iterations. It seems amazing, but it's true. We can refactor almost every if-else to some kind of iteration of keys of some JSONObject, which brings us so-called extensibility since our code is independant of details of data except the outer structure of the JSON file(^^feel free to refer to 'Parser.java' if you are interested^^).
We are confident to say that we can extend our program in several minutes unless some irrational modification of requirements.