Contract for the Material class
Today’s post is mostly organization for me, setting down guidelines for the Material class I’m working on. Still, this could also serve as an informative post as I’m using strategies set out in some of my books.
A contract is essentially what the name implies: a list of terms and conditions. In these particular circumstances, it’s a list of things that the class is expected to be able to do. In the professional world, a contract is often what a programmer will receive. How the person works out the inner dealings of the code is unimportant, so long as they accept inputs defined by the contract and return outputs defined by the contract.
So, without further ado, the Material contract:
The Material class must be able to:
-Create a new instance, with String inputs name and matcode.
-Verify the formatting of the input (11 characters, a-z only).
-Convert the characters of the matcode to integer values 0-25.
-Include classes to set individual attributes with int 0-25 input.
-[OPTIONAL] Include classes to set/get attributes by name.
-Include a class to get the current matcode of the material.
-Include all classes to produce a GUI to view and modify the material.
-Construct input panel.
-Construct edit panel.
-Construct output panel (display graphic).
-Include a list of market prices for the past 12 weeks (or more).
-Method to set current price (saving old price as above)
-Method to archive prices when they’re removed from above list.
-Method to get current price
-Method to display a graph of past prices
-[OPTIONAL] Display graph including archive.
I’m pretty sure that’s all, at least for now. I think it’s safe to say that everything except the market prices has been coded, though it hasn’t all been migrated to be within the Material class.
Remember I said that it’s up to the programmer to decide how to then code the inner workings? That’s how I think I’ve come up with another class. And then from the fact that I’m also developing the whole thing, I decided on another still. Internally, the Material class will also host the MatCode class. This class will make it easy for a Material method to alter a specific attribute by calling methods within that class. It will allow for error checking, editing materials by supplying integer OR character values, and overall serve to be a convenience class for making the Material class look cleaner. That said, it won’t be needed outside of the Material class and serves as a good internal class.
As an external class, I need Price. Basically all it does is store a price and the date that price was set. It will be used for a number of different objects and needs to be outside of the Material class. Mostly, it makes the eventual database more useful when the price is its own object storing pertinent information.
With these done in a day or two, I’ll be able to move on to the next class, probably Planet. But also expect some work done on both my old MATLAB project (ISA Calculator) mostly in the form of adding comments, and my new MATLAB project.