0% found this document useful (0 votes)
2 views

Introduction

The document outlines best programming practices and design patterns that enhance code quality, maintainability, and efficiency. It emphasizes the importance of learning these practices for personal development, team collaboration, and delivering high-quality software. Additionally, it discusses common pitfalls in programming, software development methodologies like Waterfall and Agile, and the significance of iterative processes in software development.

Uploaded by

angelbrenna20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Introduction

The document outlines best programming practices and design patterns that enhance code quality, maintainability, and efficiency. It emphasizes the importance of learning these practices for personal development, team collaboration, and delivering high-quality software. Additionally, it discusses common pitfalls in programming, software development methodologies like Waterfall and Agile, and the significance of iterative processes in software development.

Uploaded by

angelbrenna20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 48

Introduction to Best

programming Practices
and design pattern
Ivan
What is best practices in
programming
• Programming best practices are guidelines that help developers write
code that is clean(code is written in a way that makes it simple,
concise, and expressive), maintainable(your code is easy to read,
understand, modify, and reuse by yourself and others), and
efficient( response and speed).
• Adopting these practices improves the quality of the software and
makes the development process smoother.
• By adhering to these best practices, you can write code that is not
only functional but also robust, scalable, and easy to maintain.
Why learning best practices in
programming?
• Learning best programming practices is essential for several reasons,
which span across various aspects of software development, from
improving individual skills to enhancing team collaboration and
delivering high-quality products.
• In summary, learning best programming practices is crucial for
producing high-quality software, improving personal and team
productivity, enhancing security, and advancing your career.
• It equips you with the skills needed to build reliable, maintainable,
and scalable applications in a collaborative and efficient manner.
Key points why best practices is
important
A. Code Readability:
Consistent Naming Conventions:
Use descriptive and meaningful names for variables, functions, and classes.
Follow a consistent style (e.g., camelCase, snake_case).
Comments and Documentation:
Write comments to explain the purpose of the code, especially complex
logic.
Maintain up-to-date documentation for your codebase.
• Code Formatting:
Follow a consistent code style guide (e.g., PEP 8 for Python).
Use indentation and whitespace effectively to enhance readability.
Cont’d
b. Performance
Efficient Algorithms and Data Structures:
Choose appropriate algorithms and data structures for your task.
Optimize code for performance, but avoid premature optimization.
Profiling and Benchmarking:
Use profiling tools to identify performance bottlenecks.
Benchmark critical parts of the code to ensure performance goals
are met.
Cont’d
C. Codes Quality
Modularization:
Break down code into smaller, reusable functions or modules.
Aim for single responsibility per function/module.
Error Handling:
Implement robust error handling and logging.
Anticipate and gracefully manage exceptions.
Code Reviews:
Participate in and conduct regular code reviews.
Be open to feedback and strive for continuous improvement.
Cont’d
D. Testing
Automated Testing:
Write unit tests, integration tests, and end-to-end tests.
Use test frameworks and tools (e.g., pytest, JUnit).
Continuous Integration (CI):
Use CI tools to automatically run tests on code commits.
Ensure that the codebase is always in a deployable state.
Cont’d
E. Collaboration
Version Control:
Use a version control system (e.g., Git, svn).
Follow branching strategies (e.g., Git Flow).
Communication:
Maintain clear and open communication within the team.
Use collaborative tools effectively (e.g., Jira, Slack).
Cont’d
F. Security
Security Best Practices:
Follow security guidelines relevant to your technology stack.
Regularly update dependencies to avoid security vulnerabilities.
Code Reviews for Security:
Include security checks as part of the code review process.
Perform regular security audits and penetration testing.
Cont’d
G. Maintainability
Refactoring:
Regularly refactor code to improve structure and readability.
Avoid code smells and technical debt.
Dependency Management:
Manage dependencies properly and keep them updated.
Use tools like npm, pip, or Maven for dependency management.
How to get started in programming

• Identify your programming goals.


• Enroll in an introductory programming course.
• Build essential programming skills.
• Connect with other programmers.
• Complete projects.
• Explore your future in programming.
What is a software/ Application
• As you know computer cannot do anything on its own and has to be
guided by the user.
• In order to do any specific job you have to give a sequence of instructions
to the computer.
• Software refers to the set of computer programs, procedures that describe
the programs and how they are to be used.
• We can say that it is the collection of programs, which increases the
capabilities of the hardware.
• Software guides the computer at every step where to start and stop during
a particular job. The process of software development is called
programming
What is an application software
• Application software, often referred to simply as "applications" or
"apps," is a type of computer program designed to perform specific
tasks or functions for end-users.
• Unlike system software, which includes the operating system and
utilities that manage and maintain the computer hardware,
application software is created to fulfill various user needs and
requirements.
Programming best practice
• Writing good software is not an easy task, it requires a lot of coding
experience and skills.
• Therefore, inexperienced software developers or newbies suffer from
this critical task.
• In this course, we will provide guidelines to help in this important
context.
Best Practices and
Recommendations
• In this section, the proposed taxonomy that assists developers to
create good software illustrated in categories.
• The categories cover different aspects of writing any software and
they are based on software engineering, industry, and coding
experiences
Cont (…)
• The best practices and recommendations that have to be taken into
consideration are as follow:
Before Writing Software
While writing software and
After Writing a Software
Before Writing
Software
Build a good team
Work with professionals
Understand software categories
Select a development model.
Select an advanced IDE
Select a user interface
Use programming language features
Select a programming language
Select software architecture
While writing software
• Avoid quick coding
• Follow coding standards
• Simplify coding
• Reuse existing code
• Minimize code dependences
• Focus while coding
• Follow software evolution
• Use comments
• Avoid code duplication
• Use programming concept
After Writing Software
• Review code
• Test code
• Maintain code
• Create a user manual
• Make searchable
code
What is pitfalls in Programming
• It is crucial for educators to understand pitfalls for novice
programmers in programming education at computer
science/Engineering course.
• By giving well-timed advice to students who fall into a pitfall,
educators are able to achieve efficient teaching and keep up their
students’ motivation.
• However, so far, it is less well-understood how novice students edit
source code and why they fall into a pitfall.
What is pitfalls in Programming
• It is crucial for educators to understand pitfalls for novice
programmers in programming education at computer
science/Engineering course.
• By giving well-timed advice to students who fall into a pitfall,
educators are able to achieve efficient teaching and keep up their
students’ motivation.
• However, so far, it is less well-understood how novice students edit
source code and why they fall into a pitfall.
Cont…
• As computer technology offers efficient and high performance
information processing, it has got popularity over the home and office
users in the whole world.
• Software development methodologies are management practices for
software development projects.
Cont(…)
• we’re going to present some of the most common mistakes which
every Java programmer eventually makes, the reasons why they
happen and solutions to avoid them.
• Note that making mistakes are not bad. It is good for helping
programmers realize and understand the problems better as well as
improve their programming skills.
• It’s important to learn lessons from mistakes, and the more mistakes
you made, the more lessons you can learn, the more experience (and
wisdom) you have.
Cont…
• 1. Accessing non-static members from static methods (mostly from the main method)
• 2. Missing closing curly braces
• 3. Missing break in switch case construct
• 4. Confusing assignment with comparison (= and ==)
• 5. Confusing object comparison (== instead of .equals)
• 6. Confusing about 0-based or 1-based index
• 7. Using less restrictive access modifiers
• 8. Forgetting to free resources
• 9. Ignoring Exceptions
• 10. Modifying a collection while iterating it
Cont…
• Accessing non-static members from static methods (mostly from the
main method)
Cont…
Missing closing curly braces
refer to the previous example
Cont…

• Missing break in switch case construct


Cont…
• Confusing assignment with comparison (= and ==)
The = is an assignment operator whereas the == is a relational operator,
and sometimes one mistakenly uses = instead of ==. Take a look at this
code snippet:
Confusing object comparison (== instead of .equals)
The == operator compares two objects physically (their memory
addresses) whereas the equals() method compares two objects
semantically (their information). And in most of the cases, we should
compare two objects meaningfully using the equals() method.
• Confusing about 0-based or 1-based index
Like many other programming languages, array index in Java are 0-
based, which means the first element in the array starts at the index 0,
the second at 1, and so on. However, sometimes we mistakenly treat
the first element at index 1.
Cont…
• Using less restrictive access modifiers
• This is another very common mistake of all beginners: using access
modifiers without taking care of its visibility. The Java language
provides 4 access modifiers for protecting members of a class:
public > protected > default > private
These access modifiers are sorted from the least restrictive (public) to
the most restrictive (private). However, novice programmers do not
fully understand this and often use the public and default access
modifiers which make the code less secured.
Summary of access modifier
Cont…
• Forgetting to free resources
This is also a common mistake which one easily forgets to close resources
after use, such as network connections, database connections, file streams,
etc.
This mistake may lead to resources leaked or memory occupied by no longer
used objects.
Ignoring Exceptions
This is another common mistake of beginners who are too lazy to write code
for handling exception. It seems to be of no harms if the code runs fine
without exceptions. However, in case the exceptions occurred, the code can
fail silently which adds difficulty in finding the problem.
Cont…
• Modifying a collection while iterating it
Anyone who starts programming with Java makes this common
mistake: attempt to modify (remove) elements in a collection while
iterating over it.
System Development Life Cycle
(SDLC)
• The System Development Life Cycle (SDLC) is a conceptual model for
software development that divides up the process into different
phases. Each phase has a distinct role to play in the development life
cycle, and is a building block for the next phase.

There are many SDLC models, each emphasizing different aspects of


the life-cycle.
Implementing a structured approach requires selecting a model and
utilizing it through out the development life cycle
Cont…
• The following seven SDLC phases illustrate the selected Waterfall
Model
1. Software Concept
2. Analysis
3. Design
4. Coding and Debugging
5. System Integration and Testing
6. Implementation
7. Maintenance and Support
Software Development
Methodologies

• Types of software development methodology:


 waterfall
 Agile
• The key difference between Agile vs. Waterfall is that Waterfall breaks down
software development into isolated phases that flow into each other, while
Agile advocates iterative development cycles in which multiple lifecycle
phases can run in parallel.
• Whether an organization develops applications with an Agile- or Waterfall-
based methodology, all software development projects incorporate common
aspects of lifecycle phases, including:
Cont(...)
• requirements gathering;
• analysis and design;
• development and implementation;
• testing and verification; and
• deployment and ongoing maintenance
Cont(…)
How does Waterfall work?
• The Waterfall model treats each software development lifecycle
phase as distinct, isolated events. Development teams must complete
each phase in its entirety before they move onto the next phase.
• Furthermore, once teams move onto a new phase, they are not
allowed to revisit a previous one.
• Progress through the development phases flows in only one direction,
from the top to the bottom -- just like flow of a waterfall, which is
where the model's name comes from.
• Assignment: Why does Agile reject Waterfall?
Agile method
• In software development life cycle, there are two main
considerations, one is to emphasize on process and the other is the
quality of the software and process itself.
• Agile software processes is an iterative and incremental based
development, where requirements are changeable according to
customer needs.
• It helps in adaptive planning, iterative development and time boxing.
It is a theoretical framework that promotes foreseen interactions
throughout the development cycle.
Cont…
• Agile process is an iterative approach in which customer satisfaction is
at highest priority as the customer has direct involvement in
evaluating the software.
• The agile process follows the software development life cycle which
includes requirements gathering, analysis, design , coding , testing
and delivers partially implemented software and waits for the
customer feedback.
• In the whole process , customer satisfaction is at highest priority with
faster development time.
Agile process diagram
Cont…
• Lets explain this using AUCA Registration System
Lets assume in this application we have 4 module:
Registration module
Course assignments module
Schools fees payments module
 Mark sheet module
CHARACTERISTICS OF A GILE P
ROJECTS
• Agile process requires less planning and it divides the tasks into small
increments. Agile process is meant for short term projects with an
effort of team work that follows the software development life cycle.
• Software development life cycle includes the following phases
1.Requirements gathering,
2.Analysis,
3.Design,
4.Coding
5.Testing,
6.Maintenance.
Cont…
• The involvement of software team management with customers
reduces the risks
associated with the software.
• This agile process is an iterative process in which changes can be
made according to
the customer satisfaction.
• In agile process new features can be added easily by using multiple
iterations
Keys aspect of agile
methodology
• 1. Iterative
The main objective of agile software processes is satisfaction of
customers, so it focuses on single requirement with multiple
iterations.
2. Modularity
Agile process decomposes the complete system into manageable
pieces called modules. Modularity plays a major role in software
development processes
• 3. Time Boxing
As agile process is iterative in nature, it requires the time limits on
each module with respective cycle.
Cont…
4. Parsimony
In agile processes parsimony is required to mitigate risks and achieve
the goals by minimal number of modules.
5. Incremental
As the agile process is iterative in nature, it requires the system to be
developed in increments, each increment is independent of others, and
at last all increments are integrated into complete system.
Cont…
6. Adaptive
Due to the iterative nature of agile process new risks may occurs. The
adaptive characteristic of agile process allows adapting the processes
to attack the new risks and allows changes in the real time
requirements.
7. Convergent
All the risks associated with each increment are convergent in agile
process by using iterative and incremental approach.
Cont …
9. Collaborative
As agile process is modular in nature, it needs a good communication
among software development team.
Different modules need to be integrated at the end of the software
development process.
10. People Oriented
In the agile processes customer satisfaction is the first priority over the
technology and process.
A good software development team increases the performance and
productivity of the software.

You might also like