下你所需,载你所想!
汇集开发技术源码资料

C语言面向对象编程.pdf(英文版)

:906.756KB :1 :2022-09-20 18:44:41

部分简介

C语言面向对象编程.pdf(英文版)如果开发者对于本文件有需要的可以参考。


No programming technique solves all problems.
No programming language produces only correct results.
No programmer should start each project from scratch.
Object-oriented programming is the current cure-all — although it has been
around for much more then ten years. At the core, there is little more to it then
finally applying the good programming principles which we have been taught for
more then twenty years. C (Eiffel, Oberon-2, Smalltalk ... take your pick) is the
New Language because it is object-oriented — although you need not use it that
way if you do not want to (or know how to), and it turns out that you can do just as
well with plain ANSI-C. Only object-orientation permits code reuse between pro
jects — although the idea of subroutines is as old as computers and good program
mers always carried their toolkits and libraries with them.
This book is not going to praise object-oriented programming or condemn the
Old Way. We are simply going to use ANSI-C to discover how object-oriented pro
gramming is done, what its techniques are, why they help us solve bigger prob
lems, and how we harness generality and program to catch mistakes earlier. Along
the way we encounter all the jargon — classes, inheritance, instances, linkage,
methods, objects, polymorphisms, and more — but we take it out of the realm of
magic and see how it translates into the things we have known and done all along.
I had fun discovering that ANSI-C is a full-scale object-oriented language. To
share this fun you need to be reasonably fluent in ANSI-C to begin with — feeling
comfortable with structures, pointers, prototypes, and function pointers is a must.
Working through the book you will encounter all the newspeak — according to
Orwell and Webster a language ‘‘designed to diminish the range of thought’’ — and
I will try to demonstrate how it merely combines all the good programming princi
ples that you always wanted to employ into a coherent approach. As a result, you
may well become a more proficient ANSI-C programmer.
The first six chapters develop the foundations of object-oriented programming
with ANSI-C. We start with a careful information hiding technique for abstract data
types, add generic functions based on dynamic linkage and inherit code by judicious
lengthening of structures. Finally, we put it all together in a class hierarchy that
makes code much easier to maintain.
Programming takes discipline. Good programming takes a lot of discipline, a
large number of principles, and standard, defensive ways of doing things right. Pro
grammers use tools. Good programmers make tools to dispose of routine tasks
once and for all. Object-oriented programming with ANSI-C requires a fair amount
of immutable code — names may change but not the structures. Therefore, in
chapter seven we build a small preprocessor to create the boilerplate required. It
looks like yet another new object-oriented dialect language (yanoodl perhaps?) but
it should not be viewed as such — it gets the dull parts out of the way and lets us
concentrate on the creative aspects of problem solving with better techniques.
 

热门推荐

相关文章