1. New Uses For Names For Baby

    Buy a copy of a baby naming book and you’ll never be at a loss for variable names. Fred is a wonderful name and easy to type. If you’re looking for easy-to-type variable names, try adsf or aoeu if you type with a DSK keyboard.

  2. Single Letter Variable Names

    : If you call your variables a, b, c, then it will be impossible to search for instances of them using a simple text editor. Further, nobody will be able to guess what they are for. If anyone even hints at breaking the tradition honoured since FØRTRAN of using i, j and k for indexing variables, namely replacing them with ii, jj and kk, warn them about what the Spanish Inquisition did to heretics.

  3. Creative Miss-spelling

    : If you must use descriptive variable and function names, misspell them. By misspelling in some function and variable names and spelling it correctly in others (such as SetPintleOpening SetPintalClosing) we effectively negate the use of grep or IDE (Integrated Development Environment) search techniques. It works amazingly well. Add an international flavor by spelling tory or tori in different theatres/theaters.

  4. Be Abstract

    : In naming functions and variables, make heavy use of abstract words like iteverythingdatahandlestuffdo,routineperform and the digits e.g. routineX48, PerformDataFunction, DoIt, HandleStuffand do_args_method.

  5. A.C.R.O.N.Y.M.S.

    Use acronyms to keep the code terse. Real men never define acronyms; they understand them genetically. If you confuse even yourself with acronymns, secretly write code using meaningful names, then, when the code in working, use the global rename feature of Eclipse to give your variables and methods unintelligible names and acronyms, just the way a mechanical obfuscator would.

  6. Thesaurus Surrogatisation

    To break the boredom, use a thesaurus to look up as much alternate vocabulary as possible to refer to the same action, e.g. displayshowpresent. Vaguely hint there is some subtle difference, where none exists. However, if there are two similar functions that have a crucial difference, always use the same word in describing both functions (e.g. print to mean write to a file, put ink on paper and display on the screen).

  7. Eschew the Project Glossary

    Under no circumstances, succumb to demands to write a glossary with the special purpose project vocabulary unambiguously defined. Doing so would be an unprofessional breach of the structured design principle ofinformation hiding. If you are forced to write such a vocabulary, use recursive definitions such as this one taken from the Ant 1.6.5 manual: basedir : the absolute path of the project’s basedir (as set with the basedir attribute of <project>). The reader still has no idea what the basedir is, though he has been given the clue it is absolute even though all examples show it with . (which, incidentally, is relative).

    Wear your adversary down by tantalising, pretending to give information where there is really none. Disguise your vacuous statements sufficiently so the reader will blame himself for failing to understand.

    The reader asks himself, if I am trying to compile the com.mindprod.holidays package, is basedirC:\, C:\com\ , J:\com\mindprod\ or J:\com\mindprod\holidays\ ? You see why you should never use concrete examples? They are too clear. If you are forced to use them, complain that they sound childish and unprofessional. Complain that examples make it look as if that is all the product can do. You want people to appreciate fully every possible variation from the get go. You are not trying to inform, but impress! After all, no academic would be caught dead giving an example. People only respect that which is too abstract to grasp easily.

    That’s a lot to remember. You will do just fine if all you do when writing documentation is maintain the attitude that people who don’t already know this jargon are stupid fools who don’t deserve to understand.

  8. Use Plural Forms From Other Languages

    A VAX/VMS (Virtual Address Extension/Virtual Memory System) script kept track of the statii returned from various Vaxen. Esperanto, Klingon and Hobbitese qualify as languages for these purposes. For pseudo-Esperanto pluraloj, add oj. You will be doing your part toward world peace.

  9. CapiTaliSaTion

    Randomly capitalize the first letter of a syllable in the middle of a word. For example:ComputeRasterHistoGram().

  10. Reuse Names

    Wherever the rules of the language permit, give classes, constructors, methods, member variables, parameters and local variables the same names. For extra points, reuse local variable names inside {} blocks. The goal is to force the maintenance programmer to carefully examine the scope of every instance. In particular, in Java, make ordinary methods masquerade as constructors.

  11. Åccented Letters

    Use accented characters on variable names, e. g.

    typedef struct { int i; } ínt;

    where the second ínt’s í is actually i-acute. With only a simple text editor, it’s nearly impossible to distinguish the slant of the accent mark.

  12. Exploit Compiler Name Length Limits

    If the compiler will only distinguish the first, say, 8 characters of names, then vary the endings e.g.var_unit_update() in one case and var_unit_setup() in another. The compiler will treat both as var_unit.

  13. Underscore, a Friend Indeed

    Use _ and __ as identifiers.

  14. Mix Languages

    Randomly intersperse two languages (human or computer). If your boss insists you use his language, tell him you can organise your thoughts better in your own language, or, if that does not work, allege linguistic discrimination and threaten to sue your employers for a vast sum.

  15. Extended ASCII (American Standard Code for Information Interchange)

    Extended ASCII characters are perfectly valid as variable names, including ß, Ð and ñ characters. They are almost impossible to type without copying/pasting in a simple text editor.

  16. Names From Other Languages

    Use foreign language dictionaries as a source for variable names. For example, use the German punkt for point. Maintenance coders, without your firm grasp of German, will enjoy the multicultural experience of deciphering the meaning.

  17. Names From Mathematics

    Choose variable names that masquerade as mathematical operators, e.g.:

    openParen = ( slash + asterix ) / equals;
  18. Bedazzling Names

    Choose variable names with irrelevant emotional connotation, e. g.:

    marypoppins = ( superman + starship ) / god;

    This confuses the reader because they have difficulty disassociating the emotional connotations of the words from the logic they’re trying to think about.

  19. Rename and Reuse

    This trick works especially well in Ada, a language immune to many of the standard obfuscation techniques. The people who originally named all the objects and packages you use were morons. Rather than try to convince them to change, just use renames and subtypes to rename everything to names of your own devising. Make sure to leave a few references to the old names in, as a trap for the unwary.

  20. When To Use i

    Never use i for the innermost loop variable. Use anything but. Use i liberally for any other purpose especially for non-int variables. Similarly use n as a loop index.

  21. Conventions Schmentions

    Oracle’s Technetwork Coding Conventions

    Ignore Oracle’s coding conventions, after all, Sun does. Fortunately, the compiler won’t tattle when you violate them. The goal is to come up with names that differ subtlely only in case. If you are forced to use the capitalisation conventions, you can still subvert wherever the choice is ambigous, e.g. use both inputFilenameand inputfileName. Invent your own hopelessly complex naming conventions, then berate everyone else for not following them.

  22. Lower Case l Looks a Lot Like the Digit 1

    Use lower case l to indicate long constants, e. g. 10l is more likely to be mistaken for 101 that 10L is. Ban any fonts that clearly disambiguate uvw wW gq9 2z 5s il17|!j oO08 `'" ;:,. m nn rn {[()]}. Be creative.

  23. Reuse of Global Names as Private

    Declare a global array in module A and a private one of the same name in the header file for module B, so that it appears that it’s the global array you are using in module B, but it isn’t. Make no reference in the comments to this duplication.

  24. Recycling Revisited

    Use scoping as confusingly as possible by recycling variable names in contradictory ways. For example, suppose you have global variables A and B and functions foo and bar. If you know that variable A will be regularly passed to foo and B to bar, make sure to define the functions as function foo(B) and function bar(A) so that inside the functions A will always be referred to as B and vice versa. With more functions and globals, you can create vast confusing webs of mutually contradictory uses of the same names.

  25. Recycle Your Variables

    Wherever scope rules permit, reuse existing unrelated variable names. Similarly, use the same temporary variable for two unrelated purposes (purporting to save stack slots). For a fiendish variant, morph the variable, for example, assign a value to a variable at the top of a very long method and then somewhere in the middle, change the meaning of the variable in a subtle way, such as converting it from a 0-based coordinate to a 1-based coordinate. Be certain not to document this change in meaning.

  26. Cd wrttn wtht vwls s mch trsr

    When using abbreviations inside variable or method names, break the boredom with several variants for the same word and even spell it out longhand once in while. This helps defeat those lazy bums who use text search to understand only some aspect of your program. Consider variant spellings as a variant on the ploy, e.g. mixing International colour, with American color and dude-speak kulerz. If you spell out names in full, there is only one possible way to spell each name. These are too easy for the maintenance programmer to remember. Because there are so many different ways to abbreviate a word, with abbreviations, you can have several different variables that all have the same apparent purpose. As an added bonus, the maintenance programmer might not even notice they are separate variables.

  27. Misleading names

    Make sure that every method does a little bit more (or less) than its name suggests. As a simple example, a method named isValid(x) should as a side effect convert x to binary and store the result in a database.

  28. m_

    a naming convention from the world of C++ is the use of m_ in front of members. This is supposed to help you tell them apart from methods, so long as you forget that method also starts with the letter m.

  29. o_apple obj_apple

    Use an o or obj prefix for each instance of the class to show that you’re thinking of the big, polymorphic picture.

  30. Hungarian Notation

    Hungarian Notation is the tactical nuclear weapon of source code obfuscation techniques; use it! Due to the sheer volume of source code contaminated by this idiom nothing can kill a maintenance engineer faster than a well planned Hungarian Notation attack. The following tips will help you corrupt the original intent of Hungarian Notation:

    • Insist on using c for const in C++ and other languages that directly enforce the const-ness of a variable.
    • Seek out and use Hungarian warts that have meaning in languages other than your current language. For example insist on the PowerBuilder l_ and a_ {local and argument} scoping prefixes and always use the VB-esque style of having a Hungarian wart for every control type when coding to C++. Try to stay ignorant of the fact that megs of plainly visible MFC (Microsoft Foundation Classes) source code does not use Hungarian warts for control types.
    • Always violate the Hungarian principle that the most commonly used variables should carry the least extra information around with them. Achieve this end through the techniques outlined above and by insisting that each class type have a custom wart prefix. Never allow anyone to remind you that no wart tells you that something is a class. The importance of this rule cannot be overstated: if you fail to adhere to its principles the source code may become flooded with shorter variable names that have a higher vowel/consonant ratio. In the worst case scenario this can lead to a full collapse of obfuscation and the spontaneous reappearance of English Notation in code!
    • Flagrantly violate the Hungarian-esque concept that function parameters and other high visibility symbols must be given meaningful names, but that Hungarian type warts all by themselves make excellent temporary variable names.
    • Insist on carrying outright orthogonal information in your Hungarian warts. Consider this real world example: a_crszkvc30LastNameCol. It took a team of maintenance engineers nearly 3 days to figure out that this whopper variable name described a const, reference, function argument that was holding information from a database column of type Varchar[30] named LastName which was part of the table’s primary key. When properly combined with the principle that "all variables should be public" this technique has the power to render thousands of lines of source code obsolete instantly!
    • Use to your advantage the principle that the human brain can only hold 7 pieces of information concurrently. For example code written to the above standard has the following properties:
      • a single assignment statement carries 14 pieces of type and name information.
      • a single function call that passes three parameters and assigns a result carries 29 pieces of type and name information.
      • Seek to improve this excellent, but far too concise, standard. Impress management and coworkers by recommending a 5 letter day of the week prefix to help isolate code written on 'Monam' and 'FriPM'.
      • It is easy to overwhelm the short term memory with even a moderately complex nesting structure,especially when the maintenance programmer can’t see the start and end of each block on screen simultaneously.
  31. Hungarian Notation Revisited

    One followon trick in the Hungarian notation is "change the type of a variable but leave the variable name unchanged". This is almost invariably done in windows apps with the migration from Win16 :- WndProc(HWND hW, WORD wMsg, WORD wParam, LONG lParam) to Win32 WndProc(HWND hW, UINT wMsg, WPARAM wParam, LPARAM lParam) where the w values hint that they are words, but they really refer to longs. The real value of this approach comes clear with the Win64 migration, when the parameters will be 64 bits wide, but the old w and l prefixes will remain forever.

  32. Reduce, Reuse, Recycle

    If you have to define a structure to hold data for callbacks, always call the structure PRIVDATA. Every module can define it’s own PRIVDATA. In VC++, this has the advantage of confusing the debugger so that if you have a PRIVDATA variable and try to expand it in the watch window, it doesn’t know which PRIVDATA you mean, so it just picks one.

  33. Obscure film references

    Use constant names like LancelotsFavouriteColour instead of blue and assign it hex value of 0x0204FB. The color looks identical to pure blue on the screen and a maintenance programmer would have to work out 0204FB (or use some graphic tool) to know what it looks like. Only someone intimately familiar with Monty Python and the Holy Grail would know that Lancelot’s favorite color was blue. If a maintenance programmer can’t quote entire Monty Python movies from memory, he or she has no business being a programmer.

  34. Fun With Colours

    It goes without saying you should use numeric colour literals rather than named constants. Unfortunately, most skilled maintenance engineers will have learnt by now that hex coded colour values are easy to decode, e. g.0x0204FB is
    Red = 02
    Green = 04
    Blue = FB
    Which is clearly pretty much entirely blue.

    You want is to use the decimal value, 132347. There’s no way without the aid of paper or a calculator that any normal person could convert that into the colour 'blue'. For extra bonus points you can produce a decimal colour that looks like it’s expressed as hex, for example 808000. A quick glance would guess half red + half green = darkish yellow, but in fact it’s not hex, the real colour is 0xc5440 (a dark cyan).

    The Netscape colours are all carefully named. For example papayawhip is 0xffefd5. Just to keep them on their toes, define a papayawhip colour constant as 0xff00ff, a garish magenta. Have fun making up obscure colour names like algae = 0x556b2f instead of darkolivegreen. Very few people know what colour puce and teal are, but would never admit it. Exploit that.

    You can even lay a trap for a programmer who comes after you to do the dirty deed. Use accurately-named but hideous colours. If the follow-up programer is lazy, he will change the colour definitions to something sane, but will leave your original colour names.

如何写出难以维护的代码--代码命名相关推荐

  1. 教你写出可读性高的Python代码

    如果有人问起 Python 程序员他们最喜欢 Python 哪一点,他们一定会提到 Python 的高可读性.确实,对于 Python 来说,其高可读性一直是这门语言设计的核心.一个不争的事实是,相对 ...

  2. 【转载】如何写出低碳环保的 Android 代码

    如何写出低碳环保的 Android 代码 随着环境问题越来越严重,人们越来越重视低碳环保的生活方式.作为码农的我们自然也应该为环保做出应有的贡献.那么什么是低碳环保,简而言之就是就是低能量.低消耗.低 ...

  3. 你应该知道的7个写出更好的 Java 代码的技巧

    来源:SpringForAll社区 查看这些技巧和窍门可以帮助你写出更好的 Java 代码. 是的,你可以按照以下7个技巧和窍门编写出简短.整洁的 Java 代码.他们中的一些可能会让你感到惊讶,但是 ...

  4. python写出的程序如何给别人使用-涨姿势!这些小技巧让小白也可以写出更优雅的Python代码!...

    原标题:涨姿势!这些小技巧让小白也可以写出更优雅的Python代码! 一.前言 我前两天回答了两个Python相关的问题,收到了很多赞,从答案被收藏的情况来看,确实对不少人都很有帮助,所以我也很开心. ...

  5. 写出gradle风格的groovy代码

    写出gradle风格的groovy代码 我们先来看一段gradle中的代码: buildscript {repositories {jcenter()}dependencies {classpath ...

  6. 如何写出三体的MATLAB程序-代码篇

    如何写出三体的MATLAB程序-代码篇 写在前面 在上文当中我们已经对三个物体之间的受力进行了分析,也说明了在时间 t t t下的加速度.速度和位移的计算方式. 本篇中将根据上一篇的公式来写出对应的代 ...

  7. 如何写出优雅的 Go 语言代码

    如何写出优雅的 Go 语言代码 查看全文 http://www.taodudu.cc/news/show-3196428.html 相关文章: 写日志的那些事儿 写有价值的单元测试 腾讯私有云MySQ ...

  8. Java Stream如何写出高雅又装*的代码

    Java Stream如何写出高雅又装*的代码 一. 冷静分析 二. 直接开装 2.1 初级炫 2.2 普通炫 2.3 高级炫 2.4 再炫一波 拿到当前key与对应的数量 2.5 Map Reduc ...

  9. matlab模拟三体运动_如何写出三体的MATLAB程序-代码篇

    如何写出三体的MATLAB程序-代码篇 写在前面 在上文当中我们已经对三个物体之间的受力进行了分析,也说明了在时间 下的加速度.速度和位移的计算方式. 本篇中将根据上一篇的公式来写出对应的代码,并且详 ...

最新文章

  1. 【总结整理】如何做需求分析(转)
  2. python常见的错误总结
  3. java订单编号生产代码,java 订单编号 生成器,可用于生产环境
  4. MySql 常用命令总结
  5. 22-爬虫之scrapy框架分布式09
  6. 一汽大众t一roc_15万元预算能买到的紧凑型SUV——一汽-大众T-ROC探歌
  7. Kettle环境搭建及使用(数据迁移)
  8. HelloDjango 第 04 篇:Django 迁移、操作数据库
  9. 【EF】Entity Framework Core 2.0 特性介绍和使用指南
  10. 拓端tecdat|R语言HAR和HEAVY模型分析高频金融数据波动率
  11. 圈圈usb cannot convert from 'BOOL (__thiscall CMyUsbHidTestAppDlg::* )(UINT,DWORD)' to 'LRESULT (__
  12. 【Monster High】MMD镜头+动作打包下载.zip
  13. matlab interp1 spline,中国大学MOOC: MATLAB/Octave函数interp1中有一个描述插值方法的参数,其中spline表示...
  14. Axure RP Chrome插件安装
  15. MEMORY系列之“DDR概述”
  16. Android面试基础之BroadcastReceiver详解(斗帝养成系列四)
  17. br-lan、eth0、eth1及lo
  18. Samba服务和FTP服务
  19. 深耕图形领域,华为HMS Core图形计算服务提升图形应用表现
  20. python判断是不是字母_python判断字符是否为字母和数字

热门文章

  1. 商城项目15_采购需求、合并采购单、领取采购单、完成采购、仓库流程图
  2. jetson的学习资料总结
  3. 电路级静电防护设计技巧与ESD防护方法
  4. Microsoft Visio 文本框上标或下标
  5. oracle触发器调试日志,Oracle 11g 触发器调试记录Error: PLS-00201: identifier'SYS.DBMS_SYSTEM' must be declared...
  6. 关于虚拟机的十个基本小技巧
  7. 网站分析行业的“前途”和“钱途”
  8. MATLAB强化学习实战(十三) 使用强化学习智能体训练Biped机器人行走
  9. nove6怎么升级鸿蒙系统,华为手机怎么升级鸿蒙,华为鸿蒙系统支持手机型号大全...
  10. epic如何修改着色器缓存路径