What does abstraction mean in programming?

前端 未结 7 685
时光说笑
时光说笑 2020-12-07 08:40

I\'m learning python and I\'m not sure of understanding the following statement : \"The function (including its name) can capture our mental chunking, or abstraction

7条回答
  •  广开言路
    2020-12-07 09:11

    Let's say you write a function which receives a bunch of text as parameter, then reads credentials in a config file, then connects to a SMTP server using those credentials and sends a mail using that text.

    The function should be named sendMail(text), not parseTextReadCredentialsInFileConnectToSmtpThenSend(text) because it is more easy to represent what it does this way, to yourself and when presenting the API to coworkers or users... even though the 2nd name is more accurate, the first is a better abstraction.

提交回复
热议问题