Great news! I’m still officially unbeered, on day 6! However, it is looking unlikely that the trend will continue for much longer. Yumm the refreshing IPA :)
I think this is a perfect time to start tracking my unbeering trend! Or take a step towards it. Although I’m on my way to create this million dollar app, I’ll still be tracking the progress in the spreadsheet, as a backup until the app that can do that for me!
Where shall I start?
I will start with a Console App. Using Visual Studio 2018 and I’ll create an empty Console App(.Net Core). I’m picking .net core because I’d then be able to run this application in Linux and MacOS along with Windows.
- I’m creating a class to represent an actual data for a given day. i.e how many beers I had on a given day. I’m naming it Beered for now. I don’t think the name really sounds fitting but I can come back and change that later when I’ve a better name.
- Each instance of this class will hold two pieces of information for now: ForDate and Count.
- ForDate is a String type that holds the date this data is for and Count is an interger that holds the number of beers I had :)
- I’ll override the ToString() method so that it is easier for me to quickly call the method and see the output in the console.
- In the Main entry of the program, I’ll ask myself to enter the number of beers I had for each day starting January 1, 2018 until today, which is the current day this application is being run.
- Finally, I’ll print out in the console, the total number of beers(sum) I had since January 1st.
Thats it, I’m ready to start selling the application! However I think I’ll wait until I’ve polished this some more. I’ve added the code for this post in GitLab. For each iteration of the application, I plan to blog and create a separate branch for the code. This post relates to branch: learning-unbeered-1 It’s really nice of Gitlab to provide free public and private repositories!
Here are some improvements that I can make:
- Have some sort of validation! How’s that I can enter negative number to Count! I wish I could do that in real life! Oh I had -3 beers last night :)
- Find a way to store/persist the data that I entered! I don’t want to be enter number of beers I had for every single day since January 1, everytime I run the application!
- I also think ForDate should be of type DateTime instead of String. One obvious benefit with DateTime is that I’d be able to answer things like: ‘How many beers did I have since January 3rd to February 1st’ easily. With String as a data type, this would be very complicated.
Until next time, have a lovely day!