I
Immortal Nephi
Please forgive me if my writing is not clear. English is not my
primary language. Hopefully, everyone can understand my writing.
I want to explain how C++ source code is hidden so clients do not
have to know the hidden source code. Let me show three different
clients.
Client A is C++ programmer. He designs general class. General class
can be video, keyboard, or mouse. Video class can have tens or
hundreds of member functions. Tens or hundreds of member functions
are hidden in the implementation. Interface in the video class is
built-in static or DLL library. Client B needs to know fewer member
functions such as interface's selectResolution(), showDisplay(), etc.
Client B is C++ programmer. He does not know client A’s hidden
source code. He only needs to know fewer member functions in the
video interface. He imports video library into his project. Also, he
can import mouse library, keyboard library, etc. He implements his
own design. He compiles and limks video interface, keyboard
interface, mouse interface, etc into complete software. The complete
software is available to client C.
Client C is not C++ programmer. He does not know neither client A’s
nor client B’s hidden design. He uses complete software for his daily
basis.
Let’s talk about client A. You said designed class with tens or
hundreds of member functions is flawed. Please explain why? One big
member function is flawed, but small member function is not. Hundreds
of member functions have fewer lines (1 to 20 lines). They are
carefully tested to be successful.
Client A put smaller hundreds of member functions together into fewer
big member functions. Fewer member functions become available to
client B. Client B only needs to execute public member functions.
They do not need to know complex hidden hundreds of member functions.
Please tell me more why it is not a good idea to have many member
functions in one big class. How can you suggest? Should big class
break into smaller classes? Why can’t you use smaller member
functions in one big class? What is worth C++ practice how to design
class in a better way?
primary language. Hopefully, everyone can understand my writing.
I want to explain how C++ source code is hidden so clients do not
have to know the hidden source code. Let me show three different
clients.
Client A is C++ programmer. He designs general class. General class
can be video, keyboard, or mouse. Video class can have tens or
hundreds of member functions. Tens or hundreds of member functions
are hidden in the implementation. Interface in the video class is
built-in static or DLL library. Client B needs to know fewer member
functions such as interface's selectResolution(), showDisplay(), etc.
Client B is C++ programmer. He does not know client A’s hidden
source code. He only needs to know fewer member functions in the
video interface. He imports video library into his project. Also, he
can import mouse library, keyboard library, etc. He implements his
own design. He compiles and limks video interface, keyboard
interface, mouse interface, etc into complete software. The complete
software is available to client C.
Client C is not C++ programmer. He does not know neither client A’s
nor client B’s hidden design. He uses complete software for his daily
basis.
Let’s talk about client A. You said designed class with tens or
hundreds of member functions is flawed. Please explain why? One big
member function is flawed, but small member function is not. Hundreds
of member functions have fewer lines (1 to 20 lines). They are
carefully tested to be successful.
Client A put smaller hundreds of member functions together into fewer
big member functions. Fewer member functions become available to
client B. Client B only needs to execute public member functions.
They do not need to know complex hidden hundreds of member functions.
Please tell me more why it is not a good idea to have many member
functions in one big class. How can you suggest? Should big class
break into smaller classes? Why can’t you use smaller member
functions in one big class? What is worth C++ practice how to design
class in a better way?