Enums

May 27th, 2020
typescript

Clean Up

I had a pretty productive day today at work. I started off the day by fixing up the datepicker portion of the filter. For this filter, the representative will be able to choose a date range of when the leads were assigned. This means they need a starting date for the range and an end date for the range. For the native version, I'm using a spinner component, or two rather, one for each date. I don't love the spinner, but it's what people on IOS devices are likely used to at this point. For the web version, I used React Datepicker. I have two inputs, each open up a calendar when clicked on. I can tell you, anytime an outside package is incorporated into this application, it's a serious pain. Almost 100% of the time, it means we have to make 2 separate components that do the same thing, and mark one of them as being a web component. It takes at least twice the amount of time, and sometimes even longer. But, by mid-morning, I was fairly satisfied. I was able to get it styled up pretty nicely, and it looked good.

typescript

From there, I knew I had to start cleaning up some of my work. I've primarily worked on two of the screens, the leads search page and the individual leads page. The individual leads page is over 1000 lines of code, and the leads search page is fast approaching that. If it were completely up to me, I would refactor these files out into individual component files. I would much rather work with a folder of files that are less than 75 lines of code than one massive file. However, it is my cohort's preference to keep everything in one file for a screen, or as much as you can. Anytime we have a component that needs a separate web version, those are housed in a components folder. Otherwise, everything stays in one file. It drives me nuts, but I think it's more important to keep continuity throughout the project than have some files be my preference and some be his. Regardless, even within these files, I know there are places I could refactor into more reusable components and condense the code a little bit. I didn't get into that yet, but I did start working on getting rid of some strings. One of the best things about TypeScript, in my opinion, are enumerators. This helps with type checking and errors on typos with strings, so I replaced as many strings as I could with enumerators.

typescript

I worked out a great system for managing the strings attached to the icons component, and went to talk to my cohort about it. I knew he had been thinking about changing our project over to being an Expo project, but I didn't think he had committed. When I brought up the icons, he let me know he had committed to it. This meant that everything I had done with the enumerators on the icons was pretty much useless. I told him we needed to sit down and talk about exactly where we were with everything. If I had known he had committed to this, I would have worked on something else. So, we did. We sat down and went through exactly what we were going to be doing in the coming weeks with the project. I was able to get him to mock out a version of the settings screen, so tomorrow I can start working on that. I keep going back to this, but I think communication is one of the most important parts of this job. Anyone can learn the technical skills involved with this job, but if you can't communicate with your co-workers, you're dead in the water. There are things I need to work on with my communication, but I think my time spent in the service industry serves me well. Going forward, I'm going to spend more time communicating and less time writing code, because I may just be writing something that doesn't matter if we aren't communicating.

Until tomorrow!

Created by Sam Thoyre, © 2019