Sign in to follow this  
Peter_APIIT

Exceptional C++ Book Item 32 Interface Principle

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
{
private:
	boost::shared_ptr<StaffInfo> theStaffInfo;

public:

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

	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
Quote:
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
Quote:
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this