c# programming guidlinessource:
larry o’brien and bruce eckel 【程序编程相关:VB 二进制块读写类模块(第一版) 】
thinking in c# 【推荐阅读:VB 二进制块读写类模块应用实例,包括一】
begin: 【扩展信息:失去信心?还是再度迷惘 】
prentice hallupper saddle river, new jersey 07458www.phptr.com
this appendix contains suggestions to help guide you in performing low-level program design, and in writing code.
naturally, these are guidelines and not rules. the idea is to use them as inspirations, and to remember that there are
occasional situations where you need to bend or break a rule.
design0.elegance always pays off. in the short term it might seem like it takes much longer to come up with a truly graceful solution to a problem, but when it works the first time and easily adapts to new situations instead of requiring hours, days, or months of struggle, you’ll see the rewards (even if no one can measure them). not only does it give you a program that’s easier to build and debug, but it’s also easier to understand and maintain, and that’s where the financial value lies. this point can take some experience to understand, because it can appear that you’re not being productive while you’re making a piece of code elegant. resist the urge to hurry; it will only slow you down.
1.first make it work, then make it fast. this is true even if you are certain that a piece of code is really important and that it will be a principal bottleneck in your system. don’t do it. get the system going first with as simple a design as possible. then if it isn’t going fast enough, profile it. you’ll almost always discover that “your” bottleneck isn’t the problem. save your time for the really important stuff.
2.remember the “divide and conquer” principle. if the problem you’re looking at is too confusing, try to imagine what the basic operation of the program would be, given the existence of a magic “piece” that handles the hard parts. that “piece” is an object—write the code that uses the object, then look at the object and encapsulate its hard parts into other objects, etc.
3.separate the class creator from the class user (client programmer). the class user is the “customer” and doesn’t need or want to know what’s going on behind the scenes of the class. the class creator must be the expert in class design and write the class so that it can be used by the most novice programmer possible, yet still work robustly in the application. library use will be easy only if it’s transparent.
4.when you create a class, attempt to make your names so clear that comments are unnecessary. your goal should be to make the client programmer’s interface conceptually simple. to this end, use method overloading when appropriate to create an intuitive, easy-to-use interface.
... 下一页