Jump to content
  • Advertisement
Sign in to follow this  

Exceptional C++ Book Item 32 Interface Principle

This topic is 3254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In this book, herb sutter stated that a function consider as MF when it fullfill two requirements a) Mention X b) Are supplied with X Assume X is a class. I don't get this. What this statement means ? Recently, i encountered a situation that which require to apply this principle. To ease the explanation, i have attach the code below.
class Administrator : public Human
	boost::shared_ptr<StaffInfo> theStaffInfo;


	Administrator(const std::string&, const std::string&);

	void Add();
	void Delete();
	void Modified();
	void Search();

	// To Do wraps all in Administrator Impl
	void DisplayAllStaff();
	void TimeIn();
	void TimeOut();

	void Logout();
	void Exit();

	// Extra function
	void SystemMaintenance();
	void RenewLiciense();
	void InstallPlugIn();

There are only two MF use the private member which are Add() and Modified(). All others are just MF that does not use private member variable. Question: 1. Can anyone explain the interface principle based on this example ? Thanks for any help.

Share this post

Link to post
Share on other sites
Original post by Antheus
I might be just having a slow day, heat and all, but what is MF?

I am going to take a stab and guess Member Function

Edit to OP: I think what that rule is describing is the basic characteristics of a Member Function. Rule #2 (supplied with X) refers to the implicit "this" reference that gets passed to a method (member function) in most OO languages, and Rule #1 (mentions X) speaks to the fact that methods should perform some operation or in some way use the object to which they belong. Otherwise, they are simply encapsulated global functions and serve no purpose being associated with a class.

[Edited by - arbitus on August 17, 2009 9:18:10 AM]

Share this post

Link to post
Share on other sites
Original post by Peter_APIIT
herb sutter stated that a function consider as MF

Doesn't consider a function part of the interface if...?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!