So, what does a number need for it's implementation? One camp of oop says that all data fields should only be accessible/alterable through functions and methods. This ensures that all operations and changes to the data follow the rules of the class, this is especially important when creating several classes that are supposed to react is similar manners and be processable from the same functions. The argument being that none of the external services need to know what the internal data is or how it is processed.
So, bare minimum for a number is equals, add, subtract, multiply, divide, and compare (greater than, less than). There may be others that I may want / need to keep the coding internally. For the algorithms I am thinking I want to attempt, the basic parts may be enough to get it all working.
I had created a repository to hold the code I am trying, but decided that I had not started it right, so I dumped it and started a new repository. I will try and keep commit labeled in such a way to indicate what is being done and which blog entries they belong to. The current repository is OutrageousNumbers. I found a website that will check some of the most popular repositories for open source code for a name, after trying a couple I got frustrated and tried OutrageousNumbers.
While I was doing other stuff I decided to see if the "primitive" types had an interface, despite the fact that this whole project is about doing work that has already been done, I didn't feel like the interface should be repeated if an acceptable one was in use in the main parts of .Net. I found out that they don't seem to, but that in .Net 7 some Generic Math libraries were added including an INumber<Tself> interface. So, I do not need to create the interface and it already is more detailed than I was expecting to start at.
I think I will start by creating an Outrageous version of the int, not a large version, just to explore the interface and work with the many parts of that. I will check in the initial creation of the project and the class, and we will do more from there in the next installment.
No comments:
Post a Comment