Words can combine to form new words such as lifestyle ,lifelong, doorbell, life expectancy junk food and so forth.

I do not know when to attach the words and when to use hyphen or space?

is there any particular rule for that or do we have to memorize all this form of compound nouns or adjectives.

for example why life-size must be hyphenated and life long separated?

and lifestyle must be used attached together and life expectancy with space?

thanks in advance
There is no rule. Generally, they start out their lives as two words, become hyphenated along the way, and then mature into single words. You'll need to check your dictionary to be sure what stage the formation is at. On the other hand, in many cases more than one form is accepted.
Site Hint: Check out our list of pronunciation videos.
Thanks for your reply.

I have made a rule for myself which I don't know if it's right or not.

whenever we want to combine two nouns and use the combination as an adjective, we have to hyphenate them such as life-size staute and when we use a noun in combination with a past participle like made or grown in pharases like homemade or homegrown they must be attached.

but still couldn't find a justification why doorbell is one word and junk food is written as two words.

Regarding what you said, so we can expect junk food and life expectancy to be one word in future.

Once again thanks for your time and help
I suggest that you don't make your own rules for the language.