An Acute Question on Unit Testing for All Consultants
September 6, 2012 Comments Off
It’s a question from our “client”:
If I’ve got a live project running and gaining profits, I have blackbox testing ensuring all of its functionality, and I’m not going to update the project, do I still need to spend extra cost on adding unit tests for it?
Besides what my colleagues mentioned, my addtional points are as follow:
Unit testing helps to specify the purposes of the different modules within the project, which helps to reduce the cost of re-recognizing the design of the module and thus controls the cost of migrating, reusing and modifying of the modules. What’s more, unit testing makes it easier for future integration of similiar modules, platforms, etc.
According to my past experience, if there are modules to be reused, rarely they are straightforward at first glance. They are either containing complicated logic or they can be rewritten directly without too much effort(we assume people prefer a relectively independent module and thus they are not going to introduce the dependency on the existing resources). In this case it’s hard to migrate the functionality with confidence if there are no reference about the fundamental knowledge of that module.
On the one hand, it’s okay that the comprehensive API is well described in the documentation, but remember, that this is a module within a program instead of a program itself, so the documentation might not be comprehensive enough or it might not be available at all.
On the other hand, not all modules are supposed to be reused 100 percent. Sometimes we need to modify the module according to the new requirements, including changes of inputs, outputs or logics, then API doesn’t help too much, while test cases with sufficient knowledge of the module can lead you to a much easier life. That is, with a fine set of test cases covering all the blind areas of the module, getting to know what scopes the module is trying to cover, you will get a better idea on how to reuse or upgrade that module, thus you will get what you need with less effort and make it less error-prone.
In a word, if you really tend to leverage your existing successful project, a comprehensive “written down” knowledge about it with easy access is a good choice. Then probably you will be interested in adding unit tests for what has been working well so far, as they can be good indicators for the ingredients within the pearl.
Other Open Questions
How do I ensure the correctness of unit tests? How do I judge the quality of unit tests according to the given criteria?
A Snapshot of Highlights for Beginners in Application Development
September 5, 2012 § Leave a Comment
After working in a web application project for almost six months, seeing new members coming and old ones leaving, finally I’m rolling off from the project as well. It’s a pity that I can’t wait till the project go live, yet I hope I can pick up what I learned from the project so far and summarize them into tips that you can take away as follows.
The tips only cover a small fraction of what web developers should take care of, however they seem to be useful for preventing some previous bugs that we’ve encountered, the bugs that were not easily noticed at the beginning but later caused some strange behaviours.
Web I/O related
Input Toggling
Do remember to disable input fields that are not necessary as it might cause unexpected values to be recorded, rather than just hide the web elements when input options depends on other predicates (say, you need to satisfy some conditions in order to get the input fields popped up). The unexpected values usually come from historial inputs. One more thing good about disabling elements that are not in used is that it can avoid the unnecessary event bindings.
If those input fields are not supposed to be seen in some scenario, just dont’t render them at the very beginning.
Only give the input fields that you really need.
Validation Scope
Never trust user inputs, for they can be either too stupid or smart. That’s why we need validation. And validation takes carefulness.
- Reject null input if you do need the information(otherwise you had better not render the input fields at all).
- Restrict the values within the acceptable scope. The values must be within a close set all the time. Test all the boundary cases.
- If the validation rules are not applicable all the time(for example, some business logic only applies to some specific scenarios when users give the related inputs, and will be ignored in other cases), when they are not applicable(which means the inputs are not required), reset them by default as this kind of behaviours imply that the user is not going to input these specific fields. This helps to avoid the cases of capturing unvalidated inputs.
- If you are capturing a varied length Array or List from the page, make sure the correct mechanism is used for binding data input. For this part, just google it.
In a word, the ultimate goal of validation is to help you get the information you need while rejecting the others that you don’t need. Either you accept the inputs, or you reject. There’s nothing in between.
Test Coverage
Design test cases that will cover all the logic branches, and use boundary cases as test indicators.
If there are some logics that are not well described by test cases, it may cause confusion and even introduce some bugs when we do the refactoring in the future. This is quite true when we are dealing with third party services and they are non-deterministic and thus causing unexpected outcome for us to adjust. RAC is one case that we’ve come up with.
State Variables
Some web logic relies on state variables, make sure they are set and reset at the right time.
Base your design on states rather than behaviour, so that you will get a clear clue of developing and testing with less error prone outcome.
If things are too complicated, take state machine into consideration.
Knowledge Transfer
People come and leave. So others will read your codes as you will read others’. And after some time people may forget about the context where you wrote a specific piece of codes, that’s when knowledge transferring really matters. The context contains the related business logic, the defect you tried to fix, etc. To make it worse, these things are always changing so there will be a time that for others it’s hard to tell which part they should refer to and which part should be updated. Then it’s extremely important that there should be no hidden knowledge. Everything should be recorded, no matter they come in a form as test cases, comments, Jira descriptions, or even documents. While pair programming will definitely helps the knowledge transfer, people should still keep in mind that human minds are not as reliable as a well running mechanism for sharing. People may forget, yet machines seldom.
That’s why I’m writing this article.
Coursera, to Those Who Care
July 17, 2012 § Leave a Comment
I’ve benefited a lot from coursera.org. The website, which was started by Stanford volunteers, at the very beginning, delivered valuable Stanford courses lively to the whole world (those with internet access, though) including Introduction to Artificial Intelligence, Machine Learning, and Introduction to Databases. I took all of these three courses last year, and undoubtedly, deeply inspired and interested by the vivid as well as comprehensive lecturing, I’m so happy to forward this news to everyone.
Their progress in narrowing the gap of education opportunities has been witnessed by all those who really care about this area. Not only me but lots of people all over the world are gaining a lot from their on going service of resourcing knowledge for the world.
May I express my deep gratitude to all the pioneers in education who have been and will always be sharing their brilliant insights and devoting themselves into the area, that to those all, you are one of the greatest revolutions in the 21st century.
From: Coursera Staff <team>
Subject: 12 World-Class Universities Join Coursera!
Dear Courserians,
We are THRILLED to announce that 12 universities — including three international institutions — will be joining Princeton University, Stanford University, University of Michigan, and University of Pennsylvania in offering classes on Coursera.
On Coursera, you will now be able to access world-class courses from:
- California Institute of Technology
- Duke University
- Ecole Polytechnique Federale de Lausanne
- Georgia Institute of Technology
- Johns Hopkins University
- Princeton University
- Rice University
- Stanford University
- University of California, San Francisco
- University of Edinburgh
- University of Illinois at Urbana-Champaign
- University of Michigan
- University of Pennsylvania
- University of Toronto
- University of Virginia
- University of Washington
You’ll be able to choose from more than 100 new courses, from learning how to program in Scala (taught from the creator of Scala, Professor Martin Odersky from EPFL), to Professor Dan Ariely’s course on irrational behavior, to the legendary UVA course “How Things Work” with Professor Louis Bloomfield. You can check out the most current course list here — keep in mind you can enroll in a class even if the start date is to be announced.
To date, 700,000 students from 190 countries have participated in classes on Coursera, with more than 1.6 million course enrollments total!
To everyone who has taken a class on Coursera, or who has recommended us to your friends and family — thank you! Education is starting to look very different, and we’re excited and humbled to be part of it.
Very best,
Your Coursera Team | www.coursera.org
Equip Yourself for Programming
July 8, 2012 § Leave a Comment
I was once inspired by the post It’s Not Too Late to Learn How to Code, which helped me build up the confidence that I can actually start coding, even if I was studying for a degree of Economics rather than Computer Science. Make sure you like programming, then be convinced that it’s all doable and that’s the very first step you equip yourself for programming.
Before we move to Step 2, may I stay for a while on how people can actually fall in love with programming, as to someone this is totally nonsense.
- Well fair enough, programming can be cool. Hackers, Geeks and all the fancy stuff, SNS, E-commerce, Venture Capital, Startups, these concepts are flourishing in today’s IT world and guess what? They can’t live without programming!
- If the glory part doesn’t appeal to you that much, then what about programming itself is well developed based on computing science? The modeling derived from abstraction, the optimization through algorithms, they are at the forefront of human understanding, challenging your view of the world. Can anything be any more stimulating?
- Of course there are more reasons. For creators, programming is one way to make amazing things happen. Self-drived cars, artificial intelligent robots, fancy designs, and small things that make life easier, how about it, then?
- If things mentioned above doesn’t interest you at all, why are you still reading this post?
Then we come to Step 2. How we actually start programming.
- At least you have to understand that programs are created for solving problems.
If you are not good at finding and defining problems in your real life, then you may spend most of your time solving someone else’s problems, which is neither better nor worse, just a piece of fact, though a fact that may make you feel uneasy. Come on, how can you be a good programmer if you are not familiar with problems? Applying a wrong solution to a problem is nothing better than not solving it at all. - Then you try your best to solve the problem. There is always more than one way to Rome, so pick up the quickest way to start programming to solve your problem. Latest programming languages are easier to get you start. It’s only after you program that you actually feel about what programming is. (I assume that you already know how to make use of online resources to get you start.) Introduction CS courses in universities usually introduce students in this way, as you can see in Harvard, Stanford, etc.
- When you actually feel what programming is, rethink about your feeling towards it, as quite often you might feel it in a wrong way. Programming is not about figuring out what you type in (I know people might focus intensively on syntax and all the statements in the editor the very first time they started to code), but instead all the things come after your typing. How the piece of code is actually carried out by the machine, what may go wrong, what’s the better way to write it, and so on.
Step 3 is about practicing and studying, once you get started, don’t stop. Keep your mind open to others. You’ve got a long way to go to learn from others and to master it. There are two good posts related to this topic, one from CoolShell and another from Akash Manohar. Both of them contain more detailed guidelines for those who want to better their skills and understanding of programming, highly recommended.
It’s after you are getting better at programming that either you are closer to your goals or you might forget about what got you started. What do I mean? Well some people just tend to get lost in technical details and optimizing process so that they end up programming for programming instead of solving their problems. That’s not we are supposed to do. Always keep a big picture in mind for what you are doing is going to affect other people’s life. Do harmonize the world, by contributing and not producing rubbish. That’s why the latest definition of Software Excellence from ThoughtWorks put business value and everything related to a bigger eco-system into consideration. Do good stuff for good reason, or it can be a waste of effort. That’s Step 4.
I’ve shared my experience with my friends who came to me with the motivation to start programming and with the question “How do you actually managed to start programming in such a short time?”. I gave the same idea as this post, which sums up to proper motivation, interaction with programming, serious study and practice, and goal oriented mindset. Hope this post can answer you something.
What Motivates Me to Join a Company
July 8, 2012 § Leave a Comment
People join a company for various reasons.
When I was applying for a job in ThoughtWorks, I asked myself, “What forms your alliance with this company? Is that its high salary, good reputation, or something else? If you are stick to your dreams, why do you want to work for this company?”
Finally I got the answer. It’s the value ThoughtWorks claims that attracts me. I wonder if ThoughtWorks culture really goes as it says. How do they respect individuals while providing professional services, both internally and externally? How do they treasure liberty to choose? How do they make use of technology and carry out social responsibilities? Can these values last for long in a company? If it turns out that it’s the value that combines this organization, I shall see the immoral energy inside the company. It would be a fascinating thing if the ThoughtWorks world is the same as it claims. In this fast changing world everyone can be a change-maker, and it’s the common value rather than common proficiency that is bringing people together from all over the world.
My only concern is the value that I can learn from this company via practical business. Outstanding value can lead to new business in various fields and also have influences on my children, my family, my friends and all those who care about it so as to make a better world. ThoughtWorks has got its value of three pillars, named Sustainable Business, Software Excellence and Social Impact. It’s how you define them and then make it happen.
There are many entrepreneurs striving for their own beliefs. Only after they know why they do it, can they achieve it, and enjoy it.
Don’t work for money. Work for the value you believe in; work for your dream.
Build up a Info Network System with Your Interpersonal Relationship
September 21, 2011 § Leave a Comment
当我需要联络潜在客户见面,例如对方是我们目标项目的负责人,或者需要调查来访者的背景信息的真伪以预防潜在竞争者的探底测试,我会需要一个周全并可靠的情报信息网络,这个网络的覆盖面和可靠性和运作效率将很大程度决定工作能否顺利开展。这是在提升了个人综合素养以后,需要准备的事业发展奠基石。我的朋友们就是我的网络触角,同时我也是他们的触角,这是一个双向选择的过程,同时也是职业发展的提示。
Thinking in a Different Language
August 9, 2010 § Leave a Comment
People base their thoughts on languages, like speaking languages, logic languages, domain specific languages, etc.
Maybe I shall turn back to English when I’m thinking.
I find it hard again to explain some behavior done in the dilemma, since everyone has a different conception of justice,goodness and morality. Different communities has different conception as well. There is no way to be neutral, as Michael says, so it’s even impossible to set a criterion for an institution without being based on any grounds. As a result, a society need to honor the goodness in a way that is both subjective and respectful to different attitudes, but it seems harder than we human can ever imagine. I don’t understand, as I get no answer from the lectures or my own experience or anything else which satisfy the standard of sufficiency. I’m still puzzled, how can anyone achieve the ideal concept of the society?Or if anyone, he must be unknown to me.
So I don’t know the perfect model of a society, or I don’t know would it ever exist. If there were such a thing, then my curiosity will drive me to find it out in the real world with my experience, observation, thinking, studying. If there were not, that must be the flaw of humanity, a dilemma which must face human minds. One shall never hesitate to figure out a way and to invent a device to minimize the negative effect of the conflicts and let people live their own way. I think the model may derive from the existing social systems, and it makes sense to understand how every society functions and people in each society act and think.
After all, I gain a lot from this course. People have various ways of thinking , at least so far no unite value system can be built up that shares universal values. Then, telos of goodness are not avoidable, nor are debates over these questions. It can hardly be right to replace others’ value with one’s own thought. Keep an open mind. Owning a conception of justice is considered as a fortunate, but fighting for one’s justice at costs of offending another takes a second thought.
I don’t think I should keep sticking in this field right now. Instead it’s better for me to discover a new field and see if I can get inspired.
Frankly, I’m not able to tell my view of philosophy personally. I’ll keep striving for it.