<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Deep Singh</title>
    <description>The latest articles on Forem by Deep Singh (@techishdeep).</description>
    <link>https://forem.com/techishdeep</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1070350%2F81a49aa0-86d8-4288-b641-93e97135f3f6.jpg</url>
      <title>Forem: Deep Singh</title>
      <link>https://forem.com/techishdeep</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/techishdeep"/>
    <language>en</language>
    <item>
      <title>The Future of Work: AI and the Rise of Hybrid Jobs</title>
      <dc:creator>Deep Singh</dc:creator>
      <pubDate>Sun, 28 May 2023 19:17:44 +0000</pubDate>
      <link>https://forem.com/techishdeep/the-future-of-work-ai-and-the-rise-of-hybrid-jobs-59hf</link>
      <guid>https://forem.com/techishdeep/the-future-of-work-ai-and-the-rise-of-hybrid-jobs-59hf</guid>
      <description>&lt;p&gt;The AI revolution is upon us, and its transformative power is reshaping our world. From the realm of healthcare to the field of education, AI is unleashing new possibilities and pushing the boundaries of human potential.&lt;/p&gt;

&lt;p&gt;In this article, we'll embark on a multi-faceted exploration, examining how AI is illuminating healthcare with precise diagnostics, empowering education with personalized learning experiences, and opening new horizons of opportunities across various industries.&lt;/p&gt;

&lt;p&gt;First, I’d try to touch the topic from high level point of view. Later, we’ll discuss each point in more detail.&lt;/p&gt;

&lt;p&gt;Get ready to witness AI's enchanting influence as it enhances our lives and propels us towards a brighter future.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI will enhance productivity
&lt;/h2&gt;

&lt;p&gt;One of the most significant impacts of AI will be on productivity. AI-powered machines and algorithms are already being used to automate repetitive and mundane tasks, freeing up human workers to focus on more strategic and creative work.&lt;/p&gt;

&lt;p&gt;AI-powered tools can also help businesses streamline their operations, identify new opportunities, and make better decisions. This means that AI will help businesses become more efficient and productive, enabling them to achieve greater levels of success.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI will improve healthcare
&lt;/h2&gt;

&lt;p&gt;AI has the potential to transform healthcare by improving diagnosis, treatment, and patient outcomes. AI algorithms can be trained to analyze vast amounts of medical data and identify patterns and insights that humans might miss.&lt;/p&gt;

&lt;p&gt;AI-powered medical devices and robots can assist with surgeries, monitor patient health, and provide more personalized care. As AI technology advances, it will enable doctors and researchers to better understand complex diseases, develop new treatments, and improve overall healthcare outcomes.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI will transform education
&lt;/h2&gt;

&lt;p&gt;AI will also change the way we learn and teach. With AI-powered educational tools, teachers can customize learning experiences to meet the needs and learning styles of individual students.&lt;/p&gt;

&lt;p&gt;AI can also help identify learning gaps and provide targeted interventions to help students catch up.&lt;/p&gt;

&lt;p&gt;AI-powered chatbots and virtual assistants can also provide instant feedback and assistance to students, enabling them to learn more efficiently and effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI will create new job opportunities
&lt;/h2&gt;

&lt;p&gt;While there is some concern that AI will eliminate jobs, the reality is that AI will create new job opportunities. As businesses adopt AI-powered tools, there will be a growing need for people with the skills to develop, deploy, and manage these systems.&lt;/p&gt;

&lt;p&gt;AI will also create new industries and markets, such as personalized medicine, autonomous vehicles, and smart cities. As AI continues to evolve, there will be a growing demand for people with a wide range of technical and creative skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  Discussion in Detail
&lt;/h2&gt;

&lt;p&gt;As we saw how AI will change our world in profound ways. From enhancing productivity and improving healthcare and education to creating new job opportunities and industries, AI has the potential to transform every aspect of our lives. As AI technology continues to advance, we can expect to see even more exciting and innovative applications in the years ahead.&lt;/p&gt;

&lt;p&gt;Now, let’s discuss each point in detail.&lt;/p&gt;

&lt;h3&gt;
  
  
  AI Revolution: Boosting Productivity
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Automating the Mundane:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Imagine a world where tedious, repetitive tasks are taken off your plate, freeing up valuable time and mental energy. AI is making this a reality by automating mundane tasks and processes.&lt;/p&gt;

&lt;p&gt;Whether it's data entry, document processing, or customer support, AI-powered systems can handle these tasks with lightning-fast speed and precision. So, instead of spending hours tediously inputting data, professionals can focus on more strategic and creative endeavors.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To put it in a light-hearted way, AI is like having a tireless robot assistant who handles the dull tasks, allowing you to shine as the brilliant mastermind behind the scenes. So go ahead, sit back, and let the AI-powered superheroes take care of the mundane work!&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Supercharging Decision Making:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Making informed decisions is a vital aspect of any business. However, with the overwhelming amount of data available, it can be challenging to extract meaningful insights efficiently.&lt;/p&gt;

&lt;p&gt;AI steps in as the suave, data-savvy companion who effortlessly sifts through mountains of information to uncover hidden patterns, trends, and correlations.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;By leveraging AI's analytical prowess, businesses gain access to actionable insights that drive smarter decision-making. Whether it's identifying new market opportunities, optimizing supply chain management, or predicting customer behavior, AI equips professionals with the tools they need to make data-driven choices with finesse.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Unleashing Personalized Experiences:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Personalization is the name of the game in today's customer-centric world. AI takes personalization to a whole new level, tailoring experiences to individual preferences with unmatched precision. From targeted advertisements to curated product recommendations, AI algorithms analyze vast amounts of customer data to understand preferences, behaviors, and desires.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Think of AI as the genie in the lamp, granting personalized wishes to customers. By delivering hyper-personalized experiences, businesses can build stronger customer relationships, increase customer satisfaction, and ultimately, boost their bottom line.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Enhancing Collaboration:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;In the digital age, collaboration has become essential, whether you're working within a team or collaborating with clients and partners. AI is stepping in as the witty and tech-savvy mediator, revolutionizing how we collaborate and communicate.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AI-powered tools enable seamless collaboration across teams, breaking down geographical barriers and time constraints. Virtual assistants, chatbots, and project management tools powered by AI facilitate efficient communication, information sharing, and task management. With AI as the tech-savvy middleman, collaboration becomes a breeze, keeping teams connected and projects on track.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;In this AI-powered era, productivity gains are within reach like never before. By automating mundane tasks, supercharging decision-making, unleashing personalized experiences, and enhancing collaboration, AI has the potential to transform the way we work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Illuminating Healthcare with Artificial Intelligence
&lt;/h3&gt;

&lt;p&gt;When it comes to healthcare, precision, accuracy, and timely decision-making are of utmost importance. In the ever-evolving landscape of medicine, artificial intelligence (AI) is set to revolutionize healthcare, empowering medical professionals to provide better diagnoses, treatments, and patient outcomes.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Unraveling the Diagnostic Puzzle:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Diagnosing complex diseases can be like navigating a maze of symptoms, medical records, and test results. AI acts as the brilliant Sherlock Holmes of the medical world, analyzing vast amounts of patient data and identifying subtle patterns and correlations that might elude human eyes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;By training AI algorithms on massive datasets, medical professionals can leverage AI's analytical prowess to improve diagnostic accuracy.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;From radiology and pathology to genomics and clinical decision support systems, AI provides a reliable partner who assists in unraveling the diagnostic puzzle, leading to faster and more accurate diagnoses.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Enhancing Treatment Plans:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Once a diagnosis is made, developing an effective treatment plan is crucial. AI steps in as the knowledgeable medical advisor, bringing forth evidence-based insights and treatment recommendations.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;By analyzing vast amounts of medical literature, research papers, and patient data, AI can provide healthcare professionals with valuable information on the most effective treatment options for specific conditions.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This not only saves time but also improves treatment outcomes, as AI assists in selecting the most suitable therapies, dosages, and even predicting potential adverse reactions.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Revolutionizing Patient Monitoring:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Traditionally, patient monitoring involved periodic check-ups and manual observations. AI enters the scene as the diligent and vigilant bedside companion, continuously monitoring patients' vital signs and alerting healthcare providers to any deviations or anomalies.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;With wearable devices and AI-powered algorithms, patients can be remotely monitored in real-time, allowing for early detection of deteriorating health conditions. This proactive approach minimizes the risk of complications and improves patient outcomes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;So, whether it's monitoring heart rates, blood glucose levels, or sleep patterns, AI ensures that healthcare providers have access to a wealth of data to make informed decisions about patient care.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Empowering Precision Medicine:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Every individual is unique, and their response to treatments can vary significantly. AI comes forth as the precision medicine guru, unraveling the complexities of individual patients' genetic and molecular profiles.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;By analyzing vast genomic and proteomic datasets, AI enables personalized medicine tailored to an individual's specific characteristics. This can lead to more targeted therapies, reduced side effects, and improved treatment outcomes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AI's ability to uncover hidden relationships between genetic variations and diseases opens up new avenues for precision medicine and paves the way for more effective and efficient healthcare.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In the realm of healthcare, AI emerges as the charismatic and brilliant assistant, transforming the way medical professionals diagnose, treat, and monitor patients. From unraveling diagnostic puzzles to enhancing treatment plans, revolutionizing patient monitoring, and empowering precision medicine, AI is set to illuminate the healthcare landscape with its technical prowess and wit.&lt;/p&gt;

&lt;h3&gt;
  
  
  Empowering Education with a Touch of Artificial Intelligence
&lt;/h3&gt;

&lt;p&gt;Education is the cornerstone of our society, shaping minds and shaping the future. As technology continues to advance, artificial intelligence (AI) is poised to revolutionize the way we learn and teach.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Customizing Learning Experiences:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Every learner is unique, with different strengths, weaknesses, and preferred learning styles. AI enters the classroom as the perceptive and adaptable tutor, customizing learning experiences to meet the needs of individual students.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;By analyzing vast amounts of data on student performance, AI algorithms can identify knowledge gaps and tailor instructional content accordingly. This personalized approach ensures that students receive targeted support and resources, maximizing their learning potential.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;So, whether you're a visual learner, an auditory learner, or a hands-on learner, AI is here to create a tailor-made educational journey just for you.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Providing Instant Feedback:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Feedback is an essential aspect of the learning process, allowing students to understand their progress, identify areas for improvement, and build confidence. AI steps in as the quick-witted and ever-present mentor, providing instant feedback to students at every step of their learning journey.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;With AI-powered assessment tools, students can receive immediate feedback on their assignments, quizzes, and exams. Whether it's correcting grammar mistakes in an essay or pinpointing errors in a math problem, AI ensures that students receive timely feedback that fosters continuous growth and improvement.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Identifying Learning Gaps:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Identifying and addressing learning gaps is crucial for student success. AI takes on the role of the perceptive detective, analyzing student performance data to identify areas where students may be struggling.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;By monitoring student progress and performance over time, AI can identify patterns of misunderstanding or difficulty. This information enables educators to intervene and provide targeted interventions to help students overcome their learning gaps.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AI acts as a guide, leading both students and educators on a path to academic excellence.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Facilitating Collaborative Learning:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Collaboration is a vital skill in today's interconnected world. AI steps in as the charismatic and tech-savvy facilitator, revolutionizing collaborative learning experiences.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AI-powered tools enable seamless communication and collaboration among students and educators, regardless of geographical barriers. Virtual classrooms, online discussion boards, and collaborative project management platforms powered by AI empower students to work together, exchange ideas, and learn from one another.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;With AI as the digital mediator, collaboration becomes a vibrant and enriching experience.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In the realm of education, AI emerges as the witty and perceptive companion, transforming the way we learn and teach. By customizing learning experiences, providing instant feedback, identifying learning gaps, and facilitating collaborative learning, AI enhances education with its technical prowess and charm.&lt;/p&gt;

&lt;h3&gt;
  
  
  Opening New Horizons of Opportunities
&lt;/h3&gt;

&lt;p&gt;As artificial intelligence (AI) continues to evolve, it holds the potential to create new job opportunities and reshape entire industries. &lt;strong&gt;&lt;em&gt;Far from being a job-stealing force, AI is set to empower individuals, businesses, and communities with a plethora of new possibilities.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Rise of AI Expertise:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;As AI becomes more integrated into various sectors, there is a growing demand for individuals with expertise in AI development, deployment, and management. These AI experts act as the enchanting wizards, wielding the power of AI to drive innovation and solve complex problems.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;From AI engineers and data scientists to AI ethics specialists and AI trainers, the job market is witnessing a surge in AI-related roles. Embracing AI opens up exciting avenues for professionals to acquire specialized skills and become the pioneers of this transformative technology.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;AI-Powered Industries and Markets:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;AI is not only transforming existing industries but also creating entirely new markets and industries. Imagine a world where personalized medicine, autonomous vehicles, and smart cities are the norm. AI acts as the catalyst, driving the growth of these industries and fueling innovation.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For example, the development of autonomous vehicles requires a workforce skilled in AI algorithms, sensor technologies, and data analysis.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Similarly, the implementation of smart city initiatives demands professionals who can leverage AI to optimize resource allocation, improve urban planning, and enhance the quality of life for residents. As AI continues to evolve, it will spawn novel opportunities in industries we can only dream of today.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;The Human-AI Collaboration:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Contrary to popular belief, AI is not meant to replace humans; rather, it complements and augments human capabilities. The collaboration between humans and AI is a harmonious duet, where each brings its unique strengths to the table.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AI acts as the trusty sidekick, handling repetitive and mundane tasks, while humans provide the creative and strategic thinking that machines lack. This partnership opens up a realm of hybrid jobs, where professionals work alongside AI systems to achieve greater levels of productivity and efficiency. Together, humans and AI can accomplish feats that neither could achieve alone.&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Fostering Entrepreneurship and Innovation:&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;AI's transformative power extends beyond the realm of employment. It also fuels entrepreneurship and innovation, creating opportunities for individuals to build their own AI-powered ventures.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AI serves as the inspirational muse, sparking novel ideas and enabling entrepreneurs to develop innovative products and services.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;From AI-driven startups to tech incubators focused on AI applications, the entrepreneurial landscape is ripe with possibilities for those with a vision for harnessing AI's potential. This wave of AI-driven entrepreneurship will contribute to economic growth and societal progress, opening doors for those willing to embark on the entrepreneurial journey.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The AI revolution is not about replacing humans; it's about augmenting human potential and creating new possibilities. AI expertise, AI-powered industries, human-AI collaboration, and AI-driven entrepreneurship are the cornerstones of a future filled with opportunities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Conclusion
&lt;/h2&gt;

&lt;p&gt;As we conclude this captivating journey through the realms of AI, one thing becomes clear: the AI revolution is not just a technological marvel, but a catalyst for positive change.&lt;/p&gt;

&lt;p&gt;From revolutionizing healthcare diagnostics and treatment plans to personalizing education and fostering collaboration, AI is shaping industries, creating new job opportunities, and unlocking human potential like never before.&lt;/p&gt;

&lt;p&gt;So, dear readers, embrace the wit, charm, and technical insights of AI as you navigate this brave new world. Let us celebrate the AI revolution and embark on a future where intelligence and innovation intertwine to reshape our world for the better.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>career</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Choosing the Right Programming Language: A Path to Becoming a Masterful Software Engineer</title>
      <dc:creator>Deep Singh</dc:creator>
      <pubDate>Mon, 22 May 2023 21:56:25 +0000</pubDate>
      <link>https://forem.com/techishdeep/choosing-the-right-programming-language-a-path-to-becoming-a-masterful-software-engineer-m0h</link>
      <guid>https://forem.com/techishdeep/choosing-the-right-programming-language-a-path-to-becoming-a-masterful-software-engineer-m0h</guid>
      <description>&lt;p&gt;Many programmers often find themselves pondering over which programming language to learn as they embark on their journey to becoming a Software Engineer. Engulfed in debates and discussions about the best language for beginners, they sometimes lose sight of the bigger picture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instead of fixating on a specific language, it is crucial to adopt a broader perspective and strive to become a versatile "Software Engineer" rather than a specialist in a single language&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;This article aims to guide beginners on their path to learning programming languages, emphasizing the significance of foundational knowledge and a higher-level approach. By following these principles, one can cultivate the skills required to adapt to any language or tool they encounter, paving the way for a successful and enduring career.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Power of Language Agnosticism
&lt;/h2&gt;

&lt;p&gt;Imagine yourself as a carpenter who desires to excel at hammering nails into a block of wood. While this skill is valuable, it limits your capabilities to the tool at hand. However, if your goal is to construct an entire house from scratch, you need a different mindset. &lt;/p&gt;

&lt;p&gt;A master craftsperson possesses the ability to adapt to various tools, using each one effectively to accomplish specific tasks. &lt;/p&gt;

&lt;p&gt;Similarly, one should focus on acquiring a deep understanding of one language initially, to the point where its syntax, quirks, and oddities hold no surprises. This mastery serves as a solid foundation, enabling them to effortlessly embrace and excel in subsequent languages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Embracing Higher-Level Thinking
&lt;/h2&gt;

&lt;p&gt;An aspiring developer fixated on being a &lt;em&gt;Python developer&lt;/em&gt;, for instance, may hesitate to pursue a job opening that requires expertise in &lt;em&gt;Ruby&lt;/em&gt;. By thinking narrowly, they limit their opportunities and dismiss potential career growth. &lt;/p&gt;

&lt;p&gt;In contrast, a developer with a strong grasp of software engineering fundamentals possesses the confidence to learn any language as needed. Such an individual would enthusiastically apply for a job involving an unfamiliar language, knowing they can quickly adapt to its syntax and expand their repertoire. &lt;/p&gt;

&lt;p&gt;It is essential to prioritize higher-level skills that define a great software engineer, including writing detailed pseudocode, breaking down complex problems into manageable chunks, reading language documentation, and effectively seeking assistance from experienced coders on forums like StackOverflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Evolving Landscape of Programming Languages
&lt;/h2&gt;

&lt;p&gt;Programming languages rise and fall in popularity, and frameworks and libraries evolve at a rapid pace. By avoiding a narrow focus on a single language, developers can ensure their careers remain resilient amid the ever-changing tech industry. Possessing a strong foundation in software engineering empowers individuals to transition seamlessly to new languages as they emerge, safeguarding their professional growth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Selecting the First Language
&lt;/h2&gt;

&lt;p&gt;While the popularity of a language should not be a primary concern for beginners, other criteria can help guide their choice. &lt;/p&gt;

&lt;p&gt;Novice developers may initially lack the confidence to envision themselves as professionals in the field. The selection process should prioritize languages known for their beginner-friendly nature. Python and Ruby, for example, are widely regarded as accessible languages for individuals pursuing careers in web application development. &lt;/p&gt;

&lt;p&gt;However, personal preference should play a crucial role in this decision. Experimenting with various languages through platforms like Codecademy can provide valuable insights into different syntax styles, aiding in making an informed choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning the Basics and Mastering Fundamentals
&lt;/h2&gt;

&lt;p&gt;Once a language has been chosen, beginners can start their learning journey by gaining familiarity with basic syntax using tools like Codecademy. Subsequently, they can opt to delve deeper into the language to become professional developers. Personal experiences often shape this decision. &lt;/p&gt;

&lt;p&gt;For instance, after exploring HTML, CSS, Ruby, and Javascript, one may seek a comprehensive program to solidify their understanding of software engineering fundamentals. This should include mastering of the core concepts from a broader perspective. As you progress through this journey, you‘ll realize that the language itself becomes secondary to you. &lt;/p&gt;

&lt;p&gt;This shift in mindset transforms your perception from "learning a programming language" to "learning Software Engineering using the programming language." By recognizing the importance of fundamentals, you become equipped to navigate and adapt to any programming language you encounter.&lt;/p&gt;

&lt;p&gt;The significance of learning software engineering fundamentals cannot be overstated. These skills form a solid foundation that transcends specific programming languages. &lt;strong&gt;As the tech industry evolves, the popularity of languages may fluctuate, but a strong grasp of software engineering principles remains invaluable&lt;/strong&gt;. By focusing on fundamentals, aspiring developers ensure their abilities extend beyond the limitations of specific languages, enabling them to embrace new languages in the future, such as Python, Java, or Golang, with ease.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Considerations
&lt;/h2&gt;

&lt;p&gt;In conclusion, it is crucial for beginners to adopt a holistic approach to language selection and learning. Rather than fixating on the popularity of a language or becoming specialized in a single tool, aspiring developers should prioritize gaining a deep understanding of software engineering fundamentals.&lt;/p&gt;

&lt;p&gt;By cultivating a higher-level mindset, they can approach language acquisition with confidence and adaptability.&lt;/p&gt;

&lt;p&gt;While this article provides guidance based on personal experiences and research, it is essential to conduct individual research and seek diverse perspectives. The field of software engineering is vast, and opinions may vary among professionals. Therefore, it is crucial to gather information from multiple sources and form an informed opinion.&lt;/p&gt;

&lt;p&gt;In nutshell, by embracing a broader perspective and focusing on fundamental skills, aspiring developers can embark on a fulfilling journey towards becoming masterful Software Engineers.&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>programming</category>
      <category>developer</category>
      <category>career</category>
    </item>
    <item>
      <title>An Introduction to Qt and QML: Building Powerful User Interfaces</title>
      <dc:creator>Deep Singh</dc:creator>
      <pubDate>Sat, 06 May 2023 12:53:01 +0000</pubDate>
      <link>https://forem.com/techishdeep/an-introduction-to-qt-and-qml-building-powerful-user-interfaces-52lj</link>
      <guid>https://forem.com/techishdeep/an-introduction-to-qt-and-qml-building-powerful-user-interfaces-52lj</guid>
      <description>&lt;p&gt;Creating aesthetically beautiful and responsive user interfaces (UIs) is critical in the realm of software development for engaging user experiences. Qt is a popular framework, which offers developers a full box of tools for creating cross-platform applications. &lt;/p&gt;

&lt;p&gt;The Qt Meta-Object Language (QML) provides a declarative way to developing UIs within Qt, allowing for faster development and better user experiences. In this post, we'll go over the fundamentals of Qt and go into the world of QML,learning about its merits and why it's worth implementing your app into Qt/QML.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Qt Framework:
&lt;/h2&gt;

&lt;p&gt;Qt is a robust C++ framework created by The Qt Company. It offers a diverse set of libraries, tools, and APIs for developing applications. You can develop your applications either for desktop, mobile, and embedded systems. It has a wide range of functionality, including GUI creation, network management, file I/O, multimedia, and more.&lt;/p&gt;

&lt;p&gt;Qt's main feature is its cross-platform capabilities, which allow developers to create code once and distribute it across numerous operating systems, including Windows, macOS, Linux, Android, and iOS.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s QML?
&lt;/h2&gt;

&lt;p&gt;QML, an integral part of Qt, is a declarative language designed specifically for building UIs. Rather than writing UI code procedurally, QML allows developers to describe the UI structure and behavior using a hierarchical structure of objects and properties. This approach enables rapid prototyping, efficient development, and easier maintenance of UI code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Declarative Syntax
&lt;/h3&gt;

&lt;p&gt;QML utilizes a clean and intuitive syntax, inspired by &lt;strong&gt;JavaScript&lt;/strong&gt;, to describe UI components and their interactions. With a declarative approach, developers can focus on the structure and appearance of the UI, making it more intuitive and expressive.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rapid Development
&lt;/h3&gt;

&lt;p&gt;QML's simplicity and powerful features facilitate rapid UI development. The ability to create reusable components, utilize layouts for automatic UI resizing, and leverage dynamic property bindings streamlines the development process. Developers can iterate quickly, experiment with different designs, and fine-tune the UI behavior with ease.&lt;/p&gt;

&lt;h3&gt;
  
  
  Easy Integration
&lt;/h3&gt;

&lt;p&gt;QML seamlessly integrates with existing C++ code, allowing developers to combine the power of QML's declarative UI with the robustness and performance of C++. This integration enables the development of complex applications where UI and backend functionality work harmoniously together.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cross-platform Compatibility
&lt;/h3&gt;

&lt;p&gt;Qt's cross-platform nature extends to QML, enabling developers to create UIs that run on multiple operating systems without significant modifications. This versatility saves development time and resources, as UIs can be shared across platforms, reducing the need for platform-specific UI implementations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Designer and Developer Collaboration
&lt;/h3&gt;

&lt;p&gt;Qt Creator, the integrated development environment (IDE) for Qt, offers a visual editor specifically tailored for QML. This feature empowers designers to create UI mockups and prototypes directly, enhancing collaboration between designers and developers. QML's separation of UI and logic facilitates parallel workflows, where designers focus on UI design while developers handle the backend integration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Qt vs QML vs QtQuick
&lt;/h2&gt;

&lt;p&gt;The terms &lt;em&gt;Qt&lt;/em&gt;, &lt;em&gt;QML&lt;/em&gt;, and &lt;em&gt;Qt Quick&lt;/em&gt; are often used interchangeably, but they represent distinct components within the Qt framework. Here's an explanation of the differences and when to use each:&lt;/p&gt;

&lt;h3&gt;
  
  
  Qt
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Qt is a comprehensive C++ framework developed by The Qt Company.&lt;/li&gt;
&lt;li&gt;It provides a wide range of libraries, tools, and APIs for developing applications across various platforms.&lt;/li&gt;
&lt;li&gt;Qt offers functionalities such as GUI creation, network management, file I/O, multimedia, and more.&lt;/li&gt;
&lt;li&gt;It is known for its cross-platform capabilities, allowing developers to write code once and deploy it on multiple operating systems.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  QML
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;QML (Qt Meta-Object Language) is a declarative language designed specifically for building user interfaces.&lt;/li&gt;
&lt;li&gt;It is part of the Qt framework and offers an alternative approach to designing UIs compared to traditional procedural coding.&lt;/li&gt;
&lt;li&gt;With QML, developers describe the structure, behavior, and appearance of UI components using a hierarchical structure of objects and properties.&lt;/li&gt;
&lt;li&gt;QML is based on JavaScript-like syntax and allows rapid prototyping, easy maintenance, and UI code reusability.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Qt Quick
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Qt Quick is a technology built on top of QML. It provides a &lt;em&gt;set of UI components&lt;/em&gt; and &lt;em&gt;a runtime for rendering&lt;/em&gt; them.&lt;/li&gt;
&lt;li&gt;Qt Quick includes &lt;em&gt;pre-built UI components&lt;/em&gt; such as buttons, sliders, and text editors, as well as layout elements like anchors and grids.&lt;/li&gt;
&lt;li&gt;In nutshell, it’s a framework for creating visually rich and interactive user interfaces.&lt;/li&gt;
&lt;li&gt;It leverages hardware acceleration and offers a smooth user experience across various platforms.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When to Use Qt and QML
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use Qt when you need to develop applications that go beyond the scope of UI development. Qt provides extensive functionality for networking, file handling, multimedia, and more. If you require low-level access to system resources or need to implement complex algorithms, Qt's C++ APIs are well-suited.&lt;/li&gt;
&lt;li&gt;Use QML and Qt Quick when the primary focus is on creating modern and visually appealing user interfaces. QML's declarative syntax and Qt Quick's UI controls make it easy to prototype, design, and implement UIs with less code and rapid development cycles. QML is particularly useful for UI-heavy applications, mobile apps, or when collaboration between designers and developers is crucial.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When Not to Use Qt and QML
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If your application has specific performance requirements that demand fine-grained control or low-level optimizations, you might need to rely more on Qt's C++ APIs rather than QML.&lt;/li&gt;
&lt;li&gt;If you're developing a console application, server application, or a background process without a UI, using QML and Qt Quick would be unnecessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;It's also important to note that Qt and QML can be used together. You can create UIs using QML and integrate them with your C++ backend code using Qt. This allows you to take advantage of the power and performance of C++ while benefiting from the ease of use and rapid development capabilities of QML.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Qt and QML work together to create impressive applications with rich features and stunning UIs. With Qt's extensive capabilities and QML's declarative approach, developers can streamline UI development and boost productivity.&lt;/p&gt;

&lt;p&gt;By harnessing the power of Qt and QML, developers can build cross-platform applications that captivate users. The combination enables seamless integration, ensuring a cohesive user experience across different platforms. Whether you're developing for desktop, mobile, or embedded systems, Qt and QML empower you to unleash your creativity and deliver exceptional user interfaces.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>qt</category>
      <category>qml</category>
      <category>cpp</category>
    </item>
    <item>
      <title>The Power of Builder Design Pattern: How to Create Complex Objects with Ease</title>
      <dc:creator>Deep Singh</dc:creator>
      <pubDate>Mon, 01 May 2023 16:50:39 +0000</pubDate>
      <link>https://forem.com/techishdeep/the-power-of-builder-design-pattern-how-to-create-complex-objects-with-ease-49m1</link>
      <guid>https://forem.com/techishdeep/the-power-of-builder-design-pattern-how-to-create-complex-objects-with-ease-49m1</guid>
      <description>&lt;p&gt;The Builder Design Pattern is one of the most widely used patterns in software engineering. It is a creational pattern that allows you to separate the construction of complex objects from their representation.&lt;/p&gt;

&lt;p&gt;The main idea behind the Builder Design Pattern is to create a separate class (the Builder) that is responsible for creating complex objects. The client code then interacts with the Builder to build the desired object. The Builder uses a step-by-step approach to build the object, and each step can be customized to fit the specific needs of the client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I'll be discussing the examples in &lt;em&gt;Python&lt;/em&gt; and &lt;em&gt;C++&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I posted one post before on the same topic. Here, I tried to explain it differently. Please, let me know which tone suits you best. 😄&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Problem with traditional approach
&lt;/h2&gt;

&lt;p&gt;Let us see what kind of problem it can solve.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Builder Pattern&lt;/strong&gt; solves a very specific problem: &lt;strong&gt;Telescoping Constructors&lt;/strong&gt;. To understand it, let us suppose we have the following constructor definitions for class &lt;code&gt;Vehicle&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;number_of_tyres&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number_of_tyres&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This might not look like an issue at the earlier stages but if you have eight optional parameters and you want to represent every useful combination, you'll need 256 constructors. &lt;strong&gt;&lt;em&gt;This would be very cumbersome and would result in a lot of boilerplate code&lt;/em&gt;&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Let's look at an example to see how the Builder Design Pattern works in practice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Builder Design Pattern Participants
&lt;/h2&gt;

&lt;p&gt;First, let's look at various participants of builder design pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Product&lt;/strong&gt; : First, we create the product's blueprint or interface, which will define the steps required to build the product. This interface can be implemented by different classes to produce different products.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Concrete Builder&lt;/strong&gt; : Next, we create a concrete builder class that implements the product's interface and provides a method for each step required to build the product. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The concrete builder class &lt;strong&gt;&lt;em&gt;also has a method to return the final product&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Director&lt;/strong&gt; : Finally, we create a director class that will use the concrete builder to build the product. &lt;em&gt;The director class is responsible for invoking the concrete builder's methods in the correct order to produce the final product&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Builder design pattern Diagrams
&lt;/h2&gt;

&lt;p&gt;Let's see through diagrams how builder design pattern looks or works.&lt;br&gt;
Imagine we're building the same car as above. The car has many attributes, such as the &lt;em&gt;engine type&lt;/em&gt;, the &lt;em&gt;number of doors&lt;/em&gt;, and the &lt;em&gt;color&lt;/em&gt;. &lt;/p&gt;
&lt;h3&gt;
  
  
  Sequence diagram
&lt;/h3&gt;

&lt;p&gt;Below are the steps required to build a car, &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember, we can use different concrete builders to create different types of cars with different attributes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Im-AXkTl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bz7yvqbii7bxqyqzwi5i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Im-AXkTl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bz7yvqbii7bxqyqzwi5i.png" alt="Sequence Diagram" width="490" height="777"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below is the source code for above sequnce diagram in &lt;em&gt;PlantUML&lt;/em&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@startuml
title Car Building Sequence Diagram

actor Client

Client -&amp;gt; CarDirector: create director
Client -&amp;gt; AudiCarBuilder: create audi builder
CarDirector -&amp;gt; CarDirector: set builder to audi builder
Client -&amp;gt; CarDirector: build car
CarDirector -&amp;gt; AudiCarBuilder: add engine
AudiCarBuilder -&amp;gt; Car: set engine
CarDirector -&amp;gt; AudiCarBuilder: add doors
AudiCarBuilder -&amp;gt; Car: set doors
CarDirector -&amp;gt; AudiCarBuilder: paint car
AudiCarBuilder -&amp;gt; Car: paint
CarDirector -&amp;gt; AudiCarBuilder: get car
AudiCarBuilder -&amp;gt; Car: return car
CarDirector -&amp;gt; Client: return car
@enduml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Class Diagrams
&lt;/h3&gt;

&lt;p&gt;To give you a snapshot, this is how our &lt;em&gt;class skeletons&lt;/em&gt; would look like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s4CqZpOv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apjp03a7ev9cqeqvvgu0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s4CqZpOv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/apjp03a7ev9cqeqvvgu0.png" alt="Class Diagrams" width="800" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In plantUML, it looks as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@startuml

class Car {
    - engine_type: str
    - num_doors: int
    - color: str
    + set_engine(engine_type: str): void
    + set_doors(num_doors: int): void
    + paint(color: str): void    
}

class AudiCarBuilder {
    - car: Car
    + AudiCarBuilder()
    + add_engine(engine_type: str): void
    + add_doors(num_doors: int): void
    + paint(color: str): void
    + get_car(): Car
}

class CarDirector {
  - builder: ICarBuilder
  + CarDirector(audiCarBuilder: ICarBuilder)
  + build_car(): Car
}

AudiCarBuilder -&amp;gt; Car: 1
CarDirector -&amp;gt; AudiCarBuilder

@enduml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Builder design pattern implementation
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1 Declare interface of our final product&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, let's define the &lt;strong&gt;product&lt;/strong&gt;, which is &lt;strong&gt;Car&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;engine_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;num_doors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;

        &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;engine_type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; 
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;engine_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;engine_type&lt;/span&gt; 

        &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_doors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_doors&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; 
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;num_doors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;num_doors&lt;/span&gt; 

        &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; 
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;    
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our Final product &lt;code&gt;Car&lt;/code&gt; has &lt;em&gt;engine type&lt;/em&gt;, the &lt;em&gt;number of doors&lt;/em&gt;, and the &lt;em&gt;color&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2. Define the Builder class to implement each build step&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next step is to define the &lt;strong&gt;concrete builder class&lt;/strong&gt; that implements the method for each step required to build the above product. &lt;/p&gt;

&lt;p&gt;Remember, we also need to define &lt;strong&gt;&lt;em&gt;a method to return the final product&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AudiCarBuilder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;engine_type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;engine_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_doors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_doors&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_doors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_doors&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apart from defining various methods to build our final product, we also define the method to return it through function &lt;code&gt;get_car()&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Lastly, create a director class to build the final product. &lt;/p&gt;

&lt;p&gt;Remember to &lt;em&gt;invoke each construction step/method in the correct order to produce the final product&lt;/em&gt;. In our example is to first install the engine before attaching doors or starting painting. :happy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CarDirector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;build_car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"V8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_doors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Red"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_car&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our Builder implementation is now complete. 🙂&lt;/p&gt;

&lt;p&gt;Let's use it in our code base. It's too easy now to use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;AudiCarBuilder&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;director&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CarDirector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;director&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;build_car&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Engine type: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;engine_type&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Number of doors: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;num_doors&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"Color: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How builder pattern helped us
&lt;/h2&gt;

&lt;p&gt;By using the Builder pattern, we can create different concrete builders to build different types of cars with different attributes. &lt;/p&gt;

&lt;p&gt;We can also modify the steps required to build a car without modifying the Car class itself, making our code more flexible and easier to maintain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Complete implementation in C++
&lt;/h2&gt;

&lt;p&gt;Now, I feel it must be easy for you to understand how builder pattern can be written in C++ also. Still, for your reference I'm giving the source code here. 🙂&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;string&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;engine_type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;num_doors&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;set_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;engine_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;engine_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;engine_type&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;set_doors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;num_doors&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;num_doors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;num_doors&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"Car with "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;engine_type&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" engine, "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;num_doors&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" doors, and "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" color."&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ICarBuilder&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;add_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;engine_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;add_doors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;num_doors&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;get_car&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AudiCarBuilder&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ICarBuilder&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
    &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;add_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;engine_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;engine_type&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;add_doors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;num_doors&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_doors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_doors&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;get_car&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CarDirector&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
    &lt;span class="n"&gt;ICarBuilder&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="n"&gt;CarDirector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ICarBuilder&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;build_car&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;add_engine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"V6"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;add_doors&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Red"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;AudiCarBuilder&lt;/span&gt; &lt;span class="n"&gt;audiBuilder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;CarDirector&lt;/span&gt; &lt;span class="n"&gt;director&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;audiBuilder&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;director&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;build_car&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;Car&lt;/span&gt; &lt;span class="n"&gt;audiCar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;audiBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_car&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"Audi car: "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;audiCar&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;💡 Remember, same way you can also add another car builder, say &lt;em&gt;FordCarBuilder&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, the Builder pattern is a powerful design pattern that can help us create complex objects with many attributes in a more organized and maintainable way. By separating the construction of an object from its representation, we can create different types of objects with different attributes using the same building process.&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@kellysikkema?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Kelly Sikkema&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/ml1IgjV8OvY?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>programming</category>
      <category>productivity</category>
      <category>python</category>
    </item>
    <item>
      <title>The Power of Pre-Commit for Python Developers: Tips and Best Practices</title>
      <dc:creator>Deep Singh</dc:creator>
      <pubDate>Mon, 01 May 2023 14:44:09 +0000</pubDate>
      <link>https://forem.com/techishdeep/maximize-your-python-efficiency-with-pre-commit-a-complete-but-concise-guide-39a5</link>
      <guid>https://forem.com/techishdeep/maximize-your-python-efficiency-with-pre-commit-a-complete-but-concise-guide-39a5</guid>
      <description>&lt;p&gt;As a software developer, ensuring high-quality and consistent code is vital for seamless operations. Precommit is a powerful tool that can assist in achieving this by automatically checking the code before it's committed. In this article, we'll delve into using precommit with a Python project to enhance code quality and optimize the development process.&lt;/p&gt;

&lt;p&gt;Let's have a look what we're going to discuss today:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Precommit: How it works?&lt;/li&gt;
&lt;li&gt;Setup Precommit in Python&lt;/li&gt;
&lt;li&gt;Write code-checking precommit hooks&lt;/li&gt;
&lt;li&gt;Customize Precommit&lt;/li&gt;
&lt;li&gt;Benefits of Precommit in Python&lt;/li&gt;
&lt;li&gt;Precommit configuration mistakes to avoid&lt;/li&gt;
&lt;li&gt;Integrate Precommit with CI workflow&lt;/li&gt;
&lt;li&gt;Best practices for Precommit in Python&lt;/li&gt;
&lt;li&gt;Conclusion and Next Steps&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then let's start now without any further delay 😊&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Precommit and how does it work?
&lt;/h2&gt;

&lt;p&gt;Precommit is a tool used by developers to ensure code quality by running checks on code before it is committed to the repository. &lt;/p&gt;

&lt;p&gt;This tool relies on a file that contains a list of hooks that execute scripts or commands to check the code. If the code fails the checks, the commit is rejected, and the developer is asked to fix the issues. &lt;/p&gt;

&lt;p&gt;Precommit can be used to enforce consistent code style, syntax errors, and security vulnerabilities. It also supports plugins that can extend its functionality and integrate with other tools like linters, formatters, and static analysis tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup Precommit in Python
&lt;/h2&gt;

&lt;p&gt;Running &lt;code&gt;husky&lt;/code&gt; and &lt;code&gt;lint-staged&lt;/code&gt; takes much more time than I expected. Sometimes it even took more time than the committing process itself (including checking the files for any errors).&lt;/p&gt;

&lt;p&gt;To set up precommit in a Python project, you'll need to follow a few steps.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install precommit:&lt;/strong&gt; First, you need to install precommit as a dev dependency in your project. You can do this by running the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   pip &lt;span class="nb"&gt;install &lt;/span&gt;pre-commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a precommit configuration file&lt;/strong&gt;: Next, create a configuration file for precommit. In this file, you can specify the hooks to run on commit.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can do this by adding a &lt;code&gt;.pre-commit-config.yaml&lt;/code&gt; file to the root of your project. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Define precommit hooks:&lt;/strong&gt; Now, you can define the hooks that precommit will run. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For example, you can add a hook to format your code using &lt;em&gt;black&lt;/em&gt;. You can also add a hook to lint your code using a tool &lt;em&gt;flake8&lt;/em&gt; .&lt;/p&gt;

&lt;p&gt;Here's an example of how to define a precommit hook for these tasks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;   &lt;span class="na"&gt;repos&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
   &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/psf/black&lt;/span&gt;
     &lt;span class="na"&gt;rev&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;21.7b0&lt;/span&gt;
     &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;black&lt;/span&gt;
       &lt;span class="na"&gt;language_version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;python3.8&lt;/span&gt;

   &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/PyCQA/flake8&lt;/span&gt;
     &lt;span class="na"&gt;rev&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;3.9.2&lt;/span&gt;
     &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;flake8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well discuss about various of these parameters in our coming sections.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run &lt;code&gt;pre-commit install&lt;/code&gt; to install the Git hooks:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nv"&gt;$ &lt;/span&gt;pre-commit &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Commit your changes to git as usual&lt;/em&gt;. The pre-commit hooks will &lt;strong&gt;&lt;em&gt;run automatically&lt;/em&gt;&lt;/strong&gt; before the commit is created.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Test precommit hooks&lt;/strong&gt;: Although &lt;strong&gt;&lt;em&gt;pre-commit runs automatically&lt;/em&gt;&lt;/strong&gt; when you commit your changes to Git. However, if you want you &lt;strong&gt;&lt;em&gt;can run them manually&lt;/em&gt;&lt;/strong&gt; on your codebase. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can do this by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   pre-commit run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;This will scan only those files which are &lt;em&gt;staged&lt;/em&gt; in git(through &lt;code&gt;git add&lt;/code&gt;).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Add and commit changes&lt;/strong&gt;: You can now run &lt;code&gt;git commit&lt;/code&gt; as usual, and &lt;em&gt;precommit will automatically run&lt;/em&gt; the defined hooks and check your code before committing it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If pre-commit &lt;em&gt;detects any issues&lt;/em&gt;, it will print a message and prevent the commit from proceeding. You can then fix the issues and try to commit again.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Write code-checking precommit hooks
&lt;/h2&gt;

&lt;p&gt;We have already seen an example of how to write a pre-commit hook configuration. Now, let's delve deeper into it. Firstly, let's take another look at the sample configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;repos&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/PyCQA/flake8&lt;/span&gt;
  &lt;span class="na"&gt;rev&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;3.9.2&lt;/span&gt;
  &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt;   &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;flake8&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;flake8&lt;/span&gt;
      &lt;span class="na"&gt;types&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;python&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt;   &lt;span class="s"&gt;--max-line-length=88&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt;   &lt;span class="s"&gt;--ignore=E203,E501,W503&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a pre-commit hook configuration that &lt;em&gt;installs&lt;/em&gt; and &lt;em&gt;runs&lt;/em&gt; the &lt;code&gt;flake8&lt;/code&gt; linter on the specified files in a project. &lt;/p&gt;

&lt;p&gt;The configuration specifies  the repository URL of &lt;strong&gt;flake8&lt;/strong&gt; under the &lt;code&gt;repos&lt;/code&gt; section. It also specifies which version to use. &lt;/p&gt;

&lt;p&gt;The hook has the following properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;id&lt;/code&gt;: The unique identifier of the hook, which is &lt;code&gt;flake8&lt;/code&gt; in this case.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;name&lt;/code&gt;: The human-readable name of the hook that would be displayed during run.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;types&lt;/code&gt;: A list of file types that this hook should be run on. In this case, the hook runs on &lt;em&gt;python&lt;/em&gt; files.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;args&lt;/code&gt;: The arguments specifies additional arguments to pass to the command (in this case, &lt;code&gt;--max-line-length=88&lt;/code&gt; to enforce PEP8 line length limit and &lt;code&gt;--ignore=E203,E501,W503&lt;/code&gt; to ignore certain Flake8 errors).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overall, this configuration sets up an &lt;em&gt;flake8&lt;/em&gt; hook that lints common errors in your python files before they are committed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To ensure efficient development processes, it's crucial to consider the performance impact of the checks performed by &lt;em&gt;precommit&lt;/em&gt; hooks. Long-running checks can significantly impede the team's productivity, so it's vital to optimize these checks.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Custom hooks to fit your needs
&lt;/h2&gt;

&lt;p&gt;By customizing your precommit configuration, you can ensure that your team's code is held to the highest standards of quality and consistency, while also streamlining your development workflow. &lt;/p&gt;

&lt;p&gt;There are two ways to customize &lt;em&gt;hooks&lt;/em&gt; as per your needs. We'll discuss both of them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Customize existing hook
&lt;/h3&gt;

&lt;p&gt;One way to customize precommit is by &lt;em&gt;configuring&lt;/em&gt; the built-in hooks. Each precommit hook has a variety of configuration options that you can use to control its behavior. &lt;/p&gt;

&lt;p&gt;For example, you might want to &lt;em&gt;adjust the severity level&lt;/em&gt; of a particular hook's warnings, or configure a linter to ignore certain directories or files. We already saw this example in our last section.&lt;/p&gt;

&lt;p&gt;Adding to the same example, let's ask &lt;code&gt;flake8&lt;/code&gt; hook to ignore the &lt;code&gt;venv&lt;/code&gt; directory, you might add the following configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;repos&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/pre-commit/mirrors-flake8&lt;/span&gt;
    &lt;span class="na"&gt;rev&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v3.9.2&lt;/span&gt;
    &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;flake8&lt;/span&gt;
        &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;--exclude=venv&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we're using the &lt;code&gt;--exclude&lt;/code&gt; option to tell &lt;code&gt;flake8&lt;/code&gt; to skip any files or directories that match the pattern &lt;code&gt;venv&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Writing Custom hooks from scratch
&lt;/h3&gt;

&lt;p&gt;While precommit comes with a variety of built-in hook. But you can also customize precommit by creating your own hooks. This can be particularly useful if you have specific checks or processes that are unique to your project or team.&lt;/p&gt;

&lt;p&gt;You can write hooks in any language (python, c++, javascript, etc.) and use them to run custom scripts or commands on your code. &lt;/p&gt;

&lt;p&gt;To create a custom precommit hook, you first need to &lt;em&gt;define a new hook in your precommit configuration file&lt;/em&gt;. You'll need to specify the &lt;code&gt;name&lt;/code&gt; of the hook, the &lt;em&gt;script or command&lt;/em&gt; to run, and any &lt;em&gt;arguments&lt;/em&gt; or options that the script requires. &lt;/p&gt;

&lt;p&gt;For example, if you wanted to create a hook that checks for the presence of specific comments in your code, you might create a hook like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;repos&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;local&lt;/span&gt;
    &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;custom-comment-check&lt;/span&gt;
        &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Check for Required Comments&lt;/span&gt;
        &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sh&lt;/span&gt;
        &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-c"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;grep&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;-r&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;'TODO'&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;."&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we're using the &lt;code&gt;grep&lt;/code&gt; command to search for the string "TODO" in all files in the current directory and its subdirectories. This will catch any instances of the "TODO" comment that might indicate unfinished code or tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notice&lt;/strong&gt; that here we used &lt;code&gt;entry&lt;/code&gt;: The command to execute for this hook, which is &lt;code&gt;sh&lt;/code&gt; in this case to run the &lt;em&gt;shell&lt;/em&gt; command.&lt;/p&gt;

&lt;p&gt;Once you've defined your custom hook, you can run it along with the other precommit hooks by committing your code. If the hook fails, the commit will be rejected, and you'll be prompted to fix the issue before trying again.&lt;/p&gt;

&lt;p&gt;Whether you're creating custom hooks or configuring existing ones, precommit is a powerful tool that can help you take your development process to the next level.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Precommit in Python
&lt;/h2&gt;

&lt;p&gt;Now, let's explore some of the benefits of using precommit in your Python project. By convention, it should have been discussed in the beginning. But I didn't want you to bother with theoretical explainations without showing practical aspect.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Improved Code Quality&lt;/strong&gt;: One of the primary benefits is to improve the overall quality of your code. It ensure that code is consistent, readable, and follows best practices. For example, you can use precommit to check for syntax errors, enforce code formatting standards, and detect potential bugs or security vulnerabilities. This ensures that the code you commit is of high quality, reducing the likelihood of bugs or errors that could cause problems down the line.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reduced Time and Effort&lt;/strong&gt;: Precommit automates several aspects of code testing, thereby reducing the time and effort required to manually check code for errors. Instead of running individual checks, precommit runs all checks in a single command, saving developers valuable time that can be used to focus on other tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy to Use&lt;/strong&gt;: Precommit is easy to set up and use in your Python project. You can install it using pip, and the configuration file can be easily customized to meet the specific needs of your project. Precommit supports a wide range of hooks and linters, making it versatile enough to fit almost any project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Improved Collaboration&lt;/strong&gt;: Precommit helps to improve collaboration among team members. By running precommit checks before pushing changes to the repository, everyone can be confident that the code follows the same standards and conventions. This makes it easier for new team members to get up to speed and maintain consistency throughout the project.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Precommit configuration mistakes to avoid
&lt;/h2&gt;

&lt;p&gt;While using precommit can significantly improve code quality and development workflow, it's important to configure it correctly to avoid common mistakes that can lead to issues down the line. &lt;/p&gt;

&lt;p&gt;One common mistake is &lt;strong&gt;not specifying the correct version&lt;/strong&gt; of a dependency, which can cause compatibility issues with other packages. It's essential to define the correct versions of all packages used in your precommit hooks to ensure compatibility and avoid any unexpected behavior.&lt;/p&gt;

&lt;p&gt;Another common mistake is &lt;strong&gt;forgetting to update precommit configuration&lt;/strong&gt; when adding new hooks or changing existing ones. It's crucial to keep precommit configuration up to date and test the hooks regularly to catch any issues before they affect the codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrate Precommit with CI workflow
&lt;/h2&gt;

&lt;p&gt;Integrating precommit with your CI workflow can further improve code quality by catching issues before they make it to production. When precommit is integrated with a CI tool like Jenkins or Travis CI, the hooks are automatically run on every code change, ensuring that all code meets the same quality standards. Any failed hooks will prevent the code from being merged into the main branch, reducing the risk of introducing bugs or vulnerabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best practices for Precommit in Python
&lt;/h2&gt;

&lt;p&gt;Here are some best practices for using precommit in your Python development workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use pre-commit.ci&lt;/strong&gt;: Pre-commit.ci is a service that runs precommit hooks on your codebase and provides feedback on code quality. It can be integrated with your CI workflow and ensures consistent code quality across all developers.&lt;/li&gt;
&lt;li&gt;Use a virtual environment: Precommit hooks can require specific versions of libraries and tools. Using a virtual environment ensures that the hooks are run in a consistent environment and reduces the chances of version conflicts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configure hooks for the right files:&lt;/strong&gt; Some hooks can be expensive and time-consuming. Configuring hooks to run on the right files reduces build times and speeds up the development process.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, Precommit is a powerful tool for improving code quality and consistency in Python projects. &lt;/p&gt;

&lt;p&gt;By setting up custom hooks and integrating it with your CI workflow, you can catch errors and warnings before they are committed, streamlining your development process. With proper configuration and best practices, Precommit can significantly reduce bugs, save time, and enhance the overall quality of your codebase. &lt;/p&gt;

&lt;p&gt;By following the steps outlined in this article, you can easily get started with Precommit and take your Python development to the next level.&lt;/p&gt;

</description>
      <category>python</category>
      <category>webdev</category>
      <category>programming</category>
      <category>git</category>
    </item>
    <item>
      <title>Builder Design Pattern Explained Easily</title>
      <dc:creator>Deep Singh</dc:creator>
      <pubDate>Tue, 25 Apr 2023 14:56:45 +0000</pubDate>
      <link>https://forem.com/techishdeep/builder-design-pattern-explained-easily-57g9</link>
      <guid>https://forem.com/techishdeep/builder-design-pattern-explained-easily-57g9</guid>
      <description>&lt;p&gt;&lt;em&gt;The builder pattern&lt;/em&gt; helps to separate the construction of a complex object from its representation so that the same construction process can produce different representations(outputs).&lt;/p&gt;

&lt;p&gt;Let us see what kind of problem it can solve.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Builder Pattern&lt;/strong&gt; solves a very specific problem: &lt;strong&gt;Telescoping Constructors&lt;/strong&gt;. To understand it, let us suppose we have the following constructor definitions for class &lt;code&gt;Vehicle&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Vehicle&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Vehicle&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;number_of_tyres&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number_of_tyres&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This might not look like an issue at the earlier stages but if you have eight optional parameters and you want to represent every useful combination, you'll need 256 constructors.&lt;/p&gt;

&lt;p&gt;Moreover, suppose there is another constructor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Vehicle&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;number_of_headlights&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number_of_headlights&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;number_of_headlights&lt;/code&gt; has the same type as &lt;code&gt;number_of_tyres&lt;/code&gt; mentioned in the earlier constructor. Hence polymorphism concept of having different constructors for different parameters fails here.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;em&gt;Telescoping Constructors&lt;/em&gt; Problem
&lt;/h2&gt;

&lt;p&gt;If you use the Builder Pattern instead, you can simply:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;VehicleBuilder&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;SetName&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Car"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;SetTyres&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;SetHeadlights&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So in short, builder design pattern:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;allows using the same construction process to create different representations of an object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;simplifies the creation of complex objects&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Given that the builder pattern sets up a method for constructing new objects, it is understandably categorized as a &lt;strong&gt;creational design pattern&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Builder Design Pattern Participants
&lt;/h2&gt;

&lt;p&gt;The Builder Design Pattern has &lt;strong&gt;four major participants:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Director&lt;/strong&gt; : Director is the one which constructs the complex object by using the builder's interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Builder&lt;/strong&gt; : Provides an interface to create the components of a complex object/product.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Concrete Builder&lt;/strong&gt; : This actor &lt;strong&gt;creates all the parts needed of a complex object&lt;/strong&gt;. It contains a reference to the final product/output. Thus client gets the final product from this actor once object construction is completed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Product&lt;/strong&gt; : This is the final object to be constructed. It provides the interface to build all the parts of the final object and assemble them.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;strong&gt;director&lt;/strong&gt; performs the decisive process of the builder pattern, the &lt;strong&gt;separation&lt;/strong&gt; of the &lt;strong&gt;production&lt;/strong&gt; of an object/product from &lt;strong&gt;the client.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The client :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;creates a &lt;strong&gt;concrete builder&lt;/strong&gt; class object for the required product.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;creates a &lt;strong&gt;director&lt;/strong&gt; object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;injects the &lt;em&gt;concrete builder class object&lt;/em&gt; , created in the first step to the &lt;em&gt;director&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;asks the &lt;em&gt;director&lt;/em&gt; to &lt;em&gt;construct&lt;/em&gt; the object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;gets the final product from the concrete builder class object.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Builder Design Pattern in Real Life
&lt;/h2&gt;

&lt;p&gt;To explain the builder design pattern, let's take a real-life example of a burger restaurant where a customer orders a meal. The meal can consist of the main item(cheeseburger, chicken burger, etc.), a side item (French fries, etc.), and a drink(coke, coffee).&lt;/p&gt;

&lt;p&gt;The order is passed to the front desk executive who acts as a &lt;strong&gt;director&lt;/strong&gt; in this case. He will pass the order to the main chef who in turn asks the respective chefs(concrete builder) to prepare the asked meal. This entire process takes place behind the scenes. The customer does not know what is happening in the kitchen to carry out his order. However, he gets his order served at his table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Builder Design Pattern UML Diagrams
&lt;/h2&gt;

&lt;p&gt;Let us take a &lt;em&gt;vehicle&lt;/em&gt; building example where different types of vehicles are manufactured such as cars, bikes, etc. These are the &lt;strong&gt;final products&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;IVehicleBuilder&lt;/code&gt; is the interface used to create parts of the final product/object. The final assembly process is described in &lt;strong&gt;Product&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CarBuilder&lt;/code&gt; and &lt;code&gt;BikeBuilder&lt;/code&gt; are the concrete implementations of&lt;br&gt;
&lt;code&gt;IVehicleBuilder&lt;/code&gt;. The first three methods fit the engine, tires, and headlights to the vehicle. &lt;code&gt;GetVehicle()&lt;/code&gt; will return the ultimate product.&lt;/p&gt;

&lt;p&gt;Finally, &lt;code&gt;VehiclePlant&lt;/code&gt; will be acting as &lt;strong&gt;director&lt;/strong&gt;. It is ultimately responsible for constructing the vehicle, and build the product with &lt;code&gt;IVehicleBuilder&lt;/code&gt; interface. &lt;em&gt;It uses the same construct() method to create different types of vehicles.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Class Diagram
&lt;/h3&gt;

&lt;p&gt;The below graphic shows the UML class diagram of a &lt;em&gt;builder pattern&lt;/em&gt; consisting of several entities &lt;strong&gt;interacting with each other.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4sx8php15qviaixo0ryi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4sx8php15qviaixo0ryi.png" alt="Builder Pattern Class Diagram"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;
  
  
  Sequence Diagram
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frasawwphfocnl6hl36tl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frasawwphfocnl6hl36tl.png" alt="Builder Pattern Sequence Diagram"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;
&lt;h3&gt;
  
  
  In C++
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;IVehicleBuilder class:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;IVehicleBuilder&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CarBuilder Class:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CarBuilder&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;IVehicleBuilder&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
    &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Engine Added"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Tyres Inserted"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Fitted Headlight"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Vehicle class:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Vehicle&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
    &lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;emplace_back&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;PrintDetails&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;part&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;VehiclePlant class:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VehiclePlant&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
    &lt;span class="n"&gt;IVehicleBuilder&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;vehicleBuilder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="n"&gt;VehiclePlant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IVehicleBuilder&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;vBuilder&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;vehicleBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vBuilder&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;vehicleBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;vehicleBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;vehicleBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Client program:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;CarBuilder&lt;/span&gt; &lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;VehiclePlant&lt;/span&gt; &lt;span class="n"&gt;vehiclePlant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;vehiclePlant&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PrintDetails&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  In Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;abc&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ABC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;abstractmethod&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Vehicle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__parts__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__parts__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;PrintDetails&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__parts__&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;IVehicleBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ABC&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nd"&gt;@abstractmethod&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="nd"&gt;@abstractmethod&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="nd"&gt;@abstractmethod&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="nd"&gt;@abstractmethod&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CarBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IVehicleBuilder&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicle__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Vehicle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicle__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Engine Added&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicle__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Tyres Inserted&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicle__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Fitted Headlight&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicle__&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VehiclePlant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vBuilder&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicleBuilder__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vBuilder&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicleBuilder__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicleBuilder__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicleBuilder__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;carBuilder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CarBuilder&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;vehiclePlant&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;VehiclePlant &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;vehiclePlant&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Construct&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;vehicle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PrintDetails&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;br&gt;
By default, Python does not provide support for abstract classes. However, Python comes with a module that provides the base for defining &lt;strong&gt;&lt;em&gt;Abstract Base classes(ABC)&lt;/em&gt;&lt;/strong&gt;. &lt;code&gt;ABC&lt;/code&gt; works by decorating methods of the base class as abstract and then registering concrete classes as implementations of the abstract base. A method becomes abstract when decorated with the keyword &lt;code&gt;@abstractmethod&lt;/code&gt;.&lt;br&gt;
For Example (Reference taken from geeksforgeeks.com)&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;abc&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ABC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;abstractmethod&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Polygon&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ABC&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nd"&gt;@abstractmethod&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;noofsides&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Triangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Polygon&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c1"&gt;# overriding abstract method
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;noofsides&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;I have 3 sides&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Driver code
&lt;/span&gt;&lt;span class="n"&gt;R&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Triangle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;noofsides&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ​Variation of the Builder pattern
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The builder pattern&lt;/strong&gt; has a slightly modified version where &lt;em&gt;build methods&lt;/em&gt; are chained to each other like below. This method is called the &lt;strong&gt;Fluent Builder&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;    &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is accomplished by returning itself from each of the build methods. The final build() method returns the final object. Moreover, note that you don't need &lt;strong&gt;Director&lt;/strong&gt; class here.&lt;/p&gt;

&lt;p&gt;Here, is the alternate implementation:&lt;/p&gt;

&lt;h3&gt;
  
  
  in C++
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;IVehicleBuilder Class&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;IVehicleBuilder&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;IVehicleBuilder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;virtual&lt;/span&gt; &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;CarBuilder class&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CarBuilder&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;IVehicleBuilder&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
    &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CarBuilder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nl"&gt;public:&lt;/span&gt;
    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Engine Added"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Tyres Inserted"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Fitted Headlight"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;main program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;CarBuilder&lt;/span&gt; &lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PrintDetails&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use pointers instead of references. In that case, define &lt;strong&gt;Fit...()&lt;/strong&gt; methods like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Engine Added"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace your chain calls with the -&amp;gt; operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also replace your &lt;code&gt;GetVehicle()&lt;/code&gt; method with &lt;strong&gt;function operator&lt;/strong&gt; to yield the final product:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CarBuilder&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;IVehicleBuilder&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;

    &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="k"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;()()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;CarBuilder&lt;/span&gt; &lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;Vehicle&lt;/span&gt; &lt;span class="n"&gt;vehicle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;carBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;()();&lt;/span&gt;
    &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PrintDetails&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  in Python
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CarBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IVehicleBuilder&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;super&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicle__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Vehicle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicle__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Engine Added&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicle__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Tyres Inserted&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicle__&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AddPart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Fitted Headlight&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__vehicle__&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;vehicle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CarBuilder&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nc"&gt;FitEngine&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nc"&gt;FitTyres&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nc"&gt;FitHeadlight&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nc"&gt;GetVehicle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;vehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PrintDetails&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advantages vs Disadvantages
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ​Benefits
&lt;/h3&gt;

&lt;p&gt;As the construction process is totally segregated from the final object/product, so you can easily change the steps required to  build the product.&lt;/p&gt;

&lt;p&gt;As the director isn't aware of the builder process, and the build process doesn't have to change so you can easily insert new &lt;strong&gt;concrete builder&lt;/strong&gt; classes to build a new product.&lt;/p&gt;

&lt;h3&gt;
  
  
  Disadvantages
&lt;/h3&gt;

&lt;p&gt;There is a &lt;strong&gt;close coupling&lt;/strong&gt; between the product, the concrete builder, and the builder interface. Hence the change in any class requires changes in all the other classes. This makes any &lt;strong&gt;changes&lt;/strong&gt; to the &lt;strong&gt;pattern&lt;/strong&gt; a little &lt;strong&gt;difficult.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Also, if we want a mutable object (an object which can be modified after the creational process is over), we should not use this pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Words
&lt;/h2&gt;

&lt;p&gt;The builder pattern really is a powerful pattern to solve complex object creation problems.&lt;/p&gt;

&lt;p&gt;However, many programmers can be tempted to use a builder design pattern, and overlook simpler and perhaps more elegant solutions. So as a thumb rule, you don't need to use a builder pattern if the object can be constructed easily, and has a limited number of constructor parameters.&lt;/p&gt;

&lt;p&gt;A Builder pattern is usually a better candidate if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;when we want to create a complex object, which is composed of multiple parts and creation steps. Each of these steps might need to follow a specific order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We want to decouple the construction process from its representation or output. This will eventually help us to insert more &lt;em&gt;concrete builders&lt;/em&gt; whenever needed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>java</category>
      <category>cpp</category>
      <category>designpatterns</category>
      <category>python</category>
    </item>
    <item>
      <title>The Future of Serverless Computing: A Comprehensive Look at the Benefits and Challenges</title>
      <dc:creator>Deep Singh</dc:creator>
      <pubDate>Sun, 23 Apr 2023 19:28:21 +0000</pubDate>
      <link>https://forem.com/techishdeep/the-future-of-serverless-computing-a-comprehensive-look-at-the-benefits-and-challenges-202a</link>
      <guid>https://forem.com/techishdeep/the-future-of-serverless-computing-a-comprehensive-look-at-the-benefits-and-challenges-202a</guid>
      <description>&lt;p&gt;Serverless computing has become a popular approach for building and deploying applications in recent years. This technology promises to simplify the development process, improve scalability, and reduce costs. However, like any technology, serverless computing has its own set of benefits and challenges that developers need to consider before adopting it.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore the benefits and challenges of serverless computing in depth, providing real-world examples and practical advice for developers. Whether you're considering serverless for your next project or simply curious about this emerging technology, this article has everything you need to know.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Serverless Computing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Simplified Development Process
&lt;/h3&gt;

&lt;p&gt;One of the biggest benefits of serverless computing is its ability to simplify the development process. With serverless, developers can focus on writing code without having to worry about managing infrastructure or deploying their applications. This is because serverless platforms handle these tasks automatically, allowing developers to focus on what they do best - writing code.&lt;/p&gt;

&lt;p&gt;For example, consider the process of building a traditional web application. In this scenario, developers need to provision servers, install software, configure networking, and manage databases. With serverless, all of these tasks are handled by the platform, freeing up developers to focus on the business logic of their applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Improved Scalability
&lt;/h3&gt;

&lt;p&gt;Another major benefit of serverless computing is improved scalability. With traditional infrastructure, scaling can be a complex and time-consuming process. However, with serverless, scaling is handled automatically by the platform.&lt;/p&gt;

&lt;p&gt;This means that applications can handle spikes in traffic without any intervention from developers. For example, consider a website that experiences a surge in traffic during a holiday sale. With serverless, the platform automatically scales up to handle the increased load, ensuring that the website remains responsive and available.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reduced Costs
&lt;/h3&gt;

&lt;p&gt;One of the most significant benefits of serverless computing is its ability to reduce costs. With traditional infrastructure, organizations need to pay for servers, storage, networking, and other resources even when they're not being used. With serverless, organizations only pay for the resources that are consumed by their applications.&lt;/p&gt;

&lt;p&gt;This makes serverless a cost-effective option for organizations of all sizes. For example, consider a startup that's building a new application. With traditional infrastructure, the startup would need to invest a significant amount of money upfront in servers, storage, and other resources. With serverless, the startup can start small and only pay for the resources that are actually used, making it easier to manage costs and stay within budget.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-World Examples of Serverless Computing
&lt;/h2&gt;

&lt;p&gt;Now that we have a better understanding of the benefits and challenges of serverless computing, let's take a look at some real-world examples of how organizations are using this technology to improve their operations and services.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Airbnb&lt;/strong&gt;: As one of the world's largest online marketplaces for lodging, Airbnb handles an enormous amount of data and user requests. To handle this load efficiently, they turned to serverless computing. They use AWS Lambda to process user-generated data, which allows them to scale their infrastructure quickly and easily based on demand. This approach has helped them to reduce costs and improve performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Capital One&lt;/strong&gt;: Capital One is a financial services company that has leveraged serverless computing to create a more efficient and cost-effective system for handling customer requests. They use AWS Lambda to manage their mobile banking application, which allows them to process requests quickly and seamlessly. This approach has helped them to improve customer satisfaction while reducing operational costs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Coca-Cola&lt;/strong&gt;: Coca-Cola is one of the world's largest beverage companies, and they have also turned to serverless computing to streamline their operations. They use AWS Lambda to power their mobile marketing campaigns, which allows them to process massive amounts of data and user requests in real-time. This approach has helped them to improve their marketing effectiveness while reducing costs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Netflix&lt;/strong&gt;: Netflix is a leading online video streaming service that uses serverless computing to improve its services. They use AWS Lambda to handle user authentication, which allows them to scale their infrastructure quickly and easily. This approach has helped them to improve their uptime and reduce costs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lyft&lt;/strong&gt;: As a popular ride-sharing company, Lyft has also turned to serverless computing to power its services. They use AWS Lambda to process user requests, which allows them to scale their infrastructure based on demand. This approach has helped them to improve performance and reduce costs.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Challenges of Serverless Computing in the Real World
&lt;/h2&gt;

&lt;p&gt;While serverless computing offers many benefits, it also comes with some challenges that organizations must be aware of when implementing this technology. Here are a few examples:&lt;/p&gt;

&lt;h3&gt;
  
  
  Security
&lt;/h3&gt;

&lt;p&gt;Serverless computing introduces new security challenges, such as managing access controls and securing APIs. Organizations must implement best practices to ensure that their applications and data are protected.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cold Start Times
&lt;/h3&gt;

&lt;p&gt;One of the biggest challenges of serverless computing is cold start times. When an application is deployed to a serverless platform, the platform needs to allocate resources to the application before it can start running. This process can take several seconds, resulting in what's known as a cold start.&lt;/p&gt;

&lt;p&gt;Cold start times can be a problem for applications that need to respond quickly to user requests. For example, consider an e-commerce website that needs to process orders in real-time. If the application experiences a cold start, it may take several seconds to respond to a user request, resulting in a poor user experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Vendor Lock-In
&lt;/h3&gt;

&lt;p&gt;Another challenge of serverless computing is vendor lock-in. Because serverless platforms are proprietary, developers may find it difficult to move their applications to another platform if they decide to switch providers.&lt;/p&gt;

&lt;p&gt;This can be a problem for organizations that want to maintain control over their applications and avoid being locked into a single vendor. To mitigate this risk, developers should carefully evaluate serverless platforms before choosing one and consider using open-source tools whenever possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Serverless computing offers many benefits, such as reduced costs, improved scalability, and faster time to market. However, it also comes with some challenges that organizations must be aware of when implementing this technology. By understanding the benefits and challenges of serverless computing, organizations can make informed decisions about whether it is the right choice for their needs. The real-world examples provided in this article demonstrate the diverse ways that serverless computing is being used to improve operations and services across various industries.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>aws</category>
      <category>serverless</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
