Tag Archives: Learning

Logging class/method/variable name in Objective-C

Just a small post for an effective tip in Objective-C.

Usually if you use the

NSString *name = @"Hello World";
NSLog(@"%@", name);.
Output: Hell world

And usually, when we debug the program and viewing the log, we really want to know the class/method/variable name and line number as well. You can manually hard code it like

NSLog(@"ApplicationDelegate - applicationDidFinishLaunching - name - Helloworld");

But, it is really time consuming and repetitive task. For our company, we use

#define NCLog(s, ...) NSLog(@"<%@:%s:{%d}> %s = %@",
[[NSString stringWithUTF8String:__FILE__] lastPathComponent],
 NSStringFromSelector(_cmd), __LINE__, #__VA_ARGS__ , [NSString stringWithFormat:(s), ##__VA_ARGS__])

Another variant of this is (it combines both class name and method name into __FUNCTION__):

#define NCLog(s, ...) NSLog(@"<%s:{%d}> %s = %@", __FUNCTION__, __LINE__, 
 #__VA_ARGS__, [NSString stringWithFormat:(s), ##__VA_ARGS__])

Then you can just use it like NSLog. For example:

NCLog(@"Hello world");

Output: <ApplicationDelegate:applicationDidFinishLaunching:100> name: Hello World

Good luck to your new productivity:). For your programming language, stop using the System.out.println() and Console.WriteLine, find a version of yourself

Log the method name in objective-C posted in stackoverflow

Print out the variable name in Objective-C posted in stackoverflow

RoboCode Team Battle (Week 4)

Hi, everybody, the robocode competition goes up to another level, promising more fun and more jobs for you guys. We just released a new rule this morning requiring people to compete in team, 2-2 battle. The era of 1-1 battle ended. This morning is just a practice for a new game. You do not have time to improve your robot a lot, that’s ok now. You just need to have a better communication with your ally.

Now, we just take a look at battles between 2-2. There would only have 4 teams this morning but creating a lot of fun and entertain for people. Poor you guys, the people not joining this morning

The first match:

The Red and the Blue guy on the same team while the White and Black on the other team. The match was quite in the first team when the Black guy use the still strategy, which was good for some robot cases that can not shoot the still robot

The second match:

The 2 yellow guys compete with Gray and Blue guy. The 2 yellows shoot quite correctly but the strategy of the other team is against the Yellow team when they move in line but change direction really fast.

The third match:

We found the anti-Indian guy. Welcome to Yellow guys, you guys did a really well job when running in a spin strategy and the Indian strategy almost dies.

Wait for tomorrow, when we will have a real team battle. Never have the case that we will shoot each other any more. And AWARDS, will officially be given for the first 2 teams tomorrow.

RoboCode Report Week 2

And now, we are already on the week 2. Different than week 1 when I am too busy to write some brief report. I will write some brief report, feedback and evaluation about the second competition.

First, come to the battle between Police and Indian. We can see that Police does not have a big improvement over the last week, while Indian goes into the next level by getting the ideas of running around the opponents from his own opponents (ideas started by Police). We also wait for some peole to kill that suck Indian. Everybody really wants to kill the Indian

Then, we come to the next match between Tester and Rammer. Rammer tried to implements a combining strategy between Rammer, Indian and Spin Bot. But, to be honest, it was an example for what people say : “good idea, bad implementation”. Rammer tried to change the algorithm at the bad times and the RunAway strategy was not good enough. Waiting for the next version when Ramming and Indian shake their hands:D. We also welcome the new comer, a handsome guy, Phan Vo. Hope that we will see a better implementation in the next version

Yeah, now, we see how good Alosa (a loser) is and if it is a real alosa. With a quick implementation in the Web Dev class (Buu will get disappointed for that news), a new version of SweetPo has come into the world. And welcome Huy, another new comer this week. Inherits from the Indian, Huy produced a better implementation. That’s so good and fit exactly what we expect when publishing our source code. I can see a good future for Huy in later versions.

RoboCode Game competition

Hi, I am really happy and excited that we, RMIT students (RMITC), held a good competition. It was just a beginning for a series of RoboCode , game competition as said in previous post. No more talking, I will show you a demo from our students first.

That’s really cool and so simple, and we will have many more AI techniques and Software development there. We will try to add some more intelligence, game strategies in those robots to make it really fun (I already had some ideas in my head). We also have several activities around like tutorials (Instruction 1 and Instruction 2), code review (I did code review for my friends, Khang Nguyen and Phu Hoang) and open some of our source codes (Khang Nguyen, Phu Hoang, Tuan Anh, and Khang Vo). You do not need to be an expert programmer to start programming with RoboCode, the only need is your PASSION. Feel fun, just start. Play and learn. You will become an expert soon

Two more video examples

So, now, how can you join? If you are an RMIT student, it should be extremely easy, just come in. If you are not and you want to join, please contact me: vodkhang@gmail.com so that I can arrange for you to join. Or just wait, I and Youth House also try to operate some robocode competition events.

Online Programming and Software Development Competitions

In my university, it was hard to find chances to go for programming and software competitions (like ACM and Imagine Cup), part of the problem is my fault as well. So, I usually find and join online competitions. Anyway, it is not the main ideas of this post. I want to introduce programming competitions that other people can find fun.

For me, competitions are chances to be fun, to boost skills and to communicate with other people. Fun may be the most important thing, because if it is not fun, interesting and challenging, there is no reason to do it.

1. TopCoder : a lot of kinds of competitions here. This is my favourite one.

A short competition lasts about 1 hour to compete with other people in a 3-problem test with easy, normal and difficult level. You can also do code review, challenge others’ solutions by your own test cases. I love this idea because now, your solution is both validated as well as verified by other people.

It is fun and realistic for software developer. You can even earn money. The only problem is that time to compete is really short, about 2 or 3 days and require in-depth knowledge about J2EE and .NET. I did not have any time to try out with this competition

This is a NP-complete problem competition. You can only find the way to make it better, find the most optimal solution. There are many kinds of problems here: range from encryption, game strategy and image analysis. I love game strategy most. The drawback is you have to spend a lot of time but I think that’s worth and give you a lot of fun

Bug Race will be good for tester, joining, finding bugs. Studio is good for designers. That’s all I know because I never tried this

2. Sphere Online Judge (SPOJ): Pure-algorithm competitions

I think this site is good for beginner and for people who wants to boost algorithms skills and knowledge.  If you are an algorithm lover, this site will be fun; otherwise, it seems quite boring when discussion and sharing ideas are quite limited. People compete with each other to try to get a little bit faster in time to be in the top. That is the disadvantage of this site, people spend too much time for a little performance improve, which is usually not a good practice for a software developer to do so.


An algorithm competition, challenging. I tried only once in last year and then this year, I think that I am still not good enough for that. It is a 3-people team competition by solving really tough algorithm problems in 5 hours. If you win, you can go to compete onsite with a wide range of topics: Information Theory, AI, Game Theory, Networking…

4. RoboCode (I think in www.diendantinhoc.org somebody is also interested in)
I am currently doing research and trying with this one for the purpose of RMITC club. RMIT students will try to learn by doing in this challenge. I hope we can learn in many different technologies: Event-Driven, Multi-threading, Agent-Oriented, Game Strategy, Software Design… See the demo below.

For me, that game looks like another agent game that RMIT Melbourne teaches for the course Agent-Oriented Programming and Design

Software Engineering and Algorithms

Algorithms and Data Structure against Software Engineering

Firstly, I want to talk a little bit about algorithms, data structure against software engineering.  Joel’s Article pointed out an excellent point that algorithms, data structure, functional programming is really important to learn, to challenge your mentality. And he is also right that current CS (and maybe IT, SE) degree is not hard enough, simply because if you designed a stupid software, it still WORKS, students will at least get  90+ points in your assignment. I see many not excellent students get 3.8 – 4.0 without any problems, because as Joel already stated, the problem in Software Engineering is when you have to extend, to make the software scalable, not when you create it. He’s all right about that. But he may make people misunderstand.

Algorithms is not the most important skill

For me, algorithm (if we consider it as a specific method to solve a specific problem rather than defined in wikipedia) is important, but it is no longer the most important skill and knowledge software engineer must have. Software engineers, nowadays, should expert about SOLID principles, and write reusable and maintainable code. Software engineers know how to design, architect and integrate between different system to write and maintain a scalable system. Software engineers can work with usability, working directly with client, understand and see the business and users’ world. These things require practice, thinking, learning from failure not just memorize them.  There are now many different jobs that do not require software engineers to become expert in algorithms, and also many great jobs requiring you to become algorithm expert. You may say that they are different jobs (like understand user’s business would be business analysis)) rather than software developers, you are wrong. Software developers now have to understand users’ mind, in general and specific domain to write usable features (read the Usability part in understand and see the business and users’ world for more details).

Algorithms != IT

Another misunderstanding about learning algorithms is that it will give you great mind in thinking in IT. It is right but not that much. In many cases, we work directly with a specific problem, like searching, sorting and computer vision. But that is a specific problem, people tried to solve it under a specific set of constraints. But software architect see the big picture, when to integrate, what to integrate and how to integrate. Both kinds of thinking are really difficult, requires creativity and experiences but hard to go for both. If people go too much into specific problem, it takes time to become an expert in another area. So, if people love one and want to become an expert in one, go for it.

But I like Algorithms

Personally, I do like algorithms so I usually do some algorithms competition in my free time on topcoder. Currently, I am working on this problem (another link if you can not access topcoder), if you want to join, just come. More people, more fun. I will write another entry to introduce about online IT competitions.

Usability for Users

I am currently working at a mobile phone development company (Multinc) and I started to see and learn many more things about usability, which can be said as the main strength of iphone. So, I want to share some usability experience when developing and working with iphone team and as usual, I also wanted to hear more experience from other people from other cultures. Usability is a ambiguous term and almost depends on the culture and users’ type. I will try to give out experience about normal, ordinary users more than advanced (e.g IT) users because most of us create software for ordinary users rather than advanced one and may be this one is only for a group of users like American.

Most Users are stupid and lazy

First and foremost, the most important thing should stick into our, developers’ mind, is that “Most, or even all users are stupid and lazy”.  How many cases that you can teach your friends, your families or anyone using IT successfully? How many cases, even IT guys spend on reading instructions of a new software/game/websites, and how many hours for non-IT people? Our answers will make us understand clearly about users, especially non-IT people. They want to finish their jobs on computer without caring or have to care about technology at all. Why do they have to spend their valuable time for something supposed to help them make their job easier and faster?

Users are never false

The second thing is that users have problem, the fault should never be their faults, or more precisely, it must be software providers’ fault. They type some bad password, text input that we do not parse or check before and system crash. It is our faults. They use our system not in the way we want, it is our fault. IMO, there is no such thing in the world that the customer is false, they are always true, by default. So, if there is some bug, or some crash and users give bad feedback, any classic excuse (like “It works on my machine”, “They should never use my system like that” … ) never works.

Never teach users at all

The third thing can be “you should never teach or try to teach your users at all”. All assumptions like “They have to/need to read our instruction and manual” are really stupid. It is like the first one, all users are lazy (and also stupid to learn new thing), if we give users software with an instruction on how to install it, most of cases they may give up so soon, the only thing they may know is click “Next”. Despite the great idea of our software, if user can not use it in a short enough time, user will move away from it. I do not have many experience on business but with a period of time working as marketing and sales assistant teaches me one important thing: Marketing for users to come is 1 thing, keep them is another story. If users come and they leave, they will never come back. So, IMO, having a user leave is worse than not having that user at first.

Final List

Some suggestions for software development, this list is really long but I want to list few important ones:

_Be aware of any users’ problem and compatibility. One problem I still see a lot in famous/good start up is compatibility. It looks bad on my browser, and I will never come back. This depends much on our market, but I even see an anti-virus website shows ugly on Google Chrome.

_A good feedback system is important. I will never come back to any company that the customer service dare to say: “It is your fault”. Make the user feel free to write any feedback and respect them. We need them (except you are Microsoft or Google), but they do not need us yet. Treat them as “God”

_Implicit learning can always be implemented. Explicit learning is too difficult, except we have awards for any feedback or we hire people to do so, so implementing implicit learning may be a good idea. Some ways of implicit learning in software/website I can know is : logging, look at any click, any move around our system, relationships between service and product they buy, time they spend on something. Add more if you can.

Learning effects from instructors

I intended to write this blog long time ago, especially the time I went to RMIT Melbourne.

A few hours ago, I read the blog of Ngon Pham, and I decided to write about the effects of instructors (including lecturers/managers and general instructors) to students’ mind, both good and bad effects.

To start, I want to tell some of my experience when I learnt in Melbourne.

General Effects

At the beginning of every courses, the instructors come and say: “I and you will learn together, I know something, but do not know many things, you will know and may have more experience than me so please teach me if you can”. What comes to my mind first is that it is a joke, right? how can thoseprofessors with a lot of years of experience may not have something in the course/research interest that students know but they do not know. They are not joking at all when we went over the courses. They are in research for long time and they lacked industry skills/knowledge and they actually learnt it from students, it is not just small correction, it may be the whole lesson. Even some of them can learn business lessons from IT students. The best thing I see is that for unsolved problems (there are many in Intelligent System:) ), the idea of professors sometimes is not better than students. It proved and reminded me one thing: “You could never stop learning”.  (thanks to all lecturers that teach me in RMIT Melbourne)

The story I tell just shows one of the lesson. It is an obvious one. But the underlying lesson is that “Students must be strongly encouraged to argue and to teach instructors back”. For every kinds of classes/lessons, for every kinds of instructors, there will still be some areas the instructors do not know/understand best. Here are some of my advices:

For Students:

It is really good if you have the excellent instructors. But please keep in mind that it has its own bad effects. You will become passive very soon. You all think that whatever the instructors give to you must be right, well-tested over time. I see many students do not dare to challenge their instructors’ ideas simply because instructors are too excellent that every arguments they try fail. If you do not want to argue any more, you will become robot really quick. Trust me, robot will not have high position in this quickly changing society!. Asking for not understanding is not enough, challenging and arguing again is much better.

If you do not have good instructors or even bad ones, should not be disappointed. You can see it as a chance for you to self-study and argue. You can HELP to make them better, but in many cases, it is an art and depends on instructors’ mind. Some are not so opened and you must have the way to suggest your idea/ help instructors.

For instructors:

The good way for instructors to think when students argued is that “Students are helping me for free, I do not lose anything”. Another thing is that in a class, there will be 30 (or 200, depends on the university), and everybody knows that 30 CPUs working parallel can compete with 1 super computer in terms of data storage and processing. So, in many cases, their argument will become right. Open your minds and learn it, it may become a novel approach for research or your works. Instructors should also open their minds wider and encourage students more to argue and do not make students think you are too strong or too excellent. No students will try to argue when they know their opponents are too excellent and 99% of argument, they may get wrong. It may be really strange at first but it may become excellent when you get it.

Yeah, to be honest, I know that Vietnamese instructors have many difficulties, and I do not want to open a big discussion about whether we should understand them, whether we should not require them a lot. Ok, I know, but I try to HELP them become better. It is good for them and for students.