Saturday, April 10, 2010

Cosmetics Qualifications

PUBLIC GOOD CODE ...

In order, a good code
1. passes its tests successfully;
2. can be misused;
3. contains no redundancy;
4. clearly expresses the intention;
5. is as short as possible.

Paraphrase ...
A little close, points 1 , 3 , 4 and 5 is a quote from Kent Beck
, creator of the -eXtreme Programming . Practitioner programming by contract, I added point 2. (What I will not cite the work Kent Beck and Bertrand Meyer in the same post: o)

... nevertheless useful
I get to read a lot of code, binommer with many developers and teach. As part of these activities, this quote five points is very useful. I use it a lot and I quote often. I'm sure as an extreme dogmatic and stubborn ... (After all in a team, it is good to achieve a certain ratio extremist developer / developer lax)

Still there is much empirical wisdom in this quote. Among other things, the order of criteria is very important .

1. You will test
testing top the podium. A code that is not tested does not have value. Code is not guaranteed. Any line of inquiry must be covered by a test. This is true very well with the analytical tools of structural coverage.

2. You disabuse
A code that can be misused is a code undeceived. It contributes to the preventive management of defects in the application. Programming by contract is an excellent practice to key the code. Quit talking about programming by contract, it would be more accurate to say "A good guarantee its postcondition code if its precondition is guaranteed by its caller" . To learn more about this rare practice but really effective, you can read a preceding post on this topic .

3. You do not repeat yourself not
Duplication is a source of multiple faults and multiple times. It undermines the clarity of intent. Suppose that I "inherits" a untested code. Without hesitation, I prefer to spend time testing it to eliminate redundancies. (Actually, I eliminate redundancy from the tests pass: o)

4. Thou shalt be clear and explicit
The code is read much more often writes - including its author! Besides, the writer is first and foremost his own player. Much easier the lives of all these reviewers. As with the previous point, I prefer test as renaming and cut. (Same, I rename and cut out the tests pass: o)

5. Thou shalt be brief
The brevity of the code comes last because it may conflict with items 1 , 3 and 4 . In such cases, the brevity is not a priority.
To make code testable, it is often necessary to create interfaces inject dependencies to build objects . This increases code size. The test also leads to cut in small classes and there is a declarative heel to pay for this modularity.
A code without duplication can lead to an operation to create two duplicate lines. In total, counting the statement by overflow, this practice may increase the number of lines. Besides, have you noticed that the revised code examples are always longer than their original code? (see Clean Code )
To make a code more explicit, we have to standardize the level of abstraction in the code of operations. For this, we encapsulate the code level of abstraction than in a transaction. Again, we pay a fee for the statement of operations. And

test code?
This codex 5 rules apply to the code, but also tests because the tests are code. One might think that we should not test if testing is never ending. However, the practice of Test Driven Developpment end of eXtreme Programming, design integrates test test !
Indeed, when we start by writing a test that fails , then we modify the code until the test passes, we verify the accuracy of the test. Th 2-step approach is to test the test.

One more (violation of criterion 3!)
Sorry, this was the 1379th ticket to define a good code. Many books devote their pages. It's like the strings of luck / bad luck. When you read one of these tickets, one must write one to turn ...

Monday, March 22, 2010

’87 Yamaha Phazer Carb Reed

The Chinese eat dog. And cats. There.

Text Emilie-Anne Leroux

Sometimes going to a Chinese restaurant with non-Sinophiles seems difficult. Defending the safety they are constantly challenging and hygiene, the minimum age of employees, the legality of their ingredients. I find it pretty tiring having to answer their "it will surely be the cat in these sausages! "Previously, I reassured them that not. Since January 26, I'm not sure what to say ...

It started with a small article in The Economist , which I am a faithful reader. Off the menu is the title of the article revealing what is surely the most interesting for Cccidentaux of topics during the plenary session 10 of the CCP. My curiosity was piqued, especially having studied law for one year.



Did you know that no legislation prohibits the consumption of dog or cat to Canada? Indeed, if you kill yourself fido and taste it, you'd be nothing objectionable. As long as you kill it humanely. That is to say that laws exist to protect animals much concern the treatment of animals as their "placing the dish." This is because in Canada, eating cat or dog is a taboo subject outrageously.

Not quite the same in Asia. China, Japan, Korea, all have ancient traditions around the feline meat consumption and, more particularly, canine. It was found that meat special nutritional properties. There are recipes for soups to the dog, and even a dish of meat mixed serpentine and feline who is reputed to be a real treat!

I already knew that the meat is consumed canine and feline emergencies in time of war or famine. In an excellent novel about the lives of three generations of women during the 20th century Chinese Wild Swans by Jung Chang , it tells a story set during the Japanese occupation of northern China: some families have eaten their younger rather than starve. Fact true or not, in this context, it is easy to imagine he should stay or pooch or kitty in the neighborhood. What would you do? This is not a remedy limited to Asia. Even in Britain, during shortages of meat, some cats were found in pies "rabbit."

laws against eating dog meat in Asia began in Hong Kong in 1950. In 2004, it was Taiwan. China will propose a new law this April and may be the year of the Tiger she became the year of the release of cats and dogs too. The proposal on the table that would ban consumption as a measure for protection against the cruelty of animals - but change suddenly the treatment of a culinary tradition that draws on references in ancient myths. The penalty? "The law's violators" could face a penalty of up to 50,000 yuan ($ 7.325) and 15 days in police custody "under the anti-animal-cruelty laws . Far from me to assess how this law will be effective within the mindset of ordinary citizens, but I can imagine a small restaurant owner fined for $ 7.325. Surely he will think twice before continuing the practice, which some say is large decline anyway.

the Philippines since 1998, killing cats and dogs for consumption was made illegal. That said, organizations that defend animal rights reported that 12 years later, "dogs are 500.000 Killed Annually in the Philippine Islands for human consumption. "It remains to be seen how this will be successful in China.

And democracy in all this?

For a law to have impact, it still needs to find root in people's minds. The new laws must reflect a change in attitude among those who defend or initiate him. My first thought in all this was that China was complying the demands of the West and international organizations for protection against cruelty to animals. She let herself be influenced by the morals, ideals entirely cultural and even the ridiculous sublime elevation levels of the concept of pets who wins the West. Perhaps it was an attempt to appease Western critics. By cons, informing me more about the subject, I realized that the initiative came from the Chinese - some of them, anyway.

June 19, forty Chinese citizens have expressed in Shenzhen, Guangzhou to protest against a restaurant that served cat meat. The event is the result of a call made to the front-line on a website. This must be linked with the growth of the middle class in China who appropriates all Western trends - the cafes, dog strollers for dogs and everything else.

Surely democracy in its election will take a longer period of gestation, but I find it quite significant expression of the Chinese on issues that are not directly related to their own well-being (as compared to the employment or treatment of foreclosed). The law in China is not much gained here. Indeed, the Western legal procedure and substantive law are methods copied to other systems and has always managed to adapt laws and regulations to its own national needs. With China begins to make laws against animal cruelty, I feel a bit in a new era.

Personally, I do not see myself being able to kill a cat or dog. But I would not be more capable of killing a cow, duck, lamb or chicken. Western hypocrisy? You decide your level of tolerance for the personal morality of the issue. At the same time, if we think ahead to the food crises increasingly in the future, who knows what will be faced human being?