Thursday, July 30, 2015

Course of Study

I've reached a new point in my studies. I'm pretty much done with all the resources I had intended on using to learn from, so I haven't got as much structure as I've had for the past few months. This is both exciting and a little scary. I'm going to spend the next months primarily making my own apps. My original idea was an app every day, but that's just not feasible, especially as my apps get more complicated, and even with ones that aren't all that complicated, I run into issues that sometimes take hours to solve. So I'm just going to do my best to challenge myself, and make as much as I can.

I'm still going to be spending a bit of my time studying: 

  • I'm going through Derek Bana's excellent series of Android tutorials, which hopefully I'll be done with by next week. 

  • I went through the Getting Started section of the Android Developer's Guide this week. I though I might go through the whole guide, but this first section has put me off that idea. It's more informational than instructional. If what it covers isn't related to something I'm actually doing, the lessons probably aren't going to stick. It's a great resource though, that I'm sure I'll be coming back to a lot, as I need it.

  • I found a great MOOC from the University of Maryland on Coursera. It's introductory, but it's really helping me. It goes into great detail on concepts that I understood in the context of what I was doing before, but maybe didn't wholly understand. I'm finding now that my knowledge is a bit more advanced, going over introductory topics is helping me connect the dots with more complex Android concepts. 

  • I'm also doing a Kilobolt tutorial that's guiding me through recreating flappy bird with libGDX. I've got some interest in making a game of my own, so playing around with that framework has been really fun. 

  • Another thing I'd like to do is get through one or two more Udacity courses. They're really good, but I sort of hit a wall with them this month, so I'm hoping, now that I know a little more about the things that I stumbled on (Database and Testing), I'll do better with the material.

  • And, when I can find time, I'm still chipping away at the javascript exercises on freecodecamp. This is probably weird to say, but I just find javascript tantalizing. It's so powerful and versatile, and seemingly everywhere. Definitely something I'd like to add to my skillset.

Calculator V


Github


I made some UI changes, bigger button's and text sizes basically. I thought that I'd be able to somehow expand my button sizes relative to my gridlayout, but apparently that's not possible(I think.) So I ended up moving to a Linear Layout rootview, with the screen textview and five more horizontal linear layouts that house all my buttons. This allowed me to easily fill the screen with my views.

I also notices an issue with my equal button. If I pressed it before an operator was pressed or in the middle of an operation, the app crashed. This happened because I set up a condition in the equal method:

if (!operator.equals("") && !screenString.equals(""))
This was mean to stop the method from executing if the necessary values did do exist. The problem arose because I did not initialize the operator variable, and in some instances when I expected it to equal "", it's value was actually null. I initialized that value and the problem appears to be solved.


TODO:


I noticed another issue with very large numbers. When they get big enough, numbers that should be in scientific notation just appear as a decimal; I think the scientific notation part just gets cut off. I need to update the formatting of my screen output. This will probably also allow me to display integers without a ".0" appended to them.

I still want to include another display field to show operators. And I want to do something else, not sure what, to spruce up the UI.

Idea: Recipe App

My grandmother's always looking for new recipes, so I thought could make a small recipe app. It wouldn't be too earth shattering--just a search for dish that provides a list of responses. The list items will probably launch a web view when clicked on, or maybe my own activity that pulls content from a web page and a picture. This will give me a chance to work a bit with networking and APIs, or perhaps something even more complex. A cursory google search yielded a few different APIs; this one looks the most promising, mainly because it's lowest level is free.

Sunday, July 26, 2015

Calculator IV: Arithmetic Bitches!!

Github

So my logic was okay; I did work through the process correctly with my spreadsheet, but I left a few things out of my code. The first and biggest issue, was that my equal method did not include the display method, which is why nothing appeared onscreen. Once that was sorted, I noticed another problem: When a user presses the equal button, after a calculation I want them to be able to press it again and perform the operation again. 5 + 3 = 8. Press equal again and get 11. In this scenario, I was getting 8.

This was something that I worked out, but just forgot to include in my code. All I needed to fix it was to add a simple conditional in my equal method:

if(number2 == null){     
 number2 = Double.parseDouble(screenString);
}

Before the equal method calculates, it checks for a value in number2, if there is one, it stays then same, if not, then it's value becomes whatever's on screen.


Next Steps 


Now I think all I have left to do is some general prettying up. I want the button's and screen to take up the whole screen and maybe even to add some style to them. I'd like to also include another field that displays numbers and operators when they're not on screen.

Random Episodes

Just a quick idea for something I want to start working on. I while back a made a couple desktop programs, probably with visual basic, one that generated a random episodes of Seinfeld, and one for episodes of the Simpsons (I think seasons 3-11.) I'd like to combine them into one android app. It's a simple idea, but I want to have the option to select shows and seasons. So there will be a list with the two shows(hopefully more in the future), and each item can be checked or unchecked. And when clicked on, a drop down menu is revealed in which you can check or uncheck seasons of each show. The app will select a random episode from the selected seasons of the selected shows.

Saturday, July 25, 2015

Calculator III

What Did I Learn?


The difference between a double and a Double:

It turns out that a Double can equal null and  a double cannot. This was very important for my project, at least I thought it was. I've got values that need to be doubles, because of the calculations I'm doing, and I need to check them against null because that will determine what a button will do when pressed.


A bit more about the difference between public and private:

I've only got the one MainActivity class, so I figured I could make all my methods private, including the ones for button presses. When I ran my app, as soon as I pressed a button, it crashed. This happened because all those buttons are referenced in my xml. When a method is private, it's invisible to everything outside it's class.

Android Studio's warnings are not so bad:

I always thought of them as nitpicking nuisances, that mainly wanted me to extract my strings to string resources, but today, warnings reminded me to change a == comparison with strings to .equals(). I thought this would save my broken app, it didn't, but it was helpful nonetheless.


This is tricky.

I talked a big game about how easy this would be, and maybe this is easy, but I just spent hours trying to work out the logic of this calculator and it still doesn't work. I was trying to work it out in my head, but I kept losing track of my variables and what I needed them to do. So, I decided to make a spread sheet. I listed each variable, and what their values would be for each button press I went through.



What did I actually do?


First of all, I added a few conditions to limit the number of characters that users can enter, and that makes sure only 1 decimal point can be entered. 

My first plan was to have each button handle its operation. So when the add button was pressed, the value on screen would be stored in a holder value, and if there was already a value in the holder, the values would be added and returned to the screen. Pretty messy. I completely scrapped that idea, and decided to make a calculate method.


Calculate Method

The calculate method has three parameters: an operator string and two doubles. It contains a switch statement that the performs an action with the two numbers depending on the operator:
case "+":
     result = num1 + num2;

Operator Buttons

The plan for each operator button is to, when pressed, check for a value on the screen. If there's not one, nothing will happen. I made a couple global Double variables (number1 & number 2) to hold values, and a string to hold the operator. The value from the screen is stored in  number1 and the operator will be set to whatever button is pressed and the screen is cleared.

I also want users to be able to add(or whatever) to totals. So can do 2 + 2, then press plus again, which clears the screen, and  they can perform an operation on the total(4), instead of 2+2, pressing = and then performing another operation. So based on my spreadsheet, I found the situation where this is the case(number 1 != null && number2 == null) and added this condition to my operator.  In these cases, number2 is set to the value on screen, I call the calculate method and store the result in number1, then clear the screen.

This logic works for all the operators, so I was going to copy and paste it, just replacing the operators. Instead, remembering the tenant DRY, I refactored this into the operator method, which takes an operator(+, -, /, *, %) as a parameter.


Square Root

This was a little different(and its the only thing working currently), because it just takes what's on screen and shoots back it's square root. So that's not a part of the operator method, but it does factor into the Equals method. And it sets the operator to "SR."


Equal Method

For this I first need to check to see if the operator is SR, if that's the case, the squareRoot method is called. This way users can enter 81, press SR, and get 9, then press = and get 3. This piece of functionality wasn't important to me, but I wanted to be sure that after a square root press, if users do press equal, the button wouldn't be referring to an older operator.

In other cases the equal method will convert the value on the screen to a Double, store it in number2, call the calculate method, and display the results.


What went wrong?

My best guess is that the problem lies in where I'm setting the values of my number variables. Maybe they are in if statements, when they should come before them, and the proper conditions aren't being..This made less and less sense as I typed it. I think that my logic is just off. I'm going to do some debugging and see what the values actually are when buttons are pressed. And I'll probably need to overhaul my operation method.



Tuesday, July 14, 2015

Calculator II



Github

Just a quick update. I added functionality to my number and clear buttons. I originally intended to set up onclick listeners for each button, but I took a look at an app I made for a Udacity course and decided to make methods--press1, press2, etc.--and reference them in the each button's android:onClick property in XML. It's not much easier to do it that way, it just seems cleaner to me.

Taking the screenshots, I realized I need to prevent users from pressing the decimal button if it's already been pressed, and limit the number of characters that can be entered.

Right now I've got the numbers stored in a string that is added to each time the button is pressed. I think what I'm going to do next is, whenever an operator button is pressed, I'll convert whatever is in the string to a double, store that variable in a double and clear the screen. Then I can perform whatever operation is pressed with that double and whatever the new string is.

Sunday, July 12, 2015

Calculator

Github


Nothing fancy, just a calculator. Not much to look at yet, so no screenshots. I tried this a while ago when I was learning Visual Basic; I hit a snag with something, and abandoned it so I want to give it a try in Android. Maybe I'm wildly underestimating this, but I think this is going to be easy for me to put together.


Where it is now:

Just a textView and a grid layout with 16 buttons in it.


Where it's going: 

I haven't completely figured out the logic of it yet, which doesn't bode well for my "this is going to be easy" proclamation. But I'm not too worried. This is one though that I'm going to do absolutely no googling to get through. There's only one activity, so that shouldn't be a problem. I just need to figure out how to make it work.

Enemies

This is what I worked on during Ship-It Saturday. It's a note taking app, with a somewhat evil twist.




Github


What it does:

It's meant to be a highly specific note taking app. Users can add names of people, organizations, or institutions that they hate. They should be able to delete names. When they click on a name, they should be taken to an activity where they can add reasons. These will be up to 140 characters of text that can be edited or deleted once they're added.

     


Where it is now:

It's kind of a mess visually and technically. I spent way too much time on design and I think this thing kind of looks like garbage. I mostly googled the things I wanted to do, copy and pasted code from Stack Overflow and modified it to fit what I wanted.  The background is one of the first 10 things that comes up when you google the word 'enemy.' I worked the whole color scheme around that.

Right now you can press the '+', add a name to the screen via a prompt. You can also hold each list item and you're prompted to delete.



Where it's going:

I need to make the screen that shows 'reasons.' I need to make an Enemies class instead of just have the list fill up with strings. I'm also going to make a custom adapter for the list so that I can add a delete button. Even though I don't love it, I'm going to try not to do too much to change the appearance. I want to see my  awful vision out to the end.

Hackathons

I went to two hackathons this weekend. The experience was humbling, and inspiring, and a little scary, but I'm so glad that I decided to go. The first one, The AT&T Mobile App Hackathon, was just the first event that I found going on near me. I kind of make mobile apps, so I thought it would be right up my alley. When I got there though, it was clear that I was out of my depth. The focus was on IoT, which basically involves interacting with hardware. It went on from 6pm to midnight, and from 9-9 the next day. I left after a few hours, but it was worthwhile. I saw some cool sensors, I meet some smart people, I found out what IoT is, and when I got home I immediately started writing down ideas for app that I could make.

A guy I talked to that night, told me about Ship-It Saturday, a hackathon held by a web dev bootcamp called Launch Academy. It was a lot more free wheeling, non-competitive, and really just about making something, so the next day, I went to that. This one was actually perfect for me. It was a lot smaller than the night before and there was a more collegial atmosphere. I didn't work with anyone else because they were mostly doing web dev, but talked to people about their projects and my own. I didn't realize before how valuable it is to have those sort of technical conversations with people about what you're working on. Explaining my app to other people, helped me understand it better myself, and they had interesting ideas too.

I didn't have a finished product at the end of the day, but it was a great working on an app, of my own, for 9ish hours. I learned a ton--I was surprised by some of the things I managed to do, and the experience highlighted areas that I want to try to understand better.  A lot of the projects people were working on were really cool. It was great watching people collaborate and it was just good to be around peers. And they had free pizza and beer! 

I'll definitely be going to more. 

Beginning

I don't know what to call myself. A couple of times this weekend, I told people that I'm "an aspiring Android Developer." I guess that's what I am, but I felt like a doofus whenever I said it. I've been studying Android dev, Java and a little web development for months now. I've dabbled a bit with programming in the past, and I really liked it, but I never really committed. About a year ago, I decided that I wanted to make this my career. I want to be happy to go to work. I want to make things that are creative and complex. I want to do things that few other people can. So I went all in. I saved my money, quit my job, and here I am. 

Most of the work I've done so far has been through Team Treehouse. Their Android has been a great foundation for my studying. You basically just make apps of increasing complexity and they guide you through the process step-by-step. I learned an incredible amount of information and it's great to have your completed app at the end of each lesson as a tangible representation of what you've done. 


I've supplemented my studies on treehouse with a great series of java tutorials, a couple challenging courses made by Google, and some game dev tutorials. I've got a bit of an interest in web dev as well, so I've been spending a little time on freecodecamp as well. r/learnprogramming has been an important resource for me too, it's a supportive, and helpful community for anyone with questions about programming.

I know the best way for me to take my knowledge to the next level and get myself ready for a junior dev job or even an apprenticeship, is to make my own apps from scratch. That's what I'm going to be chronicling here. I'm going to build things, I'm going to break things, hopefully I'm going to get better, and hopefully so will my apps.