Stupid or Solid?
This week's reading introduced the concepts of "Stupid" or "Solid" code. These are of course acronyms for principles of bad and good code. The most important principle of S.T.U.P.I.D. code is "Tight Coupling," which is when each of the modules within a program rely heavily on each other. If when you make a change to one of your modules, you cannot proceed with the change without changing another module, you have tight coupling and therefore S.T.U.P.I.D. code. It's important that this is avoided so that changes can easily be made to modules, for example if an instance of a class needs to be replace with an instance of its sub-class. I know for a fact that I have written stupid code in the past, because I have faced challenges and found solutions to problems simply because "it works when I write it like that," without knowing how it works let alone how to make any changes to it without affecting the rest of the modules in the program.
S.O.L.I.D. code is quite the opposite of S.T.U.P.I.D. code in terms of the main principles behind it. S.O.L.I.D. code runs with modules that work with one another, but don't depend on one another. In other words, changes made to one module will not affect or in many cases break another module. Furthermore, each class should have only one single responsibility. This is apparent in the OpenMRS code, because there are lots of classes, each found in the different files for different variations of the source code. For example, there is a patient class within the "web" folder, another patient class in the "test" folder, and another in the "webapp" folder. The reason for this is so that the classes do not need to change in whichever case it is being used. Another S.O.L.I.D. principle that I noticed in the OpenMRS build is the interface segregation principle. This principle simply states that all individuals who use the platform should not be served by one single interface. When I was first building the OpenMRS application, I got the entire back-end running and tested successfully, however I quickly found out that there was no user interface installed. This was intentional on the developers' part, and its so that developers have the option to load a different interface with their own goals for development in mind.