Sunday, July 27, 2014

I love Git.

I haven't posted in a while, due to the fact that I've been extremely busy.  Recently, I was invited to join a pretty cool aviation simulation project.  Since I served in the U.S. Navy for five years as an Air Traffic Controller, I was very excited to join in.  However, most of my excitement wasn't necessarily due to the nature of the project, but due to the fact that I was given an opportunity to learn some team collaboration skills and tools.

One of the first tools that I was exposed to was Git.  Mind you, I've heard of Git before, but I thought that being a solo programmer, I wouldn't need it.  Boy, was I wrong...  Version control tools such as Git are worth their weight in gold and then some.  I instantly fell in love with ability to branch, merge and review old commits.  It allows me to review all of the notes I've placed in my commits.  That, right there, is actually a very important step.  Some people provide very minimal effort to their comments, but they serve as an invaluable tool of tracking the changes beyond what's in the code.

Furthermore, Git serves as a historical documentation of what I've done and why I should get paid for my work.  From here on, I am planning on using Git or similar tools to keep track of my projects and I recommend that anyone, no matter the size of the team, gives these tools a try.  There are many other tools besides Git, such as Mercurial.  I have it installed, but haven't had the time to try it out; therefore, I can't comment on it.  However, if you wish to learn more about their differences, here's an excellent post: http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/

As far as using Git, I take advantage of the nice interface provided by SourceTree, coupled with BitBucket.  GitHub is an excellent choice as well, but that is not what my current team uses.  If you don't want to download SourceTree, Git installation package offers an ability to install Git GUI along with its Bash, which works very well.  That is what I used prior to installing SourceTree and I did not have any problems with it (I just wanted a bit more functionality and visual comfort).

To get started with Git, here are a few valuable links:

Free Git book: http://git-scm.com/book
Free Git Videos: http://git-scm.com/videos
Git Reference Page: http://git-scm.com/docs
Git Cheat Sheet: https://help.github.com/articles/git-cheatsheet


Thursday, May 22, 2014

Initialization of Auto-Properties in C# 6.0!

Prior to C# 6.0 there have been only two reasonable options for initializing auto-properties.  One is through the backing field:

   public class Person
   {
        private int _age = 23;
        public int Age
        {
            get { return _age; }
            set
            {
                if (value != _age)
                {
                    _age = value;
                }
            }
        }
   }

...and the other is through the constructor:

   public class Person
   {
       public int Age { get; set; }

       public Person()
       {
            Age = 23;
       }
   }

This might not seem as a huge deal if you're dealing with a few properties, but what if your object has a dozen or more?  One of my current applications is using a few Model classes that contain a relatively large number of properties and it becomes cumbersome to instantiate them.  I instantiate them through the constructor option and this becomes even a bigger hassle because I have to make sure that every one of those properties is in fact instantiated within the constructor.  Thus, I spend a lot of time going back and forth, making sure that both properties and their initialization are in sync.

However, in May 2014 issue of the MSDN Magazine, Mark Michaelis announced that C# 6.0 will feature auto-property initialization:

   public class Person
   {
        public int Age { get; set; } = 23;
   }

It's that simple!  Furthermore, if the property is declared as read-only (lacking the setter), it will still be assignable at the declaration time, very much like the assignment operation in the constructor.

There are many other features that are being added in C# 6.0, but the auto-property initialization is the one I got excited over, due to the fact that it'll decrease my workload and make it easier to make my software.

Sunday, May 18, 2014

Update on the battery life of my new MacBook Pro 15 Retina using Windows 7.

I promised that I would let you know how long the battery lasts on my new MacBook Pro 15 Retina after a few weeks of field use.  I am pleased to report that under the moderate-to-heavy use the battery life has ranged anywhere from three hours during borderline heavy use to approximately four and a half hours under the moderate use.

Operations ranged from giving PowerPoint presentations, while running Access database and the showcased application in the background, to a full-on Windows Presentation Foundation development with Visual Studio 2013 and Blend open at the same time.  Note that I had my brightness set at 80%.  The laptop was able to handle everything without any notable issues and the typing experience felt great.  The touchpad functioned fantastically and I didn't feel an urge to use a mouse.  This was something I was worried about, because I'm a heavy mouse user, but after using this laptop's touchpad I now feel very much relieved.

The only draw that I noticed was the fact that I could not use the Delete button the same way as in the Windows environment.  Rather, it functions as a Backspace.  I haven't researched into a way of changing it to function as a dual button by having to press the function key for the second functionality, because it hasn't bothered me that much.  However, I'm sure there is a way.

I can't believe that I'm saying this, but I'm actually very satisfied with this Apple purchase.  I feel like I've spent a lot of money on something that's of high quality.  I wish I felt the same way about that Lenovo T440s I ended up returning.  I really wanted to like it, but it felt too cheap and the touchpad was beyond horrible (see my previous post regarding the issues).

Thursday, April 24, 2014

The search for a perfect developer laptop.

I haven't posted any updates lately, due to the fact that I've been incredibly busy with the two programs I wrote.  They are currently being beta tested at two of our locations and are soon going to be adopted at eight to nine additional locations.  One of the problems I've experienced was not being able to fix any sort of bugs at those two locations during deployments.  Both of them are approximately 90-100 miles away from my house, so I had no choice but to either wait until I can deliver the patches by driving to the locations or do it remotely via VPN.  Obviously, the second choice sounds like a better idea, but I couldn't test the releases remotely and sometimes the connection would time out during the transfer, causing more headaches.  More often than not I wouldn't have anyone at location that could assist me, because it's hard to find anyone with a good technological background that doesn't get lost at the "right click." :)

A natural solution was to acquire a laptop.  I had an ASUS Q200, but the poor fella couldn't keep up very well, even with just Visual Studio being the only program open.  Compiling basic programs became too frustrating and lengthy.  Don't get me wrong, it's a nice little laptop... for web browsing, some video streaming, email and light office work.  However, it did not belong in the software development realm.  So, I ended up selling it to my mother-in-law, who is making a good use of it now.  I began looking for a replacement and could not decide what I wanted.  I knew I needed something that had an approximately 14-inch or greater screen and could handle having Visual Studio and Blend open at the same time, without much struggle.

I ended up getting myself a Lenovo T440s.  I've never owned a Lenovo or an IBM laptop, but I've heard a lot of good things about their products and their support.  After two weeks of waiting, because my shipment got delayed in China, I finally got my laptop.  It was gorgeous.  I love the minimalist, business-like look.  My self-built desktop is of similar design.  I am not a fan of flashy lights or gimmicky additions.  T440s was very light and felt of superior quality; that is, until I began using it.  I was shocked by how cheaply the touchpad was made.  It felt as if I was robbed.  On my desk I had a $1,500 laptop with a 2-cent touchpad.  It was horrible.  Upon pressing it even lightly, it produced a horrible ratting and loud sound, similar to that of a cheap spacebar.  I haven't heard such sound in a long time, due to the fact that I use a Logitech G710+ mechanical keyboard with my desktop and my wife uses a MacBook Pro (early 2012 version).  Her touchpad has a nice, firm feel to it.  Every click actuates sharply, without any annoying after-sound.  It's my fault, really... I did not do my homework.  If I have, I would have found out about this issue on the Lenovo forums.  Many people are experiencing the same issue.

Furthermore, T440s has horrible problems with touchpad drivers, which cause the cursor to jump around erratically for no reason.  Opening or closing things became extremely frustrating, because of constant miss-clicks.  At that point I didn't even care about the sound, but I could not handle the driver issue.  I ended up following some of the tips online and got it to approximately 80% efficiency.  Still, I was upset that I spent a considerable amount of money on something that did not work properly out of the box.

I promptly contacted the support and explained the issue, thinking that it would get resolved rather quickly, due to what I've been hearing from others.  The gentleman on the line confirmed that the sound was very odd and that the model next to him did not sound anything like it.  I could not hear his clicks, while he clearly heard the rattling sound coming from my side.  I took great care not to press the touchpad too hard, because I did not want to produce an unlikely sound.  I wasn't trying to make anything up and I wanted to see if it was just me.  Maybe the sound was normal and I was simply being over-dramatic.  However, he confirmed my concerns.  The next morning I received a box for the laptop to be sent to the repair center and I was told that I would be updated on Monday regarding its status.  When Monday came, I waited until later in the afternoon and called them.  I was notified that they just received my laptop and that the repairs have began.  I was a bit frustrated that they couldn't start repairs on Friday, since I sent it out in the morning on Thursday, but it was not a huge deal.  What was a huge deal was the fact that when I got it back that Wednesday, the touchpad was exactly the same and they actually mis-aligned the keyboard bezel.  So, on the left side it was slightly overhanging and on the right side it was bulging up as if it was forced to the body.

Along with many other things during the process, that was my final straw.  I began looking at other laptops and couldn't find anything that was comparable in quality or performance.  The only brand that stood out was Apple.  Yes, I said it - Apple.  If you know me, then you know how I feel about Apple and about its fanboys.  However, I could never argue with the quality of their hardware.  At this point, I did not care that MacBook Pro 15 Retina (2.3 GHz i7 quad-core, 16GB RAM, 512GB SDD) was made by Apple.  It could run Windows 7 using bootcamp from what I've heard and I wanted to give it a try.

I've heard mixed reviews and I was worried.  Some people have mentioned that the battery life was horrible while running on Windows, others said that there could be significant display issues due to the Retina display, others mentioned that the whole process was a driver nightmare, but I was willing to give a try. Worst case, I could always return it.  Boy, was I surprised. Within an hour, I had a fully functional Windows 7 running on my new Mac.  The only issue I had was the fact that the resolution was awfully huge, and even though Windows scaled up everything to 150% (maximum on Windows 7), everything was still a bit too small, even on the 15" screen.  So, I reduced the resolution down to 1920 x 1200 from its 2800 x 1800 default.  A second part to that problem was that the DPI scaling by some programs was not done properly - chiefly, Chrome.  All I had to do was right click the executable and prevent the DPI scaling.  I then set the default zoom to 150% and it worked like a charm.  My Windows Experience Index on this laptop is 7.2, with everything except the video at 7.9 (video was 7.2 and WEI is always set to the lowest score).

To my surprise, Visual Studio 2013 and Blend had no issues at all.  They started within split of a second and everything worked flawlessly.  I tested the battery under full brightness, full-on performance settings using the Battery Eater and got approximately one hour and 15 minutes out of it.  This is actually really good, considering that even under heavy development I would never stress this computer as much as that piece of software did, unless I was trying to render something in Blender, which I would probably do only if I'm doing something on my desktop; and even if I had such process executing on my laptop, it would probably be plugged in.  So, I expect approximately four to five hours of use out of it.  I would be happy with anything over three.  I wish Apple allowed a swappable battery.  I loved the fact that T440s has an internal battery and an external battery.  Therefore, you can actually hot-swap your external battery, without having to shut down the laptop.  I'll have to look for a battery pack to go into my laptop bag, I'm sure there's something out there.

I must say, though, that Lenovo actually did a better job as far as battery goes and produced one hour and 42 minutes under a similar load.  However, it was not as powerful as the Mac, and the rendering during the stress test was becoming choppy every five minutes.  One other thing that Lenovo did much better was its cooling.  The entire time it stayed relatively cool and produces very little fan noise.  MacBook Pro, on the other hand, was very loud and extremely hot underneath and relative hot on the keyboard, as it squeezed every bit of power out of its four physical cores (eight total, due to hyper-threading).  It would be unfair to compare their hardware performance, but Lenovo did not have anything for T440s that could match the MacBook Pro 15 Retina.  PCMark gave the Mac a score of nearly 6000 (just under) and mid 3000 to the Lenovo machine.  I wrote a quick C# console program that used Fibonacci sequence of 50 numbers to test both machines.  Mac was able to produce all 50 integers within 15 minutes and a few seconds, while T440s took well over 20 minutes and actually almost hanged towards the end.

To be completely honest, if T440s did not have such a horrible touchpad, I would stick with it, because it has a phenomenal battery life, a hot swappable external battery pack (so I could carry up to two spares, due to the fact that they're very light and slim), I love the way it looks, it has a decent performance, amazing cooling and it's very light.  On top of that, it cost me approximately $1,500 after taxes (with 4GB RAM and 512GB hard drive), which is $1,000 less than MacBook Pro 15 Retina.  I would add an extra 8GB stick (the 4GB is soldered onto the board) and replace the HDD with a 256 or 512 SSD, which would still bring me well under Mac's price tag of over $2,500 after taxes and with a student discount.  However, that touchpad made it completely unusable and I am pretty darn satisfied with with Mac's performance, its screen real estate and its painless incorporation of Windows 7.  While I have bashed Apple plenty of times and I'm still sticking to most of what I've said, I will not hesitate to obtain a product of high quality.  This Mac is just that.

As a .NET/WPF developer, I've been frustrated with Microsoft plenty of times for some of the most insane bugs that I've found in WPF, which Microsoft is brushing off as of no importance.  However, there are plenty of things to like about Microsoft and Windows line (especially XP and 7).  I'm not going to list them here, because it does not pertain to the discussion, but I point this fact out so that you may understand why I'm not completely alienating Apple.  Yes, I disagree with some of their ideologies and the way they do business, but if they produce a good product, I will give them kudos for it and I will gladly adopt it.  In my opinion, MacBook Pro 15 Retina is an excellent product, comparing to a lot of its competition out there.  Of course, take what I just said with a grain of salt.  I don't have the time or the resources to test all of the available products out there, but I thought I'd share my personal experience and opinion.

I honestly did not think that I was going to like having a Mac that runs Windows, but it somehow works out very well.  An added bonus is the fact that I can switch to Mac OS to test out a ported app.  I was eyeballing the Mono project for some time and that'll give me an opportunity to test it on Mac. My next goal is to figure out how to install a Linux distro onto it, so that I can have all three.  I've heard that Parallels can do it, but I haven't had a chance to try it.  I may revisit Lenovo years from now, when they fix their touchpad problem, but for now I'm pretty satisfied with my perfect developer laptop - MacBook Pro 15 Retina running Windows 7.

UPDATE (04/24/2014):  I am not sure if Chrome was updated, but it no longer shows up blurry even without disabling the DPI scaling.  So, things just got pretty awesome. :)

UPDATE (04/27/2014):  For the past few days I've been trying to test how much time I can get out of this MacBook Pro 15 Retina.  I can report that the average battery life has been approximately two hours under heavy load.  That was with 60% display brightness and 30% dimming brightness after two minutes.  Not anything spectacular, but the fact that constant work was performed for those two hours has to be taken account.  In reality, when I begin using it out in the field, it'll probably last me 3-4 hours of moderate usage.  That, of course, is an estimate, and I'll update you after I test out it for the next few weeks.  I really wish it would have a swappable secondary battery pack like T440s, but everything else on it is amazing.  Next test will be light-to-moderate usage in home environment.  Note that, as I've mentioned, the actual field test won't be reported until after I test it out for a few weeks.

UPDATE (04/27/2014):  Well, I'm happy to report that after testing the in-home moderate usage, I was able to get four hours and thirty-five minutes out of the fully charged battery and that's not even fully discharged ( I didn't feel like going lower than 10%).  Usage consisted of downloading and installing programs, while running Visual Studio 2013, for the entire duration of the test.  I needed to install all of my productivity and development packages, so it was perfect timing.  I'll report back with the in-field findings in two weeks.

Saturday, March 15, 2014

It gets easier.

While attending college, I have been a witness to an interesting phenomenon.  A usual programming class in the Riverside Community College District would start off with approximately 30 students, give or take a few. After the initial weeding out of the ones that thought this would be an easy A, a usual class would consist of approximately 20 students.  What I've noticed is that by the end of the semester, some of the classes would have 10-15 students left.

Of course, some students realize that programming is not something they enjoy and drop a related class.  That is definitely the right thing to do when you sense that it's not your cup of tea.  One of the worst things is to waste your life away on something you don't enjoy doing.  Is a few weeks enough time to truly see if it's something you'd enjoy?  In my opinion - no.  However, I'm not here to talk about those type of students.  I want to talk about the ones that enjoy doing it, but are too scared to press on.  I lost count of the number of students who claim that they'll never get to be "good at it," or they're "not smart enough."  Wrong!  Everyone is smart enough.  Some people are naturally better at certain things, but almost everyone is able to get good at something they enjoy.  First steps are always the hardest.  It's boring and repetitive to learn fundamentals of anything.


At Big Bear Mountain
A good way to beat the notion of not being good enough to achieve something or being afraid to take on a new challenge is to just start doing it.  I am naturally pretty poor at balancing.  I am very stiff and failed many times on a skateboard.  Therefore, when I started snowboarding, I thought that it would be just to say that I've tried it, and not something I would do as a hobby.  After large number of face-plants and an almost torn knee, I got to the point where I'm very confident on the snowboard and make newbies turn their heads as I scream by them at full speed.  I stuck to it and I got good at it.  Snowboarding became my winter season hobby and I love it.

How did I get to the point where I realized that the biggest obstacle is my own mind?  Through my life experiences.  When I was 17, I joined the U.S. Navy.  When it came time to pick my rate, I chose to be an Air Traffic Controller.  My English was poor (I've only been in U.S. for three years at that time), and I was a fairly timid teenager, but I scored very well on the ASVAB. Air Traffic Control (ATC) had one of the highest attrition rates in the U.S. Navy (not counting the SEALs, of course), with approximately 40% of the personnel making it through the training program.  It sounded like a fun challenge, and it's not like I could get fired from the Navy - I would just get stuck with a different rate. I graduated in the top five of my class and within a few years I made a rank of Second Class Petty Officer (E-5).

When I left the Navy, I wanted a job that paid well, but I did not want to do Air Traffic Control.  Air Traffic Controllers get paid very well, but I was bored with it.  So, I eyed the California Highway Patrol as my next target.  The pay was good and the CHP Academy is one of the toughest law enforcement academies in the world.  With an approximate attrition rate of 40-50%, it sounded like a fun challenge.  I graduated as number 23 out of 165 in my class (we started out with 240).

Thus far, I have been choosing pretty tough careers and I've excelled in all of them.  Was it because I'm smart or strong?  Well, I'm not stupid - but it's not the reason. The reason is that I give my 100% to everything I do.  When things get tough, I don't give up.  It is tough to adopt this sort of mindset, but once you start practicing it, things will get easier.  All of a sudden, obstacles become fragile and almost anything seems achievable.  This mindset helped me a lot during my transition into software development.

When my classmates began dropping out when pointers became a thing of sorcery and impossible to understand, when memory leaks due to un-disposed objects became a thorn in the side, I simply held my breath and pushed on.  I knew that, even though I was getting lost and did not understand some of the information, I would get it some day.  Looking back at any of the concepts I struggled with previously, I smile, due to the warm and fuzzy feeling of knowing that it's because I stuck in there.

Good things are rarely easy.  Don't give up.

Tuesday, March 11, 2014

Why I love StackOverflow.

If you've been around the net long enough, you've undoubtedly come across the StackExchange. SE is a Q&A collection of sites, ranging from home improvement to computer programming. I am a member of a few of those sites, but the one I frequent the most is StackOverflow.

I began visiting SO approximately a year ago, when I started taking my first programming courses in college. Being a new programmer, I did not have a strong foundation, nor did I know of all the available resources. I did not know what books I should read or what websites I should visit.  A basic console program appeared as pure magic.  On top of that, I did not know the proper techniques to find that information myself.  I knew what I wanted, but had no idea how to get it.  As an example, approximately three weeks into my first C++ class, I decided that I wanted to make a timer that was running in a console window.  I wanted to allow the user type "stop" and press enter to stop the timer.  The problem I encountered was that it was impossible to accomplish this without knowing some of the more intermediate/advance topics.  Frustrated, I went to the campus library to see if I can get some help there.  Usually, there was an old Professor that was hanging out to assist the students with some of the basic questions.  Unfortunately, he has been out of the loop for so long, that he did not really know how to help me.  So, I made my way home and began my drilling into the net for information.  That is when I came across SO.

While I abandoned the attempt at creating my first console program that I wanted, I began absorbing all the material I came across and using SO as my guide.  I quickly learned the value of "What have you tried?" with my embarrassing first question: "C++ do{}while(); loop."  I was a bit frustrated with the comments I received, but then I learned to appreciate them.  SO strives to provide an environment where people ask clear and direct questions, while ensuring that they've attempted everything within their knowledge parameters prior to asking those questions.  It's a learning tool, not a feeding spoon.  It is true, though, that some of the members should be a bit more lenient towards newcomers. However, SO taught me how to ask the right questions and show that I've done my share of attempting to solve the problem.  It became my go-to place when I would come across problems that drove me mad for hours.  "Surely," I thought to myself, "there must be someone else who already solved this!"  Most of the time that theory held true.  However, there have been a few moments where no one could provide an answer and I had to dig further to figure it out myself.  I always make sure that if I find the solution, I share it in my post, so that if someone else has a similar problem, the solution will be available to them (ex: Window Snapping, WPF DataGrid ScrollBar Modifications).

SO became part of my daily routine not only to get answers to my questions, but also to help others.  Every time I would come across a question that I was curious about, I tried to do some research to see if I can come up with a solution.  It became an endless source of new knowledge.  Every day I would learn something new through reading some of the people's answers and questions, and doing my research.  SO is an endless repository of knowledge and assistance that, most of the time, is just a few minutes away.

Thursday, March 6, 2014

Thoughts on user experience and documentation.

I had no idea that creating a user guide would be such a chore.  For my latest program, which was deployed not too long ago at one of the offices, I had to create a user guide so that the new users would have an easier time getting started, even if I'm not around to guide them.  This would also relieve some of the pressure off of the existing users from having to teach the newcomers.

At first, this doesn't seem like a hard task, but I'm sure that anyone that has ever created a user guide can tell you that majority people just don't know how to follow instructions.  It could be that they're just not interested in the subject, so they're reading through without really "reading," or it could be that their familiarity with the technology in question is simply not high enough.  When my first program got deployed at a different office for the beta testing, I had to guide several employees through the program and steps necessary to operate it.  It was painfully shocking that I had to explain myself when I asked an employee to "right click" or press a certain button on the keyboard.  A lot of people are simply not familiar enough with computers and that's something we have to take into account.  We're so used to our environment, which is full of tech-savvy people, that when we venture outside of it, we get a culture shock.  Of course, that's a generalized statement; therefore, it may definitely not hold true for everyone, but it's enough to make my point.

So, the guide, which I just finished writing, seems like it's as thorough as it can get.  I clearly specified when and where to click the left mouse button and what keyboard key to press.  I even included images of the buttons and text fields, as well as labels and the layout description of every window.  I included several images of the windows and broke down each of the buttons and functions.  However, as thorough as it is, I am more than positive that someone will be confused at some point.  This is just a fact of life.  Not everyone's caught up with the technology, and it's progressing faster than some people's ability to learn it.

A lot of my time, lately, has been spent learning better UX methods.  It is important to remember that we're creating our programs for someone else.  That program that you just wrote may be the first program that a person has ever used.  They may have no prior technological knowledge and the last thing you want to do is to make their life miserable by providing poor documentation and a program full of bugs.  Mind you, I'm aware that there shall always be bugs; however, it frustrated me when I see someone struggling with a poorly designed program.  About a month ago, I went for a check-up with my pregnant wife, and when we were being checked in, the receptionist was frantically clicking on error message pop-up windows for about twenty to thirty seconds.  I lost the count of how many windows popped up.  That is not what we should be building. There is absolutely no reason why that person should be committing a good portion of her work time and nerves to battle a wave of error messages.

It is important that we, as developers and designers, create intuitive and frustration-free applications for our customers.  Our user documentation must be thorough and understanding of the target audience.  We must not assume that our users will have the same knowledge level as us when it comes to a particular technology being used.  Will we always please everyone?  That is the hope, but it may not always be that way.  However, me must strive to achieve that goal.  That user guide might be a chore, but it's a chore that must be done properly.