?? O'zbekistondagi N1 Akkaunt Savdo Kanali!
‼️ Eslatma: Kanalimizga Joylanayotgan Akkauntlarning Barchasi Turnirda Yutilgan!
? Kanalga Joylangan Xar Bir Akkauntga "SENATOR" Shaxsan O'zi Javob Beradi!
✍️Admin: @deSENATOR_AKKS ✅ Org ‼
©️SENATOR PUBGM
Last updated 1 year, 1 month ago
🔔 Reklama: @Edurekadmin
Ta'limda nima yangiliklar?
O'zbekiston ta'lim sferasidagi eng oxirgi va eng dolzarb yangiliklarini aynan shu kanaldan topasiz!
© Kanaldan to'liq yoki qisman ma'lumot olinganda manba ko'rsatilishi shart!
📩 @Edu_murojaatBot
Last updated 1 month, 1 week ago
Kun davomida eng sara va so'nggi yangiliklar tafsiloti bilan YO'L-YO'LAKAY tanishtirib boramiz.
Voqea va hodisaga guvoh bo‘ldingizmi, videolaringizni bizga yuboring: @yyuzbot
Reklama bo‘yicha: @zorzorads
Instagram sahifamiz: https://bit.ly/3wlZDZH
Last updated 2 weeks, 2 days ago
SOLID
Open/Closed Principle
The Open/Closed Principle states that:
Code should be open for extension — new functionality can be added.
Code should be closed for modification — existing code should not be changed.
This ensures code stability and easier maintenance. Instead of changing old code, we add new code.
Below is an example that violates the Open/Closed Principle (OCP). In this example, every time a new type of message is added, the existing code must be modified, which makes it less maintainable and more prone to bugs.
The second example shows a correct implementation of the Open/Closed Principle. Instead of modifying existing code, new behavior is added by extending the base class. This approach makes the code more flexible and easier to maintain.
Remember to write clean and readable code
```
#include
#include
// Function that violates OCP by using if-else for each message type
class MessageHandler {
public:
void handle(const std::string& type, const std::string& message) {
if (type == "text") {
std::cout << "Handling text message: " << message << '\n';
} else if (type == "error") {
std::cerr << "Handling error message: " << message << '\n';
} else {
std::cout << "Unknown message type: " << message << '\n';
}
}
};
int main() {
MessageHandler handler;
handler.handle("text", "Hello, World!");
handler.handle("error", "Something went wrong.");
handler.handle("info", "New message type!"); // Adding new types requires modifying the method
return 0;
}
```
```
#include
#include
#include
#include
// Base class that defines the interface
class MessageHandler {
public:
virtual ~MessageHandler() = default;
virtual void handle(const std::string& message) const = 0;
};
// Handler for text messages
class TextMessageHandler : public MessageHandler {
public:
void handle(const std::string& message) const override {
std::cout << "Handling text message: " << message << '\n';
}
};
// Handler for error messages
class ErrorMessageHandler : public MessageHandler {
public:
void handle(const std::string& message) const override {
std::cerr << "Handling error message: " << message << '\n';
}
};
int main() {
std::vector> handlers;
handlers.emplace_back(std::make_shared());
handlers.emplace_back(std::make_shared());
for (const auto& handler : handlers) {
handler\->handle("Hello, World!"); // No need to change the existing code
}
return 0;
}
```
#include #include #include class Quiz { private: std::vector> questions; int score = 0; public: Quiz() { questions = { {"What is 2 + 2?", "4"}, {"What…
```
#include
#include
#include
class Quiz {
private:
std::vector> questions;
int score = 0;
public:
Quiz() {
questions = {
{"What is 2 + 2?", "4"},
{"What is the capital of France?", "Paris"},
{"Who wrote '1984'?", "George Orwell"}
};
}
void runQuiz() {
for (const auto& [question, answer] : questions) {
std::cout << question << " ";
std::string userAnswer;
std::getline(std::cin, userAnswer);
if (userAnswer == answer) {
score++;
}
}
std::cout << "You scored " << score << " out of " << questions.size() << "!\n";
}
};
int main() {
Quiz quiz;
quiz.runQuiz();
return 0;
}
```
Yandex Cup dan yarim finalga kimlar chiqdi?
🔥 - yarim finaldaman.
😐 - keyingi yil Insha Allah.
Reaksiya qoldiring.
?? Happy Independence Day, Uzbekistan!
Today, on September 1st, we celebrate the 33rd anniversary of our country's independence! This day reminds us of the importance of freedom, unity, and the pursuit of prosperity. We take pride in our rich cultural heritage, hardworking people, and the progress Uzbekistan continues to make as it secures its rightful place on the global stage.
Wishing all my fellow citizens peace, prosperity, and continued success! May our nation thrive, and may each of us contribute to its bright future.
Happy Independence Day, Uzbekistan! ??
Bugun Yandex dan yozishdi. C++ Backend lead pozitsiyasida. Men esa Oson da shartnoma qilibman ???. Yandex C++ dasturchilar uchun bir nechta vakansiya elon qilgan. Shoshiling!!! Siz imkoniyatni boy bermang.
Pythonda backend yozish shunchalaram osonkiiii "Mazza"
```
@app.route('/api/register', methods=['POST'])
def register():
# Ensure you're handling JSON data
data = request.get_json()
new_user = User()
new_user.UserName = data["username"]
new_user.Email = data["email"]
new_user.set_password(data["password"])
try:
db.session.add(new_user)
db.session.commit()
return jsonify({"message": "Registration successful"}), 201
except Exception as e:
db.session.rollback()
return jsonify({"message": "Registration failed", "error": str(e)}), 500
@app.route('/api/logout')
def logout():
session.pop('logged_in', None)
session.pop('user_id', None)
flash('You have been logged out!', 'success')
return redirect(url_for('index'))
@app.route("/api/clients", methods = ["GET", "POST"])
def clients():
if True:
if request.method == "GET":
clients = Tourist.query.all()
return jsonify([client.to_dict() for client in clients]), 200
elif request.method == "POST":
client = Tourist.from_dict(request.get_json())
db.session.add(client)
db.session.commit()
return jsonify({"message":"Add new tourist"}) , 201
```
Xuddi hech narsa yozmay uzi ishlab ketadigandek
Microsoft rasmiy ravishda telegramda Copilot botini taqdim etdi.
Bilaszlar Copilot backendida GPT-4 bepul ishlaydi.
Foydalanamiz!!!!!!!
https://www.microsoft.com/ru-ru/edge/copilot-for-social?form=MY02F9
https://t.me/CopilotOfficialBot
Microsoft
Copilot для Telegram | Майкрософт Copilot
Попробуйте Copilot для Telegram, вашего персонального помощника по обмену сообщениями с помощью ИИ. Отправляйте текстовые сообщения, создавайте, переводите, выполняйте поиск и многое другое, где бы вы ни находились, с помощью Copilot.
?? O'zbekistondagi N1 Akkaunt Savdo Kanali!
‼️ Eslatma: Kanalimizga Joylanayotgan Akkauntlarning Barchasi Turnirda Yutilgan!
? Kanalga Joylangan Xar Bir Akkauntga "SENATOR" Shaxsan O'zi Javob Beradi!
✍️Admin: @deSENATOR_AKKS ✅ Org ‼
©️SENATOR PUBGM
Last updated 1 year, 1 month ago
🔔 Reklama: @Edurekadmin
Ta'limda nima yangiliklar?
O'zbekiston ta'lim sferasidagi eng oxirgi va eng dolzarb yangiliklarini aynan shu kanaldan topasiz!
© Kanaldan to'liq yoki qisman ma'lumot olinganda manba ko'rsatilishi shart!
📩 @Edu_murojaatBot
Last updated 1 month, 1 week ago
Kun davomida eng sara va so'nggi yangiliklar tafsiloti bilan YO'L-YO'LAKAY tanishtirib boramiz.
Voqea va hodisaga guvoh bo‘ldingizmi, videolaringizni bizga yuboring: @yyuzbot
Reklama bo‘yicha: @zorzorads
Instagram sahifamiz: https://bit.ly/3wlZDZH
Last updated 2 weeks, 2 days ago