Showing posts with label definitions. Show all posts
Showing posts with label definitions. Show all posts

Saturday, June 10, 2023

Interface, IReallyBigNumber Or Something

In the last entry I talked about designing an interface for a number. So, what is an interface? I always struggle with how deep to go in answering some questions. I currently work in C#. C# is an object-oriented language, meaning that data is structured into classes. A class is a collection of data about a specific thing, and occasionally functions related to that class or contained data. Now one of the concept of object-oriented programming (oop) is polymorphism. Polymorphism is the idea that objects of different classes can be sent to a function of a specific class. One of the ways of supporting this is called an interface. It is like a class, but only has function declarations. Any function call that requires that interface will accept an object of a class that implements that interface.

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.

Sunday, May 29, 2016

Version Control Made Easy... Or Hard, Not Sure Which.

For those not familiar with version control, version control is something that it's used to keep track of a project and the changes that are made. This way previous versions can be gotten to if errors are introduced, to easy multiple people working on the same files, or for other reasons. In the situation that I am discussing this the files are primarily code files, but they don't have to be.

Most of my experience so far is with Microsoft's version control systems SourceSafe and Team Foundation Server (TFS). However, Git is slightly cheaper (free), with web based hosts that are also cheap (free) like GitHub. I am used to how TFS works, I am learning how Git works. The differences in Git leads to a slightly different vocabulary. And those that don't know version control won't know the terms anyway.

For convenience sake I will put several definitions here for those with questions.

A repository is a project and all associated files and all their versions.

A branch is an independent group of files, often a copy of all project files, but not necessarily. The master branch is the main branch of the repository and usually considered "the code" or "the source". Most other branches will be copies of the master branch allowing the code to be edited without effecting the master branch.

To clone a repository means to copy the entire repository to your local machine. This allows the code to be worked on with out needing to maintain a network connection.

To commit code means to persist the changes in the local repository, making them the "official" latest version.

To do a push is to sync a local repository with the main repository. This step is necessary due to the detached nature of the local repository in Git.

A pull request is a request to include changes that have been made in one branch in another.

A merge is the process of comparing changes made in two locations to determine which changes need to be included and which can or need to be dropped. It is possible for multiple people to make changes to the same file and those changes to conflict.

If you have any question please feel free to ask. I realize that this may not cover everything that some might want to know.