Tuesday, October 31, 2017

Angular...a new language beginning

I have been doing a lot with Angular lately. I am really enjoying it. The entire time I should have been posting my progress, but no excuses, I haven't done it.

I will be posting my progress on Angular starting...soon :) . While you anxiously await I have started a real simple shopping tool (right now it is just the menu and navigation) that I will be updating. Don't worry, you can't buy anything and it won't take your money, yet. It can be found at https://myshoppingtool.firebaseapp.com/

Watch for more updates coming soon!


"They always say time changes things, but you actually have to change them yourself." - Andy Warhol

Tuesday, July 18, 2017

The failure to a win

My last post was about not being able to get some code to work. I declared it a failure. A failure that I should learn from. I am here, a couple weeks later, to say that I did learn something from the whole experience. I think most of us have seen the comic, or a similar comic as what I have below


That was exactly what happened except it wasn't a semi-colon. I was missing two words and an equal sign, Mode=TwoWay, where I was giving my binding information. In that particular XAML file, I was not using Mode=TwoWay in any other lines of code. However, I did use it on other pages. Why did I miss this one piece?

I came back to my solution a week later with new eyes. It took me about 15 minutes to see what my issues was. I add Mode=TwoWay and, presto!, my code is working as I expected. What was it about taking a step back from the code that helped me see what was missing?

The important lesson I feel I came away with, is that sometimes it is good to have a fresh set of eyes take a look at the code. In my case, it was taking a week off allowed me to get a fresh perspective, but we can't always do that at work. Yet, it can still be important to get a fresh set of eyes.

We look at code all day and may start missing pieces that would actually help solve our issues. Making sure we know when to ask for help and get another person looking at the code can be very beneficial.

Take that "week" off  and get fresh eyes to look at your code.

Here is a screen shot of my minimal viable product (I know the UI isn't great that will be coming...soonish). Now to see if I can get some services to the online movie providers (not looking so great, I have only been able to find an API to Plex Servers and the rest of the providers are either hidden really well, don't exist, or I am searching for the wrong things).

"It is better to know some of the questions than all of the answers." - James Thurber

Thursday, June 29, 2017

When frustration runs high...

Lately, I have been a little frustrated with the app I have been building in Xamarin.Forms. I am trying to use MVVM and I have most of it working, yeah! I just have one attribute that isn't not getting saved from the view. It is the only value that sits on a different SQLite table then all the rest. Do I blame it on that? Am I not calling the correct items in the view model?

Anyway, I have been stuck for more then a few days. And each day I don't make much, if any, progress. What happens? Frustration builds up. The first line where I say a little frustrated, that is a lie. I have been getting more frustrated. I shouldn't be getting too frustrated, I know that some frustration is good and will actually help you grow. I have been hearing a lot that failing is good and we learn from each failure. Is it time to chalk this one up to a failure?

Let's be honest, I got to the point the other night where I really just wanted to get the app to work. I did part of it in code behind (I know, I know, I won't be able to test it!) and got it partly working. You can now select the storage for the movie, but it won't save. I am missing something in the view model, but I already knew that. Using just the view model I was not able to get the data to populate or pull up the correct page.


Great! Now I can select the storage type and save my movie information! Bad news, it doesn't save the storage piece. I save the movie and come back into the detail and the storage type is missing. I need to go back and learn more about how MVVM is working. I have a cursory understanding, but not a full understanding. My app broke when I tried to add a second SQLite table into the mix. Take out the new table and you can have a list of movies, no problem. But, I also had an example of the one table scenario that used MVVM that I could model.

Maybe a failure now, but a failed project which I want to come back to after taking a step back and taking some time on another project to continue my learning, perhaps more about MVVM and a smaller project that implements it. Or, next time I am in the office I hope one of our MVVM experts are in the office as well and I can ask them. Would it be ok to use Skype to call someone up to ask help on a personal project?

The frustration may be good, but how much frustration is good? This is probably a question each person needs to ask themselves. It will be different for everyone.

"Nothing makes one feel so strong as a call for help." - Pope Paul VI

Thursday, May 18, 2017

Tracking Improvements

We all want to make improvements to ourselves. It is a long process that takes a lot of work and continuous effort towards our goals. Recently, I have been asking myself a few questions about my goals and the progress that I am making towards them.

The first question is, what are my goals? This is a question that I never have really asked before. I always knew that I wasn't going to be a truck driver like my dad, but beyond that I was always flying by the seat of my pants. It seemed to work out relatively well at first. I graduated high school and went to college. I can't even tell you how many different courses I took in college to find what I "wanted to be when I grew up." I decided finance. Well, I didn't love finance so I changed careers and now am a Software Engineer in Test. I like this job for the most part, but what is my end goal?

 I would say I want to become a full developer, this raises another question on is this a good long term goal for me? Great, I have an end goal for now. But what is the time frame for this goal? 1 year, 5 years, 10 years (better not be the later two). To reach this goal I have been setting intermediate goals. Here are a few of the goals I have been thinking of lately:

  • Build API
  • Build App
  • Deliver App to App stores
  • Speak at a conference

Great news! I have already completed the first one. I know that each of those goals have steps I need to take in order to reach them, I just need to figure them out. Not only do I need to figure the steps I need to take, but I also need to keep track of what I am doing to achieve these goals.

I recently saw part of how a person I look up to keeps track of his goals and self improvements. I look up to him as I believe he is very organized and able to keep up on everything, from sports (both U of U and BYU!) to family, and technology to his work. I can't even keep straight who the quarter back is for the U of U, how can I be expected to remember so many other things. I need to find a process that works for me that allows me to keep track of my daily activities, my goals (need to look at more and come up with a long term plan), the stuff I read, and other activities I feel will help me reach my goals.

The plan I saw was a checklist of sorts that had many different categories. I saw it and decided to try something similar in OneNote. I created different tabs, 5 year goal (nothing here yet), 1 year goal (becoming a dev and the ones you see above), monthly goals (did this for one month then forgot all about it), and daily goals. My daily goals are simple, like read a tech blog and learn some code. Really generic and I know in order to reach my long term goal of becoming a full dev I need to get more specific goals. That then shows my lack of what I don't know. What are the daily goals that will help me reach my long term goals? 

I have recently been teaching myself Xamarin.Forms using a course through Udemy and other online resources. I posted about my learning of MVVM the other day. Let's be honest, the MVVM "challenge" has been really hard. It is refactoring some code that I wrote early in the course. This let me to think that I don't know the basics as well as I maybe should. I had trouble separating out the responsibilities and seeing what each ViewModel would need in order to work correctly (it still isn't working, the app dies when I try to save and then won't start up again until I delete the SQLite Database that was created). I also took more then a few hints from the answers to find that in some parts I was doing well and had a good start and others I was totally wrong. 

I here that everyone uses Google to help with their work. But what goals do I need each day to reach my end goals and how do I keep track of them. There are some days where I am really good at keeping track of the daily goals. Other days, like Tuesday, I totally forget to even look at my goals and many of them don't get done. Questions arise such as how often should I look at the longer term goals and adjust them? I think this will be an iterative process. Find something that doesn't work and move to the next method. Keep trying, just like code, right? One day I will find something that works.

"Success is not a good teacher, failure makes you humble." - Shah Rukh Khan


Monday, May 15, 2017

Attempt at explaining MVVM

100 Days of Code is done. I may not be coding every day (last weekend we went to Moab and spend our days in Arches National Park and I didn't code) but I am still taking time to learn things. I am nearing the end of a Xamarin.Forms class on Udemy taught by Moshfegh Hamedani. I have one more activity left and then "Beyond the Basics" section to go. Then I will be a great Xamarin.Forms developer, right?

Well, I will have more tools to help me at least do some development in Xamarin.Forms. Today I did the section on MVVM (Model-View-View Model) pattern. I knew that using the code behind, like we did in all the examples, may not be the best way to code in XAML. We use MVVM in some of our applications at work and I thought this section would be great to learn for my own project and also so I can better understand what we are doing at work.

We hear that teaching is the best way to learn. And by we, I mean that I have heard that many times and again today in a video post on YouTube channel called Top 8 developer habits: Teaching - Fun Fun Function. Watching that today I thought, why not, let's blog about MVVM to help make sure I really understand what I learned.

What is the best way to describe MVVM? Well, it helps separate concerns of the front end and the back-end logic. This will ensure that the front end doesn't need to know the logic behind the data and the back end get's to do all the calculations and only give the data when it is asked for. Your view just needs to know what to pull and the model will just store the content.

Model: The model is a domain model that has both the behavior and the data. When you enter new data to be stored, the model will handle any transformations to new data and then store the data.

View: This is what the end user sees, so make it pretty. It isn't going to do much else.

View-Model: This is a layer of abstraction between the model and the views. The view model will make the calls to the model and send the data to the view to be shown. It also works the other way. It can take that data from the View and send it to the model to be stored. It will also know what to do when you change a setting or click a button (that doesn't change/add data to the model) in the View. It let's the model just know what to do with the data and the view to just continue looking pretty.

Quick lovely drawing that you probably won't be able to read:

Ok, why do you want to use MVVM? From what I have heard (I still need to do this on my own) it makes your code more testable. If you are using Xamarin.Forms and do all the code in the code behind, you can't test it. It is too tightly coupled with the XAML code and your tests won't be able to see what is happening in the UX layer. MVVM will also keep a separation of powers.

What could be a downside of MVVM? The amount of time it takes to implement MVVM may be overkill when you have a simple application or you never plan on doing testing (pretty sure this is unit tests, you will always want to have some sort of testing before you release to the wild). What is the size of the application it would be overkill? Good question, maybe a small to medium application would be fine using just code behind or using a model and view alone. Large projects you will probably want to use some framework that will allow for better testing.

That is probably an over simplification of the MVVM model, I think I am going to put some time on my team leads calendar tomorrow to discuss it with him and make sure I have it correct, isn't Ryan lucky?

"All great achievements require time." - Maya Angelou

Monday, April 17, 2017

Experience of #100DaysOfCode

I did a post at the beginning and now I am doing one at the end (I should have done in between, but I can't go back now) of 100 days of code. You think that 100 days is a long time, but it isn't even a third of the year and the time flew by! Some days coding was really difficult and I wasn't able to get a full hour of coding done while other days were much easier and I didn't feel that an hour of coding was enough (don't worry on those days I would spend more time coding). But do I feel that it was beneficial to take time out of each day to learn to code?

I often thought that it was too difficult to code everyday, after all, I do have things to do on the weekends, like go to a movie or something. Okay, honestly, I have a three year old and I can't tell you the last time I did that on a weekend. It still felt that coding everyday, including weekends was going to be too difficult, at first. I stuck to it and coded everyday (the 100 days of code does allow you to take a day off every now and again and I took advantage of that on a few occasions). I also felt that coding on Saturday and Sunday got easier as the end got closer, in fact I almost felt my day wasn't complete without doing some code for the day.

I also logged my progress every night in a log file on github and posted tweets to Twitter each night. Knowing that the people on Twitter would see my progress helped keep me motivated and a few times I actually got support from the Twitter community when I posted a question. This helped in knowing that, if I got stuck, there was someone out there in the Twitterverse that knows the answer and would be able to help. Keeping the log is very helpful and I will continue keeping some sort of log about my learning. Maybe I will keep the same format as the link above (that is what I used tonight) or maybe I will find something that will work better for me, only time will tell.

Did I learn anything while doing all this? The answer is yes, I did learn more then a few things. My first project was to learn how to build an API. I have a working API now, it is still on a local DB and hasn't been deployed, but it works! And I have made a number of Xamarin Cross-Platform apps using Xamarin.Forms, although I must admit, none of these were my own ideas and either came from Xamarin University, Pluralsight, or Udemy. Even though the mobile apps were not what I dreamed up, they did teach me so much about the different platforms available and XAML.

Why do these matter to me? The team I work on at work is over an API that was just released a few months ago. The team built it from ground up and I tested it. Often, the developers would talk about the context or the model or pretty much anything else and I was clueless. Now I hear what they are saying and am actually able to comprehend what it actually means. I have even fixed a few bugs on my own (I have been given the ability to do this, I didn't go rogue). It feels good to be able to pick up an item from our backlog and debug the issue AND actually find the root cause. Then when I send out that pull request, it feels good!

We have other tools at work that my team does not own. Some of those are written using XAML. Before 100 days of code I would have no idea how to debug anything in these products. In fact, I would avoid them at all cost, because I would not only waste my time looking for the issues, I would also waste another developers time having them walk me through the issue and how to fix it. Guess what! I have also been able to dive into these products and fix one bug in XAML code (we just got one product under our charter that is in XAML so I get the API and XAML now). This bug didn't require me going to another dev asking for hours of help to debug the issue.

Was it worth it? There is definitely something to coding every day. I was able to fix bugs before 100 days of code, but I didn't spend enough time learning for myself. 100 days of code made me think about a project or two of my own. These personal side projects kept me wanting to learn every day and kept my motivation high. The side benefits to my personal projects were that I learned better what my team and department do every day. So, yes I think it was worth coding every day for 100 days. Will I keep coding every day? I think that I will code a lot more often then I did before. I have formed new habits. I used to sit down and watch T.V. at night after everyone else had gone to bed. Now, I code. I enjoy the coding every night so much more then watching T.V. I think watching T.V. was a time filler for me. I wanted to learn how to code, but I didn't know where to start or what I should be doing. I had to actually think about what I was going to do and this was the best thing for me. I have a list of things that I need to do to continue learning to code and there is so much more to learn!

Would I do it again? That is the question. I do enjoy coding every night, but having to do it every night is rather difficult. Some nights you just don't want to do it and you have to tell yourself this is a pledge I made to myself and just do it. I may do it again in the future, we will see. For now, I will keep coding most nights and keep posting progress.

My Github Projects during 100 days of code:
100 days of code log
Xamarin Layouts
Xamarin "Essentials" Project
Movie API
Others at https://github.com/robertjorg/ (I know I need to clean them up, at least a little bit!)

Tell me and I forget. Teach me and I remember. Involve me and I learn. - Benjamin Franklin

Thursday, January 12, 2017

My next steps - My own project and 100 Days of Code

I finished the book Head First C#. What is the next step? I don't want to lose any of the information I was supposed to have learned. I have another book "Beginning C# Object-Oriented Programming." I look at the book every now and again and think I should start reading it. I probably will very soon. But, I also started thinking that there is no better way then to program my own personal project to help me feel invested in the programming and gain a benefit for something that I want to do.

I was invested in learning while going through the book, but maybe not as invested as I could have been. I took time to take notes while reading and really tried to understand what the exercises were trying to teach. I may have not always had an idea of where, outside of the written steps, would I be able to use the code. My new idea, using what I learned to create my own project. And what better way to stay accountable then posting on twitter every day on the progress I am making than making a commitment with 100 days of code.

I would be more invested in my own project as it is my idea and I would really like to see it come to life. Over the years I have had many ideas that I wanted an app that filled a "need" (or at least a need for me). Some of the ideas have apps out there and sometimes I have downloaded them (such as when I wanted an app that not only kept recipes, but made a grocery list for me). Others I have just looked at and said, I might try to create my own. The first one I wanted to try is a movie database.

I have a lot of movies and can always go look at the movies, but sometimes I want to be lazy and just pull out my phone to see what movies I have. I decided to jump in. Right away I jumped in and thought I need to do an API. Day 1 on my Twitter feed: Starting the API. The API would allow me to either later create a web, desktop, or phone app. I got going. I was reading through tutorials and watching videos, I felt I was learning and even got an API to send data back (although hardcoded data).



Learning is good. However, as I kept going, I was missing something. The tutorial of creating the API came with the database already created and the interactions between the API and the database were already created. I learned this quickly. The video I was watching talked about the data context, at work my co-workers talked about context on the API we are building as well, but I wasn't sure how the context was created (or really how the context interacted where it needed).

Time to take a step back. What is the context and how does it talk to the database? Luckily, I was talking to my co-worker, Peter, and he mentioned that Entity Framework is what we used at work. Eureka! Entity framework is the first step I should take. I found a Pluralsight course on Entity Framework 6. And this helped! Making sure Entity Framework got the correct relationships in the database took me a while. I think what I was missing was that each of the classes had to refer to each other. My "MoviesOwned" class had to have an object for "MovieTitles" and "MovieTitles" had to know about "MoviesOwned." Once I added all these relationships Entity Framework recognized my relationships.

public class MoviesOwned
    {
        public List MovieTitles { get; set; }

        public int MovieTitlesId { get; set; }
     }
public class MovieTitles
    {
        public MoviesOwned Movie { get; set; }

        public int MoviesOwnedId { get; set; }
    }

I was able to see that the relationships were in my model I used a tool called Entity Framework Power Tools. However, I use Visual Studio 2015 and this didn't show up in my list of Extensions and Updates. However, Julie Lerman had a great blog post on how to fix this issue.

I know know the context is the database context. It has an object from each of the classes so it knows what needs to be created. Entity Framework is then able to see what database objects you want and looks at the class of each of those objects to determine the structure of the database.The key is to have your context class inherit from DbContext (I believe this comes from Entity Framework)




After deployment, I see my database in SQLExpress (I need to figure out how to not use Express so I can host the database somewhere else).

The question becomes, is the structure really correct? And will I be able to write code that will communicate with the database correctly?

You can see daily progress on Twitter, @robertjorg.
You can see my daily log (called log.md) uploaded to GitHub: https://github.com/robertjorg/100-days-of-code/
I am being transparent and posting my work to Github. Maybe someone will see issues I am coding and plus I am blogging about what I am doing anyway. That link is: https://github.com/robertjorg/MovieDatabase

I hope to blog more because I should be coding every day and it is something I am choosing the project so I hope to be more attached to the code.

"The length of a file should be directly related to the endurance of the human bladder."
-Alfred Hithcock