Entries in CS193 (3)

Monday
Nov212011

Back On Track, and Running!

So many great things happened during this week, that I don't even know where to start!  Well, let's start from the beginning of the week.


Just as the Assignment #1 was done and over with the updated Stanford iOS course CS193p has been posted on iTunes!  This one is also done by Paul Hegarty, great instructor and very engaging man, but this time it's specific to iOS5 and uses the latest version of XCode (4.2).  After I've watched a couple of first lectures I firmly decided to switch from XCode 4.02 to the most recent one (I'd been holding to the old version because of the old lectures, so to be compatible).  It was quite easy to do, because I've advanced only to lecture 4 and did only one assignment.


I then updated XCode and found it to be a very much big improvement over what I had before!  Two most striking features are the Storyboard (and its automatic code generation) and the Automatic Reference Count (it vastly improves the memory management, especially when someone like me has a poor understanding of how memory should be managed).


Following the update, I've completed three lectures of the new course and did the very first assignment (it's also a calculator, but this time RPN).  I've enjoyed coding in the XCode so much that I re-made the calculator a couple more times, which also helped me to get used to the new subtleties of the app and the way it works.


Another bit of a good news is that I've decided to update my system to Lion (eventually), and join Apple Developer Program for iOS and OS X.  I've started the sign up process some days ago, and right now I'm in the middle of making it all work (for some reason I need to fax my confirmation to Apple, and the most interesting part in here is where do I find... a fax-machine!).


There was only one semi-bad event, I had Internet outage during Sunday, so this post came out late, sorry.  However, the good side is that I've had lots of time on my hand to code, code, code!

Sunday
Nov132011

I've Build... a Calculator!

Just as I expected there were more time to study and code after the 10th of November.  So, I went ahead and did one assignment from Stanford CS193 course on iOS programming and coded a calculator.  Now, I do remember coding one calculator in the past, but that was more of remembering the code rather than understanding the code.  This time I was able not only replicate what the instructor was doing, but go one extra step thurther and improve the original concept.

The calculator was supposed to be a usual one, supporting floating numbers and basic set of operations:  addition, subtraction, division, multiplication, and square root extraction.  It was very simplistic in both visual design and structural complexity.  Speaking of structure, though simple it quite well illustrates the Model-View-Controller paradigm, having three distinct classes:  CalculatorBrain (model), CalculatorViewController (controller), and the view which is build via Interface Builder in XCode.  While coding I've realized the boundaries between the three classes, and was even able to implement the extra features in the correct way, choosing the right class to modify!

My additions to the original app were just three buttons:  'AC' to reset everything back to 0, '+/-' to be able to enter negative numbers, and '.' to have the ability to enter floating point numbers.  It didn't take long for me to implement any of these features, but it surely provided a great experience and boosted my interest to continue with the studies.

I'm not posting any screenshots of the calculator here, because it's way too generic and frankly speaking looks ugly to me.  However, it served its purpose very well, and it even posed some design questions I really need to consider for my future apps.

I'm going to have a bit more free time during this week, so there will be more coding, studying, and hopefully great screenshots of my first apps posted here!

Sunday
Jul312011

Good week

This week results are great and important.  I've completed 3 problems from Project Euler in the last two days.  One of them even took me just 20-25 minutes to come up with an algorithm and to code, and it worked fine from the beginning, no bugs.  

However there was one problem (#10), which took me 2 hours to optimize for a quicker solution.  Finding the sum of all primes between 1 and 2,000,000 was not a quick task to complete by brute force alone.  I did my very best to think of and implement all sorts of possible shortcuts in calculations, and still it took about 5 minutes for my program to come up with the answer (it was correct, but still it's very slow).  At that point, when I'd run out of ideas for improvement, I've decided to settle with the way it worked, entered the result into the problem's page, and got access to 'post-mortem' explanation and the best algorithms for solving it.  As I imagined it was beyond my current math abilities, but still I could trace the logics and finally understood the idea behind it.  I don't think I'm going to implement it, but who knows maybe during the week ahead I would want to take a 'coding hour'.  :)

Another important thing happened around Thursday.  I've re-installed XCode 4 on my MacBook, and now it handles all my C++ templates and files perfectly well!  First, I've uninstalled both XCode 3.2 and XCode 4 (thanks Internet, there are many helpful pages about this process and how to do it right), then I've downloaded XCode 4 over again, and finally installed it.  After that everything worked smoothly, without any errors or glitches.  Once again I felt how much more polished and though-out the XCode 4 interface and workflow are.  Really pleasant experience.

I was reading a lot during the week, and there are very good chances will finish the chapter I'm currently on this evening.  I also watched Lecture 1 from CS193 course, which is specific about iOS development.  It's an introductory lecture, so no really hard materials there.  I might continue watching along, in parallel with the current C++ course lectures, until I get stuck.  Besides, my day-time job vacation time has just started and it doesn't hurt to force my studies just a bit.  :)