Soap as well known is used for cleaning. There are liquid as well as solid forms of soap. However both forms have the same principle of action. All compounds and materials that are available synthetically or naturally can be divided into two chemical characteristics. These are hydrophobic and hydrophilic characteristics depending on their structure.
Hydrophobic compounds refer to a compound wich is insoluble in water. The technical meaning of hydrophobic is dislike water. HYdrophilic compound refers to a compound which is soluble in water. The meaning of hydrophilic is love water.
In the spectrum of compounds between completely hydrophilic to completely hydrophobic there are enormous number of compounds whether natural or synthetic that have variable amount of hhydrophobicity and hydtophilicity. These two technical names have other names. These are polar and non polar.
Polar compounds are normally hydrohpilic which non-polar compounds are normally hydrophobic. The more polar the compound the more it is hydrophilic. the more non-polar the compound is the more it is hyrophobic.
Example of a hydrophilic compound is acetone which is a polar ketone and is soluble in water. An example of a non-polar compound is cyclohexane. This compound is an extremely hydrophobic compound and is thus water insoluble. If you try to dissolve cyclohexane in water you will observe two layers on the bottom in the water due to its larger density.
Since soap was designed for cleaning , it was normal to think that it will remove both hydrophilic and hydrophobic compounds or polar and non-polar dirts.
The basic principle behind the action of soap is for a compound to be able to dissolve both polar and non-polar compounds simultaneously. Water is actually a soap for polar compounds because we can remove them by washing with water. An example f a hydrophobic soap is hexane. Hexane is actually a solvent for nonpolar compounds.
So if you are a chemist and wants to design a soap. it must be a molecule in the liquid or solid phase that have both polar and nonpolar structres. The design of the hydrophobic part can be designed according to the degree of non polarity of the compound we wish to remove. analogously the design of the polar structre canbe adjusted based on the extent of polarity of the cmpound we wish to dissolve or remove.
In your design you mast take into account the extent of toxicity of your compound.
A simple design of a primitive soap is to use fatty acids with long hydrophobic methylene chains and to use the ionized form of the carboxylic acid. In this way the fatty acid has two structures within one molecule. one is polar which will help to solubilize polar compounds and the other is nonpolar which will help to solubilize lipids and non-polar compounds.