Categories
iPhone app

Ads or no ads

Reading Time: 2 minutes

Should I put iAd to my iOS apps on iTunes App store? Should I put the google adsense back to my blog? The reason I am asking this question is: while personally I really don’t like the ads on Facebook, LinkedIn, or the iAds on some apps like Echofon, I understand this is a meaningful way for app developers to make some money. This applies to me as well. While I did not spend whole a lot time working on my apps (in aggregate), I cannot go on this app dev road without any meaningful downloads/income revenue forever. I can do it for a while. But not for too long. I believe Ray Wenderlich talked about the importance of Ad revenue at recent raywenderlich.com podcast. One of the episode of Paul Kemp’s the App Guy Podcast (onemob.com) , talked about something similar.

I guess, the trick is to balance the ads and app. We don’t want ads to totally destroy the good experience of an app, but at the same time, if the app revenue could help the developer keep going, go for it. We live in a commercial world, no money, no bread. No bread, how can app developers survive?

photo

Btw, I found the Apple developer documentation for iAd is insufficient or not up-to-date. For example, it uses requiredContentSizeIdentifiers in the tutorial, which is already deprecated in iOS 6. I found it won’t compile with iOS 7 SDK. I have seen in the past Apple does not always updates its developer documentation. Maybe they have not given high priority to this. I am sure if they pay attention, they can fix it.

    Categories
    Software development

    Singleton pattern backfired on me

    Reading Time: 2 minutes

    This is a continuation of my earlier post of Tree, recursive function and my dumb mistake. As I said in my last post, my solution was to create hash maps (singleton) to store those for the session. The main motivation was to help out the performance. But I found out it backfired on me, a few days ago and today. In both cases, it has to do with the hash map I created, it was something like (object , a list of objects). In both cases the list of objects was actually dynamic, and I made an assumption it was static. In other words, I thought I only need to put the mapping to the map once, then I can use it happily ever after. I think there might be ways to get around it, i.e., I should update the map when that list does change. I will investigate and work on it more. (Update 05-30-14) So I found a solution to one scenario, I was able to update the map as needed. And I use put method (java hashmap) to do that update.

      Categories
      iPhone app Software development

      What types of developer are you?

      Reading Time: 3 minutes

      Or am I? 🙂 I think I’m a pragmatic programmer. Note this is also a book title I read, by pragmatic (note not agile), I think it’s about balance between software quality, effort and delivery date. It’s also about releasing software with known risks (including bugs) 🙁

      Pragmatic_Programmer

      I thought about this as I started practicing some new (new to me) programming techniques, e.g., pair programming, test driven development (TDD), and also seen developers of different personalities/experience adjusting to this, at the same time trying to deliver the project on schedule. I felt and considered myself to be lucky in this aspect, as I thought my career at UGS/Siemens PLM Software laid the foundation for me as developer, in other words, I was very lucky to work with some excellent developers (definitely top 20% according to Jeff Atwood, co-founder of stack overflow), and received their guidance and mentoring in my programming formative years. Note I was not doing Agile, TDD, pair programming at that time, at least not formally. But at the latter part of my stay there, I did quite a bit automated unit/regression tests there. Also, although there is no pair programming, whenever I feel stuck, I could go to a senior member of the team, and talk. Not to mention the long debug session. I wrote about them in my blog long time ago (in Chinese, such as this one and this one).

      Categories
      iPhone app

      Three good iOS Mac focused podcast

      Reading Time: 2 minutes

      I have listened to Paul Kemp’s the App Guy Podcast (TAGP) recently, got to know this from @raywenderlich via twitter. Paul’s podcast is not purely technical, it’s more about entrepreneurship, and start own business. It’s an interview format. Paul usually asks indie developers (iOS, web, etc.) questions on how they get started, any pain points or difficulties to strike out on own, vs. getting steady paycheck from corp. Paul himself is an indie developer/podcast too. I think Paul is a good interviewer because he asks good questions, which reminds me of other good/great interviewer such as Charlie Rose (PBS/CBS), and Wealthtrack’s Consuelo Mack (formerly PBS). Again this is not only about blocks, MVC, Xcode, but more about going indie (independent developer).

      Another good podcast, which started recently, is raywenderlich’s. There we have Ray plus 4 developers (Tammy, Jake, Felipe, and Mic). It’s more technical, but it also covers going indie. For that matter, the 4 podcasters have been going indie for some time, and Ray himself was an independent developer before the tutorial site/book took off. So they have a lot to share. And we (as techies) got to listen all the nitty gritty of NSNotifications, design patterns as well, which is cool.

      Categories
      Software development

      Dumb code mistake continues

      Reading Time: < 1 minute

      So I was able to fix that performance problem I mentioned in my previous post. But I inadvertently introduced a new problem in my previous fix. And here is the gist of how I did:


      while (some condition) {
      if(some other condition) {
      ...
      return;
      }
      }

      Guess what, I was able to put it into infinite loop…I can explain more if needed 🙂

      Categories
      Software development

      Tree, recursive function and my dumb mistake

      Reading Time: < 1 minute

      Tree data structure is fairly common in software development, and luckily I have quite a bit experience working on those in my career. I started working on this as I was working for UGS/Siemens PLM Software, and I was involved in the development of XML based data adapter for CAD data exchange, a key piece of information we want to translate is the assembly information, or product structure, or in computer/software terms, the tree hierarchy. I did learned a few things on recursive function, etc. Interestingly enough, later on I got a interview phone call from Google, and the guy asked me about recursion, for a simple problem like this: basically they are 100 matches, every time one can take one or 2, how many combinations are there? I said let’s do it in recursive fashion, after quite a bit reminder/hint, finally I said n(100) = n(99) + n(98)

      But they were not very impressed with me, as I did not come up with the solutions fast enough, which is fine. I am who I am, I can work on those kind of interesting problems, in my own pace. Or explained in my Chinese name, it’s getting faster gradually 🙂

      My dumb mistake

      Categories
      Software development

      Test Driven Development and Unit Test

      Reading Time: 2 minutes

      (Update 02-19-2021)

      spring.io Testing the Web Layer

      Mockito Example with Best Practices

      JUnit and Mockito : Best Practices, Do’s and Don’ts

      (Original) Test Driven Development (TDD) is getting popular these days. I had opportunity to being exposed it recently. I am not new to unit test. In the software company I worked for 8 years, we have regression test suites that runs automatically (at least daily), and we update the test suites as we find edge cases from customer bug reports, or in our development. That was about 8 years ago. Since the switch into Java land (2010), I started using JUnit and create/run the unit tests. One thing I was exposed to recently is Mocking in unit test, and TDD. Both takes a little time, and I am not fully bought into TDD yet. But I did learned something interesting on both topics lately, and like to share.

      1) TDD
      One of my coworker is very experienced and in-grained in this, as we are doing pair programming, I learned this a bit. An interesting back and forth as I was making changes to a method.

      Coworker: “Do you have a test case?”
      Me: test case for what?
      Coworker: for the change?
      Me: do we need this? …

      But eventually we wrote the case, magically the web app also worked as soon as we passed the unit test. But overall I still have some reservation to do this, as I am not good at mocking e.g. Mockito, or writing test, and I think there is some cases pair programming can get the code right without go heavy in unit test.

      Some links for mockito and spring test

      Stubbing and Mocking with Mockito and JUnit


      https://www.vogella.com/tutorials/Mockito/article.html
      https://stackoverflow.com/questions/39486521/how-do-i-mock-a-rest-template-exchange
      https://www.baeldung.com/spring-mock-rest-template
      https://stackoverflow.com/questions/11969609/junit-mockito-when-thenreturn-throws-nullpointerexception/18060451
      https://javacodehouse.com/blog/mockito-tutorial/

      2) Unit test (auto test suites)
      I heard from my coworker recently that test suites should not use the implementation data source (database). I thought the main reason is the heavy weight/use from database resources point of view. But there is more, today I found if auto test consistently changes things on dev database, it’s really hard to find out the root cause, and cause confusion. Initially we thought the problem was caused by batch job, or the web app, spent a lot time trying to figure out, both are not the cause. And luckily, at the end we were able to find out the real cause.

      Categories
      iPhone app

      How to make iPhone app iPhone 5 5s compatible

      Reading Time: 2 minutes

      (Update 03-05-2019, almost 5 years since original post) I did something similar for iPhone X, XR, XS screen size. Basically I stretched the Default-568h@2x.png to Default-375w-812h@3x.png and added that in the “launch image”. I also noticed the some of the nib files have the wrong constraints for label, textfield and button. I made some simple changes so that the top and bottom portions stick. Last but not least, the constraints and the size of google admob banner ads needed similar work: I did the needful and checked those changes worked both for iPhone SE and iPhone X.

      I don’t have iPhone X (XR or XS). My first impression they are much longer than the SE I have.

      (Original 04-13-2014) I found some iPhone apps are still not updated to take advantage the iPhone 5 screen size (4 inch vs. iPhone 4/4s 3.5 inch). I think in many cases the owner of the apps may not have time or the developers don’t know how to stretch the screen. This is a quite common problem. The solution is also fairly straightforward. We only need the stretched version of the screenshot, and name it as Default-568h@2x.png (exactly like this). But to get this all started, you might want to use this blank png file, something like this:

      Default-568h@2x

      Add this file to the Xcode project, and run the simulator. Screen capture the first screen and edit it to make sure it’s 640×1136, and name it as the file name above. This way the app will both have a good launch screen and stretched screen for iPhone 5/5s

      (Update 04-20-14) I found something more interesting. When I tried to add auto layout for the nib (xib) file created in Xcode 3.x, it basically give me a blanket (black) screen. So basically we can not reuse those old nibs for auto layout.

      Categories
      Software development

      If it’s not broken, don’t fix it?

      Reading Time: < 1 minute

      This is the common saying I heard a lot when I started worked for a software company on development. I can list some of the pros and cons of fix it.

      Pros
      Architecture chaos: if not fixing it, basically as the software ages, per the “broken windows” theory, people would just throw in changes to get things done, without carefully thinking about the architecture, dependencies. And this leads to the related problem below.

      Code hard to maintain: it will become harder and harder to fix bugs, or add new features with the code in a messy state.

      Cons
      Introduce new bugs by accident. Or the fix making the software worse. While it’s unlikely, it’s still possible. Not carefully planned fix could introduce bugs, and make the software worse. I have done my share of that too 🙁

      Refactor
      If we were to work on the clean up, refactor the code, as a minimum we should have the regression test suites. Or in ideal world, we would have automated unit tests, which could help both speed up development, and give another level of confidence for the code change.

      Categories
      iPhone app

      iPad number input only

      Reading Time: < 1 minute

      There was not an easy way to show the number only keypad on iPad. I used to create a custom number input pad like below.

      iPad_number_input

      I loosely followed raywenderlich.com custom input tutorial. Email me at minjie Dot xu At gmail Dot com if you need the source code. And please ask nicely.