CPPPROGLIB Telegram 6052
⬆️ Hotkey boost: Рефакторинг функций

Надо вынести кусок логики в функцию? Тогда можно воспользоваться встроенными возможностями редактора кода которым пользуешься.


💡 Примеры для разных редакторов:

✏️ CLion:

• выдели код → Ctrl+Alt+M (Extract Function)

✏️ VS Code:

• выдели код → Ctrl+Shift+R → Extract to function

✏️ Visual Studio:

• выдели код → Ctrl+R, M (Extract Function)


🍴 Пример использования:

void mainLogic(const std::string& user) {
// До рефакторинга
if (user.size() > 3 && user[0] == 'A') {
std::cout << "Valid user: " << user << std::endl;
}
}


После рефакторинга VS Code сам создаст функцию:

bool shouldProcessUser(const std::string& user) {
return user.size() > 3 && user[0] == 'A';
}

void mainLogic(const std::string& user) {
if (shouldProcessUser(user)) {
std::cout << "Valid user: " << user << std::endl;
}
}


Библиотека C/C++ разработчика

#буст
Please open Telegram to view this post
VIEW IN TELEGRAM
👍7🔥1



tgoop.com/cppproglib/6052
Create:
Last Update:

⬆️ Hotkey boost: Рефакторинг функций

Надо вынести кусок логики в функцию? Тогда можно воспользоваться встроенными возможностями редактора кода которым пользуешься.


💡 Примеры для разных редакторов:

✏️ CLion:

• выдели код → Ctrl+Alt+M (Extract Function)

✏️ VS Code:

• выдели код → Ctrl+Shift+R → Extract to function

✏️ Visual Studio:

• выдели код → Ctrl+R, M (Extract Function)


🍴 Пример использования:

void mainLogic(const std::string& user) {
// До рефакторинга
if (user.size() > 3 && user[0] == 'A') {
std::cout << "Valid user: " << user << std::endl;
}
}


После рефакторинга VS Code сам создаст функцию:

bool shouldProcessUser(const std::string& user) {
return user.size() > 3 && user[0] == 'A';
}

void mainLogic(const std::string& user) {
if (shouldProcessUser(user)) {
std::cout << "Valid user: " << user << std::endl;
}
}


Библиотека C/C++ разработчика

#буст

BY Библиотека C/C++ разработчика | cpp, boost, qt


Share with your friend now:
tgoop.com/cppproglib/6052

View MORE
Open in Telegram


Telegram News

Date: |

“Hey degen, are you stressed? Just let it all out,” he wrote, along with a link to join the group. Commenting about the court's concerns about the spread of false information related to the elections, Minister Fachin noted Brazil is "facing circumstances that could put Brazil's democracy at risk." During the meeting, the information technology secretary at the TSE, Julio Valente, put forward a list of requests the court believes will disinformation. But a Telegram statement also said: "Any requests related to political censorship or limiting human rights such as the rights to free speech or assembly are not and will not be considered." Just as the Bitcoin turmoil continues, crypto traders have taken to Telegram to voice their feelings. Crypto investors can reduce their anxiety about losses by joining the “Bear Market Screaming Therapy Group” on Telegram. The SUCK Channel on Telegram, with a message saying some content has been removed by the police. Photo: Telegram screenshot.
from us


Telegram Библиотека C/C++ разработчика | cpp, boost, qt
FROM American